From be0e09bd7f94df837d255e5d3f4ef92a5cd3dbdb Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Thu, 11 Dec 2014 13:22:43 -0600
Subject: [PATCH] only negotiate codecs that were previously negotiated on
 re-invites unless its intentional to change codecs

---
 src/switch_core_media.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/switch_core_media.c b/src/switch_core_media.c
index 1c7c369474..f6e7b32b39 100644
--- a/src/switch_core_media.c
+++ b/src/switch_core_media.c
@@ -3442,6 +3442,12 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
 				reneg = 0;
 			}
 			
+			if (sdp_type == SDP_TYPE_RESPONSE && smh->num_negotiated_codecs) {
+				/* response to re-invite or update, only negotiated codecs are valid */
+				reneg = 0;
+			}
+
+
 			if (!reneg && smh->num_negotiated_codecs) {
 				codec_array = smh->negotiated_codecs;
 				total_codecs = smh->num_negotiated_codecs;
@@ -8002,6 +8008,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
 
 				a_engine->codec_negotiated = 0;
 				v_engine->codec_negotiated = 0;
+				smh->num_negotiated_codecs = 0;
 				switch_channel_clear_flag(session->channel, CF_VIDEO_POSSIBLE);
 				switch_core_media_prepare_codecs(session, SWITCH_TRUE);
 				switch_core_media_check_video_codecs(session);