Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 2831333002: Allow a received audio codec's payload type to change. (Closed)
Patch Set: Updating a test. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/audio_codecs/audio_format.cc ('k') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvoiceengine.cc
diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc
index 2384ac28f173870959c97b6bc78224f931a03464..5fec94d131c32c215cf29d7045012189872ed6ed 100644
--- a/webrtc/media/engine/webrtcvoiceengine.cc
+++ b/webrtc/media/engine/webrtcvoiceengine.cc
@@ -1515,20 +1515,10 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
RecreateAudioReceiveStream();
}
- // Set a new payload type -> decoder map. The new map must be a superset of
- // the old one.
+ // Set a new payload type -> decoder map.
void RecreateAudioReceiveStream(
const std::map<int, webrtc::SdpAudioFormat>& decoder_map) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
- RTC_DCHECK([&] {
- for (const auto& item : config_.decoder_map) {
- auto it = decoder_map.find(item.first);
- if (it == decoder_map.end() || *it != item) {
- return false; // The old map isn't a subset of the new map.
- }
- }
- return true;
- }());
config_.decoder_map = decoder_map;
RecreateAudioReceiveStream();
}
@@ -1857,14 +1847,10 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecs(
// already be receiving packets with that payload type.
for (const AudioCodec& codec : codecs) {
AudioCodec old_codec;
- // TODO(solenberg): This isn't strictly correct. It should be possible to
- // add an additional payload type for a codec. That would result in a new
- // decoder object being allocated. What shouldn't work is to remove a PT
- // mapping that was previously configured.
if (FindCodec(recv_codecs_, codec, &old_codec)) {
if (old_codec.id != codec.id) {
- LOG(LS_ERROR) << codec.name << " payload type changed.";
- return false;
+ LOG(LS_WARNING) << codec.name << " payload type changed.";
+ new_codecs.push_back(codec);
kwiberg-webrtc 2017/04/24 08:39:34 This warning will trigger if you try to map a fres
Taylor Brandstetter 2017/04/24 22:44:53 I wanted to keep the log statement as a warning, b
kwiberg-webrtc 2017/04/25 09:06:04 OK. But the message is no longer accurate, since t
Taylor Brandstetter 2017/04/26 23:04:39 Fixed log message.
}
} else {
new_codecs.push_back(codec);
@@ -1886,6 +1872,15 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecs(
LOG(LS_ERROR) << "Unsupported codec: " << format;
return false;
}
+ // If a payload type is already mapped to a codec, it's illegal to map it
+ // to a new codec.
kwiberg-webrtc 2017/04/24 08:39:34 Add a TODO about checking for clashes with previou
Taylor Brandstetter 2017/04/24 22:44:54 Done.
+ auto existing = decoder_map_.find(codec.id);
kwiberg-webrtc 2017/04/24 08:39:34 const?
Taylor Brandstetter 2017/04/24 22:44:54 What's our style for this sort of thing? Just "con
kwiberg-webrtc 2017/04/25 09:06:04 The style guide basically just says "use const whe
Taylor Brandstetter 2017/04/26 23:04:39 Done.
+ if (existing != decoder_map_.end() && !existing->second.Matches(format)) {
+ LOG(LS_ERROR) << "Attempting to use payload type " << codec.id << " for "
+ << codec.name << ", but it is already used for "
+ << existing->second.name;
+ return false;
+ }
decoder_map.insert({codec.id, std::move(format)});
}
« no previous file with comments | « webrtc/api/audio_codecs/audio_format.cc ('k') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698