From c584bf55112fd52d67b673cdb6fbf85023721632 Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Thu, 20 Nov 2014 11:33:25 -0600
Subject: [PATCH] FS-7500: reverse default for CF_VIDEO_ECHO to false and now
 it must be enabled when desired instead of disabled when not needed

---
 src/mod/applications/mod_conference/mod_conference.c | 5 -----
 src/mod/applications/mod_fsv/mod_fsv.c               | 3 ---
 src/mod/formats/mod_vlc/mod_vlc.c                    | 3 ---
 src/switch_core_session.c                            | 2 +-
 src/switch_ivr_async.c                               | 2 ++
 src/switch_ivr_bridge.c                              | 4 ----
 6 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c
index 3787f107ec..b89413cf37 100644
--- a/src/mod/applications/mod_conference/mod_conference.c
+++ b/src/mod/applications/mod_conference/mod_conference.c
@@ -2252,10 +2252,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe
 
 		if (switch_channel_test_flag(channel, CF_VIDEO)) {
 			if (switch_test_flag(conference, CFLAG_VIDEO_BRIDGE)) {
-				switch_channel_set_flag(channel, CF_VIDEO_ECHO);
 				switch_channel_clear_flag(channel, CF_VIDEO_PASSIVE);
-			} else {
-				switch_channel_clear_flag(channel, CF_VIDEO_ECHO);
 			}
 			/* Tell the channel to request a fresh vid frame */
 			switch_core_session_refresh_video(member->session);
@@ -2503,7 +2500,6 @@ static void conference_set_video_floor_holder(conference_obj_t *conference, conf
 		if (!imember->channel || !switch_channel_test_flag(imember->channel, CF_VIDEO)) {
 			continue;
 		}
-		switch_channel_clear_flag(imember->channel, CF_VIDEO_ECHO);
 
 		if (imember == conference->video_floor_holder) {
 			switch_channel_set_flag(imember->channel, CF_VIDEO_PASSIVE);
@@ -4334,7 +4330,6 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
 
 		if (switch_channel_test_flag(channel, CF_VIDEO) && !switch_test_flag(member, MFLAG_ACK_VIDEO)) {
 			switch_set_flag_locked(member, MFLAG_ACK_VIDEO);
-			switch_channel_clear_flag(channel, CF_VIDEO_ECHO);
 			switch_core_session_refresh_video(member->session);
 			conference_set_video_floor_holder(member->conference, member, SWITCH_FALSE);
 		}
diff --git a/src/mod/applications/mod_fsv/mod_fsv.c b/src/mod/applications/mod_fsv/mod_fsv.c
index cdd9c3a03c..c544abcaa7 100644
--- a/src/mod/applications/mod_fsv/mod_fsv.c
+++ b/src/mod/applications/mod_fsv/mod_fsv.c
@@ -616,7 +616,6 @@ SWITCH_STANDARD_APP(play_yuv_function)
 	yuv = img->planes[SWITCH_PLANE_PACKED];
 
 	// switch_channel_set_flag(channel, CF_VIDEO_PASSIVE);
-	switch_channel_clear_flag(channel, CF_VIDEO_ECHO);
 
 	vid_buffer = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
 
@@ -699,9 +698,7 @@ SWITCH_STANDARD_APP(play_yuv_function)
  done:
 
 	switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
-
 	// switch_channel_clear_flag(channel, CF_VIDEO_PASSIVE);
-	switch_channel_set_flag(channel, CF_VIDEO_ECHO);
 }
 
 
diff --git a/src/mod/formats/mod_vlc/mod_vlc.c b/src/mod/formats/mod_vlc/mod_vlc.c
index ce1f9bd553..5f2ce61921 100644
--- a/src/mod/formats/mod_vlc/mod_vlc.c
+++ b/src/mod/formats/mod_vlc/mod_vlc.c
@@ -613,9 +613,6 @@ SWITCH_STANDARD_APP(play_video_function)
 
 	switch_size_t audio_datalen;
 
-
-	switch_channel_clear_flag(channel, CF_VIDEO_ECHO);
-
 	context = switch_core_session_alloc(session, sizeof(vlc_video_context_t));
 	switch_assert(context);
 	memset(context, 0, sizeof(vlc_file_context_t));
diff --git a/src/switch_core_session.c b/src/switch_core_session.c
index bcb92197b1..ea5259db1c 100644
--- a/src/switch_core_session.c
+++ b/src/switch_core_session.c
@@ -2677,7 +2677,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_async(sw
 
 SWITCH_DECLARE(void) switch_core_session_video_reset(switch_core_session_t *session)
 {
-	switch_channel_set_flag(session->channel, CF_VIDEO_ECHO);
+	switch_channel_clear_flag(session->channel, CF_VIDEO_ECHO);
 	switch_channel_clear_flag(session->channel, CF_VIDEO_PASSIVE);
 	switch_channel_clear_flag(session->channel, CF_VIDEO_DECODED_READ);
 	switch_core_session_refresh_video(session);
diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c
index e54a762924..57cc405523 100644
--- a/src/switch_ivr_async.c
+++ b/src/switch_ivr_async.c
@@ -652,6 +652,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_echo(switch_core_session_t *s
 		switch_core_session_raw_read(session);
 	}
 
+	switch_channel_set_flag(channel, CF_VIDEO_ECHO);
+
 	while (switch_channel_ready(channel)) {
 		status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c
index cee19190e8..8f09c61ea1 100644
--- a/src/switch_ivr_bridge.c
+++ b/src/switch_ivr_bridge.c
@@ -244,10 +244,6 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
 	chan_a = switch_core_session_get_channel(session_a);
 	chan_b = switch_core_session_get_channel(session_b);
 
-	switch_channel_clear_flag(chan_a, CF_VIDEO_ECHO);
-	switch_channel_clear_flag(chan_b, CF_VIDEO_ECHO);
-	
-
 	if ((exec_app = switch_channel_get_variable(chan_a, "bridge_pre_execute_app"))) {
 		exec_data = switch_channel_get_variable(chan_a, "bridge_pre_execute_data");
 	}