OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions_manager.h" |
| 12 |
| 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/logging.h" |
| 15 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" |
| 16 |
| 17 namespace webrtc { |
| 18 |
| 19 RtpHeaderExtensionsManager::RtpHeaderExtensionsManager() { |
| 20 for (ExtensionType& extension : id_to_type_) { |
| 21 extension = kInvalidType; |
| 22 } |
| 23 } |
| 24 |
| 25 bool RtpHeaderExtensionsManager::RegisterByName(const std::string& name, |
| 26 MediaType type, |
| 27 uint8_t id) { |
| 28 return TryRegister<AbsoluteSendTime>(name, type, id) || |
| 29 TryRegister<AudioLevel>(name, type, id) || |
| 30 TryRegister<TransmissionOffset>(name, type, id) || |
| 31 TryRegister<TransportSequenceNumber>(name, type, id) || |
| 32 TryRegister<VideoOrientation>(name, type, id); |
| 33 } |
| 34 |
| 35 bool RtpHeaderExtensionsManager::Register(ExtensionType type, uint8_t id) { |
| 36 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 37 RTC_CHECK(kMinId <= id && id <= kMaxId); |
| 38 if (id_to_type_[id - 1] != kInvalidType) { |
| 39 LOG(LS_ERROR) << "Extension with id " << static_cast<int>(id) |
| 40 << " already registered"; |
| 41 return false; |
| 42 } |
| 43 id_to_type_[id - 1] = type; |
| 44 return true; |
| 45 } |
| 46 |
| 47 uint8_t RtpHeaderExtensionsManager::GetId(ExtensionType type) const { |
| 48 for (uint8_t i = kMinId; i <= kMaxId; ++i) { |
| 49 if (id_to_type_[i - 1] == type) { |
| 50 return i; |
| 51 } |
| 52 } |
| 53 return kInvalidId; |
| 54 } |
| 55 } // namespace webrtc |
OLD | NEW |