提交 10010d47 authored 作者: Anthony Minessale's avatar Anthony Minessale

wip

上级 1ab88581
......@@ -43,8 +43,31 @@ typedef enum {
SM_NDLB_DISABLE_SRTP_AUTH = (1 << 3)
} switch_core_media_NDLB_t;
typedef enum {
SCMF_DISABLE_TRANSCODING = (1 << 0)
} switch_core_media_flag_t;
struct switch_media_handle_s;
typedef enum {
STYPE_INTVAL,
STYPE_UINTVAL,
STYPE_CHARVAL,
} scm_type_t;
typedef enum {
SCM_INBOUND_CODEC_STRING,
SCM_OUTBOUND_CODEC_STRING,
SCM_TEST,
SCM_MAX
} scm_param_t;
#define switch_media_get_param_int(_h, _p) *(int *)switch_media_get_param(_h, _p)
#define switch_media_get_param_uint(_h, _p) *(uint32_t *)switch_media_get_param(_h, _p)
#define switch_media_get_param_char(_h, _p) (char *)switch_media_get_param(_h, _p)
SWITCH_DECLARE(switch_status_t) switch_media_handle_create(switch_media_handle_t **smhp, switch_core_session_t *session);
SWITCH_DECLARE(switch_media_handle_t *) switch_core_session_get_media_handle(switch_core_session_t *session);
......@@ -53,6 +76,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_media_handle_ready(switch_co
SWITCH_DECLARE(void) switch_media_handle_set_ndlb(switch_media_handle_t *smh, switch_core_media_NDLB_t flag);
SWITCH_DECLARE(void) switch_media_handle_clear_ndlb(switch_media_handle_t *smh, switch_core_media_NDLB_t flag);
SWITCH_DECLARE(int32_t) switch_media_handle_test_ndlb(switch_media_handle_t *smh, switch_core_media_NDLB_t flag);
SWITCH_DECLARE(void) switch_media_handle_set_media_flag(switch_media_handle_t *smh, switch_core_media_flag_t flag);
SWITCH_DECLARE(void) switch_media_handle_clear_media_flag(switch_media_handle_t *smh, switch_core_media_flag_t flag);
SWITCH_DECLARE(int32_t) switch_media_handle_test_media_flag(switch_media_handle_t *smh, switch_core_media_flag_t flag);
SWITCH_DECLARE(void) switch_core_session_check_outgoing_crypto(switch_core_session_t *session, const char *sec_var);
SWITCH_DECLARE(const char *) switch_core_session_local_crypto_key(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(int) switch_core_session_check_incoming_crypto(switch_core_session_t *session,
......@@ -64,6 +90,10 @@ SWITCH_DECLARE(void) switch_core_session_get_recovery_crypto_key(switch_core_ses
SWITCH_DECLARE(void) switch_core_media_set_rtp_session(switch_core_session_t *session, switch_media_type_t type, switch_rtp_t *rtp_session);
SWITCH_DECLARE(void) switch_media_set_param(switch_media_handle_t *smh, scm_param_t param, ...);
SWITCH_DECLARE(void *) switch_media_get_param(switch_media_handle_t *smh, scm_param_t param);
SWITCH_DECLARE(const char *)switch_core_media_get_codec_string(switch_core_session_t *session);
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
......
......@@ -611,6 +611,7 @@ struct sofia_profile {
uint8_t pflags[PFLAG_MAX];
unsigned int mflags;
unsigned int ndlb;
unsigned int media_flags;
uint32_t max_calls;
uint32_t nonce_ttl;
nua_t *nua;
......
......@@ -4251,7 +4251,9 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
}
} else if (!strcasecmp(var, "disable-transcoding")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_DISABLE_TRANSCODING);
profile->media_flags |= SCMF_DISABLE_TRANSCODING;
} else {
profile->media_flags &= ~SCMF_DISABLE_TRANSCODING;
}
} else if (!strcasecmp(var, "rtp-rewrite-timestamps")) {
if (switch_true(val)) {
......
......@@ -281,6 +281,11 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
switch_media_handle_create(&tech_pvt->media_handle, session);
switch_media_handle_set_ndlb(tech_pvt->media_handle, tech_pvt->profile->ndlb);
switch_media_handle_set_media_flag(tech_pvt->media_handle, tech_pvt->profile->media_flags);
switch_media_set_param(tech_pvt->media_handle, SCM_INBOUND_CODEC_STRING, profile->inbound_codec_string);
switch_media_set_param(tech_pvt->media_handle, SCM_OUTBOUND_CODEC_STRING, profile->inbound_codec_string);
switch_core_session_set_private(session, tech_pvt);
......
......@@ -848,7 +848,7 @@ uint8_t sofia_media_negotiate_sdp(switch_core_session_t *session, const char *r_
if (mimp) {
char tmp[50];
const char *mirror = switch_channel_get_variable(tech_pvt->channel, "sip_mirror_remote_audio_codec_payload");
const char *mirror = switch_channel_get_variable(tech_pvt->channel, "rtp_mirror_remote_audio_codec_payload");
tech_pvt->rm_encoding = switch_core_session_strdup(session, (char *) map->rm_encoding);
tech_pvt->iananame = switch_core_session_strdup(session, (char *) mimp->iananame);
......@@ -874,7 +874,7 @@ uint8_t sofia_media_negotiate_sdp(switch_core_session_t *session, const char *r_
}
switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->audio_recv_pt);
switch_channel_set_variable(tech_pvt->channel, "sip_audio_recv_pt", tmp);
switch_channel_set_variable(tech_pvt->channel, "rtp_audio_recv_pt", tmp);
}
......@@ -1768,7 +1768,7 @@ void sofia_media_set_sdp_codec_string(switch_core_session_t *session, const char
if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
if ((sdp = sdp_session(parser))) {
sofia_media_set_r_sdp_codec_string(session, sofia_media_get_codec_string(tech_pvt), sdp);
sofia_media_set_r_sdp_codec_string(session, switch_core_media_get_codec_string(tech_pvt->session), sdp);
}
sdp_parser_free(parser);
......@@ -1903,6 +1903,7 @@ switch_status_t sofia_media_tech_set_codec(private_object_t *tech_pvt, int force
switch_yield(tech_pvt->read_impl.microseconds_per_packet);
switch_core_codec_destroy(&tech_pvt->read_codec);
switch_core_codec_destroy(&tech_pvt->write_codec);
switch_channel_audio_sync(tech_pvt->channel);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Already using %s\n", tech_pvt->read_impl.iananame);
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
......@@ -2996,27 +2997,6 @@ void sofia_media_set_local_sdp(private_object_t *tech_pvt, const char *ip, switc
switch_safe_free(buf);
}
const char *sofia_media_get_codec_string(private_object_t *tech_pvt)
{
const char *preferred = NULL, *fallback = NULL;
if (!(preferred = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) {
preferred = switch_channel_get_variable(tech_pvt->channel, "codec_string");
}
if (!preferred) {
if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
preferred = tech_pvt->profile->outbound_codec_string;
fallback = tech_pvt->profile->inbound_codec_string;
} else {
preferred = tech_pvt->profile->inbound_codec_string;
fallback = tech_pvt->profile->outbound_codec_string;
}
}
return !zstr(preferred) ? preferred : fallback;
}
void sofia_media_tech_prepare_codecs(private_object_t *tech_pvt)
{
const char *abs, *codec_string = NULL;
......@@ -3045,7 +3025,7 @@ void sofia_media_tech_prepare_codecs(private_object_t *tech_pvt)
}
if (!(codec_string = switch_channel_get_variable(tech_pvt->channel, "codec_string"))) {
codec_string = sofia_media_get_codec_string(tech_pvt);
codec_string = switch_core_media_get_codec_string(tech_pvt->session);
}
if (codec_string && *codec_string == '=') {
......@@ -3067,12 +3047,11 @@ void sofia_media_tech_prepare_codecs(private_object_t *tech_pvt)
ready:
if (codec_string) {
char *tmp_codec_string;
if ((tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string))) {
char *tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string);
tech_pvt->codec_order_last = switch_separate_string(tmp_codec_string, ',', tech_pvt->codec_order, SWITCH_MAX_CODECS);
tech_pvt->num_codecs =
switch_loadable_module_get_codecs_sorted(tech_pvt->codecs, SWITCH_MAX_CODECS, tech_pvt->codec_order, tech_pvt->codec_order_last);
}
} else {
tech_pvt->num_codecs = switch_loadable_module_get_codecs(tech_pvt->codecs, sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]));
}
......@@ -3080,6 +3059,7 @@ void sofia_media_tech_prepare_codecs(private_object_t *tech_pvt)
}
void sofia_media_check_video_codecs(private_object_t *tech_pvt)
{
if (tech_pvt->num_codecs && !sofia_test_flag(tech_pvt, TFLAG_VIDEO)) {
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论