summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorRiza Sulistyo <riza@teluu.com>2016-08-05 13:06:14 +0000
committerRiza Sulistyo <riza@teluu.com>2016-08-05 13:06:14 +0000
commite4e49af40f2f327610fb066e2313dbfffc57f717 (patch)
tree923506cd930983247fa11ce6f0ebb9772cae036c /pjmedia
parenta95fd7ee553a5b1774d263e5be91c859719189da (diff)
Re #1910: Send the additional keyframe only after the initial one.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5411 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/src/pjmedia/vid_stream.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/pjmedia/src/pjmedia/vid_stream.c b/pjmedia/src/pjmedia/vid_stream.c
index c586018f..06e7b499 100644
--- a/pjmedia/src/pjmedia/vid_stream.c
+++ b/pjmedia/src/pjmedia/vid_stream.c
@@ -152,7 +152,6 @@ struct pjmedia_vid_stream
unsigned rx_frame_cnt; /**< # of array in rx_frames */
pjmedia_frame *rx_frames; /**< Temp. buffer for incoming
frame assembly. */
-
pj_bool_t force_keyframe;/**< Forced to encode keyframe? */
unsigned num_keyframe; /**< The number of keyframe needed
to be sent, after the stream
@@ -821,6 +820,7 @@ static pj_status_t put_frame(pjmedia_port *port,
pjmedia_vid_encode_opt enc_opt;
unsigned pkt_cnt = 0;
pj_timestamp initial_time;
+ pj_timestamp null_ts ={0};
#if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA != 0
/* If the interval since last sending packet is greater than
@@ -858,7 +858,9 @@ static pj_status_t put_frame(pjmedia_port *port,
frame_out.size = 0;
/* Check if need to send keyframe. */
- if (stream->num_keyframe) {
+ if (stream->num_keyframe &&
+ (pj_cmp_timestamp(&null_ts, &stream->last_keyframe_tx) != 0))
+ {
unsigned elapse_time;
pj_timestamp now;
@@ -869,8 +871,7 @@ static pj_status_t put_frame(pjmedia_port *port,
if (elapse_time > stream->info.sk_cfg.interval)
{
stream->force_keyframe = PJ_TRUE;
- if (--stream->num_keyframe)
- stream->last_keyframe_tx = now;
+ --stream->num_keyframe;
}
}
@@ -903,6 +904,13 @@ static pj_status_t put_frame(pjmedia_port *port,
pj_get_timestamp(&initial_time);
+ if ((stream->num_keyframe) &&
+ ((frame_out.bit_info & PJMEDIA_VID_FRM_KEYFRAME)
+ == PJMEDIA_VID_FRM_KEYFRAME))
+ {
+ stream->last_keyframe_tx = initial_time;
+ }
+
/* Loop while we have frame to send */
for (;;) {
status = pjmedia_rtp_encode_rtp(&channel->rtp,