mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 00:00:44 +00:00
FS-9665 #resolve [Add video_pre_call_banner feature]
This commit is contained in:
parent
8e6d89733a
commit
34238d2bd0
@ -1506,7 +1506,8 @@ typedef enum {
|
|||||||
CF_VIDEO_WRITING,
|
CF_VIDEO_WRITING,
|
||||||
CF_SLA_INTERCEPT,
|
CF_SLA_INTERCEPT,
|
||||||
CF_VIDEO_BREAK,
|
CF_VIDEO_BREAK,
|
||||||
CF_AUDIO_PAUSE,
|
CF_AUDIO_PAUSE_READ,
|
||||||
|
CF_AUDIO_PAUSE_WRITE,
|
||||||
CF_VIDEO_PAUSE_READ,
|
CF_VIDEO_PAUSE_READ,
|
||||||
CF_VIDEO_PAUSE_WRITE,
|
CF_VIDEO_PAUSE_WRITE,
|
||||||
CF_BYPASS_MEDIA_AFTER_HOLD,
|
CF_BYPASS_MEDIA_AFTER_HOLD,
|
||||||
|
@ -181,6 +181,7 @@ static switch_status_t png_file_read_video(switch_file_handle_t *handle, switch_
|
|||||||
{
|
{
|
||||||
png_file_context_t *context = (png_file_context_t *)handle->private_info;
|
png_file_context_t *context = (png_file_context_t *)handle->private_info;
|
||||||
switch_image_t *dup = NULL;
|
switch_image_t *dup = NULL;
|
||||||
|
int have_frame = 0;
|
||||||
|
|
||||||
if ((flags & SVR_CHECK)) {
|
if ((flags & SVR_CHECK)) {
|
||||||
return SWITCH_STATUS_BREAK;
|
return SWITCH_STATUS_BREAK;
|
||||||
@ -190,18 +191,21 @@ static switch_status_t png_file_read_video(switch_file_handle_t *handle, switch_
|
|||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((context->reads++ % 20) == 0) {
|
if ((flags && SVR_BLOCK)) {
|
||||||
|
switch_yield(33000);
|
||||||
|
have_frame = 1;
|
||||||
|
} else if ((context->reads++ % 20) == 0) {
|
||||||
|
have_frame = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (have_frame) {
|
||||||
switch_img_copy(context->img, &dup);
|
switch_img_copy(context->img, &dup);
|
||||||
frame->img = dup;
|
frame->img = dup;
|
||||||
context->sent++;
|
context->sent++;
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
if ((flags && SVR_BLOCK)) {
|
|
||||||
switch_yield(5000);
|
|
||||||
}
|
|
||||||
return SWITCH_STATUS_BREAK;
|
return SWITCH_STATUS_BREAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -97,7 +97,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_channel_test_flag(session->channel, CF_AUDIO_PAUSE)) {
|
if (switch_channel_test_flag(session->channel, CF_AUDIO_PAUSE_READ)) {
|
||||||
switch_yield(20000);
|
switch_yield(20000);
|
||||||
*frame = &runtime.dummy_cng_frame;
|
*frame = &runtime.dummy_cng_frame;
|
||||||
// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Media Paused!!!!\n");
|
// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Media Paused!!!!\n");
|
||||||
@ -1039,7 +1039,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_channel_test_flag(session->channel, CF_AUDIO_PAUSE)) {
|
if (switch_channel_test_flag(session->channel, CF_AUDIO_PAUSE_WRITE)) {
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4159,7 +4159,8 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_channel_clear_flag(channel, CF_AUDIO_PAUSE);
|
switch_channel_clear_flag(channel, CF_AUDIO_PAUSE_READ);
|
||||||
|
switch_channel_clear_flag(channel, CF_AUDIO_PAUSE_WRITE);
|
||||||
|
|
||||||
if (dtls_ok(session) && (tmp = switch_channel_get_variable(smh->session->channel, "webrtc_enable_dtls")) && switch_false(tmp)) {
|
if (dtls_ok(session) && (tmp = switch_channel_get_variable(smh->session->channel, "webrtc_enable_dtls")) && switch_false(tmp)) {
|
||||||
switch_channel_clear_flag(smh->session->channel, CF_DTLS_OK);
|
switch_channel_clear_flag(smh->session->channel, CF_DTLS_OK);
|
||||||
@ -5563,7 +5564,8 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
|||||||
pmap->recv_pt = 97;
|
pmap->recv_pt = 97;
|
||||||
pmap->codec_ms = 20;
|
pmap->codec_ms = 20;
|
||||||
a_engine->cur_payload_map = pmap;
|
a_engine->cur_payload_map = pmap;
|
||||||
switch_channel_set_flag(channel, CF_AUDIO_PAUSE);
|
switch_channel_set_flag(channel, CF_AUDIO_PAUSE_READ);
|
||||||
|
switch_channel_set_flag(channel, CF_AUDIO_PAUSE_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
|
|||||||
switch_frame_t *read_frame = 0;
|
switch_frame_t *read_frame = 0;
|
||||||
int set_decoded_read = 0, refresh_timer = 0;
|
int set_decoded_read = 0, refresh_timer = 0;
|
||||||
int refresh_cnt = 300;
|
int refresh_cnt = 300;
|
||||||
|
|
||||||
vh->up = 1;
|
vh->up = 1;
|
||||||
|
|
||||||
switch_core_session_read_lock(vh->session_a);
|
switch_core_session_read_lock(vh->session_a);
|
||||||
@ -133,13 +133,14 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
status = switch_core_session_read_video_frame(vh->session_a, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
status = switch_core_session_read_video_frame(vh->session_a, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||||
|
|
||||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||||
switch_cond_next();
|
switch_cond_next();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (switch_test_flag(read_frame, SFF_CNG) ||
|
if (switch_test_flag(read_frame, SFF_CNG) ||
|
||||||
switch_channel_test_flag(channel, CF_LEG_HOLDING) || switch_channel_test_flag(b_channel, CF_VIDEO_READ_FILE_ATTACHED)) {
|
switch_channel_test_flag(channel, CF_LEG_HOLDING) || switch_channel_test_flag(b_channel, CF_VIDEO_READ_FILE_ATTACHED)) {
|
||||||
continue;
|
continue;
|
||||||
@ -285,6 +286,8 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
|||||||
switch_codec_implementation_t read_impl = { 0 };
|
switch_codec_implementation_t read_impl = { 0 };
|
||||||
uint32_t txt_launch = 0;
|
uint32_t txt_launch = 0;
|
||||||
struct vid_helper th = { 0 };
|
struct vid_helper th = { 0 };
|
||||||
|
const char *banner_file = NULL;
|
||||||
|
int played_banner = 0, banner_counter = 0;
|
||||||
|
|
||||||
#ifdef SWITCH_VIDEO_IN_THREADS
|
#ifdef SWITCH_VIDEO_IN_THREADS
|
||||||
struct vid_helper vh = { 0 };
|
struct vid_helper vh = { 0 };
|
||||||
@ -299,7 +302,6 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
|||||||
|
|
||||||
switch_core_session_get_read_impl(session_a, &read_impl);
|
switch_core_session_get_read_impl(session_a, &read_impl);
|
||||||
|
|
||||||
|
|
||||||
input_callback = data->input_callback;
|
input_callback = data->input_callback;
|
||||||
user_data = data->session_data;
|
user_data = data->session_data;
|
||||||
stream_id = data->stream_id;
|
stream_id = data->stream_id;
|
||||||
@ -346,6 +348,17 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
|||||||
goto end_of_bridge_loop;
|
goto end_of_bridge_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (switch_channel_test_flag(chan_a, CF_BRIDGE_ORIGINATOR) && (banner_file = switch_channel_get_variable(chan_a, "video_pre_call_banner"))) {
|
||||||
|
switch_channel_set_flag(chan_a, CF_AUDIO_PAUSE_READ);
|
||||||
|
switch_channel_set_flag(chan_b, CF_AUDIO_PAUSE_READ);
|
||||||
|
switch_channel_set_flag(chan_a, CF_AUDIO_PAUSE_WRITE);
|
||||||
|
switch_channel_set_flag(chan_b, CF_AUDIO_PAUSE_WRITE);
|
||||||
|
switch_channel_set_flag(chan_a, CF_VIDEO_PAUSE_READ);
|
||||||
|
switch_channel_set_flag(chan_b, CF_VIDEO_PAUSE_READ);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (bypass_media_after_bridge) {
|
if (bypass_media_after_bridge) {
|
||||||
const char *source_a = switch_channel_get_variable(chan_a, "source");
|
const char *source_a = switch_channel_get_variable(chan_a, "source");
|
||||||
const char *source_b = switch_channel_get_variable(chan_b, "source");
|
const char *source_b = switch_channel_get_variable(chan_b, "source");
|
||||||
@ -494,6 +507,37 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (read_frame_count >= DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) {
|
if (read_frame_count >= DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) {
|
||||||
|
if (!played_banner && switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO) &&
|
||||||
|
switch_channel_test_flag(chan_a, CF_ANSWERED) && switch_channel_test_flag(chan_b, CF_ANSWERED) &&
|
||||||
|
++banner_counter > 100 &&
|
||||||
|
switch_channel_test_flag(chan_a, CF_VIDEO_READY) && switch_channel_test_flag(chan_b, CF_VIDEO_READY) &&
|
||||||
|
switch_channel_test_flag(chan_a, CF_BRIDGE_ORIGINATOR) && banner_file) {
|
||||||
|
const char *b_banner_file = switch_channel_get_variable(chan_b, "video_pre_call_banner");
|
||||||
|
|
||||||
|
if (!b_banner_file) {
|
||||||
|
b_banner_file = switch_channel_get_variable(chan_a, "video_pre_call_banner_bleg");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
switch_channel_clear_flag(chan_a, CF_VIDEO_PAUSE_READ);
|
||||||
|
switch_channel_clear_flag(chan_b, CF_VIDEO_PAUSE_READ);
|
||||||
|
|
||||||
|
if (b_banner_file) {
|
||||||
|
switch_ivr_broadcast(switch_core_session_get_uuid(session_a), banner_file, SMF_ECHO_ALEG);
|
||||||
|
switch_ivr_broadcast(switch_core_session_get_uuid(session_b), b_banner_file, SMF_ECHO_ALEG);
|
||||||
|
} else {
|
||||||
|
switch_ivr_broadcast(switch_core_session_get_uuid(session_a), banner_file, SMF_ECHO_ALEG | SMF_ECHO_BLEG);
|
||||||
|
}
|
||||||
|
|
||||||
|
played_banner = 1;
|
||||||
|
|
||||||
|
switch_channel_clear_flag(chan_a, CF_AUDIO_PAUSE_READ);
|
||||||
|
switch_channel_clear_flag(chan_b, CF_AUDIO_PAUSE_READ);
|
||||||
|
switch_channel_clear_flag(chan_a, CF_AUDIO_PAUSE_WRITE);
|
||||||
|
switch_channel_clear_flag(chan_b, CF_AUDIO_PAUSE_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!exec_check) {
|
if (!exec_check) {
|
||||||
switch_channel_execute_on(chan_a, SWITCH_CHANNEL_EXECUTE_ON_PRE_BRIDGE_VARIABLE);
|
switch_channel_execute_on(chan_a, SWITCH_CHANNEL_EXECUTE_ON_PRE_BRIDGE_VARIABLE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user