mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-16 16:24:13 +00:00
almost rid of crufty tech_pvt members
This commit is contained in:
1 parent
75c95fa98e
commit
85308861d8
6 files changed
+354
-285
No files matched your search
@@ -692,7 +692,7 @@ struct private_object {
|
||||
// uint32_t bitrate;
|
||||
switch_caller_profile_t *caller_profile;
|
||||
//uint32_t timestamp_send;
|
||||
switch_rtp_t *rtp_session;
|
||||
// switch_rtp_t *rtp_session;
|
||||
|
||||
// uint32_t video_ssrc;
|
||||
sofia_profile_t *profile;
|
||||
@@ -753,7 +753,7 @@ struct private_object {
|
||||
// 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_rtp_t *video_rtp_session;
|
||||
// switch_port_t adv_sdp_video_port;
|
||||
// switch_port_t local_sdp_video_port;
|
||||
// char *video_rm_encoding;
|
||||
|
||||
@@ -4975,8 +4975,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
||||
sofia_update_callee_id(session, profile, sip, SWITCH_FALSE);
|
||||
|
||||
if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING)) {
|
||||
tech_pvt->check_frames = 0;
|
||||
tech_pvt->last_ts = 0;
|
||||
switch_core_media_reset_autofix_timing(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7365,7 +7364,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
}
|
||||
|
||||
if (dtmf.digit) {
|
||||
if (tech_pvt->dtmf_type == DTMF_INFO ||
|
||||
if (tech_pvt->mparams.dtmf_type == DTMF_INFO ||
|
||||
sofia_test_pflag(tech_pvt->profile, PFLAG_LIBERAL_DTMF) || switch_channel_test_flag(tech_pvt->channel, CF_LIBERAL_DTMF)) {
|
||||
/* queue it up */
|
||||
switch_channel_queue_dtmf(channel, &dtmf);
|
||||
|
||||
@@ -107,7 +107,7 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
|
||||
tech_pvt->mparams.recv_te = tech_pvt->mparams.te = profile->te;
|
||||
}
|
||||
|
||||
tech_pvt->dtmf_type = tech_pvt->profile->dtmf_type;
|
||||
tech_pvt->mparams.dtmf_type = tech_pvt->profile->dtmf_type;
|
||||
|
||||
if (!sofia_test_media_flag(tech_pvt->profile, SCMF_SUPPRESS_CNG)) {
|
||||
if (tech_pvt->bcng_pt) {
|
||||
|
||||
@@ -133,256 +133,6 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
|
||||
|
||||
|
||||
|
||||
void sofia_media_set_sdp_codec_string(switch_core_session_t *session, const char *r_sdp)
|
||||
{
|
||||
sdp_parser_t *parser;
|
||||
sdp_session_t *sdp;
|
||||
private_object_t *tech_pvt = switch_core_session_get_private(session);
|
||||
|
||||
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, switch_core_media_get_codec_string(tech_pvt->session), sdp);
|
||||
}
|
||||
|
||||
sdp_parser_free(parser);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void add_audio_codec(sdp_rtpmap_t *map, int ptime, char *buf, switch_size_t buflen)
|
||||
{
|
||||
int codec_ms = ptime;
|
||||
uint32_t map_bit_rate = 0;
|
||||
char ptstr[20] = "";
|
||||
char ratestr[20] = "";
|
||||
char bitstr[20] = "";
|
||||
switch_codec_fmtp_t codec_fmtp = { 0 };
|
||||
|
||||
if (!codec_ms) {
|
||||
codec_ms = switch_default_ptime(map->rm_encoding, map->rm_pt);
|
||||
}
|
||||
|
||||
map_bit_rate = switch_known_bitrate((switch_payload_t)map->rm_pt);
|
||||
|
||||
if (!ptime && !strcasecmp(map->rm_encoding, "g723")) {
|
||||
ptime = codec_ms = 30;
|
||||
}
|
||||
|
||||
if (zstr(map->rm_fmtp)) {
|
||||
if (!strcasecmp(map->rm_encoding, "ilbc")) {
|
||||
ptime = codec_ms = 30;
|
||||
map_bit_rate = 13330;
|
||||
}
|
||||
} else {
|
||||
if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) {
|
||||
if (codec_fmtp.bits_per_second) {
|
||||
map_bit_rate = codec_fmtp.bits_per_second;
|
||||
}
|
||||
if (codec_fmtp.microseconds_per_packet) {
|
||||
codec_ms = (codec_fmtp.microseconds_per_packet / 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (map->rm_rate) {
|
||||
switch_snprintf(ratestr, sizeof(ratestr), "@%uh", (unsigned int) map->rm_rate);
|
||||
}
|
||||
|
||||
if (codec_ms) {
|
||||
switch_snprintf(ptstr, sizeof(ptstr), "@%di", codec_ms);
|
||||
}
|
||||
|
||||
if (map_bit_rate) {
|
||||
switch_snprintf(bitstr, sizeof(bitstr), "@%db", map_bit_rate);
|
||||
}
|
||||
|
||||
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), ",%s%s%s%s", map->rm_encoding, ratestr, ptstr, bitstr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void sofia_media_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp)
|
||||
{
|
||||
char buf[1024] = { 0 };
|
||||
sdp_media_t *m;
|
||||
sdp_attribute_t *attr;
|
||||
int ptime = 0, dptime = 0;
|
||||
sdp_connection_t *connection;
|
||||
sdp_rtpmap_t *map;
|
||||
short int match = 0;
|
||||
int i;
|
||||
int already_did[128] = { 0 };
|
||||
int num_codecs = 0;
|
||||
char *codec_order[SWITCH_MAX_CODECS];
|
||||
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS] = { 0 };
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
private_object_t *tech_pvt = switch_core_session_get_private(session);
|
||||
int prefer_sdp = 0;
|
||||
const char *var;
|
||||
|
||||
if ((var = switch_channel_get_variable(channel, "ep_codec_prefer_sdp")) && switch_true(var)) {
|
||||
prefer_sdp = 1;
|
||||
}
|
||||
|
||||
if (!zstr(codec_string)) {
|
||||
char *tmp_codec_string;
|
||||
if ((tmp_codec_string = strdup(codec_string))) {
|
||||
num_codecs = switch_separate_string(tmp_codec_string, ',', codec_order, SWITCH_MAX_CODECS);
|
||||
num_codecs = switch_loadable_module_get_codecs_sorted(codecs, SWITCH_MAX_CODECS, codec_order, num_codecs);
|
||||
switch_safe_free(tmp_codec_string);
|
||||
}
|
||||
} else {
|
||||
num_codecs = switch_loadable_module_get_codecs(codecs, SWITCH_MAX_CODECS);
|
||||
}
|
||||
|
||||
if (!channel || !num_codecs) {
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch_core_media_find_zrtp_hash(session, sdp);
|
||||
switch_core_media_pass_zrtp_hash(session);
|
||||
|
||||
for (m = sdp->sdp_media; m; m = m->m_next) {
|
||||
ptime = dptime;
|
||||
if (m->m_type == sdp_media_image && m->m_port) {
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",t38");
|
||||
} else if (m->m_type == sdp_media_audio && m->m_port) {
|
||||
for (attr = m->m_attributes; attr; attr = attr->a_next) {
|
||||
if (zstr(attr->a_name)) {
|
||||
continue;
|
||||
}
|
||||
if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) {
|
||||
ptime = atoi(attr->a_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
connection = sdp->sdp_connection;
|
||||
if (m->m_connections) {
|
||||
connection = m->m_connections;
|
||||
}
|
||||
|
||||
if (!connection) {
|
||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "Cannot find a c= line in the sdp at media or session level!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND || prefer_sdp) {
|
||||
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
||||
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = codecs[i];
|
||||
|
||||
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
|
||||
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
|
||||
} else {
|
||||
if (map->rm_encoding) {
|
||||
match = strcasecmp(map->rm_encoding, imp->iananame) ? 0 : 1;
|
||||
} else {
|
||||
match = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
add_audio_codec(map, ptime, buf, sizeof(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
for (i = 0; i < num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = codecs[i];
|
||||
if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO || imp->ianacode > 127 || already_did[imp->ianacode]) {
|
||||
continue;
|
||||
}
|
||||
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
||||
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
|
||||
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
|
||||
} else {
|
||||
if (map->rm_encoding) {
|
||||
match = strcasecmp(map->rm_encoding, imp->iananame) ? 0 : 1;
|
||||
} else {
|
||||
match = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
add_audio_codec(map, ptime, buf, sizeof(buf));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (m->m_type == sdp_media_video && m->m_port) {
|
||||
connection = sdp->sdp_connection;
|
||||
if (m->m_connections) {
|
||||
connection = m->m_connections;
|
||||
}
|
||||
|
||||
if (!connection) {
|
||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_ERROR, "Cannot find a c= line in the sdp at media or session level!\n");
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = codecs[i];
|
||||
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO || imp->ianacode > 127 || already_did[imp->ianacode]) {
|
||||
continue;
|
||||
}
|
||||
for (map = m->m_rtpmaps; map; map = map->rm_next) {
|
||||
if (map->rm_pt > 127 || already_did[map->rm_pt]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
|
||||
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
|
||||
} else {
|
||||
if (map->rm_encoding) {
|
||||
match = strcasecmp(map->rm_encoding, imp->iananame) ? 0 : 1;
|
||||
} else {
|
||||
match = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
if (ptime > 0) {
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh@%di", imp->iananame, (unsigned int) map->rm_rate,
|
||||
ptime);
|
||||
} else {
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh", imp->iananame, (unsigned int) map->rm_rate);
|
||||
}
|
||||
already_did[imp->ianacode] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buf[0] == ',') {
|
||||
switch_channel_set_variable(channel, "ep_codec_string", buf + 1);
|
||||
}
|
||||
}
|
||||
|
||||
switch_status_t sofia_media_tech_media(private_object_t *tech_pvt, const char *r_sdp)
|
||||
{
|
||||
uint8_t match = 0;
|
||||
@@ -412,19 +162,6 @@ switch_status_t sofia_media_tech_media(private_object_t *tech_pvt, const char *r
|
||||
}
|
||||
|
||||
|
||||
void sofia_media_deactivate_rtp(private_object_t *tech_pvt)
|
||||
{
|
||||
int loops = 0;
|
||||
while (loops < 10 && (sofia_test_flag(tech_pvt, TFLAG_READING) || sofia_test_flag(tech_pvt, TFLAG_WRITING))) {
|
||||
switch_yield(10000);
|
||||
loops++;
|
||||
}
|
||||
|
||||
switch_core_media_deactivate_rtp(tech_pvt->session);
|
||||
|
||||
}
|
||||
|
||||
|
||||
char *sofia_media_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type)
|
||||
{
|
||||
char *extra_headers = NULL;
|
||||
|
||||
Reference in new issue
Block a user