| 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 |
| 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" |
| 19 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 20 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 20 | 21 |
| 21 namespace webrtc { | 22 namespace webrtc { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 bool PayloadIsCompatible(const RtpUtility::Payload& payload, | 26 bool PayloadIsCompatible(const RtpUtility::Payload& payload, |
| 26 const CodecInst& audio_codec) { | 27 const CodecInst& audio_codec) { |
| 27 if (!payload.audio) | 28 if (!payload.audio) |
| 28 return false; | 29 return false; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 113 |
| 113 RTPPayloadRegistry::RTPPayloadRegistry() | 114 RTPPayloadRegistry::RTPPayloadRegistry() |
| 114 : incoming_payload_type_(-1), | 115 : incoming_payload_type_(-1), |
| 115 last_received_payload_type_(-1), | 116 last_received_payload_type_(-1), |
| 116 last_received_media_payload_type_(-1), | 117 last_received_media_payload_type_(-1), |
| 117 rtx_(false), | 118 rtx_(false), |
| 118 ssrc_rtx_(0) {} | 119 ssrc_rtx_(0) {} |
| 119 | 120 |
| 120 RTPPayloadRegistry::~RTPPayloadRegistry() = default; | 121 RTPPayloadRegistry::~RTPPayloadRegistry() = default; |
| 121 | 122 |
| 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 |
| 122 int32_t RTPPayloadRegistry::RegisterReceivePayload(const CodecInst& audio_codec, | 148 int32_t RTPPayloadRegistry::RegisterReceivePayload(const CodecInst& audio_codec, |
| 123 bool* created_new_payload) { | 149 bool* created_new_payload) { |
| 124 rtc::CritScope cs(&crit_sect_); | 150 rtc::CritScope cs(&crit_sect_); |
| 125 | 151 |
| 126 #if RTC_DCHECK_IS_ON | 152 #if RTC_DCHECK_IS_ON |
| 127 RTC_DCHECK(!used_for_video_); | 153 RTC_DCHECK(!used_for_video_); |
| 128 used_for_audio_ = true; | 154 used_for_audio_ = true; |
| 129 #endif | 155 #endif |
| 130 | 156 |
| 131 *created_new_payload = false; | 157 *created_new_payload = false; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 const char* payload_name) const { | 422 const char* payload_name) const { |
| 397 rtc::CritScope cs(&crit_sect_); | 423 rtc::CritScope cs(&crit_sect_); |
| 398 for (const auto& it : payload_type_map_) { | 424 for (const auto& it : payload_type_map_) { |
| 399 if (_stricmp(it.second.name, payload_name) == 0) | 425 if (_stricmp(it.second.name, payload_name) == 0) |
| 400 return it.first; | 426 return it.first; |
| 401 } | 427 } |
| 402 return -1; | 428 return -1; |
| 403 } | 429 } |
| 404 | 430 |
| 405 } // namespace webrtc | 431 } // namespace webrtc |
| OLD | NEW |