Note: We no longer publish the latest version of our code here. We primarily use a kumc-bmi github organization. The heron ETL repository, in particular, is not public. Peers in the informatics community should see MultiSiteDev for details on requesting access.

source: webrtc/webrtc/modules/rtp_rtcp/source/rtp_header_extension.h @ 0:4bda6873e34c

pub_scrub_3792 tip
Last change on this file since 0:4bda6873e34c was 0:4bda6873e34c, checked in by Michael Prittie <mprittie@…>, 6 years ago

Scrubbed password for publication.

File size: 2.6 KB
Line 
1/*
2 *  Copyright (c) 2012 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#ifndef WEBRTC_MODULES_RTP_RTCP_RTP_HEADER_EXTENSION_H_
12#define WEBRTC_MODULES_RTP_RTCP_RTP_HEADER_EXTENSION_H_
13
14#include <map>
15
16#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
17#include "webrtc/typedefs.h"
18
19namespace webrtc {
20
21const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE;
22
23const size_t kRtpOneByteHeaderLength = 4;
24const size_t kTransmissionTimeOffsetLength = 4;
25const size_t kAudioLevelLength = 2;
26const size_t kAbsoluteSendTimeLength = 4;
27
28struct HeaderExtension {
29  HeaderExtension(RTPExtensionType extension_type)
30    : type(extension_type),
31      length(0) {
32    // TODO(solenberg): Create handler classes for header extensions so we can
33    // get rid of switches like these as well as handling code spread out all
34    // over.
35    switch (type) {
36      case kRtpExtensionTransmissionTimeOffset:
37        length = kTransmissionTimeOffsetLength;
38        break;
39      case kRtpExtensionAudioLevel:
40        // TODO(solenberg): Because of how the audio level extension is handled
41        // in RTPSenderAudio::SendAudio(), we cannot set the actual length here
42        // but must leave it at zero. The consequence is that any other header
43        // extensions registered for an audio channel are effectively ignored.
44        // length = kAudioLevelLength;
45        break;
46      case kRtpExtensionAbsoluteSendTime:
47        length = kAbsoluteSendTimeLength;
48        break;
49      default:
50        assert(false);
51    }
52  }
53
54   const RTPExtensionType type;
55   uint8_t length;
56};
57
58class RtpHeaderExtensionMap {
59 public:
60  RtpHeaderExtensionMap();
61  ~RtpHeaderExtensionMap();
62
63  void Erase();
64
65  int32_t Register(const RTPExtensionType type, const uint8_t id);
66
67  int32_t Deregister(const RTPExtensionType type);
68
69  int32_t GetType(const uint8_t id, RTPExtensionType* type) const;
70
71  int32_t GetId(const RTPExtensionType type, uint8_t* id) const;
72
73  uint16_t GetTotalLengthInBytes() const;
74
75  int32_t GetLengthUntilBlockStartInBytes(const RTPExtensionType type) const;
76
77  void GetCopy(RtpHeaderExtensionMap* map) const;
78
79  int32_t Size() const;
80
81  RTPExtensionType First() const;
82
83  RTPExtensionType Next(RTPExtensionType type) const;
84
85 private:
86  std::map<uint8_t, HeaderExtension*> extensionMap_;
87};
88}
89
90#endif // WEBRTC_MODULES_RTP_RTCP_RTP_HEADER_EXTENSION_H_
Note: See TracBrowser for help on using the repository browser.