FS-7499 FS-7508 FS-7501 some more general improvements for initial call setup

This commit is contained in:
Anthony Minessale 2015-05-05 13:27:52 -05:00 committed by Michael Jerris
parent aacede1914
commit dc4c38dab5
7 changed files with 69 additions and 15 deletions

View File

@ -328,6 +328,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_sessi
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

View File

@ -41,6 +41,7 @@ typedef enum {
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);

View File

@ -772,7 +772,7 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
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);

View File

@ -1785,7 +1785,8 @@ SWITCH_DECLARE(char *) switch_channel_get_cap_string(switch_channel_t *channel)
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);
@ -1793,9 +1794,16 @@ SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, sw
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);
}

View File

@ -1947,8 +1947,11 @@ static void check_jb_sync(switch_core_session_t *session)
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;
@ -1959,13 +1962,20 @@ static void check_jb_sync(switch_core_session_t *session)
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);
}
}
@ -2088,7 +2098,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
}
smh->vid_frames++;
if (smh->vid_frames == 45) {
if (smh->vid_frames == 1 || ((smh->vid_frames % 300) == 0)) {
check_jb_sync(session);
}
}

View File

@ -3855,6 +3855,17 @@ static void jb_logger(const char *file, const char *func, int line, int level, c
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)) {
@ -5415,7 +5426,9 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t
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) {
@ -5423,11 +5436,14 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t
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

View File

@ -412,6 +412,24 @@ SWITCH_DECLARE(void) switch_vb_reset(switch_vb_t *vb)
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);