MILESTONE: working audio and no reference to rtp_session in all of sofia

This commit is contained in:
Anthony Minessale 2012-12-22 16:54:35 -06:00
parent caee4cbf46
commit 75c95fa98e
5 changed files with 155 additions and 64 deletions

View File

@ -142,12 +142,6 @@ typedef struct switch_core_media_params_s {
int num_codecs;//x:tp
int hold_laps;//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)
@ -222,16 +216,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
SWITCH_DECLARE(void) switch_core_media_break(switch_media_handle_t *smh, switch_media_type_t type);
SWITCH_DECLARE(void) switch_core_media_kill_socket(switch_media_handle_t *smh, switch_media_type_t type);
SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833(switch_media_handle_t *smh, switch_media_type_t type, const switch_dtmf_t *dtmf);
SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833_in(switch_media_handle_t *smh, switch_media_type_t type, const switch_dtmf_t *dtmf);
SWITCH_DECLARE(uint8_t) switch_core_media_ready(switch_media_handle_t *smh, switch_media_type_t type);
SWITCH_DECLARE(void) switch_core_media_set_recv_pt(switch_media_handle_t *smh, switch_media_type_t type, switch_payload_t pt);
SWITCH_DECLARE(void) switch_core_media_set_telephony_event(switch_media_handle_t *smh, switch_media_type_t type, switch_payload_t te);
SWITCH_DECLARE(void) switch_core_media_set_telephony_recv_event(switch_media_handle_t *smh, switch_media_type_t type, switch_payload_t te);
SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_stats(switch_media_handle_t *smh, switch_media_type_t type, switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_status_t) switch_core_media_udptl_mode(switch_media_handle_t *smh, switch_media_type_t type);
SWITCH_DECLARE(void) switch_core_media_break(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(void) switch_core_media_kill_socket(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833(switch_core_session_t *session, switch_media_type_t type, const switch_dtmf_t *dtmf);
SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833_in(switch_core_session_t *session, switch_media_type_t type, const switch_dtmf_t *dtmf);
SWITCH_DECLARE(uint8_t) switch_core_media_ready(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(void) switch_core_media_set_recv_pt(switch_core_session_t *session, switch_media_type_t type, switch_payload_t pt);
SWITCH_DECLARE(void) switch_core_media_set_telephony_event(switch_core_session_t *session, switch_media_type_t type, switch_payload_t te);
SWITCH_DECLARE(void) switch_core_media_set_telephony_recv_event(switch_core_session_t *session, switch_media_type_t type, switch_payload_t te);
SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_stats(switch_core_session_t *session, switch_media_type_t type, switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_status_t) switch_core_media_udptl_mode(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(void) switch_core_media_set_rtp_flag(switch_core_session_t *session, switch_media_type_t type, switch_rtp_flag_t flag);
SWITCH_DECLARE(void) switch_core_media_clear_rtp_flag(switch_core_session_t *session, switch_media_type_t type, switch_rtp_flag_t flag);
SWITCH_DECLARE(stfu_instance_t *) switch_core_media_get_jb(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_core_session_t *session, switch_media_type_t type, switch_memory_pool_t *pool);
SWITCH_END_EXTERN_C
#endif

View File

@ -5154,14 +5154,14 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
}
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) && has_t38) {
if (switch_core_media_ready(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_core_media_udptl_mode(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO);
if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_core_media_udptl_mode(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO);
if ((uuid = switch_channel_get_partner_uuid(channel)) && (other_session = switch_core_session_locate(uuid))) {
if (switch_core_session_compare(session, other_session)) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
if (switch_rtp_ready(other_tech_pvt->rtp_session)) {
switch_rtp_udptl_mode(other_tech_pvt->rtp_session);
if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_core_media_udptl_mode(other_tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO);
}
}
switch_core_session_rwunlock(other_session);
@ -5234,9 +5234,10 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
}
if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU) && has_t38) {
if (switch_core_media_ready(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO) && switch_rtp_ready(other_tech_pvt->rtp_session)) {
if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) &&
switch_core_media_ready(other_tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_channel_clear_flag(tech_pvt->channel, CF_NOTIMER_DURING_BRIDGE);
switch_core_media_udptl_mode(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO);
switch_core_media_udptl_mode(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating T38 Passthru\n");
}
}
@ -5387,8 +5388,8 @@ void *SWITCH_THREAD_FUNC media_on_hold_thread_run(switch_thread_t *thread, void
switch_ivr_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE);
if (tech_pvt->rtp_session) {
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_core_media_clear_rtp_flag(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, SWITCH_RTP_FLAG_AUTOADJ);
}
switch_core_media_toggle_hold(session, 1);
@ -5998,7 +5999,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
if (!switch_core_media_ready(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO)) {
if (!switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
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);
@ -6156,7 +6157,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
break;
case nua_callstate_ready:
if (r_sdp && !is_dup_sdp && switch_core_media_ready(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO) && !sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
if (r_sdp && !is_dup_sdp && switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) && !sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
/* sdp changed since 18X w sdp, we're supposed to ignore it but we, of course, were pressured into supporting it */
uint8_t match = 0;

View File

@ -1142,7 +1142,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
}
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
if (switch_core_media_ready(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO)) {
if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_core_media_proxy_remote_addr(session, NULL);
}
switch_core_media_patch_sdp(tech_pvt->session);
@ -1325,11 +1325,13 @@ void sofia_glue_do_xfer_invite(switch_core_session_t *session)
#define add_stat(_i, _s) \
switch_snprintf(var_name, sizeof(var_name), "rtp_%s_%s", switch_str_nil(prefix), _s) ; \
switch_snprintf(var_val, sizeof(var_val), "%" SWITCH_SIZE_T_FMT, _i); \
switch_channel_set_variable(tech_pvt->channel, var_name, var_val)
switch_channel_set_variable(channel, var_name, var_val)
static void set_stats(switch_rtp_t *rtp_session, private_object_t *tech_pvt, const char *prefix)
static void set_stats(switch_core_session_t *session, switch_media_type_t type, const char *prefix)
{
switch_rtp_stats_t *stats = switch_rtp_get_stats(rtp_session, NULL);
switch_rtp_stats_t *stats = switch_core_media_get_stats(session, type, NULL);
switch_channel_t *channel = switch_core_session_get_channel(session);
char var_name[256] = "", var_val[35] = "";
if (stats) {
@ -1361,13 +1363,8 @@ static void set_stats(switch_rtp_t *rtp_session, private_object_t *tech_pvt, con
void sofia_glue_set_rtp_stats(private_object_t *tech_pvt)
{
if (tech_pvt->rtp_session) {
set_stats(tech_pvt->rtp_session, tech_pvt, "audio");
}
if (tech_pvt->video_rtp_session) {
set_stats(tech_pvt->video_rtp_session, tech_pvt, "video");
}
set_stats(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, "audio");
set_stats(tech_pvt->session, SWITCH_MEDIA_TYPE_VIDEO, "video");
}
/* map sip responses to QSIG cause codes ala RFC4497 section 8.4.4 */
@ -1991,24 +1988,24 @@ int sofia_recover_callback(switch_core_session_t *session)
goto end;
}
if (switch_core_media_ready(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO)) {
if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
if ((tmp = switch_channel_get_variable(channel, "sip_audio_recv_pt"))) {
switch_core_media_set_recv_pt(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO, (switch_payload_t)atoi(tmp));
switch_core_media_set_recv_pt(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, (switch_payload_t)atoi(tmp));
}
}
if (switch_core_media_ready(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_VIDEO)) {
if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_VIDEO)) {
if ((tmp = switch_channel_get_variable(channel, "sip_video_recv_pt"))) {
switch_core_media_set_recv_pt(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO, (switch_payload_t)atoi(tmp));
switch_core_media_set_recv_pt(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, (switch_payload_t)atoi(tmp));
}
}
if (tech_pvt->te) {
switch_core_media_set_telephony_event(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO, tech_pvt->te);
switch_core_media_set_telephony_event(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, tech_pvt->te);
}
if (tech_pvt->recv_te) {
switch_core_media_set_telephony_recv_event(tech_pvt->media_handle, SWITCH_MEDIA_TYPE_AUDIO, tech_pvt->recv_te);
switch_core_media_set_telephony_recv_event(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, tech_pvt->recv_te);
}
}

View File

@ -122,9 +122,6 @@ 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);

View File

@ -386,7 +386,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_co
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;;
return SWITCH_STATUS_FALSE;
}
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
@ -2931,7 +2931,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;;
return SWITCH_STATUS_FALSE;
}
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
@ -3142,8 +3142,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
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)) {
@ -3514,9 +3512,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
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),
@ -4813,7 +4808,7 @@ SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session)
SWITCH_DECLARE(void) switch_core_media_start_udptl(switch_core_session_t *session, switch_t38_options_t *t38_options)
{
switch_media_handle_t *smh;
switch_rtp_engine_t *a_engine;;
switch_rtp_engine_t *a_engine;
if (!(smh = session->media_handle)) {
return;
@ -5234,64 +5229,146 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
}
SWITCH_DECLARE(void) switch_core_media_break(switch_media_handle_t *smh, switch_media_type_t type)
SWITCH_DECLARE(void) switch_core_media_break(switch_core_session_t *session, switch_media_type_t type)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
switch_rtp_break(smh->engines[type].rtp_session);
}
}
SWITCH_DECLARE(void) switch_core_media_kill_socket(switch_media_handle_t *smh, switch_media_type_t type)
SWITCH_DECLARE(void) switch_core_media_kill_socket(switch_core_session_t *session, switch_media_type_t type)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
switch_rtp_kill_socket(smh->engines[type].rtp_session);
}
}
SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833(switch_media_handle_t *smh, switch_media_type_t type, const switch_dtmf_t *dtmf)
SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833(switch_core_session_t *session, switch_media_type_t type, const switch_dtmf_t *dtmf)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
return switch_rtp_queue_rfc2833(smh->engines[type].rtp_session, dtmf);
}
return SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833_in(switch_media_handle_t *smh, switch_media_type_t type, const switch_dtmf_t *dtmf)
SWITCH_DECLARE(switch_status_t) switch_core_media_queue_rfc2833_in(switch_core_session_t *session, switch_media_type_t type, const switch_dtmf_t *dtmf)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
return switch_rtp_queue_rfc2833_in(smh->engines[type].rtp_session, dtmf);
}
return SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(uint8_t) switch_core_media_ready(switch_media_handle_t *smh, switch_media_type_t type)
SWITCH_DECLARE(uint8_t) switch_core_media_ready(switch_core_session_t *session, switch_media_type_t type)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return 0;
}
return switch_rtp_ready(smh->engines[type].rtp_session);
}
SWITCH_DECLARE(void) switch_core_media_set_recv_pt(switch_media_handle_t *smh, switch_media_type_t type, switch_payload_t pt)
SWITCH_DECLARE(void) switch_core_media_set_rtp_flag(switch_core_session_t *session, switch_media_type_t type, switch_rtp_flag_t flag)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
switch_rtp_set_flag(smh->engines[type].rtp_session, flag);
}
}
SWITCH_DECLARE(void) switch_core_media_clear_rtp_flag(switch_core_session_t *session, switch_media_type_t type, switch_rtp_flag_t flag)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
switch_rtp_clear_flag(smh->engines[type].rtp_session, flag);
}
}
SWITCH_DECLARE(void) switch_core_media_set_recv_pt(switch_core_session_t *session, switch_media_type_t type, switch_payload_t pt)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
switch_rtp_set_recv_pt(smh->engines[type].rtp_session, pt);
}
}
SWITCH_DECLARE(void) switch_core_media_set_telephony_event(switch_media_handle_t *smh, switch_media_type_t type, switch_payload_t te)
SWITCH_DECLARE(void) switch_core_media_set_telephony_event(switch_core_session_t *session, switch_media_type_t type, switch_payload_t te)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
switch_rtp_set_telephony_event(smh->engines[type].rtp_session, te);
}
}
SWITCH_DECLARE(void) switch_core_media_set_telephony_recv_event(switch_media_handle_t *smh, switch_media_type_t type, switch_payload_t te)
SWITCH_DECLARE(void) switch_core_media_set_telephony_recv_event(switch_core_session_t *session, switch_media_type_t type, switch_payload_t te)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
switch_rtp_set_telephony_recv_event(smh->engines[type].rtp_session, te);
}
}
SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_media_handle_t *smh, switch_media_type_t type, switch_memory_pool_t *pool)
SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_core_session_t *session, switch_media_type_t type, switch_memory_pool_t *pool)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return NULL;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
return switch_rtp_get_stats(smh->engines[type].rtp_session, pool);
}
@ -5299,15 +5376,35 @@ SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_media_ha
return NULL;
}
SWITCH_DECLARE(switch_status_t) switch_core_media_udptl_mode(switch_media_handle_t *smh, switch_media_type_t type)
SWITCH_DECLARE(switch_status_t) switch_core_media_udptl_mode(switch_core_session_t *session, switch_media_type_t type)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
return switch_rtp_udptl_mode(smh->engines[type].rtp_session);
}
return SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(stfu_instance_t *) switch_core_media_get_jb(switch_core_session_t *session, switch_media_type_t type)
{
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return NULL;
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
return switch_rtp_get_jitter_buffer(smh->engines[type].rtp_session);
}
return NULL;
}