it's suprising what 195 lines of code can do
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7475 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
1d5a083c39
commit
af40b99b80
|
@ -1294,7 +1294,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
|
|||
/* Reactivate the NAT buster flag. */
|
||||
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
goto video;
|
||||
}
|
||||
|
||||
tech_pvt->rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip,
|
||||
|
@ -1398,6 +1398,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
|
|||
switch_channel_set_variable(tech_pvt->channel, SOFIA_SECURE_MEDIA_CONFIRMED_VARIABLE, "true");
|
||||
}
|
||||
|
||||
video:
|
||||
|
||||
sofia_glue_check_video_codecs(tech_pvt);
|
||||
|
||||
|
@ -1496,7 +1497,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *val;
|
||||
const char *crypto = NULL;
|
||||
int got_crypto = 0;
|
||||
int got_crypto = 0, got_audio = 0;
|
||||
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
|
@ -1578,7 +1579,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||
|
||||
ptime = dptime;
|
||||
|
||||
if (m->m_type == sdp_media_audio) {
|
||||
if (m->m_type == sdp_media_audio && !got_audio) {
|
||||
sdp_rtpmap_t *map;
|
||||
|
||||
for (attr = m->m_attributes; attr; attr = attr->a_next) {
|
||||
|
@ -1657,7 +1658,8 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||
if (match) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Our existing codec [%s] is still good, let's keep it\n",
|
||||
tech_pvt->rm_encoding);
|
||||
goto end;
|
||||
got_audio = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1846,6 +1848,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (mimp) {
|
||||
if ((tech_pvt->video_rm_encoding = switch_core_session_strdup(session, (char *) rm_encoding))) {
|
||||
char tmp[50];
|
||||
|
@ -1859,6 +1862,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||
switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_video_port);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE, tmp);
|
||||
break;
|
||||
} else {
|
||||
vmatch = 0;
|
||||
}
|
||||
|
@ -1867,8 +1871,6 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_SDP);
|
||||
|
||||
return match;
|
||||
|
|
|
@ -47,7 +47,7 @@ static void *SWITCH_THREAD_FUNC echo_video_thread(switch_thread_t *thread, void
|
|||
switch_frame_t *read_frame;
|
||||
|
||||
eh->up = 1;
|
||||
while(switch_channel_ready(channel) && switch_channel_get_state(channel) == CS_LOOPBACK) {
|
||||
while(switch_channel_ready(channel)) {
|
||||
status = switch_core_session_read_video_frame(session, &read_frame, -1, 0);
|
||||
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
|
|
|
@ -35,6 +35,48 @@ static const switch_state_handler_table_t audio_bridge_peer_state_handlers;
|
|||
|
||||
/* Bridge Related Stuff*/
|
||||
/*********************************************************************************/
|
||||
|
||||
struct vid_helper {
|
||||
switch_core_session_t *session_a;
|
||||
switch_core_session_t *session_b;
|
||||
int up;
|
||||
};
|
||||
|
||||
static void *SWITCH_THREAD_FUNC video_bridge_thread(switch_thread_t *thread, void *obj)
|
||||
{
|
||||
struct vid_helper *vh = obj;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(vh->session_a);
|
||||
switch_status_t status;
|
||||
switch_frame_t *read_frame;
|
||||
|
||||
vh->up = 1;
|
||||
while(switch_channel_ready(channel) && vh->up == 1) {
|
||||
status = switch_core_session_read_video_frame(vh->session_a, &read_frame, -1, 0);
|
||||
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch_core_session_write_video_frame(vh->session_b, read_frame, -1, 0);
|
||||
|
||||
}
|
||||
vh->up = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void launch_video(struct vid_helper *vh)
|
||||
{
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
|
||||
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(vh->session_a));
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_create(&thread, thd_attr, video_bridge_thread, vh, switch_core_session_get_pool(vh->session_a));
|
||||
}
|
||||
|
||||
|
||||
struct switch_ivr_bridge_data {
|
||||
switch_core_session_t *session;
|
||||
char b_uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
|
@ -54,8 +96,9 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
|
|||
switch_channel_t *chan_a, *chan_b;
|
||||
switch_frame_t *read_frame;
|
||||
switch_core_session_t *session_a, *session_b;
|
||||
uint32_t loop_count = 0;
|
||||
uint32_t loop_count = 0, vid_launch = 0;
|
||||
const char *app_name = NULL, *app_arg = NULL;
|
||||
struct vid_helper vh = { 0 };
|
||||
|
||||
session_a = data->session;
|
||||
if (!(session_b = switch_core_session_locate(data->b_uuid))) {
|
||||
|
@ -114,6 +157,13 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO) && !vid_launch) {
|
||||
vid_launch++;
|
||||
vh.session_a = session_a;
|
||||
vh.session_b = session_b;
|
||||
launch_video(&vh);
|
||||
}
|
||||
|
||||
/* if 1 channel has DTMF pass it to the other */
|
||||
while (switch_channel_has_dtmf(chan_a)) {
|
||||
switch_dtmf_t dtmf = { 0, 0 };
|
||||
|
@ -187,6 +237,15 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
|
|||
}
|
||||
}
|
||||
|
||||
if (vh.up) {
|
||||
vh.up = -1;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ending video thread.\n");
|
||||
while(vh.up) {
|
||||
switch_yield(100000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (switch_channel_get_state(chan_b) >= CS_HANGUP) {
|
||||
if (originator && switch_channel_ready(chan_a) && !switch_channel_test_flag(chan_a, CF_ANSWERED)) {
|
||||
switch_channel_hangup(chan_a, switch_channel_get_cause(chan_b));
|
||||
|
|
Loading…
Reference in New Issue