omg it can make calls ... long way to go ...
This commit is contained in:
parent
48554d1a85
commit
d012c5f392
|
@ -138,6 +138,13 @@ typedef struct switch_core_media_params_s {
|
|||
|
||||
char *adv_sdp_audio_ip;
|
||||
|
||||
int num_codecs;//x:tp
|
||||
|
||||
// HACK REMOVE ME
|
||||
switch_rtp_t *rtp_session;
|
||||
switch_rtp_t *video_rtp_session;
|
||||
|
||||
|
||||
} switch_core_media_params_t;
|
||||
|
||||
static inline const char *switch_media_type2str(switch_media_type_t type)
|
||||
|
@ -202,6 +209,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
|
|||
SWITCH_DECLARE(switch_status_t) switch_core_media_ext_address_lookup(switch_core_session_t *session, char **ip, switch_port_t *port, const char *sourceip);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_core_session_t *session,
|
||||
switch_core_session_t *other_session, switch_t38_options_t *t38_options);
|
||||
SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *session, const char *ip, switch_port_t port, const char *sr, int force);
|
||||
SWITCH_DECLARE(void)switch_core_media_set_local_sdp(switch_core_session_t *session, const char *sdp_str, switch_bool_t dup);
|
||||
SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session);
|
||||
SWITCH_DECLARE(void) switch_core_media_set_image_sdp(switch_core_session_t *session, switch_t38_options_t *t38_options, int insist);
|
||||
SWITCH_DECLARE(void) switch_core_media_prepare_codecs(switch_core_session_t *session, switch_bool_t force);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
#endif
|
||||
|
|
|
@ -685,7 +685,7 @@ struct private_object {
|
|||
char *codec_order[SWITCH_MAX_CODECS];
|
||||
int codec_order_last;
|
||||
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
|
||||
int num_codecs;
|
||||
|
||||
const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS];
|
||||
int num_negotiated_codecs;
|
||||
switch_codec_t read_codec;
|
||||
|
@ -873,18 +873,10 @@ void sofia_glue_global_standby(switch_bool_t on);
|
|||
|
||||
switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt);
|
||||
|
||||
void sofia_glue_deactivate_rtp(private_object_t *tech_pvt);
|
||||
|
||||
void sofia_media_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch_port_t port, const char *sr, int force);
|
||||
|
||||
void sofia_media_tech_prepare_codecs(private_object_t *tech_pvt);
|
||||
|
||||
const char *sofia_media_get_codec_string(private_object_t *tech_pvt);
|
||||
|
||||
void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *profile, private_object_t *tech_pvt, const char *channame);
|
||||
|
||||
switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt, int force);
|
||||
|
||||
switch_status_t sofia_glue_do_invite(switch_core_session_t *session);
|
||||
|
||||
uint8_t sofia_media_negotiate_sdp(switch_core_session_t *session, const char *r_sdp);
|
||||
|
@ -1069,7 +1061,7 @@ char *sofia_glue_strip_uri(const char *str);
|
|||
int sofia_glue_transport_has_tls(const sofia_transport_t tp);
|
||||
const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name);
|
||||
switch_status_t sofia_media_build_crypto(private_object_t *tech_pvt, int index, switch_rtp_crypto_key_type_t type, switch_rtp_crypto_direction_t direction);
|
||||
void sofia_media_tech_patch_sdp(private_object_t *tech_pvt);
|
||||
|
||||
void sofia_presence_event_thread_start(void);
|
||||
void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int reboot);
|
||||
void sofia_reg_check_call_id(sofia_profile_t *profile, const char *call_id);
|
||||
|
@ -1086,7 +1078,6 @@ void sofia_reg_send_reboot(sofia_profile_t *profile, const char *callid, const c
|
|||
void sofia_glue_restart_all_profiles(void);
|
||||
const char *sofia_state_string(int state);
|
||||
void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout);
|
||||
void sofia_glue_set_udptl_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *t38_options, int insist);
|
||||
|
||||
/*
|
||||
* Logging control functions
|
||||
|
@ -1111,7 +1102,6 @@ switch_status_t list_profiles_full(const char *line, const char *cursor, switch_
|
|||
switch_status_t list_profiles(const char *line, const char *cursor, switch_console_callback_match_t **matches);
|
||||
|
||||
sofia_cid_type_t sofia_cid_name2type(const char *name);
|
||||
void sofia_media_tech_set_local_sdp(private_object_t *tech_pvt, const char *sdp_str, switch_bool_t dup);
|
||||
void sofia_glue_set_rtp_stats(private_object_t *tech_pvt);
|
||||
void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port);
|
||||
sofia_destination_t *sofia_glue_get_destination(char *data);
|
||||
|
|
|
@ -5805,7 +5805,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
} else {
|
||||
uint8_t match = 0;
|
||||
|
||||
if (tech_pvt->num_codecs) {
|
||||
if (tech_pvt->mparams->num_codecs) {
|
||||
match = sofia_media_negotiate_sdp(session, r_sdp);
|
||||
}
|
||||
|
||||
|
@ -5888,8 +5888,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
switch_channel_hangup(channel, SWITCH_CAUSE_MANDATORY_IE_MISSING);
|
||||
} else {
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP");
|
||||
sofia_glue_tech_choose_port(tech_pvt, 0);
|
||||
sofia_media_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
|
||||
switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0);
|
||||
switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0);
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_3PCC);
|
||||
switch_channel_set_state(channel, CS_HIBERNATE);
|
||||
if (sofia_use_soa(tech_pvt)) {
|
||||
|
@ -5911,8 +5911,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
// so can be made to work with bypass media as we have time to find out what the other end thinks codec offer should be...
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP");
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_3PCC);
|
||||
//sofia_glue_tech_choose_port(tech_pvt, 0);
|
||||
//sofia_media_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
|
||||
//switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0);
|
||||
//switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0);
|
||||
sofia_set_flag(tech_pvt, TFLAG_LATE_NEGOTIATION);
|
||||
//Moves into CS_INIT so call moves forward into the dialplan
|
||||
switch_channel_set_state(channel, CS_INIT);
|
||||
|
@ -5980,14 +5980,14 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
tech_pvt->hold_laps = 1;
|
||||
switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp);
|
||||
switch_channel_clear_flag(channel, CF_PROXY_MODE);
|
||||
sofia_media_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE);
|
||||
switch_core_media_set_local_sdp(tech_pvt->session, NULL, SWITCH_FALSE);
|
||||
|
||||
if (!switch_channel_media_ready(channel)) {
|
||||
if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) {
|
||||
//const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
|
||||
|
||||
tech_pvt->num_codecs = 0;
|
||||
sofia_media_tech_prepare_codecs(tech_pvt);
|
||||
|
||||
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_TRUE);
|
||||
if (sofia_media_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
|
@ -5999,14 +5999,14 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
|
||||
|
||||
if (!switch_rtp_ready(tech_pvt->rtp_session)) {
|
||||
sofia_media_tech_prepare_codecs(tech_pvt);
|
||||
if ((status = sofia_glue_tech_choose_port(tech_pvt, 0)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_FALSE);
|
||||
if ((status = switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
switch_core_session_rwunlock(other_session);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
sofia_media_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
|
||||
switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 1);
|
||||
|
||||
if (sofia_use_soa(tech_pvt)) {
|
||||
nua_respond(tech_pvt->nh, SIP_200_OK,
|
||||
|
@ -6098,7 +6098,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
|
||||
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);
|
||||
|
||||
if (tech_pvt->num_codecs) {
|
||||
if (tech_pvt->mparams->num_codecs) {
|
||||
match = sofia_media_negotiate_sdp(session, r_sdp);
|
||||
}
|
||||
|
||||
|
@ -6108,11 +6108,11 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
}
|
||||
|
||||
if (match) {
|
||||
if (sofia_glue_tech_choose_port(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
sofia_media_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
|
||||
switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0);
|
||||
|
||||
if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Reinvite RTP Error!\n");
|
||||
|
@ -6131,7 +6131,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
if (is_ok) {
|
||||
|
||||
if (switch_core_session_local_crypto_key(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
|
||||
sofia_media_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
|
||||
switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0);
|
||||
}
|
||||
if (sofia_use_soa(tech_pvt)) {
|
||||
nua_respond(tech_pvt->nh, SIP_200_OK,
|
||||
|
@ -6162,14 +6162,14 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
|
||||
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);
|
||||
|
||||
if (tech_pvt->num_codecs) {
|
||||
if (tech_pvt->mparams->num_codecs) {
|
||||
match = sofia_media_negotiate_sdp(session, r_sdp);
|
||||
}
|
||||
if (match) {
|
||||
if (sofia_glue_tech_choose_port(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
sofia_media_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
|
||||
switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Processing updated SDP\n");
|
||||
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);
|
||||
|
@ -6222,7 +6222,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
uint8_t match = 0;
|
||||
int is_ok = 1;
|
||||
|
||||
if (tech_pvt->num_codecs) {
|
||||
if (tech_pvt->mparams->num_codecs) {
|
||||
match = sofia_media_negotiate_sdp(session, r_sdp);
|
||||
}
|
||||
|
||||
|
@ -6255,7 +6255,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);
|
||||
tech_pvt->nh = tech_pvt->nh2;
|
||||
tech_pvt->nh2 = NULL;
|
||||
if (sofia_glue_tech_choose_port(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0) == SWITCH_STATUS_SUCCESS) {
|
||||
if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cheater Reinvite RTP Error!\n");
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
|
@ -6318,7 +6318,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
} else {
|
||||
uint8_t match = 0;
|
||||
|
||||
if (tech_pvt->num_codecs) {
|
||||
if (tech_pvt->mparams->num_codecs) {
|
||||
match = sofia_media_negotiate_sdp(session, r_sdp);
|
||||
}
|
||||
|
||||
|
@ -6327,7 +6327,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
if (match) {
|
||||
switch_channel_check_zrtp(channel);
|
||||
|
||||
if (sofia_glue_tech_choose_port(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0) == SWITCH_STATUS_SUCCESS) {
|
||||
if (sofia_media_activate_rtp(tech_pvt) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_mark_answered(channel);
|
||||
} else {
|
||||
|
@ -8119,7 +8119,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
|||
}
|
||||
|
||||
//sofia_glue_set_name(tech_pvt, channel_name);
|
||||
sofia_media_tech_prepare_codecs(tech_pvt);
|
||||
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_FALSE);
|
||||
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "INBOUND CALL");
|
||||
|
||||
|
|
|
@ -83,6 +83,9 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
|
|||
switch_mutex_lock(tech_pvt->flag_mutex);
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
|
||||
tech_pvt->mparams = switch_core_session_alloc(session, sizeof(*tech_pvt->mparams));
|
||||
|
||||
|
||||
/* copy flags from profile to the sofia private */
|
||||
for (x = 0; x < TFLAG_MAX; x++) {
|
||||
tech_pvt->flags[x] = profile->flags[x];
|
||||
|
@ -138,6 +141,8 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
|
|||
switch_channel_set_cap(tech_pvt->channel, CC_FS_RTP);
|
||||
switch_channel_set_cap(tech_pvt->channel, CC_QUEUEABLE_DTMF_DELAY);
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
@ -153,6 +158,8 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
|
|||
tech_pvt->mparams->jb_msec = profile->jb_msec;
|
||||
tech_pvt->mparams->rtcp_audio_interval_msec = profile->rtcp_audio_interval_msec;
|
||||
tech_pvt->mparams->rtcp_video_interval_msec = profile->rtcp_video_interval_msec;
|
||||
tech_pvt->mparams->sdp_username = profile->sdp_username;
|
||||
|
||||
|
||||
switch_media_handle_create(&tech_pvt->media_handle, session, tech_pvt->mparams);
|
||||
switch_media_handle_set_media_flags(tech_pvt->media_handle, tech_pvt->profile->media_flags);
|
||||
|
@ -696,7 +703,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
|
||||
cid_name = caller_profile->caller_id_name;
|
||||
cid_num = caller_profile->caller_id_number;
|
||||
sofia_media_tech_prepare_codecs(tech_pvt);
|
||||
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_FALSE);
|
||||
switch_core_media_check_video_codecs(tech_pvt->session);
|
||||
check_decode(cid_name, session);
|
||||
check_decode(cid_num, session);
|
||||
|
@ -708,13 +715,13 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
|
||||
max_forwards = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE);
|
||||
|
||||
if ((status = sofia_glue_tech_choose_port(tech_pvt, 0)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Port Error!\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
if (!switch_channel_get_private(tech_pvt->channel, "t38_options") || zstr(tech_pvt->mparams->local_sdp_str)) {
|
||||
sofia_media_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
|
||||
switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0);
|
||||
}
|
||||
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_READY);
|
||||
|
@ -1136,7 +1143,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
if (switch_rtp_ready(tech_pvt->rtp_session)) {
|
||||
switch_core_media_proxy_remote_addr(session, NULL);
|
||||
}
|
||||
sofia_media_tech_patch_sdp(tech_pvt);
|
||||
switch_core_media_patch_sdp(tech_pvt->session);
|
||||
}
|
||||
|
||||
if (!zstr(tech_pvt->dest)) {
|
||||
|
@ -1976,7 +1983,7 @@ int sofia_recover_callback(switch_core_session_t *session)
|
|||
//sofia_media_tech_set_video_codec(tech_pvt, 1);
|
||||
}
|
||||
|
||||
sofia_media_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
|
||||
switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 1);
|
||||
|
||||
if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
|
||||
goto end;
|
||||
|
|
|
@ -122,6 +122,10 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
|
|||
status = switch_core_media_activate_rtp(tech_pvt->session);
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
|
||||
///HACK REMOVE ME
|
||||
tech_pvt->rtp_session = tech_pvt->mparams->rtp_session;
|
||||
tech_pvt->video_rtp_session = tech_pvt->mparams->video_rtp_session;
|
||||
|
||||
if (status == SWITCH_STATUS_SUCCESS) {
|
||||
sofia_set_flag(tech_pvt, TFLAG_RTP);
|
||||
sofia_set_flag(tech_pvt, TFLAG_IO);
|
||||
|
@ -394,7 +398,7 @@ switch_status_t sofia_media_tech_media(private_object_t *tech_pvt, const char *r
|
|||
}
|
||||
|
||||
if ((match = sofia_media_negotiate_sdp(tech_pvt->session, r_sdp))) {
|
||||
if (sofia_glue_tech_choose_port(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -411,69 +415,6 @@ switch_status_t sofia_media_tech_media(private_object_t *tech_pvt, const char *r
|
|||
}
|
||||
|
||||
|
||||
void sofia_media_tech_prepare_codecs(private_object_t *tech_pvt)
|
||||
{
|
||||
const char *abs, *codec_string = NULL;
|
||||
const char *ocodec = NULL;
|
||||
|
||||
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) || switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tech_pvt->num_codecs) {
|
||||
return;
|
||||
}
|
||||
|
||||
tech_pvt->payload_space = 0;
|
||||
|
||||
switch_assert(tech_pvt->session != NULL);
|
||||
|
||||
if ((abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) {
|
||||
/* inherit_codec == true will implicitly clear the absolute_codec_string
|
||||
variable if used since it was the reason it was set in the first place and is no longer needed */
|
||||
if (switch_true(switch_channel_get_variable(tech_pvt->channel, "inherit_codec"))) {
|
||||
switch_channel_set_variable(tech_pvt->channel, "absolute_codec_string", NULL);
|
||||
}
|
||||
codec_string = abs;
|
||||
goto ready;
|
||||
}
|
||||
|
||||
if (!(codec_string = switch_channel_get_variable(tech_pvt->channel, "codec_string"))) {
|
||||
codec_string = switch_core_media_get_codec_string(tech_pvt->session);
|
||||
}
|
||||
|
||||
if (codec_string && *codec_string == '=') {
|
||||
codec_string++;
|
||||
goto ready;
|
||||
}
|
||||
|
||||
|
||||
if ((ocodec = switch_channel_get_variable(tech_pvt->channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
|
||||
if (!codec_string || sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_TRANSCODING)) {
|
||||
codec_string = ocodec;
|
||||
} else {
|
||||
if (!(codec_string = switch_core_session_sprintf(tech_pvt->session, "%s,%s", ocodec, codec_string))) {
|
||||
codec_string = ocodec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ready:
|
||||
|
||||
if (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]));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void sofia_media_deactivate_rtp(private_object_t *tech_pvt)
|
||||
{
|
||||
int loops = 0;
|
||||
|
|
|
@ -135,7 +135,7 @@ struct switch_media_handle_s {
|
|||
char *codec_order[SWITCH_MAX_CODECS];//x:tp
|
||||
int codec_order_last;//x:tp
|
||||
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];//x:tp
|
||||
int num_codecs;//x:tp
|
||||
|
||||
int payload_space;//x:tp
|
||||
char *origin;//x:tp
|
||||
int hold_laps;//x:tp
|
||||
|
@ -858,8 +858,10 @@ SWITCH_DECLARE(void) switch_media_handle_set_media_flags(switch_media_handle_t *
|
|||
switch_assert(smh);
|
||||
|
||||
for(i = 0; i < SCMF_MAX; i++) {
|
||||
if (flags[i]) {
|
||||
smh->media_flags[i] = flags[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -920,10 +922,10 @@ SWITCH_DECLARE(void) switch_core_media_prepare_codecs(switch_core_session_t *ses
|
|||
}
|
||||
|
||||
if (force) {
|
||||
smh->num_codecs = 0;
|
||||
smh->mparams->num_codecs = 0;
|
||||
}
|
||||
|
||||
if (smh->num_codecs) {
|
||||
if (smh->mparams->num_codecs) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -966,9 +968,9 @@ SWITCH_DECLARE(void) switch_core_media_prepare_codecs(switch_core_session_t *ses
|
|||
if (codec_string) {
|
||||
char *tmp_codec_string = switch_core_session_strdup(smh->session, codec_string);
|
||||
smh->codec_order_last = switch_separate_string(tmp_codec_string, ',', smh->codec_order, SWITCH_MAX_CODECS);
|
||||
smh->num_codecs = switch_loadable_module_get_codecs_sorted(smh->codecs, SWITCH_MAX_CODECS, smh->codec_order, smh->codec_order_last);
|
||||
smh->mparams->num_codecs = switch_loadable_module_get_codecs_sorted(smh->codecs, SWITCH_MAX_CODECS, smh->codec_order, smh->codec_order_last);
|
||||
} else {
|
||||
smh->num_codecs = switch_loadable_module_get_codecs(smh->codecs, sizeof(smh->codecs) / sizeof(smh->codecs[0]));
|
||||
smh->mparams->num_codecs = switch_loadable_module_get_codecs(smh->codecs, sizeof(smh->codecs) / sizeof(smh->codecs[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -986,7 +988,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (!(smh->flags & SCMF_RUNNING)) {
|
||||
if (!smh->media_flags[SCMF_RUNNING]) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1002,7 +1004,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
|
|||
engine->read_frame.datalen = 0;
|
||||
|
||||
|
||||
while ((smh->flags & SCMF_RUNNING) && engine->read_frame.datalen == 0) {
|
||||
while (smh->media_flags[SCMF_RUNNING] && engine->read_frame.datalen == 0) {
|
||||
engine->read_frame.flags = SFF_NONE;
|
||||
|
||||
status = switch_rtp_zerocopy_read_frame(engine->rtp_session, &engine->read_frame, flags);
|
||||
|
@ -1249,7 +1251,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
|
|||
|
||||
if (engine->read_frame.datalen == 0) {
|
||||
*frame = NULL;
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
*frame = &engine->read_frame;
|
||||
|
@ -1270,7 +1271,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_sessio
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (!(smh->flags & SCMF_RUNNING)) {
|
||||
if (!smh->media_flags[SCMF_RUNNING]) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1355,7 +1356,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_get_offered_pt(switch_core_ses
|
|||
}
|
||||
|
||||
|
||||
for (i = 0; i < smh->num_codecs; i++) {
|
||||
for (i = 0; i < smh->mparams->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = smh->codecs[i];
|
||||
|
||||
if (!strcasecmp(imp->iananame, mimp->iananame)) {
|
||||
|
@ -1629,10 +1630,10 @@ SWITCH_DECLARE(void) switch_core_media_check_video_codecs(switch_core_session_t
|
|||
return;
|
||||
}
|
||||
|
||||
if (smh->num_codecs && !switch_channel_test_flag(session->channel, CF_VIDEO_POSSIBLE)) {
|
||||
if (smh->mparams->num_codecs && !switch_channel_test_flag(session->channel, CF_VIDEO_POSSIBLE)) {
|
||||
int i;
|
||||
smh->video_count = 0;
|
||||
for (i = 0; i < smh->num_codecs; i++) {
|
||||
for (i = 0; i < smh->mparams->num_codecs; i++) {
|
||||
|
||||
if (smh->codecs[i]->codec_type == SWITCH_CODEC_TYPE_VIDEO) {
|
||||
smh->video_count++;
|
||||
|
@ -1680,7 +1681,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
|||
|
||||
|
||||
codec_array = smh->codecs;
|
||||
total_codecs = smh->num_codecs;
|
||||
total_codecs = smh->mparams->num_codecs;
|
||||
|
||||
|
||||
if (!(parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
|
||||
|
@ -1814,10 +1815,10 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
|||
codec_array = smh->negotiated_codecs;
|
||||
total_codecs = smh->num_negotiated_codecs;
|
||||
} else if (reneg) {
|
||||
smh->num_codecs = 0;
|
||||
smh->mparams->num_codecs = 0;
|
||||
switch_core_media_prepare_codecs(session, SWITCH_FALSE);
|
||||
codec_array = smh->codecs;
|
||||
total_codecs = smh->num_codecs;
|
||||
total_codecs = smh->mparams->num_codecs;
|
||||
}
|
||||
|
||||
if (switch_stristr("T38FaxFillBitRemoval:", r_sdp) || switch_stristr("T38FaxTranscodingMMR:", r_sdp) ||
|
||||
|
@ -2075,7 +2076,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
|||
last = first + 1;
|
||||
} else {
|
||||
first = 0;
|
||||
last = smh->num_codecs;
|
||||
last = smh->mparams->num_codecs;
|
||||
}
|
||||
|
||||
codec_ms = ptime;
|
||||
|
@ -3132,14 +3133,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
|
|||
}
|
||||
|
||||
if (switch_channel_up(session->channel)) {
|
||||
a_engine->rtp_session = switch_rtp_new(a_engine->codec_params.remote_sdp_ip,
|
||||
a_engine->codec_params.remote_sdp_port,
|
||||
a_engine->rtp_session = switch_rtp_new(a_engine->codec_params.local_sdp_ip,
|
||||
a_engine->codec_params.local_sdp_port,
|
||||
a_engine->codec_params.remote_sdp_ip,
|
||||
a_engine->codec_params.remote_sdp_port,
|
||||
a_engine->codec_params.agreed_pt,
|
||||
a_engine->read_impl.samples_per_packet,
|
||||
a_engine->codec_params.codec_ms * 1000,
|
||||
flags, timer_name, &err, switch_core_session_get_pool(session));
|
||||
//HACK REMOVE ME
|
||||
smh->mparams->rtp_session = a_engine->rtp_session;
|
||||
}
|
||||
|
||||
if (switch_rtp_ready(a_engine->rtp_session)) {
|
||||
|
@ -3502,13 +3505,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
|
|||
flags[SWITCH_RTP_FLAG_NOBLOCK] = 0;
|
||||
flags[SWITCH_RTP_FLAG_VIDEO]++;
|
||||
|
||||
v_engine->rtp_session = switch_rtp_new(a_engine->codec_params.remote_sdp_ip,
|
||||
v_engine->rtp_session = switch_rtp_new(a_engine->codec_params.local_sdp_ip,
|
||||
v_engine->codec_params.local_sdp_port,
|
||||
v_engine->codec_params.remote_sdp_ip,
|
||||
v_engine->codec_params.remote_sdp_port,
|
||||
v_engine->codec_params.agreed_pt,
|
||||
1, 90000, flags, NULL, &err, switch_core_session_get_pool(session));
|
||||
|
||||
|
||||
//HACK REMOVE ME
|
||||
smh->mparams->video_rtp_session = v_engine->rtp_session;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%sVIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n",
|
||||
switch_channel_test_flag(session->channel, CF_PROXY_MEDIA) ? "PROXY " : "",
|
||||
switch_channel_get_name(session->channel),
|
||||
|
@ -3630,7 +3637,7 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
|
|||
|
||||
|
||||
|
||||
for (i = 0; i < smh->num_codecs; i++) {
|
||||
for (i = 0; i < smh->mparams->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = smh->codecs[i];
|
||||
int this_ptime = (imp->microseconds_per_packet / 1000);
|
||||
|
||||
|
@ -3679,7 +3686,7 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
|
|||
|
||||
memset(already_did, 0, sizeof(already_did));
|
||||
|
||||
for (i = 0; i < smh->num_codecs; i++) {
|
||||
for (i = 0; i < smh->mparams->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = smh->codecs[i];
|
||||
char *fmtp = imp->fmtp;
|
||||
int this_ptime = imp->microseconds_per_packet / 1000;
|
||||
|
@ -3876,7 +3883,7 @@ SWITCH_DECLARE(void)switch_core_media_set_local_sdp(switch_core_session_t *sessi
|
|||
|
||||
//?
|
||||
#define SDPBUFLEN 65536
|
||||
void sofia_media_set_local_sdp(switch_core_session_t *session, const char *ip, switch_port_t port, const char *sr, int force)
|
||||
SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *session, const char *ip, switch_port_t port, const char *sr, int force)
|
||||
{
|
||||
char *buf;
|
||||
int ptime = 0;
|
||||
|
@ -3929,7 +3936,7 @@ void sofia_media_set_local_sdp(switch_core_session_t *session, const char *ip, s
|
|||
|
||||
smh->payload_space = 98;
|
||||
|
||||
for (i = 0; i < smh->num_codecs; i++) {
|
||||
for (i = 0; i < smh->mparams->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = smh->codecs[i];
|
||||
|
||||
smh->ianacodes[i] = imp->ianacode;
|
||||
|
@ -4095,7 +4102,7 @@ void sofia_media_set_local_sdp(switch_core_session_t *session, const char *ip, s
|
|||
//switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=encryption:optional\n");
|
||||
}
|
||||
|
||||
} else if (smh->num_codecs) {
|
||||
} else if (smh->mparams->num_codecs) {
|
||||
int i;
|
||||
int cur_ptime = 0, this_ptime = 0, cng_type = 0;
|
||||
const char *mult;
|
||||
|
@ -4131,7 +4138,7 @@ void sofia_media_set_local_sdp(switch_core_session_t *session, const char *ip, s
|
|||
|
||||
} else {
|
||||
|
||||
for (i = 0; i < smh->num_codecs; i++) {
|
||||
for (i = 0; i < smh->mparams->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = smh->codecs[i];
|
||||
|
||||
if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO) {
|
||||
|
@ -4187,10 +4194,10 @@ void sofia_media_set_local_sdp(switch_core_session_t *session, const char *ip, s
|
|||
if (v_engine->codec_params.rm_encoding) {
|
||||
switch_core_media_set_video_codec(session, 0);
|
||||
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", v_engine->codec_params.agreed_pt);
|
||||
} else if (smh->num_codecs) {
|
||||
} else if (smh->mparams->num_codecs) {
|
||||
int i;
|
||||
int already_did[128] = { 0 };
|
||||
for (i = 0; i < smh->num_codecs; i++) {
|
||||
for (i = 0; i < smh->mparams->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = smh->codecs[i];
|
||||
|
||||
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
|
||||
|
@ -4243,11 +4250,11 @@ void sofia_media_set_local_sdp(switch_core_session_t *session, const char *ip, s
|
|||
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\n", v_engine->codec_params.pt, pass_fmtp);
|
||||
}
|
||||
|
||||
} else if (smh->num_codecs) {
|
||||
} else if (smh->mparams->num_codecs) {
|
||||
int i;
|
||||
int already_did[128] = { 0 };
|
||||
|
||||
for (i = 0; i < smh->num_codecs; i++) {
|
||||
for (i = 0; i < smh->mparams->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = smh->codecs[i];
|
||||
char *fmtp = NULL;
|
||||
uint32_t ianacode = smh->ianacodes[i];
|
||||
|
|
|
@ -1610,6 +1610,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||
|
||||
tstatus = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_SINGLE_READ, 0);
|
||||
|
||||
|
||||
if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue