SWITCH_DECLARE(switch_timer_t *) switch_rtp_get_media_timer(switch_rtp_t *rtp_session);
SWITCH_DECLARE(switch_status_t) switch_rtp_set_video_buffer_size(switch_rtp_t *rtp_session, uint32_t frames);
+SWITCH_DECLARE(uint32_t) switch_rtp_get_video_buffer_size(switch_rtp_t *rtp_session);
/*!
\brief Acvite a jitter buffer on an RTP session
SWITCH_BEGIN_EXTERN_C
SWITCH_DECLARE(switch_status_t) switch_vb_create(switch_vb_t **vbp, uint32_t min_frame_len, uint32_t max_frame_len, switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_status_t) switch_vb_set_frames(switch_vb_t *vb, uint32_t min_frame_len, uint32_t max_frame_len);
+SWITCH_DECLARE(switch_status_t) switch_vb_get_frames(switch_vb_t *vb, uint32_t *min_frame_len, uint32_t *max_frame_len);
SWITCH_DECLARE(switch_status_t) switch_vb_destroy(switch_vb_t **vbp);
SWITCH_DECLARE(void) switch_vb_reset(switch_vb_t *vb);
SWITCH_DECLARE(void) switch_vb_debug_level(switch_vb_t *vb, uint8_t level);
if (context->is_vp9) {
is_keyframe = IS_VP9_KEY_FRAME(*(unsigned char *)frame->data);
} else { // vp8
- is_keyframe = (*(unsigned char *)frame->data & 0x10) || IS_VP8_KEY_FRAME((uint8_t *)frame->data);
+ is_keyframe = IS_VP8_KEY_FRAME((uint8_t *)frame->data);
}
// if (is_keyframe) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "got key %d\n", is_keyframe);
SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, switch_channel_flag_t flag, uint32_t value)
{
int HELD = 0;
-
+ int just_set = 0;
+
switch_assert(channel);
switch_assert(channel->flag_mutex);
if (flag == CF_LEG_HOLDING && !channel->flags[flag] && channel->flags[CF_ANSWERED]) {
HELD = 1;
}
- channel->flags[flag] = value;
+ if (channel->flags[flag] != value) {
+ just_set = 1;
+ channel->flags[flag] = value;
+ }
switch_mutex_unlock(channel->flag_mutex);
+ if (flag == CF_VIDEO_READY && just_set) {
+ switch_core_session_request_video_refresh(channel->session);
+ }
+
if (flag == CF_ORIGINATOR && switch_channel_test_flag(channel, CF_ANSWERED) && switch_channel_up_nosig(channel)) {
switch_channel_set_callstate(channel, CCS_RING_WAIT);
}
jb_sync_msec = tmp;
}
}
- // TBD IMPROVE get_fps func
- fps = 15; //switch_core_media_get_video_fps(session);
+ if (smh->vid_frames < 10) {
+ fps = 15;
+ } else {
+ fps = switch_core_media_get_video_fps(session);
+ }
if (!fps) return;
frames = fps / (1000 / jb_sync_msec);
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
- SWITCH_LOG_DEBUG, "%s Sync Audio and Video Jitterbuffer to %dms %u Video Frames FPS %u\n",
- switch_channel_get_name(session->channel),
- jb_sync_msec, frames, fps);
-
- switch_rtp_set_video_buffer_size(v_engine->rtp_session, frames);
- check_jb(session, NULL, jb_sync_msec, jb_sync_msec);
+ if (frames == switch_rtp_get_video_buffer_size(v_engine->rtp_session)) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
+ SWITCH_LOG_DEBUG1, "%s Audio and Video Jitterbuffer settings not changed %dms %u Video Frames FPS %u\n",
+ switch_channel_get_name(session->channel),
+ jb_sync_msec, frames, fps);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
+ SWITCH_LOG_INFO, "%s Sync Audio and Video Jitterbuffer to %dms %u Video Frames FPS %u\n",
+ switch_channel_get_name(session->channel),
+ jb_sync_msec, frames, fps);
+
+ switch_rtp_set_video_buffer_size(v_engine->rtp_session, frames);
+ check_jb(session, NULL, jb_sync_msec, jb_sync_msec);
+ }
}
}
smh->vid_frames++;
- if (smh->vid_frames == 45) {
+ if (smh->vid_frames == 1 || ((smh->vid_frames % 300) == 0)) {
check_jb_sync(session);
}
}
va_end(ap);
}
+SWITCH_DECLARE(uint32_t) switch_rtp_get_video_buffer_size(switch_rtp_t *rtp_session)
+{
+ uint32_t frames = 0;
+
+ if (rtp_session->vb) {
+ switch_vb_get_frames(rtp_session->vb, &frames, NULL);
+ }
+
+ return frames;
+}
+
SWITCH_DECLARE(switch_status_t) switch_rtp_set_video_buffer_size(switch_rtp_t *rtp_session, uint32_t frames)
{
if (!switch_rtp_ready(rtp_session)) {
if (msg->header.type == RTCP_PT_PSFB && (extp->header.fmt == RTCP_PSFB_FIR || extp->header.fmt == RTCP_PSFB_PLI)) {
switch_core_media_gen_key_frame(rtp_session->session);
- //switch_channel_set_flag(switch_core_session_get_channel(rtp_session->session), CF_VIDEO_REFRESH_REQ);
+ if (rtp_session->vbw) {
+ switch_vb_reset(rtp_session->vbw);
+ }
}
if (msg->header.type == RTCP_PT_RTPFB && extp->header.fmt == RTCP_RTPFB_NACK) {
int i;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Got NACK count %d\n", ntohs(extp->header.length) - 2);
- switch_core_media_gen_key_frame(rtp_session->session);
+
+
for (i = 0; i < ntohs(extp->header.length) - 2; i++) {
handle_nack(rtp_session, *nack);
nack++;
}
+
+ switch_core_media_gen_key_frame(rtp_session->session);
}
} else
switch_mutex_unlock(vb->mutex);
}
+SWITCH_DECLARE(switch_status_t) switch_vb_get_frames(switch_vb_t *vb, uint32_t *min_frame_len, uint32_t *max_frame_len)
+{
+
+ switch_mutex_lock(vb->mutex);
+
+ if (min_frame_len) {
+ *min_frame_len = vb->min_frame_len;
+ }
+
+ if (max_frame_len) {
+ *max_frame_len = vb->max_frame_len;
+ }
+
+ switch_mutex_unlock(vb->mutex);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
SWITCH_DECLARE(switch_status_t) switch_vb_set_frames(switch_vb_t *vb, uint32_t min_frame_len, uint32_t max_frame_len)
{
switch_mutex_lock(vb->mutex);