提交 9c72dc95 authored 作者: Seven Du's avatar Seven Du

add CF_MEDIA_PAUSE channel flag to allow waiting for IO before media codec is ready

This could be used at endpoints where signalling and media negotiated separately like in H323
上级 b8dc0713
...@@ -1362,6 +1362,7 @@ typedef enum { ...@@ -1362,6 +1362,7 @@ typedef enum {
CF_VIDEO_ECHO, CF_VIDEO_ECHO,
CF_SLA_INTERCEPT, CF_SLA_INTERCEPT,
CF_VIDEO_BREAK, CF_VIDEO_BREAK,
CF_MEDIA_PAUSE,
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ /* 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() */ /* 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 CF_FLAG_MAX
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* Anthony Minessale II <anthm@freeswitch.org> * Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com> * Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org> * Paul D. Tinsley <pdt at jackhammer.org>
* Seven Du <dujinfang@gmail.com>
* *
* *
* switch_core_io.c -- Main Core Library (Media I/O) * switch_core_io.c -- Main Core Library (Media I/O)
...@@ -45,6 +46,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor ...@@ -45,6 +46,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
if (switch_channel_test_flag(session->channel, CF_MEDIA_PAUSE)) {
return SWITCH_STATUS_SUCCESS;
}
if (session->endpoint_interface->io_routines->write_video_frame) { if (session->endpoint_interface->io_routines->write_video_frame) {
if ((status = session->endpoint_interface->io_routines->write_video_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) { if ((status = session->endpoint_interface->io_routines->write_video_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
for (ptr = session->event_hooks.video_write_frame; ptr; ptr = ptr->next) { for (ptr = session->event_hooks.video_write_frame; ptr; ptr = ptr->next) {
...@@ -69,6 +74,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core ...@@ -69,6 +74,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
if (switch_channel_test_flag(session->channel, CF_MEDIA_PAUSE)) {
*frame = &runtime.dummy_cng_frame;
switch_yield(20000);
return SWITCH_STATUS_SUCCESS;
}
if (session->endpoint_interface->io_routines->read_video_frame) { if (session->endpoint_interface->io_routines->read_video_frame) {
if ((status = session->endpoint_interface->io_routines->read_video_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) { if ((status = session->endpoint_interface->io_routines->read_video_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
for (ptr = session->event_hooks.video_read_frame; ptr; ptr = ptr->next) { for (ptr = session->event_hooks.video_read_frame; ptr; ptr = ptr->next) {
...@@ -165,6 +176,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi ...@@ -165,6 +176,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
*frame = &runtime.dummy_cng_frame; *frame = &runtime.dummy_cng_frame;
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if (switch_channel_test_flag(session->channel, CF_MEDIA_PAUSE)) {
switch_yield(20000);
*frame = &runtime.dummy_cng_frame;
// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Media Paused!!!!\n");
return SWITCH_STATUS_SUCCESS;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has no read codec.\n", switch_channel_get_name(session->channel)); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has no read codec.\n", switch_channel_get_name(session->channel));
switch_channel_hangup(session->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); switch_channel_hangup(session->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
...@@ -1033,6 +1052,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess ...@@ -1033,6 +1052,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
} }
} }
if (switch_channel_test_flag(session->channel, CF_MEDIA_PAUSE)) {
return SWITCH_STATUS_SUCCESS;
}
if (!(session->write_codec && switch_core_codec_ready(session->write_codec)) && !pass_cng) { if (!(session->write_codec && switch_core_codec_ready(session->write_codec)) && !pass_cng) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has no write codec.\n", switch_channel_get_name(session->channel)); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has no write codec.\n", switch_channel_get_name(session->channel));
switch_channel_hangup(session->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); switch_channel_hangup(session->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论