git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7531 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2008-02-05 21:09:52 +00:00
parent c5d8b78f6d
commit b100a406b6
4 changed files with 61 additions and 11 deletions

View File

@@ -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 @@ static void *SWITCH_THREAD_FUNC echo_video_thread(switch_thread_t *thread, void
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_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session)
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 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session)
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 {