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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc

Issue 2772043002: Revert of WebRtcVoiceMediaChannel::AddRecvStream: Don't call SetRecPayloadType (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" 11 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/logging.h" 16 #include "webrtc/base/logging.h"
17 #include "webrtc/base/stringutils.h" 17 #include "webrtc/base/stringutils.h"
18 #include "webrtc/common_types.h" 18 #include "webrtc/common_types.h"
19 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
20 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 19 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
21 20
22 namespace webrtc { 21 namespace webrtc {
23 22
24 namespace { 23 namespace {
25 24
26 bool PayloadIsCompatible(const RtpUtility::Payload& payload, 25 bool PayloadIsCompatible(const RtpUtility::Payload& payload,
27 const CodecInst& audio_codec) { 26 const CodecInst& audio_codec) {
28 if (!payload.audio) 27 if (!payload.audio)
29 return false; 28 return false;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 112
114 RTPPayloadRegistry::RTPPayloadRegistry() 113 RTPPayloadRegistry::RTPPayloadRegistry()
115 : incoming_payload_type_(-1), 114 : incoming_payload_type_(-1),
116 last_received_payload_type_(-1), 115 last_received_payload_type_(-1),
117 last_received_media_payload_type_(-1), 116 last_received_media_payload_type_(-1),
118 rtx_(false), 117 rtx_(false),
119 ssrc_rtx_(0) {} 118 ssrc_rtx_(0) {}
120 119
121 RTPPayloadRegistry::~RTPPayloadRegistry() = default; 120 RTPPayloadRegistry::~RTPPayloadRegistry() = default;
122 121
123 void RTPPayloadRegistry::SetAudioReceivePayloads(
124 std::map<int, SdpAudioFormat> codecs) {
125 rtc::CritScope cs(&crit_sect_);
126
127 #if RTC_DCHECK_IS_ON
128 RTC_DCHECK(!used_for_video_);
129 used_for_audio_ = true;
130 #endif
131
132 payload_type_map_.clear();
133 for (const auto& kv : codecs) {
134 const int& rtp_payload_type = kv.first;
135 const SdpAudioFormat& audio_format = kv.second;
136 const CodecInst ci = SdpToCodecInst(rtp_payload_type, audio_format);
137 RTC_DCHECK(IsPayloadTypeValid(rtp_payload_type));
138 payload_type_map_.insert(
139 std::make_pair(rtp_payload_type, CreatePayloadType(ci)));
140 }
141
142 // Clear the value of last received payload type since it might mean
143 // something else now.
144 last_received_payload_type_ = -1;
145 last_received_media_payload_type_ = -1;
146 }
147
148 int32_t RTPPayloadRegistry::RegisterReceivePayload(const CodecInst& audio_codec, 122 int32_t RTPPayloadRegistry::RegisterReceivePayload(const CodecInst& audio_codec,
149 bool* created_new_payload) { 123 bool* created_new_payload) {
150 rtc::CritScope cs(&crit_sect_); 124 rtc::CritScope cs(&crit_sect_);
151 125
152 #if RTC_DCHECK_IS_ON 126 #if RTC_DCHECK_IS_ON
153 RTC_DCHECK(!used_for_video_); 127 RTC_DCHECK(!used_for_video_);
154 used_for_audio_ = true; 128 used_for_audio_ = true;
155 #endif 129 #endif
156 130
157 *created_new_payload = false; 131 *created_new_payload = false;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 const char* payload_name) const { 396 const char* payload_name) const {
423 rtc::CritScope cs(&crit_sect_); 397 rtc::CritScope cs(&crit_sect_);
424 for (const auto& it : payload_type_map_) { 398 for (const auto& it : payload_type_map_) {
425 if (_stricmp(it.second.name, payload_name) == 0) 399 if (_stricmp(it.second.name, payload_name) == 0)
426 return it.first; 400 return it.first;
427 } 401 }
428 return -1; 402 return -1;
429 } 403 }
430 404
431 } // namespace webrtc 405 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h ('k') | webrtc/test/mock_voe_channel_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698