[Freeswitch-svn] [commit] r7531 - in freeswitch/trunk/src: . mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Tue Feb 5 16:09:52 EST 2008
Author: anthm
Date: Tue Feb 5 16:09:52 2008
New Revision: 7531
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/switch_ivr_async.c
freeswitch/trunk/src/switch_ivr_bridge.c
freeswitch/trunk/src/switch_rtp.c
Log:
update
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Tue Feb 5 16:09:52 2008
@@ -1413,16 +1413,18 @@
sofia_glue_check_video_codecs(tech_pvt);
if (switch_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding) {
- flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_NOBLOCK | SWITCH_RTP_FLAG_RAW_WRITE);
+ flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_AUTOADJ |
+ SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_NOBLOCK | SWITCH_RTP_FLAG_RAW_WRITE);
sofia_glue_tech_set_video_codec(tech_pvt, 0);
+ /* set video timer to 10ms so it can co-exist with audio */
tech_pvt->video_rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_video_port,
tech_pvt->remote_sdp_video_ip,
tech_pvt->remote_sdp_video_port,
tech_pvt->video_agreed_pt,
- tech_pvt->video_read_codec.implementation->samples_per_frame,
- 0,
+ 1,
+ 10000,
(switch_rtp_flag_t) flags,
NULL,
&err,
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Tue Feb 5 16:09:52 2008
@@ -33,6 +33,7 @@
#include <switch.h>
+#ifdef SWITCH_VIDEO_IN_THREADS
struct echo_helper {
switch_core_session_t *session;
int up;
@@ -54,24 +55,32 @@
break;
}
+ if (switch_test_flag(read_frame, SFF_CNG)) {
+ continue;
+ }
+
switch_core_session_write_video_frame(session, read_frame, -1, 0);
}
eh->up = 0;
return NULL;
}
+#endif
SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session)
{
switch_status_t status;
switch_frame_t *read_frame;
- struct echo_helper eh = {0};
switch_channel_t *channel = switch_core_session_get_channel(session);
+#ifdef SWITCH_VIDEO_IN_THREADS
+ struct echo_helper eh = {0};
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL;
+#endif
switch_channel_pre_answer(channel);
-
+
+#ifdef SWITCH_VIDEO_IN_THREADS
if (switch_channel_test_flag(channel, CF_VIDEO)) {
eh.session = session;
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
@@ -79,6 +88,7 @@
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&thread, thd_attr, echo_video_thread, &eh, switch_core_session_get_pool(session));
}
+#endif
while(switch_channel_ready(channel)) {
status = switch_core_session_read_frame(session, &read_frame, -1, 0);
@@ -86,13 +96,31 @@
break;
}
switch_core_session_write_frame(session, read_frame, -1, 0);
+
+#ifndef SWITCH_VIDEO_IN_THREADS
+ status = switch_core_session_read_video_frame(session, &read_frame, -1, 0);
+
+ if (!SWITCH_READ_ACCEPTABLE(status)) {
+ break;
+ }
+
+ if (switch_test_flag(read_frame, SFF_CNG)) {
+ continue;
+ }
+
+ switch_core_session_write_video_frame(session, read_frame, -1, 0);
+#endif
+
}
+#ifdef SWITCH_VIDEO_IN_THREADS
if (eh.up) {
while(eh.up) {
switch_yield(1000);
}
}
+#endif
+
}
typedef struct {
Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c (original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c Tue Feb 5 16:09:52 2008
@@ -36,6 +36,7 @@
/* Bridge Related Stuff*/
/*********************************************************************************/
+#ifdef SWITCH_VIDEO_IN_THREADS
struct vid_helper {
switch_core_session_t *session_a;
switch_core_session_t *session_b;
@@ -52,7 +53,7 @@
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;
}
@@ -64,7 +65,6 @@
return NULL;
}
-
static void launch_video(struct vid_helper *vh)
{
switch_thread_t *thread;
@@ -75,7 +75,7 @@
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));
}
-
+#endif
struct switch_ivr_bridge_data {
switch_core_session_t *session;
@@ -96,9 +96,12 @@
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, vid_launch = 0;
+ uint32_t loop_count = 0;
const char *app_name = NULL, *app_arg = NULL;
+#ifdef SWITCH_VIDEO_IN_THREADS
struct vid_helper vh = { 0 };
+ uint32_t vid_launch = 0;
+#endif
session_a = data->session;
if (!(session_b = switch_core_session_locate(data->b_uuid))) {
@@ -157,12 +160,14 @@
continue;
}
+#ifdef SWITCH_VIDEO_IN_THREADS
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);
}
+#endif
/* if 1 channel has DTMF pass it to the other */
while (switch_channel_has_dtmf(chan_a)) {
@@ -216,6 +221,19 @@
}
}
+#ifndef SWITCH_VIDEO_IN_THREADS
+ if (switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO)) {
+ /* read video from 1 channel and write it to the other */
+ status = switch_core_session_read_video_frame(session_a, &read_frame, -1, 0);
+
+ if (!SWITCH_READ_ACCEPTABLE(status)) {
+ break;
+ }
+
+ switch_core_session_write_video_frame(session_b, read_frame, -1, 0);
+ }
+#endif
+
/* read audio from 1 channel and write it to the other */
status = switch_core_session_read_frame(session_a, &read_frame, -1, stream_id);
@@ -237,6 +255,7 @@
}
}
+#ifdef SWITCH_VIDEO_IN_THREADS
if (vh.up) {
vh.up = -1;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ending video thread.\n");
@@ -244,6 +263,7 @@
switch_yield(100000);
}
}
+#endif
if (switch_channel_get_state(chan_b) >= CS_HANGUP) {
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Tue Feb 5 16:09:52 2008
@@ -1040,7 +1040,7 @@
while (switch_rtp_ready(rtp_session)) {
bytes = sizeof(rtp_msg_t);
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *) &rtp_session->recv_msg, &bytes);
-
+
if (!SWITCH_STATUS_IS_BREAK(status) && rtp_session->timer.interval) {
switch_core_timer_step(&rtp_session->timer);
}
@@ -1151,7 +1151,7 @@
}
bytes = jb_frame->dlen + rtp_header_len;
rtp_session->recv_msg.header.ts = htonl(jb_frame->ts);
- } else if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { /* We're late! We're Late! */
+ } else if (!bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { /* We're late! We're Late! */
uint8_t *data = (uint8_t *) rtp_session->recv_msg.body;
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) {
More information about the Freeswitch-svn
mailing list