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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h

Issue 2871813003: Add write support for the RtpStreamId and RepairedRtpStreamId header extensions. (Closed)
Patch Set: Created 3 years, 7 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
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 #include <string> 14 #include <string>
15 15
16 #include "webrtc/api/video/video_content_type.h" 16 #include "webrtc/api/video/video_content_type.h"
17 #include "webrtc/api/video/video_rotation.h" 17 #include "webrtc/api/video/video_rotation.h"
18 #include "webrtc/base/array_view.h" 18 #include "webrtc/base/array_view.h"
19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
20 20
21 namespace webrtc { 21 namespace webrtc {
22 22
23 class AbsoluteSendTime { 23 class AbsoluteSendTime {
24 public: 24 public:
25 static constexpr RTPExtensionType kId = kRtpExtensionAbsoluteSendTime; 25 static constexpr RTPExtensionType kId = kRtpExtensionAbsoluteSendTime;
26 static constexpr uint8_t kValueSizeBytes = 3; 26 static constexpr uint8_t kValueSizeBytes = 3;
27 static constexpr const char* kUri = 27 static constexpr const char* kUri =
28 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; 28 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time";
29 29
30 static size_t ValueSize(int64_t time_ms) { return kValueSizeBytes; }
danilchap 2017/05/09 15:40:52 may be put this function just before Write functio
erikvarga1 2017/05/10 10:52:27 Done.
30 static bool Parse(rtc::ArrayView<const uint8_t> data, uint32_t* time_24bits); 31 static bool Parse(rtc::ArrayView<const uint8_t> data, uint32_t* time_24bits);
31 static bool Write(uint8_t* data, int64_t time_ms); 32 static bool Write(uint8_t* data, int64_t time_ms);
32 33
33 static constexpr uint32_t MsTo24Bits(int64_t time_ms) { 34 static constexpr uint32_t MsTo24Bits(int64_t time_ms) {
34 return static_cast<uint32_t>(((time_ms << 18) + 500) / 1000) & 0x00FFFFFF; 35 return static_cast<uint32_t>(((time_ms << 18) + 500) / 1000) & 0x00FFFFFF;
35 } 36 }
36 }; 37 };
37 38
38 class AudioLevel { 39 class AudioLevel {
39 public: 40 public:
40 static constexpr RTPExtensionType kId = kRtpExtensionAudioLevel; 41 static constexpr RTPExtensionType kId = kRtpExtensionAudioLevel;
41 static constexpr uint8_t kValueSizeBytes = 1; 42 static constexpr uint8_t kValueSizeBytes = 1;
42 static constexpr const char* kUri = 43 static constexpr const char* kUri =
43 "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; 44 "urn:ietf:params:rtp-hdrext:ssrc-audio-level";
44 45
46 static size_t ValueSize(bool voice_activity, uint8_t audio_level) {
47 return kValueSizeBytes;
48 }
45 static bool Parse(rtc::ArrayView<const uint8_t> data, 49 static bool Parse(rtc::ArrayView<const uint8_t> data,
46 bool* voice_activity, 50 bool* voice_activity,
47 uint8_t* audio_level); 51 uint8_t* audio_level);
48 static bool Write(uint8_t* data, bool voice_activity, uint8_t audio_level); 52 static bool Write(uint8_t* data, bool voice_activity, uint8_t audio_level);
49 }; 53 };
50 54
51 class TransmissionOffset { 55 class TransmissionOffset {
52 public: 56 public:
53 static constexpr RTPExtensionType kId = kRtpExtensionTransmissionTimeOffset; 57 static constexpr RTPExtensionType kId = kRtpExtensionTransmissionTimeOffset;
54 static constexpr uint8_t kValueSizeBytes = 3; 58 static constexpr uint8_t kValueSizeBytes = 3;
55 static constexpr const char* kUri = "urn:ietf:params:rtp-hdrext:toffset"; 59 static constexpr const char* kUri = "urn:ietf:params:rtp-hdrext:toffset";
56 60
61 static size_t ValueSize(int32_t rtp_time) { return kValueSizeBytes; }
57 static bool Parse(rtc::ArrayView<const uint8_t> data, int32_t* rtp_time); 62 static bool Parse(rtc::ArrayView<const uint8_t> data, int32_t* rtp_time);
58 static bool Write(uint8_t* data, int32_t rtp_time); 63 static bool Write(uint8_t* data, int32_t rtp_time);
59 }; 64 };
60 65
61 class TransportSequenceNumber { 66 class TransportSequenceNumber {
62 public: 67 public:
63 static constexpr RTPExtensionType kId = kRtpExtensionTransportSequenceNumber; 68 static constexpr RTPExtensionType kId = kRtpExtensionTransportSequenceNumber;
64 static constexpr uint8_t kValueSizeBytes = 2; 69 static constexpr uint8_t kValueSizeBytes = 2;
65 static constexpr const char* kUri = 70 static constexpr const char* kUri =
66 "http://www.ietf.org/id/" 71 "http://www.ietf.org/id/"
67 "draft-holmer-rmcat-transport-wide-cc-extensions-01"; 72 "draft-holmer-rmcat-transport-wide-cc-extensions-01";
73 static size_t ValueSize(uint16_t value) { return kValueSizeBytes; }
68 static bool Parse(rtc::ArrayView<const uint8_t> data, uint16_t* value); 74 static bool Parse(rtc::ArrayView<const uint8_t> data, uint16_t* value);
69 static bool Write(uint8_t* data, uint16_t value); 75 static bool Write(uint8_t* data, uint16_t value);
70 }; 76 };
71 77
72 class VideoOrientation { 78 class VideoOrientation {
73 public: 79 public:
74 static constexpr RTPExtensionType kId = kRtpExtensionVideoRotation; 80 static constexpr RTPExtensionType kId = kRtpExtensionVideoRotation;
75 static constexpr uint8_t kValueSizeBytes = 1; 81 static constexpr uint8_t kValueSizeBytes = 1;
76 static constexpr const char* kUri = "urn:3gpp:video-orientation"; 82 static constexpr const char* kUri = "urn:3gpp:video-orientation";
77 83
84 static size_t ValueSize(VideoRotation* value) { return kValueSizeBytes; }
danilchap 2017/05/09 15:40:51 remove *
erikvarga1 2017/05/10 10:52:27 Done.
78 static bool Parse(rtc::ArrayView<const uint8_t> data, VideoRotation* value); 85 static bool Parse(rtc::ArrayView<const uint8_t> data, VideoRotation* value);
79 static bool Write(uint8_t* data, VideoRotation value); 86 static bool Write(uint8_t* data, VideoRotation value);
87 static size_t ValueSize(uint8_t value) { return kValueSizeBytes; }
80 static bool Parse(rtc::ArrayView<const uint8_t> data, uint8_t* value); 88 static bool Parse(rtc::ArrayView<const uint8_t> data, uint8_t* value);
81 static bool Write(uint8_t* data, uint8_t value); 89 static bool Write(uint8_t* data, uint8_t value);
82 }; 90 };
83 91
84 class PlayoutDelayLimits { 92 class PlayoutDelayLimits {
85 public: 93 public:
86 static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay; 94 static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay;
87 static constexpr uint8_t kValueSizeBytes = 3; 95 static constexpr uint8_t kValueSizeBytes = 3;
88 static constexpr const char* kUri = 96 static constexpr const char* kUri =
89 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; 97 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay";
90 98
91 // Playout delay in milliseconds. A playout delay limit (min or max) 99 // Playout delay in milliseconds. A playout delay limit (min or max)
92 // has 12 bits allocated. This allows a range of 0-4095 values which 100 // has 12 bits allocated. This allows a range of 0-4095 values which
93 // translates to a range of 0-40950 in milliseconds. 101 // translates to a range of 0-40950 in milliseconds.
94 static constexpr int kGranularityMs = 10; 102 static constexpr int kGranularityMs = 10;
95 // Maximum playout delay value in milliseconds. 103 // Maximum playout delay value in milliseconds.
96 static constexpr int kMaxMs = 0xfff * kGranularityMs; // 40950. 104 static constexpr int kMaxMs = 0xfff * kGranularityMs; // 40950.
97 105
106 static size_t ValueSize(const PlayoutDelay& playout_delay) {
danilchap 2017/05/09 15:40:52 feel free to omit parameter name when it doesn't a
erikvarga1 2017/05/10 10:52:26 Done.
107 return kValueSizeBytes;
108 }
98 static bool Parse(rtc::ArrayView<const uint8_t> data, 109 static bool Parse(rtc::ArrayView<const uint8_t> data,
99 PlayoutDelay* playout_delay); 110 PlayoutDelay* playout_delay);
100 static bool Write(uint8_t* data, const PlayoutDelay& playout_delay); 111 static bool Write(uint8_t* data, const PlayoutDelay& playout_delay);
101 }; 112 };
102 113
103 class VideoContentTypeExtension { 114 class VideoContentTypeExtension {
104 public: 115 public:
105 static constexpr RTPExtensionType kId = kRtpExtensionVideoContentType; 116 static constexpr RTPExtensionType kId = kRtpExtensionVideoContentType;
106 static constexpr uint8_t kValueSizeBytes = 1; 117 static constexpr uint8_t kValueSizeBytes = 1;
107 static constexpr const char* kUri = 118 static constexpr const char* kUri =
108 "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"; 119 "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type";
109 120
121 static size_t ValueSize(VideoContentType content_type) {
122 return kValueSizeBytes;
123 }
110 static bool Parse(rtc::ArrayView<const uint8_t> data, 124 static bool Parse(rtc::ArrayView<const uint8_t> data,
111 VideoContentType* content_type); 125 VideoContentType* content_type);
112 static bool Write(uint8_t* data, VideoContentType content_type); 126 static bool Write(uint8_t* data, VideoContentType content_type);
113 }; 127 };
114 128
115 class RtpStreamId { 129 class RtpStreamId {
116 public: 130 public:
117 static constexpr RTPExtensionType kId = kRtpExtensionRtpStreamId; 131 static constexpr RTPExtensionType kId = kRtpExtensionRtpStreamId;
118 // TODO(danilchap): Implement write support of dynamic size extension that 132 // TODO(danilchap): Implement write support of dynamic size extension that
119 // allows to remove the ValueSize constant. 133 // allows to remove the ValueSize constant.
120 static constexpr uint8_t kValueSizeBytes = 1; 134 static constexpr uint8_t kValueSizeBytes = 1;
121 static constexpr const char* kUri = 135 static constexpr const char* kUri =
122 "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"; 136 "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id";
123 137
124 static bool Parse(rtc::ArrayView<const uint8_t> data, StreamId* rid); 138 static size_t ValueSize(const StreamId& rsid) { return rsid.size(); }
125 static bool Parse(rtc::ArrayView<const uint8_t> data, std::string* rid); 139 static bool Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid);
140 static bool Write(uint8_t* data, const StreamId& rsid);
141
142 static size_t ValueSize(const std::string& rsid) { return rsid.size(); }
143 static bool Parse(rtc::ArrayView<const uint8_t> data, std::string* rsid);
144 static bool Write(uint8_t* data, const std::string& rsid);
126 }; 145 };
127 146
128 class RepairedRtpStreamId { 147 class RepairedRtpStreamId {
129 public: 148 public:
130 static constexpr RTPExtensionType kId = kRtpExtensionRepairedRtpStreamId; 149 static constexpr RTPExtensionType kId = kRtpExtensionRepairedRtpStreamId;
131 // TODO(danilchap): Implement write support of dynamic size extension that 150 // TODO(danilchap): Implement write support of dynamic size extension that
132 // allows to remove the ValueSize constant. 151 // allows to remove the ValueSize constant.
133 static constexpr uint8_t kValueSizeBytes = 1; 152 static constexpr uint8_t kValueSizeBytes = 1;
134 static constexpr const char* kUri = 153 static constexpr const char* kUri =
135 "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"; 154 "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id";
136 155
137 static bool Parse(rtc::ArrayView<const uint8_t> data, StreamId* rid); 156 static size_t ValueSize(const StreamId& rsid) {
138 static bool Parse(rtc::ArrayView<const uint8_t> data, std::string* rid); 157 return RtpStreamId::ValueSize(rsid);
danilchap 2017/05/09 15:40:51 may be move implementation to .cc for consistency
erikvarga1 2017/05/10 10:52:27 Done. Should this also be done for the ValueSize f
danilchap 2017/05/10 11:25:17 it is not required - functions that short are ok t
erikvarga1 2017/05/10 14:48:19 Alright, in that case I think it should be OK like
158 }
159 static bool Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid);
160 static bool Write(uint8_t* data, const StreamId& rsid);
161
162 static size_t ValueSize(const std::string& rsid) {
163 return RtpStreamId::ValueSize(rsid);
164 }
165 static bool Parse(rtc::ArrayView<const uint8_t> data, std::string* rsid);
166 static bool Write(uint8_t* data, const std::string& rsid);
139 }; 167 };
140 168
141 } // namespace webrtc 169 } // namespace webrtc
142 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ 170 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698