From 957e802fe0e6e765425955cc1e3e02f73d1a670b Mon Sep 17 00:00:00 2001 From: "pbos@webrtc.org" Date: Mon, 10 Nov 2014 12:36:11 +0000 Subject: [PATCH] Refactor SetDefaultEncoderConfig to work on existing codecs. Addresses issue where SetDefaultEncoderConfig modifies the codec list rather than just the targeted codec. This was previously done just to pass more unit tests rather than be done properly. This incidentally addresses a TODO causing this to work with external codecs as well. R=stefan@webrtc.org BUG=1788 Review URL: https://webrtc-codereview.appspot.com/32009004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7667 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/media/webrtc/webrtcvideoengine2.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc index 8a1bad05d7..74f34cd2f0 100644 --- a/talk/media/webrtc/webrtcvideoengine2.cc +++ b/talk/media/webrtc/webrtcvideoengine2.cc @@ -359,9 +359,17 @@ int WebRtcVideoEngine2::GetCapabilities() { return VIDEO_RECV | VIDEO_SEND; } bool WebRtcVideoEngine2::SetDefaultEncoderConfig( const VideoEncoderConfig& config) { const VideoCodec& codec = config.max_codec; - // TODO(pbos): Make use of external encoder factory. - if (!CodecIsInternallySupported(codec.name)) { - LOG(LS_ERROR) << "SetDefaultEncoderConfig, codec not supported:" + bool supports_codec = false; + for (size_t i = 0; i < video_codecs_.size(); ++i) { + if (CodecNameMatches(video_codecs_[i].name, codec.name)) { + video_codecs_[i] = codec; + supports_codec = true; + break; + } + } + + if (!supports_codec) { + LOG(LS_ERROR) << "SetDefaultEncoderConfig, codec not supported: " << codec.ToString(); return false; } @@ -371,8 +379,6 @@ bool WebRtcVideoEngine2::SetDefaultEncoderConfig( codec.height, VideoFormat::FpsToInterval(codec.framerate), FOURCC_ANY); - video_codecs_.clear(); - video_codecs_.push_back(codec); return true; }