}
if (su_casematch(name, "CT"))
- modifier = sdp_bw_ct, name = NULL;
+ modifier = sdp_bw_ct, name = "CT";
else if (su_casematch(name, "TIAS") == 1)
- modifier = sdp_bw_tias, name = NULL;
+ modifier = sdp_bw_tias, name = "TIAS";
else if (su_casematch(name, "AS") == 1)
- modifier = sdp_bw_as, name = NULL;
+ modifier = sdp_bw_as, name = "AS";
else
- modifier = sdp_bw_x;
+ modifier = sdp_bw_x, name = "BW-X";
if (STRICT(p))
PARSE_CHECK_REST(p, r, "b");
}
if (context->codec_settings.video.bandwidth) {
- context->bandwidth = context->codec_settings.video.bandwidth * 8;
+ context->bandwidth = context->codec_settings.video.bandwidth;
} else {
- context->bandwidth = switch_calc_bitrate(context->codec_settings.video.width, context->codec_settings.video.height, 1, 15) * 8;
+ context->bandwidth = switch_calc_bitrate(context->codec_settings.video.width, context->codec_settings.video.height, 1, 15);
}
sane = switch_calc_bitrate(1920, 1080, 2, 30);
- if (context->bandwidth / 8 > sane) {
+ if (context->bandwidth > sane) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "BITRATE TRUNCATED TO %d\n", sane);
- context->bandwidth = sane * 8;
+ context->bandwidth = sane;
}
+
+ context->bandwidth *= 3;
//context->encoder_ctx->bit_rate = context->bandwidth * 1024;
context->encoder_ctx->width = context->codec_settings.video.width;
switch_thread_id_t thread_id;
uint8_t new_ice;
uint8_t new_dtls;
+ uint32_t sdp_bw;
} switch_rtp_engine_t;
struct switch_media_handle_s {
switch(type) {
case SWITCH_MEDIA_TYPE_AUDIO:
break;
- case SWITCH_MEDIA_TYPE_VIDEO:
- {
- const char *bwv = switch_channel_get_variable(session->channel, "rtp_video_max_bandwidth");
+ case SWITCH_MEDIA_TYPE_VIDEO: {
+ uint32_t system_bw = 0;
- if (!bwv) {
- bwv = switch_channel_get_variable(session->channel, "rtp_video_max_bandwidth_out");
- }
+ const char *bwv = switch_channel_get_variable(session->channel, "rtp_video_max_bandwidth");
+
+ if (!bwv) {
+ bwv = switch_channel_get_variable(session->channel, "rtp_video_max_bandwidth_out");
+ }
+
+ if (!bwv) {
+ bwv = "1mb";
+ }
+
+ system_bw = switch_parse_bandwidth_string(bwv);
- if (!bwv) {
- bwv = "1mb";
- }
-
- engine->codec_settings.video.bandwidth = switch_parse_bandwidth_string(bwv);
+ printf("%d %d\n", engine->sdp_bw, system_bw);
+
+ if (engine->sdp_bw && engine->sdp_bw <= system_bw) {
+ engine->codec_settings.video.bandwidth = engine->sdp_bw;
+ } else {
+ engine->codec_settings.video.bandwidth = system_bw;
}
+ }
break;
default:
break;
maxptime = atoi(attr->a_value);
} else if (got_crypto < 1 && !strcasecmp(attr->a_name, "crypto") && !zstr(attr->a_value)) {
int crypto_tag;
-
+
if (!(smh->mparams->ndlb & SM_NDLB_ALLOW_CRYPTO_IN_AVP) &&
!switch_true(switch_channel_get_variable(session->channel, "rtp_allow_crypto_in_avp"))) {
if (m->m_proto != sdp_proto_srtp && !got_webrtc) {
v_engine->rmode = sdp_media_flow(m->m_mode);
if (sdp_type == SDP_TYPE_REQUEST) {
+ sdp_bandwidth_t *bw;
+ int tias = 0;
+
+ for (bw = m->m_bandwidths; bw; bw = bw->b_next) {
+ if (bw->b_modifier == sdp_bw_as && !tias) {
+ v_engine->sdp_bw = bw->b_value / 1024;
+ } else if (bw->b_modifier == sdp_bw_tias) {
+ tias = 1;
+ v_engine->sdp_bw = bw->b_value / 1024;
+ }
+ }
+
switch(v_engine->rmode) {
case SWITCH_MEDIA_FLOW_RECVONLY:
switch_channel_set_variable(smh->session->channel, "video_media_flow", "sendonly");
int restart_limit_on_dtmf = 0;
const char *prefix, *var, *video_file = NULL;
int vid_play_file_flags = SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT | SWITCH_FILE_FLAG_VIDEO;
-
+ int echo_on = 0;
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
if (!switch_test_flag(&vfh, SWITCH_FILE_OPEN)) {
+ echo_on = 1;
+ switch_channel_set_flag_recursive(channel, CF_VIDEO_DECODED_READ);
switch_channel_set_flag(channel, CF_VIDEO_ECHO);
}
"Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate,
fh->channels, read_impl.microseconds_per_packet / 1000);
if (switch_core_file_has_video(fh)) {
- switch_channel_clear_flag(channel, CF_VIDEO_ECHO);
- switch_channel_clear_flag_recursive(channel, CF_VIDEO_DECODED_READ);
+ if (echo_on) {
+ switch_channel_clear_flag(channel, CF_VIDEO_ECHO);
+ switch_channel_clear_flag_recursive(channel, CF_VIDEO_DECODED_READ);
+ echo_on = 0;
+ }
switch_core_media_set_video_file(session, NULL, SWITCH_RW_READ);
if (switch_test_flag(&vfh, SWITCH_FILE_OPEN)) {
switch_core_media_set_video_file(session, NULL, SWITCH_RW_WRITE);
if (fill_cng || waste_resources) {
switch_core_codec_destroy(&write_codec);
}
-
+
if (switch_core_file_has_video(fh)) {
- switch_channel_clear_flag(channel, CF_VIDEO_ECHO);
- switch_channel_clear_flag_recursive(channel, CF_VIDEO_DECODED_READ);
+ if (echo_on) {
+ switch_channel_clear_flag(channel, CF_VIDEO_ECHO);
+ switch_channel_clear_flag_recursive(channel, CF_VIDEO_DECODED_READ);
+ echo_on = 0;
+ }
switch_core_media_set_video_file(session, NULL, SWITCH_RW_READ);
if (switch_test_flag(&vfh, SWITCH_FILE_OPEN)) {
switch_core_media_set_video_file(session, NULL, SWITCH_RW_WRITE);