This commit is contained in:
Anthony Minessale 2016-07-21 14:31:56 -05:00
parent 497b8926d7
commit c556e5269b
4 changed files with 59 additions and 28 deletions

View File

@ -9159,16 +9159,9 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
if (sip && sip->sip_content_type && sip->sip_content_type->c_type && sip->sip_content_type->c_subtype &&
sip->sip_payload && sip->sip_payload->pl_data) {
if (!strncasecmp(sip->sip_content_type->c_type, "application", 11) && !strcasecmp(sip->sip_content_type->c_subtype, "media_control+xml")) {
switch_core_session_t *other_session;
if (switch_channel_test_flag(channel, CF_VIDEO)) {
switch_core_media_gen_key_frame(session);
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
sofia_glue_build_vid_refresh_message(other_session, sip->sip_payload->pl_data);
switch_core_session_rwunlock(other_session);
} else {
switch_channel_set_flag(channel, CF_VIDEO_REFRESH_REQ);
}
switch_channel_set_flag(channel, CF_VIDEO_REFRESH_REQ);
}
} else if (!strncasecmp(sip->sip_content_type->c_type, "application", 11) &&

View File

@ -1926,6 +1926,15 @@ static void check_jb(switch_core_session_t *session, const char *input, int32_t
switch_rtp_set_video_buffer_size(v_engine->rtp_session, frames, max_frames);
}
return;
} else if (!strcasecmp(input, "vpause")) {
switch_rtp_pause_jitter_buffer(v_engine->rtp_session, SWITCH_TRUE);
return;
} else if (!strcasecmp(input, "vresume")) {
switch_rtp_pause_jitter_buffer(v_engine->rtp_session, SWITCH_FALSE);
return;
} else if (!strcasecmp(input, "vstop")) {
switch_rtp_deactivate_jitter_buffer(v_engine->rtp_session);
return;
} else if (!strncasecmp(input, "vdebug:", 7)) {
s = input + 7;
@ -2050,6 +2059,11 @@ static void check_jb_sync(switch_core_session_t *session)
}
fps = switch_core_media_get_video_fps(session);
if (switch_test_flag(smh, SMF_JB_PAUSED)) {
return;
}
switch_rtp_get_video_buffer_size(v_engine->rtp_session, &min_frames, &max_frames, &cur_frames, NULL);
@ -2637,7 +2651,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_sessio
return SWITCH_STATUS_GENERR;
}
if (!switch_test_flag(frame, SFF_CNG) && !switch_test_flag(frame, SFF_PROXY_PACKET)) {
if (type == SWITCH_MEDIA_TYPE_AUDIO && !switch_test_flag(frame, SFF_CNG) && !switch_test_flag(frame, SFF_PROXY_PACKET)) {
if (engine->read_impl.encoded_bytes_per_packet) {
bytes = engine->read_impl.encoded_bytes_per_packet;
frames = ((int) frame->datalen / bytes);
@ -9630,19 +9644,29 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
case SWITCH_MESSAGE_INDICATE_BRIDGE:
{
if (switch_rtp_ready(a_engine->rtp_session)) {
if (switch_rtp_ready(a_engine->rtp_session) || switch_rtp_ready(v_engine->rtp_session)) {
const char *val;
int ok = 0;
if (!switch_channel_test_flag(session->channel, CF_VIDEO) &&
if (
(!(val = switch_channel_get_variable(session->channel, "rtp_jitter_buffer_during_bridge")) || switch_false(val))) {
if (switch_channel_test_flag(session->channel, CF_JITTERBUFFER) && switch_channel_test_cap_partner(session->channel, CC_FS_RTP)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s PAUSE Jitterbuffer\n", switch_channel_get_name(session->channel));
switch_rtp_pause_jitter_buffer(a_engine->rtp_session, SWITCH_TRUE);
if (a_engine->rtp_session) {
switch_rtp_pause_jitter_buffer(a_engine->rtp_session, SWITCH_TRUE);
}
if (v_engine->rtp_session) {
switch_rtp_pause_jitter_buffer(v_engine->rtp_session, SWITCH_TRUE);
}
switch_set_flag(smh, SMF_JB_PAUSED);
}
}
}
if (switch_rtp_ready(a_engine->rtp_session)) {
const char *val;
int ok = 0;
if (switch_channel_test_flag(session->channel, CF_PASS_RFC2833) && switch_channel_test_flag_partner(session->channel, CF_FS_RTP)) {
switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833);
@ -9689,18 +9713,26 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
}
goto end;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
if (switch_rtp_ready(a_engine->rtp_session)) {
if (switch_rtp_ready(a_engine->rtp_session) || switch_rtp_ready(v_engine->rtp_session)) {
if (switch_test_flag(smh, SMF_JB_PAUSED)) {
switch_clear_flag(smh, SMF_JB_PAUSED);
if (switch_channel_test_flag(session->channel, CF_JITTERBUFFER)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s RESUME Jitterbuffer\n", switch_channel_get_name(session->channel));
switch_rtp_pause_jitter_buffer(a_engine->rtp_session, SWITCH_FALSE);
if (a_engine->rtp_session) {
switch_rtp_pause_jitter_buffer(a_engine->rtp_session, SWITCH_FALSE);
}
if (v_engine->rtp_session) {
switch_rtp_pause_jitter_buffer(v_engine->rtp_session, SWITCH_FALSE);
}
}
}
}
if (switch_rtp_ready(a_engine->rtp_session)) {
if (switch_rtp_test_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s deactivate passthru 2833 mode.\n",
switch_channel_get_name(session->channel));
@ -11272,7 +11304,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
switch_status_t status = SWITCH_STATUS_FALSE;
switch_time_t now = switch_micro_time_now();
switch_codec_t *codec = switch_core_session_get_video_write_codec(session);
switch_timer_t *timer;
//switch_timer_t *timer;
switch_media_handle_t *smh;
switch_image_t *dup_img = NULL, *img = frame->img;
switch_status_t encode_status;
@ -11422,6 +11454,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
frame = &write_frame;
frame->img = img;
#if 0
if (!switch_test_flag(frame, SFF_USE_VIDEO_TIMESTAMP)) {
if (!(timer = switch_core_media_get_timer(session, SWITCH_MEDIA_TYPE_VIDEO))) {
@ -11435,6 +11468,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
frame->timestamp = timer->samplecount;
}
#endif
switch_clear_flag(frame, SFF_SAME_IMAGE);
frame->m = 0;

View File

@ -195,6 +195,7 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
if (switch_channel_media_up(b_channel)) {
switch_set_flag(read_frame, SFF_PROXY_PACKET);
if (switch_core_session_write_video_frame(vh->session_b, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
switch_cond_next();
continue;

View File

@ -4060,7 +4060,7 @@ SWITCH_DECLARE(switch_jb_t *) switch_rtp_get_jitter_buffer(switch_rtp_t *rtp_ses
SWITCH_DECLARE(switch_status_t) switch_rtp_pause_jitter_buffer(switch_rtp_t *rtp_session, switch_bool_t pause)
{
if (!switch_rtp_ready(rtp_session) || !rtp_session->jb) {
if (!switch_rtp_ready(rtp_session) || (!rtp_session->jb && !rtp_session->vb)) {
return SWITCH_STATUS_FALSE;
}
@ -4069,7 +4069,11 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_pause_jitter_buffer(switch_rtp_t *rtp
}
if (rtp_session->pause_jb && !pause) {
switch_jb_reset(rtp_session->jb);
if (rtp_session->vb) {
switch_jb_reset(rtp_session->vb);
} else {
switch_jb_reset(rtp_session->jb);
}
}
rtp_session->pause_jb = pause ? 1 : 0;
@ -5639,7 +5643,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
if (rtp_session->has_rtp && *bytes) {
uint32_t read_ssrc = ntohl(rtp_session->last_rtp_hdr.ssrc);
if (rtp_session->vb && jb_valid(rtp_session)) {
if (rtp_session->vb && jb_valid(rtp_session) && !rtp_session->pause_jb) {
status = switch_jb_put_packet(rtp_session->vb, (switch_rtp_packet_t *) &rtp_session->recv_msg, *bytes);
if (status == SWITCH_STATUS_TOO_LATE) {
@ -5734,7 +5738,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
}
}
if (rtp_session->vb && jb_valid(rtp_session)) {
if (rtp_session->vb && jb_valid(rtp_session) && !rtp_session->pause_jb) {
switch_status_t vstatus = switch_jb_get_packet(rtp_session->vb, (switch_rtp_packet_t *) &rtp_session->recv_msg, bytes);
status = vstatus;
@ -6324,7 +6328,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
pt = 200000;
}
if (rtp_session->vb) {
if (rtp_session->vb && !rtp_session->pause_jb) {
if (switch_jb_poll(rtp_session->vb)) {
pt = 0;
}
@ -6333,12 +6337,12 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
if ((io_flags & SWITCH_IO_FLAG_NOBLOCK)) {
pt = 0;
}
poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, pt);
//if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF Poll %d\n", poll_status);
// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF Poll %d %d\n", pt, poll_status);
//}
if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->dtmf_data.out_digit_dur > 0) {
@ -6355,7 +6359,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
}
if (poll_status == SWITCH_STATUS_SUCCESS || (rtp_session->vb && switch_jb_poll(rtp_session->vb))) {
if (poll_status == SWITCH_STATUS_SUCCESS || (rtp_session->vb && !rtp_session->pause_jb && switch_jb_poll(rtp_session->vb))) {
got_rtp_poll = 1;
@ -7290,7 +7294,6 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
}
}
if (switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_GEN_TS_DELTA) || switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) {
/* Normalize the timestamps to our own base by generating a made up starting point then adding the measured deltas to that base
so if the timestamps and ssrc of the source change, it will not break the other end's jitter bufffer / decoder etc *cough* CHROME *cough*