OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ | 10 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ |
11 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ | 11 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ |
12 | 12 |
13 #include <stdint.h> | 13 #include <stdint.h> |
14 | 14 |
15 #include "webrtc/api/video/video_rotation.h" | 15 #include "webrtc/api/video/video_rotation.h" |
| 16 #include "webrtc/base/array_view.h" |
16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 | 20 |
20 class AbsoluteSendTime { | 21 class AbsoluteSendTime { |
21 public: | 22 public: |
22 static constexpr RTPExtensionType kId = kRtpExtensionAbsoluteSendTime; | 23 static constexpr RTPExtensionType kId = kRtpExtensionAbsoluteSendTime; |
23 static constexpr uint8_t kValueSizeBytes = 3; | 24 static constexpr uint8_t kValueSizeBytes = 3; |
24 static constexpr const char* kUri = | 25 static constexpr const char* kUri = |
25 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; | 26 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; |
26 | 27 |
27 static bool Parse(const uint8_t* data, uint32_t* time_24bits); | 28 static bool Parse(rtc::ArrayView<const uint8_t> data, uint32_t* time_24bits); |
28 static bool Write(uint8_t* data, int64_t time_ms); | 29 static bool Write(uint8_t* data, int64_t time_ms); |
29 | 30 |
30 static constexpr uint32_t MsTo24Bits(int64_t time_ms) { | 31 static constexpr uint32_t MsTo24Bits(int64_t time_ms) { |
31 return static_cast<uint32_t>(((time_ms << 18) + 500) / 1000) & 0x00FFFFFF; | 32 return static_cast<uint32_t>(((time_ms << 18) + 500) / 1000) & 0x00FFFFFF; |
32 } | 33 } |
33 }; | 34 }; |
34 | 35 |
35 class AudioLevel { | 36 class AudioLevel { |
36 public: | 37 public: |
37 static constexpr RTPExtensionType kId = kRtpExtensionAudioLevel; | 38 static constexpr RTPExtensionType kId = kRtpExtensionAudioLevel; |
38 static constexpr uint8_t kValueSizeBytes = 1; | 39 static constexpr uint8_t kValueSizeBytes = 1; |
39 static constexpr const char* kUri = | 40 static constexpr const char* kUri = |
40 "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; | 41 "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; |
41 | 42 |
42 static bool Parse(const uint8_t* data, | 43 static bool Parse(rtc::ArrayView<const uint8_t> data, |
43 bool* voice_activity, | 44 bool* voice_activity, |
44 uint8_t* audio_level); | 45 uint8_t* audio_level); |
45 static bool Write(uint8_t* data, bool voice_activity, uint8_t audio_level); | 46 static bool Write(uint8_t* data, bool voice_activity, uint8_t audio_level); |
46 }; | 47 }; |
47 | 48 |
48 class TransmissionOffset { | 49 class TransmissionOffset { |
49 public: | 50 public: |
50 static constexpr RTPExtensionType kId = kRtpExtensionTransmissionTimeOffset; | 51 static constexpr RTPExtensionType kId = kRtpExtensionTransmissionTimeOffset; |
51 static constexpr uint8_t kValueSizeBytes = 3; | 52 static constexpr uint8_t kValueSizeBytes = 3; |
52 static constexpr const char* kUri = "urn:ietf:params:rtp-hdrext:toffset"; | 53 static constexpr const char* kUri = "urn:ietf:params:rtp-hdrext:toffset"; |
53 | 54 |
54 static bool Parse(const uint8_t* data, int32_t* rtp_time); | 55 static bool Parse(rtc::ArrayView<const uint8_t> data, int32_t* rtp_time); |
55 static bool Write(uint8_t* data, int32_t rtp_time); | 56 static bool Write(uint8_t* data, int32_t rtp_time); |
56 }; | 57 }; |
57 | 58 |
58 class TransportSequenceNumber { | 59 class TransportSequenceNumber { |
59 public: | 60 public: |
60 static constexpr RTPExtensionType kId = kRtpExtensionTransportSequenceNumber; | 61 static constexpr RTPExtensionType kId = kRtpExtensionTransportSequenceNumber; |
61 static constexpr uint8_t kValueSizeBytes = 2; | 62 static constexpr uint8_t kValueSizeBytes = 2; |
62 static constexpr const char* kUri = | 63 static constexpr const char* kUri = |
63 "http://www.ietf.org/id/" | 64 "http://www.ietf.org/id/" |
64 "draft-holmer-rmcat-transport-wide-cc-extensions-01"; | 65 "draft-holmer-rmcat-transport-wide-cc-extensions-01"; |
65 static bool Parse(const uint8_t* data, uint16_t* value); | 66 static bool Parse(rtc::ArrayView<const uint8_t> data, uint16_t* value); |
66 static bool Write(uint8_t* data, uint16_t value); | 67 static bool Write(uint8_t* data, uint16_t value); |
67 }; | 68 }; |
68 | 69 |
69 class VideoOrientation { | 70 class VideoOrientation { |
70 public: | 71 public: |
71 static constexpr RTPExtensionType kId = kRtpExtensionVideoRotation; | 72 static constexpr RTPExtensionType kId = kRtpExtensionVideoRotation; |
72 static constexpr uint8_t kValueSizeBytes = 1; | 73 static constexpr uint8_t kValueSizeBytes = 1; |
73 static constexpr const char* kUri = "urn:3gpp:video-orientation"; | 74 static constexpr const char* kUri = "urn:3gpp:video-orientation"; |
74 | 75 |
75 static bool Parse(const uint8_t* data, VideoRotation* value); | 76 static bool Parse(rtc::ArrayView<const uint8_t> data, VideoRotation* value); |
76 static bool Write(uint8_t* data, VideoRotation value); | 77 static bool Write(uint8_t* data, VideoRotation value); |
77 static bool Parse(const uint8_t* data, uint8_t* value); | 78 static bool Parse(rtc::ArrayView<const uint8_t> data, uint8_t* value); |
78 static bool Write(uint8_t* data, uint8_t value); | 79 static bool Write(uint8_t* data, uint8_t value); |
79 }; | 80 }; |
80 | 81 |
81 class PlayoutDelayLimits { | 82 class PlayoutDelayLimits { |
82 public: | 83 public: |
83 static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay; | 84 static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay; |
84 static constexpr uint8_t kValueSizeBytes = 3; | 85 static constexpr uint8_t kValueSizeBytes = 3; |
85 static constexpr const char* kUri = | 86 static constexpr const char* kUri = |
86 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; | 87 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; |
87 | 88 |
88 // Playout delay in milliseconds. A playout delay limit (min or max) | 89 // Playout delay in milliseconds. A playout delay limit (min or max) |
89 // has 12 bits allocated. This allows a range of 0-4095 values which | 90 // has 12 bits allocated. This allows a range of 0-4095 values which |
90 // translates to a range of 0-40950 in milliseconds. | 91 // translates to a range of 0-40950 in milliseconds. |
91 static constexpr int kGranularityMs = 10; | 92 static constexpr int kGranularityMs = 10; |
92 // Maximum playout delay value in milliseconds. | 93 // Maximum playout delay value in milliseconds. |
93 static constexpr int kMaxMs = 0xfff * kGranularityMs; // 40950. | 94 static constexpr int kMaxMs = 0xfff * kGranularityMs; // 40950. |
94 | 95 |
95 static bool Parse(const uint8_t* data, PlayoutDelay* playout_delay); | 96 static bool Parse(rtc::ArrayView<const uint8_t> data, |
| 97 PlayoutDelay* playout_delay); |
96 static bool Write(uint8_t* data, const PlayoutDelay& playout_delay); | 98 static bool Write(uint8_t* data, const PlayoutDelay& playout_delay); |
97 }; | 99 }; |
98 | 100 |
99 } // namespace webrtc | 101 } // namespace webrtc |
100 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ | 102 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ |
OLD | NEW |