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

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

Issue 2763323002: DCHECK that no RTPPayloadRegistry instance is used for both audio and video (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
« no previous file with comments | « webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 : incoming_payload_type_(-1), 114 : incoming_payload_type_(-1),
115 last_received_payload_type_(-1), 115 last_received_payload_type_(-1),
116 last_received_media_payload_type_(-1), 116 last_received_media_payload_type_(-1),
117 rtx_(false), 117 rtx_(false),
118 ssrc_rtx_(0) {} 118 ssrc_rtx_(0) {}
119 119
120 RTPPayloadRegistry::~RTPPayloadRegistry() = default; 120 RTPPayloadRegistry::~RTPPayloadRegistry() = default;
121 121
122 int32_t RTPPayloadRegistry::RegisterReceivePayload(const CodecInst& audio_codec, 122 int32_t RTPPayloadRegistry::RegisterReceivePayload(const CodecInst& audio_codec,
123 bool* created_new_payload) { 123 bool* created_new_payload) {
124 #if RTC_DCHECK_IS_ON
125 RTC_DCHECK(!used_for_video_);
126 used_for_audio_ = true;
127 #endif
128
124 *created_new_payload = false; 129 *created_new_payload = false;
125 if (!IsPayloadTypeValid(audio_codec.pltype)) 130 if (!IsPayloadTypeValid(audio_codec.pltype))
126 return -1; 131 return -1;
127 132
128 rtc::CritScope cs(&crit_sect_); 133 rtc::CritScope cs(&crit_sect_);
the sun 2017/03/22 14:28:01 My only concern would be whether this class is rac
kwiberg-webrtc 2017/03/22 17:46:42 Good point. I'll do that.
129 134
130 auto it = payload_type_map_.find(audio_codec.pltype); 135 auto it = payload_type_map_.find(audio_codec.pltype);
131 if (it != payload_type_map_.end()) { 136 if (it != payload_type_map_.end()) {
132 // We already use this payload type. Check if it's the same as we already 137 // We already use this payload type. Check if it's the same as we already
133 // have. If same, ignore sending an error. 138 // have. If same, ignore sending an error.
134 if (PayloadIsCompatible(it->second, audio_codec)) { 139 if (PayloadIsCompatible(it->second, audio_codec)) {
135 it->second.typeSpecific.Audio.rate = 0; 140 it->second.typeSpecific.Audio.rate = 0;
136 return 0; 141 return 0;
137 } 142 }
138 LOG(LS_ERROR) << "Payload type already registered: " << audio_codec.pltype; 143 LOG(LS_ERROR) << "Payload type already registered: " << audio_codec.pltype;
139 return -1; 144 return -1;
140 } 145 }
141 146
142 // Audio codecs must be unique. 147 // Audio codecs must be unique.
143 DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType(audio_codec); 148 DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType(audio_codec);
144 149
145 payload_type_map_[audio_codec.pltype] = CreatePayloadType(audio_codec); 150 payload_type_map_[audio_codec.pltype] = CreatePayloadType(audio_codec);
146 *created_new_payload = true; 151 *created_new_payload = true;
147 152
148 // Successful set of payload type, clear the value of last received payload 153 // Successful set of payload type, clear the value of last received payload
149 // type since it might mean something else. 154 // type since it might mean something else.
150 last_received_payload_type_ = -1; 155 last_received_payload_type_ = -1;
151 last_received_media_payload_type_ = -1; 156 last_received_media_payload_type_ = -1;
152 return 0; 157 return 0;
153 } 158 }
154 159
155 int32_t RTPPayloadRegistry::RegisterReceivePayload( 160 int32_t RTPPayloadRegistry::RegisterReceivePayload(
156 const VideoCodec& video_codec) { 161 const VideoCodec& video_codec) {
162 #if RTC_DCHECK_IS_ON
163 RTC_DCHECK(!used_for_audio_);
164 used_for_video_ = true;
165 #endif
166
157 if (!IsPayloadTypeValid(video_codec.plType)) 167 if (!IsPayloadTypeValid(video_codec.plType))
158 return -1; 168 return -1;
159 169
160 rtc::CritScope cs(&crit_sect_); 170 rtc::CritScope cs(&crit_sect_);
161 171
162 auto it = payload_type_map_.find(video_codec.plType); 172 auto it = payload_type_map_.find(video_codec.plType);
163 if (it != payload_type_map_.end()) { 173 if (it != payload_type_map_.end()) {
164 // We already use this payload type. Check if it's the same as we already 174 // We already use this payload type. Check if it's the same as we already
165 // have. If same, ignore sending an error. 175 // have. If same, ignore sending an error.
166 if (PayloadIsCompatible(it->second, video_codec)) 176 if (PayloadIsCompatible(it->second, video_codec))
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 const char* payload_name) const { 396 const char* payload_name) const {
387 rtc::CritScope cs(&crit_sect_); 397 rtc::CritScope cs(&crit_sect_);
388 for (const auto& it : payload_type_map_) { 398 for (const auto& it : payload_type_map_) {
389 if (_stricmp(it.second.name, payload_name) == 0) 399 if (_stricmp(it.second.name, payload_name) == 0)
390 return it.first; 400 return it.first;
391 } 401 }
392 return -1; 402 return -1;
393 } 403 }
394 404
395 } // namespace webrtc 405 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698