提交 521e3b0a authored 作者: Anthony Minessale's avatar Anthony Minessale

figure out when we are on hold

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3185 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 e22015c7
差异被折叠。
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -161,7 +161,8 @@ typedef enum { ...@@ -161,7 +161,8 @@ typedef enum {
TFLAG_NOHUP = (1 << 18), TFLAG_NOHUP = (1 << 18),
TFLAG_XFER = (1 << 19), TFLAG_XFER = (1 << 19),
TFLAG_NOMEDIA = (1 << 20), TFLAG_NOMEDIA = (1 << 20),
TFLAG_BUGGY_2833 = (1 << 21) TFLAG_BUGGY_2833 = (1 << 21),
TFLAG_SIP_HOLD = (1 << 22)
} TFLAGS; } TFLAGS;
static struct { static struct {
...@@ -1203,12 +1204,15 @@ static void deactivate_rtp(private_object_t *tech_pvt) ...@@ -1203,12 +1204,15 @@ static void deactivate_rtp(private_object_t *tech_pvt)
} }
} }
static switch_status_t tech_set_codec(private_object_t *tech_pvt) static switch_status_t tech_set_codec(private_object_t *tech_pvt, int force)
{ {
switch_channel_t *channel; switch_channel_t *channel;
assert(tech_pvt->codecs[tech_pvt->codec_index] != NULL); assert(tech_pvt->codecs[tech_pvt->codec_index] != NULL);
if (tech_pvt->read_codec.implementation) { if (tech_pvt->read_codec.implementation) {
if (!force) {
return SWITCH_STATUS_SUCCESS;
}
if (strcasecmp(tech_pvt->read_codec.implementation->iananame, tech_pvt->rm_encoding) || if (strcasecmp(tech_pvt->read_codec.implementation->iananame, tech_pvt->rm_encoding) ||
tech_pvt->read_codec.implementation->samples_per_second != tech_pvt->rm_rate) { tech_pvt->read_codec.implementation->samples_per_second != tech_pvt->rm_rate) {
...@@ -1291,7 +1295,7 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt) ...@@ -1291,7 +1295,7 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if ((status = tech_set_codec(tech_pvt)) != SWITCH_STATUS_SUCCESS) { if ((status = tech_set_codec(tech_pvt, 0)) != SWITCH_STATUS_SUCCESS) {
return status; return status;
} }
...@@ -1945,6 +1949,8 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp) ...@@ -1945,6 +1949,8 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
uint8_t match = 0; uint8_t match = 0;
private_object_t *tech_pvt; private_object_t *tech_pvt;
sdp_media_t *m; sdp_media_t *m;
sdp_attribute_t *a;
tech_pvt = switch_core_session_get_private(session); tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL); assert(tech_pvt != NULL);
...@@ -1956,6 +1962,14 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp) ...@@ -1956,6 +1962,14 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
} }
} }
for (a = sdp->sdp_attributes; a; a = a->a_next) {
if (!strcasecmp(a->a_name, "sendonly")) {
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
} else if (!strcasecmp(a->a_name, "sendrecv")) {
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
}
}
for (m = sdp->sdp_media; m ; m = m->m_next) { for (m = sdp->sdp_media; m ; m = m->m_next) {
if (m->m_type == sdp_media_audio) { if (m->m_type == sdp_media_audio) {
sdp_rtpmap_t *map; sdp_rtpmap_t *map;
...@@ -1992,7 +2006,7 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp) ...@@ -1992,7 +2006,7 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp)
} }
if (match) { if (match) {
if (tech_set_codec(tech_pvt) != SWITCH_STATUS_SUCCESS) { if (tech_set_codec(tech_pvt, 1) != SWITCH_STATUS_SUCCESS) {
match = 0; match = 0;
} }
break; break;
...@@ -2441,14 +2455,15 @@ static void sip_i_state(int status, ...@@ -2441,14 +2455,15 @@ static void sip_i_state(int status,
match = negotiate_sdp(session, sdp); match = negotiate_sdp(session, sdp);
} }
} }
tech_choose_port(tech_pvt); if (match) {
set_local_sdp(tech_pvt); tech_choose_port(tech_pvt);
tech_set_codec(tech_pvt); set_local_sdp(tech_pvt);
switch_set_flag_locked(tech_pvt, TFLAG_REINVITE); switch_set_flag_locked(tech_pvt, TFLAG_REINVITE);
activate_rtp(tech_pvt); activate_rtp(tech_pvt);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Processing Reinvite\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Processing Reinvite\n");
if (parser) { if (parser) {
sdp_parser_free(parser); sdp_parser_free(parser);
}
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论