Line data Source code
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 : #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_
11 : #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_
12 :
13 : #include <stdint.h>
14 :
15 : #include "webrtc/common_types.h"
16 : #include "webrtc/api/video/video_rotation.h"
17 : #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
18 :
19 : namespace webrtc {
20 :
21 : class AbsoluteSendTime {
22 : public:
23 : static constexpr RTPExtensionType kId = kRtpExtensionAbsoluteSendTime;
24 : static constexpr uint8_t kValueSizeBytes = 3;
25 : static constexpr const char* kUri =
26 : "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time";
27 :
28 : static bool Parse(const uint8_t* data, uint32_t* time_24bits);
29 : static bool Write(uint8_t* data, int64_t time_ms);
30 :
31 0 : static constexpr uint32_t MsTo24Bits(int64_t time_ms) {
32 0 : return static_cast<uint32_t>(((time_ms << 18) + 500) / 1000) & 0x00FFFFFF;
33 : }
34 : };
35 :
36 : class AudioLevel {
37 : public:
38 : static constexpr RTPExtensionType kId = kRtpExtensionAudioLevel;
39 : static constexpr uint8_t kValueSizeBytes = 1;
40 : static constexpr const char* kUri =
41 : "urn:ietf:params:rtp-hdrext:ssrc-audio-level";
42 :
43 : static bool Parse(const uint8_t* data,
44 : bool* voice_activity,
45 : uint8_t* audio_level);
46 : static bool Write(uint8_t* data, bool voice_activity, uint8_t audio_level);
47 : };
48 :
49 : class TransmissionOffset {
50 : public:
51 : static constexpr RTPExtensionType kId = kRtpExtensionTransmissionTimeOffset;
52 : static constexpr uint8_t kValueSizeBytes = 3;
53 : static constexpr const char* kUri = "urn:ietf:params:rtp-hdrext:toffset";
54 :
55 : static bool Parse(const uint8_t* data, int32_t* rtp_time);
56 : static bool Write(uint8_t* data, int32_t rtp_time);
57 : };
58 :
59 : class TransportSequenceNumber {
60 : public:
61 : static constexpr RTPExtensionType kId = kRtpExtensionTransportSequenceNumber;
62 : static constexpr uint8_t kValueSizeBytes = 2;
63 : static constexpr const char* kUri =
64 : "http://www.ietf.org/id/"
65 : "draft-holmer-rmcat-transport-wide-cc-extensions-01";
66 : static bool Parse(const uint8_t* data, uint16_t* value);
67 : static bool Write(uint8_t* data, uint16_t value);
68 : };
69 :
70 : class VideoOrientation {
71 : public:
72 : static constexpr RTPExtensionType kId = kRtpExtensionVideoRotation;
73 : static constexpr uint8_t kValueSizeBytes = 1;
74 : static constexpr const char* kUri = "urn:3gpp:video-orientation";
75 :
76 : static bool Parse(const uint8_t* data, VideoRotation* value);
77 : static bool Write(uint8_t* data, VideoRotation value);
78 : static bool Parse(const uint8_t* data, uint8_t* value);
79 : static bool Write(uint8_t* data, uint8_t value);
80 : };
81 :
82 : class PlayoutDelayLimits {
83 : public:
84 : static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay;
85 : static constexpr uint8_t kValueSizeBytes = 3;
86 : static constexpr const char* kUri =
87 : "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay";
88 :
89 : // Playout delay in milliseconds. A playout delay limit (min or max)
90 : // has 12 bits allocated. This allows a range of 0-4095 values which
91 : // translates to a range of 0-40950 in milliseconds.
92 : static constexpr int kGranularityMs = 10;
93 : // Maximum playout delay value in milliseconds.
94 : static constexpr int kMaxMs = 0xfff * kGranularityMs; // 40950.
95 :
96 : static bool Parse(const uint8_t* data, PlayoutDelay* playout_delay);
97 : static bool Write(uint8_t* data, const PlayoutDelay& playout_delay);
98 : };
99 :
100 : class StreamId {
101 : public:
102 : static constexpr RTPExtensionType kId = kRtpExtensionRtpStreamId;
103 : static constexpr uint8_t kValueSizeBytes = 1; // variable! we add the RID length to this
104 : static constexpr const char* kUri = "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id";
105 :
106 : static bool Parse(const uint8_t* data, char rid[kRIDSize+1]);
107 : static bool Write(uint8_t* data, const char *rid); // 1-16 bytes
108 : };
109 :
110 : } // namespace webrtc
111 : #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_
|