From badd59d609b5d5583c01d543e0d6b3a9cb365df1 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 14 Apr 2020 19:52:38 +0000 Subject: [PATCH] [core, mod_verto] remove CF_VIDEO_ONLY and pay attention to the streams instead and add CF_NO_RECOVER flag for verto --- src/include/switch_types.h | 2 +- .../mod_conference/conference_event.c | 2 +- .../mod_conference/conference_member.c | 2 +- .../mod_conference/mod_conference.c | 28 +++++++++---------- src/mod/endpoints/mod_verto/mod_verto.c | 17 +++++++---- src/switch_core_media.c | 8 ++++-- 6 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 674de974d0..a1bc0204ec 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1595,7 +1595,7 @@ typedef enum { CF_VIDEO_DECODED_READ, CF_VIDEO_DEBUG_READ, CF_VIDEO_DEBUG_WRITE, - CF_VIDEO_ONLY, + CF_NO_RECOVER, CF_VIDEO_READY, CF_VIDEO_MIRROR_INPUT, CF_VIDEO_READ_FILE_ATTACHED, diff --git a/src/mod/applications/mod_conference/conference_event.c b/src/mod/applications/mod_conference/conference_event.c index 806dfc95ed..23adb127a8 100644 --- a/src/mod/applications/mod_conference/conference_event.c +++ b/src/mod/applications/mod_conference/conference_event.c @@ -634,7 +634,7 @@ void conference_event_adv_la(conference_obj_t *conference, conference_member_t * switch_channel_set_flag(member->channel, CF_VIDEO_REFRESH_REQ); switch_core_media_gen_key_frame(member->session); - if (conference && conference->la && member->session && !switch_channel_test_flag(member->channel, CF_VIDEO_ONLY)) { + if (conference && conference->la && member->session) { cJSON *msg, *data; const char *uuid = switch_core_session_get_uuid(member->session); const char *cookie = switch_channel_get_variable(member->channel, "event_channel_cookie"); diff --git a/src/mod/applications/mod_conference/conference_member.c b/src/mod/applications/mod_conference/conference_member.c index 74264b0677..f9c036baec 100644 --- a/src/mod/applications/mod_conference/conference_member.c +++ b/src/mod/applications/mod_conference/conference_member.c @@ -186,7 +186,7 @@ void conference_member_update_status_field(conference_member_t *member) cJSON_AddItemToObject(video, "visible", cJSON_CreateFalse()); } - cJSON_AddItemToObject(video, "videoOnly", cJSON_CreateBool(switch_channel_test_flag(member->channel, CF_VIDEO_ONLY))); + cJSON_AddItemToObject(video, "noRecover", cJSON_CreateBool(switch_channel_test_flag(member->channel, CF_NO_RECOVER))); if (switch_true(switch_channel_get_variable_dup(member->channel, "video_screen_share", SWITCH_FALSE, -1))) { cJSON_AddItemToObject(video, "screenShare", cJSON_CreateTrue()); } diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 670d6ac9de..875d0f9731 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -2474,21 +2474,21 @@ SWITCH_STANDARD_APP(conference_function) switch_core_session_set_video_read_callback(session, conference_video_thread_callback, (void *)&member); switch_core_session_set_text_read_callback(session, conference_text_thread_callback, (void *)&member); - if (switch_channel_test_flag(channel, CF_VIDEO_ONLY) || !switch_channel_test_flag(channel, CF_AUDIO)) { - while(conference_utils_member_test_flag((&member), MFLAG_RUNNING) && switch_channel_ready(channel)) { - switch_frame_t *read_frame; - if (switch_channel_test_flag(channel, CF_AUDIO)) { - switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); - } - switch_yield(100000); - } - } else { - - /* Run the conference loop */ - do { + /* Run the conference loop */ + do { + switch_media_flow_t audio_flow = switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_AUDIO); + + if (switch_channel_test_flag(channel, CF_AUDIO) && (audio_flow == SWITCH_MEDIA_FLOW_SENDRECV || audio_flow == SWITCH_MEDIA_FLOW_RECVONLY)) { conference_loop_output(&member); - } while (member.loop_loop); - } + } else { + if (conference_utils_member_test_flag((&member), MFLAG_RUNNING) && switch_channel_ready(channel)) { + switch_yield(100000); + member.loop_loop = 1; + } else { + break; + } + } + } while (member.loop_loop); switch_core_session_video_reset(session); switch_channel_clear_flag_recursive(channel, CF_VIDEO_DECODED_READ); diff --git a/src/mod/endpoints/mod_verto/mod_verto.c b/src/mod/endpoints/mod_verto/mod_verto.c index 3a94f112c8..b5dcce2269 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.c +++ b/src/mod/endpoints/mod_verto/mod_verto.c @@ -1347,7 +1347,7 @@ static void detach_calls(jsock_t *jsock) continue; } - if (switch_channel_test_flag(tech_pvt->channel, CF_VIDEO_ONLY)) { + if (switch_channel_test_flag(tech_pvt->channel, CF_NO_RECOVER)) { switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_NORMAL_CLEARING); continue; } @@ -2762,7 +2762,7 @@ static int verto_recover_callback(switch_core_session_t *session) const char *profile_name = NULL, *jsock_uuid_str = NULL; switch_channel_t *channel = switch_core_session_get_channel(session); - if (switch_channel_test_flag(channel, CF_VIDEO_ONLY)) { + if (switch_channel_test_flag(channel, CF_NO_RECOVER)) { return 0; } @@ -3817,7 +3817,7 @@ static switch_bool_t verto__info_func(const char *method, cJSON *params, jsock_t static switch_bool_t verto__invite_func(const char *method, cJSON *params, jsock_t *jsock, cJSON **response) { - cJSON *obj = cJSON_CreateObject(), *screenShare = NULL, *dedEnc = NULL, *mirrorInput, *bandwidth = NULL, *canvas = NULL; + cJSON *obj = cJSON_CreateObject(), *vobj = NULL, *dedEnc = NULL, *mirrorInput, *bandwidth = NULL, *canvas = NULL; switch_core_session_t *session = NULL; switch_channel_t *channel; switch_event_t *var_event; @@ -3899,9 +3899,16 @@ static switch_bool_t verto__invite_func(const char *method, cJSON *params, jsock err = 1; goto cleanup; } - if ((screenShare = cJSON_GetObjectItem(dialog, "screenShare")) && screenShare->type == cJSON_True) { + if ((vobj = cJSON_GetObjectItem(dialog, "screenShare")) && vobj->type == cJSON_True) { switch_channel_set_variable(channel, "video_screen_share", "true"); - switch_channel_set_flag(channel, CF_VIDEO_ONLY); + } + + if ((vobj = cJSON_GetObjectItem(dialog, "secondSource")) && vobj->type == cJSON_True) { + switch_channel_set_variable(channel, "video_second_source", "true"); + } + + if ((vobj = cJSON_GetObjectItem(dialog, "recoverCall")) && vobj->type == cJSON_False) { + switch_channel_set_flag(channel, CF_NO_RECOVER); } if ((dedEnc = cJSON_GetObjectItem(dialog, "dedEnc")) && dedEnc->type == cJSON_True) { diff --git a/src/switch_core_media.c b/src/switch_core_media.c index b6cb4b6670..bfaff77289 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -3459,8 +3459,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_sessio } } - if (switch_channel_test_flag(session->channel, CF_VIDEO_ONLY) && type == SWITCH_MEDIA_TYPE_AUDIO) { - return SWITCH_STATUS_SUCCESS; + if (type == SWITCH_MEDIA_TYPE_AUDIO) { + switch_media_flow_t audio_flow = switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_AUDIO); + + if (audio_flow != SWITCH_MEDIA_FLOW_SENDRECV && audio_flow != SWITCH_MEDIA_FLOW_SENDONLY) { + return SWITCH_STATUS_SUCCESS; + } } if (type != SWITCH_MEDIA_TYPE_TEXT) {