From ee0b00e8a9cc2d8f4578912a389dee92ac020ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Bostr=C3=B6m?= Date: Wed, 22 Apr 2015 18:41:14 +0200 Subject: [PATCH] Prevent recv-stream reconfig on identical codecs. Receive streams seem to be reconfigured with identical codecs when another stream is removed. Preventing this reconfiguration makes sure that existing streams don't report stats during teardown when the stream is still supposed to be running. BUG=1788 R=asapersson@webrtc.org Review URL: https://webrtc-codereview.appspot.com/44249004 Cr-Commit-Position: refs/heads/master@{#9059} --- talk/media/webrtc/webrtcvideoengine2.cc | 18 ++++++++++++++++++ talk/media/webrtc/webrtcvideoengine2.h | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc index b9816fc161..ec4f983ebd 100644 --- a/talk/media/webrtc/webrtcvideoengine2.cc +++ b/talk/media/webrtc/webrtcvideoengine2.cc @@ -718,6 +718,19 @@ bool WebRtcVideoChannel2::SetRecvCodecs(const std::vector& codecs) { return false; } + // Prevent reconfiguration when setting identical receive codecs. + if (recv_codecs_.size() == supported_codecs.size()) { + bool reconfigured = false; + for (size_t i = 0; i < supported_codecs.size(); ++i) { + if (recv_codecs_[i] != supported_codecs[i]) { + reconfigured = true; + break; + } + } + if (!reconfigured) + return true; + } + recv_codecs_ = supported_codecs; rtc::CritScope stream_lock(&stream_crit_); @@ -2250,6 +2263,11 @@ bool WebRtcVideoChannel2::VideoCodecSettings::operator==( rtx_payload_type == other.rtx_payload_type; } +bool WebRtcVideoChannel2::VideoCodecSettings::operator!=( + const WebRtcVideoChannel2::VideoCodecSettings& other) const { + return !(*this == other); +} + std::vector WebRtcVideoChannel2::MapCodecs(const std::vector& codecs) { assert(!codecs.empty()); diff --git a/talk/media/webrtc/webrtcvideoengine2.h b/talk/media/webrtc/webrtcvideoengine2.h index 927e699e3e..b8ddfc6f11 100644 --- a/talk/media/webrtc/webrtcvideoengine2.h +++ b/talk/media/webrtc/webrtcvideoengine2.h @@ -246,7 +246,9 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, struct VideoCodecSettings { VideoCodecSettings(); - bool operator ==(const VideoCodecSettings& other) const; + + bool operator==(const VideoCodecSettings& other) const; + bool operator!=(const VideoCodecSettings& other) const; VideoCodec codec; webrtc::FecConfig fec;