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

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

Issue 1739273002: [Draft] RtpPacket sketched. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase to use landed version of rtp::Packet Created 4 years, 8 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
(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
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_header_extensions_manager.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_packet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698