mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-07 13:35:00 +00:00
MILESTONE: all the crap out of tech_pvt and sofia in general related to media shit
This commit is contained in:
parent
85308861d8
commit
078d963222
@ -134,14 +134,14 @@ typedef struct switch_core_media_params_s {
|
|||||||
|
|
||||||
switch_mutex_t *mutex;
|
switch_mutex_t *mutex;
|
||||||
|
|
||||||
switch_payload_t te;//x:tp
|
switch_payload_t te;
|
||||||
switch_payload_t recv_te;//x:tp
|
switch_payload_t recv_te;
|
||||||
|
|
||||||
char *adv_sdp_audio_ip;
|
char *adv_sdp_audio_ip;
|
||||||
|
|
||||||
int num_codecs;//x:tp
|
int num_codecs;
|
||||||
int hold_laps;//x:tp
|
int hold_laps;
|
||||||
switch_core_media_dtmf_t dtmf_type;//x:tp
|
switch_core_media_dtmf_t dtmf_type;
|
||||||
|
|
||||||
} switch_core_media_params_t;
|
} switch_core_media_params_t;
|
||||||
|
|
||||||
@ -238,7 +238,8 @@ SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_core_ses
|
|||||||
SWITCH_DECLARE(void) switch_core_media_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp);
|
SWITCH_DECLARE(void) switch_core_media_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp);
|
||||||
SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_t *session, const char *r_sdp);
|
SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_t *session, const char *r_sdp);
|
||||||
SWITCH_DECLARE(void) switch_core_media_reset_autofix_timing(switch_core_session_t *session, switch_media_type_t type);
|
SWITCH_DECLARE(void) switch_core_media_reset_autofix_timing(switch_core_session_t *session, switch_media_type_t type);
|
||||||
|
SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session);
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_core_media_codec_chosen(switch_core_session_t *session, switch_media_type_t media);
|
||||||
|
|
||||||
SWITCH_END_EXTERN_C
|
SWITCH_END_EXTERN_C
|
||||||
#endif
|
#endif
|
||||||
|
@ -667,40 +667,19 @@ struct sofia_profile {
|
|||||||
switch_core_media_vflag_t vflags;
|
switch_core_media_vflag_t vflags;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
|
||||||
struct private_object {
|
struct private_object {
|
||||||
sofia_private_t *sofia_private;
|
sofia_private_t *sofia_private;
|
||||||
uint8_t flags[TFLAG_MAX];
|
uint8_t flags[TFLAG_MAX];
|
||||||
// switch_payload_t agreed_pt;
|
|
||||||
// switch_payload_t audio_recv_pt;
|
|
||||||
// switch_payload_t video_recv_pt;
|
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
switch_channel_t *channel;
|
switch_channel_t *channel;
|
||||||
switch_media_handle_t *media_handle;
|
switch_media_handle_t *media_handle;
|
||||||
switch_core_media_params_t mparams;
|
switch_core_media_params_t mparams;
|
||||||
|
|
||||||
//switch_frame_t read_frame;
|
|
||||||
char *codec_order[SWITCH_MAX_CODECS];
|
|
||||||
//int codec_order_last;
|
|
||||||
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
|
|
||||||
|
|
||||||
const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS];
|
|
||||||
//int num_negotiated_codecs;
|
|
||||||
//switch_codec_t read_codec;
|
|
||||||
//switch_codec_t write_codec;
|
|
||||||
//uint32_t codec_ms;
|
|
||||||
// uint32_t bitrate;
|
|
||||||
switch_caller_profile_t *caller_profile;
|
switch_caller_profile_t *caller_profile;
|
||||||
//uint32_t timestamp_send;
|
|
||||||
// switch_rtp_t *rtp_session;
|
|
||||||
|
|
||||||
// uint32_t video_ssrc;
|
|
||||||
sofia_profile_t *profile;
|
sofia_profile_t *profile;
|
||||||
char *reply_contact;
|
char *reply_contact;
|
||||||
char *from_uri;
|
char *from_uri;
|
||||||
char *to_uri;
|
char *to_uri;
|
||||||
char *from_address;
|
|
||||||
char *to_address;
|
|
||||||
char *callid;
|
char *callid;
|
||||||
char *contact_url;
|
char *contact_url;
|
||||||
char *from_str;
|
char *from_str;
|
||||||
@ -709,14 +688,9 @@ struct private_object {
|
|||||||
char *preferred_id;
|
char *preferred_id;
|
||||||
char *privacy;
|
char *privacy;
|
||||||
char *gateway_from_str;
|
char *gateway_from_str;
|
||||||
char *rm_encoding;
|
|
||||||
char *iananame;
|
|
||||||
char *rm_fmtp;
|
|
||||||
char *fmtp_out;
|
|
||||||
char *dest;
|
char *dest;
|
||||||
char *dest_to;
|
char *dest_to;
|
||||||
char *key;
|
char *key;
|
||||||
char *xferto;
|
|
||||||
char *kick;
|
char *kick;
|
||||||
char *origin;
|
char *origin;
|
||||||
char *hash_key;
|
char *hash_key;
|
||||||
@ -733,133 +707,6 @@ struct private_object {
|
|||||||
char *x_freeswitch_support_local;
|
char *x_freeswitch_support_local;
|
||||||
char *last_sent_callee_id_name;
|
char *last_sent_callee_id_name;
|
||||||
char *last_sent_callee_id_number;
|
char *last_sent_callee_id_number;
|
||||||
|
|
||||||
//unsigned long rm_rate;
|
|
||||||
//switch_payload_t pt;
|
|
||||||
switch_mutex_t *flag_mutex;
|
|
||||||
switch_mutex_t *sofia_mutex;
|
|
||||||
////switch_payload_t te;
|
|
||||||
////switch_payload_t recv_te;
|
|
||||||
//switch_payload_t bte;
|
|
||||||
//switch_payload_t cng_pt;
|
|
||||||
//switch_payload_t bcng_pt;
|
|
||||||
sofia_transport_t transport;
|
|
||||||
nua_handle_t *nh;
|
|
||||||
nua_handle_t *nh2;
|
|
||||||
sip_contact_t *contact;
|
|
||||||
//uint32_t max_missed_packets;
|
|
||||||
//uint32_t max_missed_hold_packets;
|
|
||||||
/** VIDEO **/
|
|
||||||
// switch_frame_t video_read_frame;
|
|
||||||
// switch_codec_t video_read_codec;
|
|
||||||
// switch_codec_t video_write_codec;
|
|
||||||
// switch_rtp_t *video_rtp_session;
|
|
||||||
// switch_port_t adv_sdp_video_port;
|
|
||||||
// switch_port_t local_sdp_video_port;
|
|
||||||
// char *video_rm_encoding;
|
|
||||||
// switch_payload_t video_pt;
|
|
||||||
// unsigned long video_rm_rate;
|
|
||||||
// uint32_t video_codec_ms;
|
|
||||||
// char *video_rm_fmtp;
|
|
||||||
// switch_payload_t video_agreed_pt;
|
|
||||||
// char *video_fmtp_out;
|
|
||||||
// uint32_t video_count;
|
|
||||||
//switch_core_media_dtmf_t dtmf_type;
|
|
||||||
int q850_cause;
|
|
||||||
int got_bye;
|
|
||||||
//int hold_laps;
|
|
||||||
switch_thread_id_t locker;
|
|
||||||
//switch_size_t last_ts;
|
|
||||||
//uint32_t check_frames;
|
|
||||||
//uint32_t mismatch_count;
|
|
||||||
//uint32_t last_codec_ms;
|
|
||||||
//uint8_t codec_reinvites;
|
|
||||||
nua_event_t want_event;
|
|
||||||
switch_rtp_bug_flag_t rtp_bugs;
|
|
||||||
// switch_rtp_bug_flag_t video_rtp_bugs;
|
|
||||||
//switch_codec_implementation_t read_impl;
|
|
||||||
//switch_codec_implementation_t write_impl;
|
|
||||||
char *user_via;
|
|
||||||
char *redirected;
|
|
||||||
sofia_cid_type_t cid_type;
|
|
||||||
switch_payload_t payload_space;
|
|
||||||
switch_payload_t ianacodes[SWITCH_MAX_CODECS];
|
|
||||||
uint32_t session_timeout;
|
|
||||||
enum nua_session_refresher session_refresher;
|
|
||||||
char *respond_phrase;
|
|
||||||
int respond_code;
|
|
||||||
char *respond_dest;
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
struct private_object {
|
|
||||||
sofia_private_t *sofia_private;
|
|
||||||
uint8_t flags[TFLAG_MAX];
|
|
||||||
switch_payload_t agreed_pt;
|
|
||||||
switch_payload_t audio_recv_pt;
|
|
||||||
switch_payload_t video_recv_pt;
|
|
||||||
switch_core_session_t *session;
|
|
||||||
switch_channel_t *channel;
|
|
||||||
switch_media_handle_t *media_handle;
|
|
||||||
switch_core_media_params_t mparams;
|
|
||||||
|
|
||||||
switch_frame_t read_frame;
|
|
||||||
char *codec_order[SWITCH_MAX_CODECS];
|
|
||||||
int codec_order_last;
|
|
||||||
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
|
|
||||||
|
|
||||||
const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS];
|
|
||||||
int num_negotiated_codecs;
|
|
||||||
switch_codec_t read_codec;
|
|
||||||
switch_codec_t write_codec;
|
|
||||||
uint32_t codec_ms;
|
|
||||||
uint32_t bitrate;
|
|
||||||
switch_caller_profile_t *caller_profile;
|
|
||||||
uint32_t timestamp_send;
|
|
||||||
switch_rtp_t *rtp_session;
|
|
||||||
|
|
||||||
uint32_t video_ssrc;
|
|
||||||
sofia_profile_t *profile;
|
|
||||||
char *reply_contact;
|
|
||||||
char *from_uri;
|
|
||||||
char *to_uri;
|
|
||||||
char *from_address;
|
|
||||||
char *to_address;
|
|
||||||
char *callid;
|
|
||||||
char *contact_url;
|
|
||||||
char *from_str;
|
|
||||||
char *rpid;
|
|
||||||
char *asserted_id;
|
|
||||||
char *preferred_id;
|
|
||||||
char *privacy;
|
|
||||||
char *gateway_from_str;
|
|
||||||
char *rm_encoding;
|
|
||||||
char *iananame;
|
|
||||||
char *rm_fmtp;
|
|
||||||
char *fmtp_out;
|
|
||||||
char *dest;
|
|
||||||
char *dest_to;
|
|
||||||
char *key;
|
|
||||||
char *xferto;
|
|
||||||
char *kick;
|
|
||||||
char *origin;
|
|
||||||
char *hash_key;
|
|
||||||
char *chat_from;
|
|
||||||
char *chat_to;
|
|
||||||
char *e_dest;
|
|
||||||
char *call_id;
|
|
||||||
char *invite_contact;
|
|
||||||
char *local_url;
|
|
||||||
char *gateway_name;
|
|
||||||
char *record_route;
|
|
||||||
char *route_uri;
|
|
||||||
char *x_freeswitch_support_remote;
|
|
||||||
char *x_freeswitch_support_local;
|
|
||||||
char *last_sent_callee_id_name;
|
|
||||||
char *last_sent_callee_id_number;
|
|
||||||
|
|
||||||
unsigned long rm_rate;
|
|
||||||
switch_payload_t pt;
|
|
||||||
switch_mutex_t *flag_mutex;
|
switch_mutex_t *flag_mutex;
|
||||||
switch_mutex_t *sofia_mutex;
|
switch_mutex_t *sofia_mutex;
|
||||||
switch_payload_t te;
|
switch_payload_t te;
|
||||||
@ -871,50 +718,20 @@ struct private_object {
|
|||||||
nua_handle_t *nh;
|
nua_handle_t *nh;
|
||||||
nua_handle_t *nh2;
|
nua_handle_t *nh2;
|
||||||
sip_contact_t *contact;
|
sip_contact_t *contact;
|
||||||
uint32_t max_missed_packets;
|
|
||||||
uint32_t max_missed_hold_packets;
|
|
||||||
/** VIDEO **/
|
|
||||||
switch_frame_t video_read_frame;
|
|
||||||
switch_codec_t video_read_codec;
|
|
||||||
switch_codec_t video_write_codec;
|
|
||||||
switch_rtp_t *video_rtp_session;
|
|
||||||
switch_port_t adv_sdp_video_port;
|
|
||||||
switch_port_t local_sdp_video_port;
|
|
||||||
char *video_rm_encoding;
|
|
||||||
switch_payload_t video_pt;
|
|
||||||
unsigned long video_rm_rate;
|
|
||||||
uint32_t video_codec_ms;
|
|
||||||
char *video_rm_fmtp;
|
|
||||||
switch_payload_t video_agreed_pt;
|
|
||||||
char *video_fmtp_out;
|
|
||||||
uint32_t video_count;
|
|
||||||
switch_core_media_dtmf_t dtmf_type;
|
|
||||||
int q850_cause;
|
int q850_cause;
|
||||||
int got_bye;
|
int got_bye;
|
||||||
int hold_laps;
|
|
||||||
switch_thread_id_t locker;
|
|
||||||
switch_size_t last_ts;
|
|
||||||
uint32_t check_frames;
|
|
||||||
uint32_t mismatch_count;
|
|
||||||
uint32_t last_codec_ms;
|
|
||||||
uint8_t codec_reinvites;
|
|
||||||
nua_event_t want_event;
|
nua_event_t want_event;
|
||||||
switch_rtp_bug_flag_t rtp_bugs;
|
switch_rtp_bug_flag_t rtp_bugs;
|
||||||
switch_rtp_bug_flag_t video_rtp_bugs;
|
|
||||||
switch_codec_implementation_t read_impl;
|
|
||||||
switch_codec_implementation_t write_impl;
|
|
||||||
char *user_via;
|
char *user_via;
|
||||||
char *redirected;
|
char *redirected;
|
||||||
sofia_cid_type_t cid_type;
|
sofia_cid_type_t cid_type;
|
||||||
switch_payload_t payload_space;
|
|
||||||
switch_payload_t ianacodes[SWITCH_MAX_CODECS];
|
|
||||||
uint32_t session_timeout;
|
uint32_t session_timeout;
|
||||||
enum nua_session_refresher session_refresher;
|
enum nua_session_refresher session_refresher;
|
||||||
char *respond_phrase;
|
char *respond_phrase;
|
||||||
int respond_code;
|
int respond_code;
|
||||||
char *respond_dest;
|
char *respond_dest;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
struct callback_t {
|
struct callback_t {
|
||||||
char *val;
|
char *val;
|
||||||
@ -1252,7 +1069,7 @@ switch_bool_t sofia_glue_profile_exists(const char *key);
|
|||||||
void sofia_glue_global_siptrace(switch_bool_t on);
|
void sofia_glue_global_siptrace(switch_bool_t on);
|
||||||
void sofia_glue_global_capture(switch_bool_t on);
|
void sofia_glue_global_capture(switch_bool_t on);
|
||||||
void sofia_glue_global_watchdog(switch_bool_t on);
|
void sofia_glue_global_watchdog(switch_bool_t on);
|
||||||
void sofia_media_proxy_codec(switch_core_session_t *session, const char *r_sdp);
|
|
||||||
void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const char *pl);
|
void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const char *pl);
|
||||||
char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua_handle_t *nh, sofia_dispatch_event_t *de, sofia_nat_parse_t *np);
|
char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua_handle_t *nh, sofia_dispatch_event_t *de, sofia_nat_parse_t *np);
|
||||||
void sofia_glue_pause_jitterbuffer(switch_core_session_t *session, switch_bool_t on);
|
void sofia_glue_pause_jitterbuffer(switch_core_session_t *session, switch_bool_t on);
|
||||||
|
@ -4920,11 +4920,11 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
|||||||
sip->sip_payload && sip->sip_payload->pl_data && !strcasecmp(tech_pvt->iananame, "PROXY")) {
|
sip->sip_payload && sip->sip_payload->pl_data && !strcasecmp(tech_pvt->iananame, "PROXY")) {
|
||||||
switch_core_session_t *other_session;
|
switch_core_session_t *other_session;
|
||||||
|
|
||||||
sofia_media_proxy_codec(session, sip->sip_payload->pl_data);
|
switch_core_media_proxy_codec(session, sip->sip_payload->pl_data);
|
||||||
|
|
||||||
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
|
||||||
if (switch_core_session_compare(session, other_session)) {
|
if (switch_core_session_compare(session, other_session)) {
|
||||||
sofia_media_proxy_codec(other_session, sip->sip_payload->pl_data);
|
switch_core_media_proxy_codec(other_session, sip->sip_payload->pl_data);
|
||||||
}
|
}
|
||||||
switch_core_session_rwunlock(other_session);
|
switch_core_session_rwunlock(other_session);
|
||||||
}
|
}
|
||||||
|
@ -34,69 +34,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void sofia_media_proxy_codec(switch_core_session_t *session, const char *r_sdp)
|
|
||||||
{
|
|
||||||
sdp_media_t *m;
|
|
||||||
sdp_parser_t *parser = NULL;
|
|
||||||
sdp_session_t *sdp;
|
|
||||||
private_object_t *tech_pvt = switch_core_session_get_private(session);
|
|
||||||
sdp_attribute_t *attr;
|
|
||||||
int ptime = 0, dptime = 0;
|
|
||||||
|
|
||||||
if (!(parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sdp = sdp_session(parser))) {
|
|
||||||
sdp_parser_free(parser);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_assert(tech_pvt != NULL);
|
|
||||||
|
|
||||||
|
|
||||||
for (attr = sdp->sdp_attributes; attr; attr = attr->a_next) {
|
|
||||||
if (zstr(attr->a_name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcasecmp(attr->a_name, "ptime")) {
|
|
||||||
dptime = atoi(attr->a_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (m = sdp->sdp_media; m; m = m->m_next) {
|
|
||||||
|
|
||||||
ptime = dptime;
|
|
||||||
//maxptime = dmaxptime;
|
|
||||||
|
|
||||||
if (m->m_proto == sdp_proto_rtp) {
|
|
||||||
sdp_rtpmap_t *map;
|
|
||||||
for (attr = m->m_attributes; attr; attr = attr->a_next) {
|
|
||||||
if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) {
|
|
||||||
ptime = atoi(attr->a_value);
|
|
||||||
} else if (!strcasecmp(attr->a_name, "maxptime") && attr->a_value) {
|
|
||||||
//maxptime = atoi(attr->a_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
|
||||||
tech_pvt->iananame = switch_core_session_strdup(tech_pvt->session, map->rm_encoding);
|
|
||||||
tech_pvt->rm_rate = map->rm_rate;
|
|
||||||
tech_pvt->codec_ms = ptime;
|
|
||||||
switch_core_media_set_codec(tech_pvt->session, 0, tech_pvt->profile->codec_flags);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sdp_parser_free(parser);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t sofia_media_negotiate_sdp(switch_core_session_t *session, const char *r_sdp)
|
uint8_t sofia_media_negotiate_sdp(switch_core_session_t *session, const char *r_sdp)
|
||||||
{
|
{
|
||||||
uint8_t t, p = 0;
|
uint8_t t, p = 0;
|
||||||
|
@ -95,22 +95,22 @@ typedef struct switch_rtp_engine_s {
|
|||||||
switch_secure_settings_t ssec;
|
switch_secure_settings_t ssec;
|
||||||
switch_media_type_t type;
|
switch_media_type_t type;
|
||||||
|
|
||||||
switch_rtp_t *rtp_session;//x:tp
|
switch_rtp_t *rtp_session;
|
||||||
switch_frame_t read_frame;//x:tp
|
switch_frame_t read_frame;
|
||||||
switch_codec_t read_codec;//x:tp
|
switch_codec_t read_codec;
|
||||||
switch_codec_t write_codec;//x:tp
|
switch_codec_t write_codec;
|
||||||
|
|
||||||
switch_codec_implementation_t read_impl;//x:tp
|
switch_codec_implementation_t read_impl;
|
||||||
switch_codec_implementation_t write_impl;//x:tp
|
switch_codec_implementation_t write_impl;
|
||||||
|
|
||||||
uint32_t codec_ms;//x:tp
|
uint32_t codec_ms;
|
||||||
switch_size_t last_ts;//x:tp
|
switch_size_t last_ts;
|
||||||
uint32_t check_frames;//x:tp
|
uint32_t check_frames;
|
||||||
uint32_t mismatch_count;//x:tp
|
uint32_t mismatch_count;
|
||||||
uint32_t last_codec_ms;//x:tp
|
uint32_t last_codec_ms;
|
||||||
uint8_t codec_reinvites;//x:tp
|
uint8_t codec_reinvites;
|
||||||
uint32_t max_missed_packets;//x:tp
|
uint32_t max_missed_packets;
|
||||||
uint32_t max_missed_hold_packets;//x:tp
|
uint32_t max_missed_hold_packets;
|
||||||
uint32_t ssrc;
|
uint32_t ssrc;
|
||||||
|
|
||||||
switch_rtp_bug_flag_t rtp_bugs;
|
switch_rtp_bug_flag_t rtp_bugs;
|
||||||
@ -133,19 +133,19 @@ struct switch_media_handle_s {
|
|||||||
smh_flag_t flags;
|
smh_flag_t flags;
|
||||||
switch_rtp_engine_t engines[SWITCH_MEDIA_TYPE_TOTAL];
|
switch_rtp_engine_t engines[SWITCH_MEDIA_TYPE_TOTAL];
|
||||||
|
|
||||||
char *codec_order[SWITCH_MAX_CODECS];//x:tp
|
char *codec_order[SWITCH_MAX_CODECS];
|
||||||
int codec_order_last;//x:tp
|
int codec_order_last;
|
||||||
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];//x:tp
|
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
|
||||||
|
|
||||||
int payload_space;//x:tp
|
int payload_space;
|
||||||
char *origin;//x:tp
|
char *origin;
|
||||||
|
|
||||||
switch_payload_t cng_pt;//x:tp
|
switch_payload_t cng_pt;
|
||||||
|
|
||||||
const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS];//x:tp
|
const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS];
|
||||||
int num_negotiated_codecs;//x:tp
|
int num_negotiated_codecs;
|
||||||
switch_payload_t ianacodes[SWITCH_MAX_CODECS];//x:tp
|
switch_payload_t ianacodes[SWITCH_MAX_CODECS];
|
||||||
int video_count;//x:tp
|
int video_count;
|
||||||
|
|
||||||
uint32_t owner_id;
|
uint32_t owner_id;
|
||||||
uint32_t session_id;
|
uint32_t session_id;
|
||||||
@ -5730,6 +5730,127 @@ SWITCH_DECLARE(void) switch_core_media_set_r_sdp_codec_string(switch_core_sessio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//?
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_core_media_codec_chosen(switch_core_session_t *session, switch_media_type_t type)
|
||||||
|
{
|
||||||
|
switch_rtp_engine_t *engine;
|
||||||
|
switch_media_handle_t *smh;
|
||||||
|
|
||||||
|
if (!(smh = session->media_handle)) {
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
engine = &smh->engines[type];
|
||||||
|
|
||||||
|
if (engine->codec_params.iananame) {
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//?
|
||||||
|
SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_t *session)
|
||||||
|
{
|
||||||
|
switch_rtp_engine_t *a_engine, *v_engine;
|
||||||
|
switch_media_handle_t *smh;
|
||||||
|
|
||||||
|
if (!(smh = session->media_handle)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
|
||||||
|
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
|
||||||
|
|
||||||
|
a_engine->codec_params.iananame = switch_core_session_strdup(session, "PROXY");
|
||||||
|
a_engine->codec_params.rm_rate = 8000;
|
||||||
|
a_engine->codec_params.codec_ms = 20;
|
||||||
|
|
||||||
|
if (switch_channel_test_flag(session->channel, CF_PROXY_MEDIA)) {
|
||||||
|
const char *r_sdp = switch_channel_get_variable(session->channel, SWITCH_R_SDP_VARIABLE);
|
||||||
|
|
||||||
|
if (switch_stristr("m=video", r_sdp)) {
|
||||||
|
switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 1);
|
||||||
|
v_engine->codec_params.rm_encoding = "PROXY-VID";
|
||||||
|
v_engine->codec_params.rm_rate = 90000;
|
||||||
|
v_engine->codec_params.codec_ms = 0;
|
||||||
|
switch_channel_set_flag(session->channel, CF_VIDEO);
|
||||||
|
switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//?
|
||||||
|
SWITCH_DECLARE(void) switch_core_media_proxy_codec(switch_core_session_t *session, const char *r_sdp)
|
||||||
|
{
|
||||||
|
sdp_media_t *m;
|
||||||
|
sdp_parser_t *parser = NULL;
|
||||||
|
sdp_session_t *sdp;
|
||||||
|
sdp_attribute_t *attr;
|
||||||
|
int ptime = 0, dptime = 0;
|
||||||
|
switch_rtp_engine_t *a_engine;
|
||||||
|
switch_media_handle_t *smh;
|
||||||
|
|
||||||
|
if (!(smh = session->media_handle)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
|
||||||
|
|
||||||
|
if (!(parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sdp = sdp_session(parser))) {
|
||||||
|
sdp_parser_free(parser);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (attr = sdp->sdp_attributes; attr; attr = attr->a_next) {
|
||||||
|
if (zstr(attr->a_name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcasecmp(attr->a_name, "ptime")) {
|
||||||
|
dptime = atoi(attr->a_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (m = sdp->sdp_media; m; m = m->m_next) {
|
||||||
|
|
||||||
|
ptime = dptime;
|
||||||
|
//maxptime = dmaxptime;
|
||||||
|
|
||||||
|
if (m->m_proto == sdp_proto_rtp) {
|
||||||
|
sdp_rtpmap_t *map;
|
||||||
|
for (attr = m->m_attributes; attr; attr = attr->a_next) {
|
||||||
|
if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) {
|
||||||
|
ptime = atoi(attr->a_value);
|
||||||
|
} else if (!strcasecmp(attr->a_name, "maxptime") && attr->a_value) {
|
||||||
|
//maxptime = atoi(attr->a_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
||||||
|
a_engine->codec_params.iananame = switch_core_session_strdup(session, map->rm_encoding);
|
||||||
|
a_engine->codec_params.rm_rate = map->rm_rate;
|
||||||
|
a_engine->codec_params.codec_ms = ptime;
|
||||||
|
switch_core_media_set_codec(session, 0, smh->mparams->codec_flags);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sdp_parser_free(parser);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user