eat inbound vid while playing fsv files

This commit is contained in:
Anthony Minessale 2012-01-17 12:19:23 -06:00
parent 362c571647
commit c358f67fe4
4 changed files with 44 additions and 10 deletions

View File

@ -995,7 +995,9 @@ SWITCH_DECLARE(void) switch_core_thread_session_end(_In_ switch_core_session_t *
\brief Launch a service thread on a session to drop inbound data
\param session the session the launch thread on
*/
SWITCH_DECLARE(void) switch_core_service_session(_In_ switch_core_session_t *session);
SWITCH_DECLARE(void) switch_core_service_session_av(_In_ switch_core_session_t *session, switch_bool_t audio, switch_bool_t video);
#define switch_core_service_session(_s) switch_core_service_session_av(_s, SWITCH_TRUE, SWITCH_FALSE)
/*!
\brief Request an outgoing session spawned from an existing session using a desired endpoing module

View File

@ -1206,6 +1206,8 @@ typedef enum {
CF_INTERCEPT,
CF_INTERCEPTED,
CF_VIDEO_REFRESH_REQ,
CF_SERVICE_AUDIO,
CF_SERVICE_VIDEO,
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
/* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
CF_FLAG_MAX

View File

@ -370,6 +370,8 @@ SWITCH_STANDARD_APP(play_fsv_function)
}
switch_core_session_set_read_codec(session, &codec);
switch_core_service_session_av(session, SWITCH_FALSE, SWITCH_TRUE);
while (switch_channel_ready(channel)) {
if (read(fd, &bytes, sizeof(bytes)) != sizeof(bytes)) {
@ -440,6 +442,8 @@ SWITCH_STANDARD_APP(play_fsv_function)
}
switch_core_thread_session_end(session);
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "OK");
end:

View File

@ -397,6 +397,8 @@ static void *SWITCH_THREAD_FUNC switch_core_service_thread(switch_thread_t *thre
switch_channel_set_flag(channel, CF_SERVICE);
while (switch_channel_test_flag(channel, CF_SERVICE)) {
if (switch_channel_test_flag(channel, CF_SERVICE_AUDIO)) {
switch (switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0)) {
case SWITCH_STATUS_SUCCESS:
case SWITCH_STATUS_TIMEOUT:
@ -404,12 +406,28 @@ static void *SWITCH_THREAD_FUNC switch_core_service_thread(switch_thread_t *thre
break;
default:
switch_channel_clear_flag(channel, CF_SERVICE);
continue;
break;
}
}
if (switch_channel_test_flag(channel, CF_SERVICE_VIDEO) && switch_channel_test_flag(channel, CF_VIDEO)) {
switch (switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0)) {
case SWITCH_STATUS_SUCCESS:
case SWITCH_STATUS_TIMEOUT:
case SWITCH_STATUS_BREAK:
break;
default:
switch_channel_clear_flag(channel, CF_SERVICE);
break;
}
}
}
switch_mutex_unlock(session->frame_read_mutex);
switch_channel_clear_flag(channel, CF_SERVICE_AUDIO);
switch_channel_clear_flag(channel, CF_SERVICE_VIDEO);
switch_core_session_rwunlock(session);
return NULL;
@ -425,9 +443,14 @@ SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_session_t *sessi
switch_assert(channel);
switch_channel_clear_flag(channel, CF_SERVICE);
switch_channel_clear_flag(channel, CF_SERVICE_AUDIO);
switch_channel_clear_flag(channel, CF_SERVICE_VIDEO);
switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
}
SWITCH_DECLARE(void) switch_core_service_session(switch_core_session_t *session)
SWITCH_DECLARE(void) switch_core_service_session_av(switch_core_session_t *session, switch_bool_t audio, switch_bool_t video)
{
switch_channel_t *channel;
switch_assert(session);
@ -435,6 +458,9 @@ SWITCH_DECLARE(void) switch_core_service_session(switch_core_session_t *session)
channel = switch_core_session_get_channel(session);
switch_assert(channel);
if (audio) switch_channel_set_flag(channel, CF_SERVICE_AUDIO);
if (video) switch_channel_set_flag(channel, CF_SERVICE_VIDEO);
switch_core_session_launch_thread(session, (void *(*)(switch_thread_t *,void *))switch_core_service_thread, session);
}