| OLD | NEW |
| 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 Loading... |
| 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 rtc::CritScope cs(&crit_sect_); |
| 125 |
| 126 #if RTC_DCHECK_IS_ON |
| 127 RTC_DCHECK(!used_for_video_); |
| 128 used_for_audio_ = true; |
| 129 #endif |
| 130 |
| 124 *created_new_payload = false; | 131 *created_new_payload = false; |
| 125 if (!IsPayloadTypeValid(audio_codec.pltype)) | 132 if (!IsPayloadTypeValid(audio_codec.pltype)) |
| 126 return -1; | 133 return -1; |
| 127 | 134 |
| 128 rtc::CritScope cs(&crit_sect_); | |
| 129 | |
| 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 rtc::CritScope cs(&crit_sect_); |
| 163 |
| 164 #if RTC_DCHECK_IS_ON |
| 165 RTC_DCHECK(!used_for_audio_); |
| 166 used_for_video_ = true; |
| 167 #endif |
| 168 |
| 157 if (!IsPayloadTypeValid(video_codec.plType)) | 169 if (!IsPayloadTypeValid(video_codec.plType)) |
| 158 return -1; | 170 return -1; |
| 159 | 171 |
| 160 rtc::CritScope cs(&crit_sect_); | |
| 161 | |
| 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)) |
| 167 return 0; | 177 return 0; |
| 168 LOG(LS_ERROR) << "Payload type already registered: " | 178 LOG(LS_ERROR) << "Payload type already registered: " |
| 169 << static_cast<int>(video_codec.plType); | 179 << static_cast<int>(video_codec.plType); |
| 170 return -1; | 180 return -1; |
| 171 } | 181 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |