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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/rtp_header_extensions_manager.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_header_extensions_manager.cc b/webrtc/modules/rtp_rtcp/source/rtp_header_extensions_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..95b57cc57a00e8f49b1207b9d927aff89df6e0c5
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/source/rtp_header_extensions_manager.cc
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions_manager.h"
+
+#include "webrtc/base/checks.h"
+#include "webrtc/base/logging.h"
+#include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h"
+
+namespace webrtc {
+
+RtpHeaderExtensionsManager::RtpHeaderExtensionsManager() {
+ for (ExtensionType& extension : id_to_type_) {
+ extension = kInvalidType;
+ }
+}
+
+bool RtpHeaderExtensionsManager::RegisterByName(const std::string& name,
+ MediaType type,
+ uint8_t id) {
+ return TryRegister<AbsoluteSendTime>(name, type, id) ||
+ TryRegister<AudioLevel>(name, type, id) ||
+ TryRegister<TransmissionOffset>(name, type, id) ||
+ TryRegister<TransportSequenceNumber>(name, type, id) ||
+ TryRegister<VideoOrientation>(name, type, id);
+}
+
+bool RtpHeaderExtensionsManager::Register(ExtensionType type, uint8_t id) {
+ RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
+ RTC_CHECK(kMinId <= id && id <= kMaxId);
+ if (id_to_type_[id - 1] != kInvalidType) {
+ LOG(LS_ERROR) << "Extension with id " << static_cast<int>(id)
+ << " already registered";
+ return false;
+ }
+ id_to_type_[id - 1] = type;
+ return true;
+}
+
+uint8_t RtpHeaderExtensionsManager::GetId(ExtensionType type) const {
+ for (uint8_t i = kMinId; i <= kMaxId; ++i) {
+ if (id_to_type_[i - 1] == type) {
+ return i;
+ }
+ }
+ return kInvalidId;
+}
+} // namespace webrtc
« 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