Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEL-6183: disable video codecs #331

Draft
wants to merge 1 commit into
base: telnyx/telephony/master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/include/switch_core_media.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ typedef struct switch_core_media_params_s {

char *inbound_codec_string;
char *outbound_codec_string;
switch_bool_t disable_video_codecs;

char *timer_name;

Expand Down
1 change: 1 addition & 0 deletions src/mod/endpoints/mod_sofia/mod_sofia.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ struct sofia_profile {
unsigned int tls_timeout;
char *inbound_codec_string;
char *outbound_codec_string;
switch_bool_t disable_video_codecs;
int running;
int dtmf_duration;
uint8_t flags[TFLAG_MAX];
Expand Down
2 changes: 2 additions & 0 deletions src/mod/endpoints/mod_sofia/sofia.c
Original file line number Diff line number Diff line change
Expand Up @@ -6076,6 +6076,8 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
profile->inbound_codec_string = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "outbound-codec-prefs")) {
profile->outbound_codec_string = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "disable-video-codecs")) {
profile->disable_video_codecs = switch_true(val);
} else if (!strcasecmp(var, "challenge-realm")) {
profile->challenge_realm = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "challenge-opaque")) {
Expand Down
1 change: 1 addition & 0 deletions src/mod/endpoints/mod_sofia/sofia_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
tech_pvt->mparams.ndlb = tech_pvt->profile->mndlb;
tech_pvt->mparams.inbound_codec_string = profile->inbound_codec_string;
tech_pvt->mparams.outbound_codec_string = profile->outbound_codec_string;
tech_pvt->mparams.disable_video_codecs = profile->disable_video_codecs;
tech_pvt->mparams.auto_rtp_bugs = profile->auto_rtp_bugs;
tech_pvt->mparams.timer_name = profile->timer_name;
tech_pvt->mparams.vflags = profile->vflags;
Expand Down
15 changes: 10 additions & 5 deletions src/switch_core_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -4505,23 +4505,28 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_add_ice_acl(switch_core_sessio
SWITCH_DECLARE(void) switch_core_media_check_video_codecs(switch_core_session_t *session)
{
switch_media_handle_t *smh;
const char *disable_video;

switch_assert(session);

if (!(smh = session->media_handle)) {
return;
}

if (smh->mparams->num_codecs && !switch_channel_test_flag(session->channel, CF_VIDEO_POSSIBLE)) {
if (!zstr(disable_video = switch_channel_get_variable(session->channel, "disable_video_codecs"))) {
if (switch_true(disable_video)) {
switch_channel_set_flag(session->channel, CF_NOVIDEO);
}
} else if (smh->mparams->disable_video_codecs) {
switch_channel_set_flag(session->channel, CF_NOVIDEO);
}

if (smh->mparams->num_codecs && !switch_channel_test_flag(session->channel, CF_VIDEO_POSSIBLE) && !switch_channel_test_flag(session->channel, CF_NOVIDEO)) {
int i;
smh->video_count = 0;
for (i = 0; i < smh->mparams->num_codecs; i++) {

if (smh->codecs[i]->codec_type == SWITCH_CODEC_TYPE_VIDEO) {
if (switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_INBOUND &&
switch_channel_test_flag(session->channel, CF_NOVIDEO)) {
continue;
}
smh->video_count++;
}
}
Expand Down