danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 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 | |
pbos | c7c26a0 | 2017-01-02 08:42:32 -0800 | [diff] [blame] | 13 | #include <stdint.h> |
| 14 | |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame^] | 15 | #include "webrtc/api/video/video_content_type.h" |
nisse | af91689 | 2017-01-10 07:44:26 -0800 | [diff] [blame] | 16 | #include "webrtc/api/video/video_rotation.h" |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 17 | #include "webrtc/base/array_view.h" |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 18 | #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | class AbsoluteSendTime { |
| 23 | public: |
| 24 | static constexpr RTPExtensionType kId = kRtpExtensionAbsoluteSendTime; |
| 25 | static constexpr uint8_t kValueSizeBytes = 3; |
danilchap | 6ba58d6 | 2016-11-09 05:46:39 -0800 | [diff] [blame] | 26 | static constexpr const char* kUri = |
| 27 | "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; |
danilchap | e2a0177 | 2016-10-28 07:08:58 -0700 | [diff] [blame] | 28 | |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 29 | static bool Parse(rtc::ArrayView<const uint8_t> data, uint32_t* time_24bits); |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 30 | static bool Write(uint8_t* data, int64_t time_ms); |
danilchap | a897f26 | 2016-08-26 05:42:41 -0700 | [diff] [blame] | 31 | |
| 32 | static constexpr uint32_t MsTo24Bits(int64_t time_ms) { |
| 33 | return static_cast<uint32_t>(((time_ms << 18) + 500) / 1000) & 0x00FFFFFF; |
| 34 | } |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | class AudioLevel { |
| 38 | public: |
| 39 | static constexpr RTPExtensionType kId = kRtpExtensionAudioLevel; |
| 40 | static constexpr uint8_t kValueSizeBytes = 1; |
danilchap | 6ba58d6 | 2016-11-09 05:46:39 -0800 | [diff] [blame] | 41 | static constexpr const char* kUri = |
| 42 | "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; |
danilchap | e2a0177 | 2016-10-28 07:08:58 -0700 | [diff] [blame] | 43 | |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 44 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 45 | bool* voice_activity, |
| 46 | uint8_t* audio_level); |
| 47 | static bool Write(uint8_t* data, bool voice_activity, uint8_t audio_level); |
| 48 | }; |
| 49 | |
| 50 | class TransmissionOffset { |
| 51 | public: |
| 52 | static constexpr RTPExtensionType kId = kRtpExtensionTransmissionTimeOffset; |
| 53 | static constexpr uint8_t kValueSizeBytes = 3; |
danilchap | 6ba58d6 | 2016-11-09 05:46:39 -0800 | [diff] [blame] | 54 | static constexpr const char* kUri = "urn:ietf:params:rtp-hdrext:toffset"; |
danilchap | e2a0177 | 2016-10-28 07:08:58 -0700 | [diff] [blame] | 55 | |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 56 | static bool Parse(rtc::ArrayView<const uint8_t> data, int32_t* rtp_time); |
Danil Chapovalov | 31e4e80 | 2016-08-03 18:27:40 +0200 | [diff] [blame] | 57 | static bool Write(uint8_t* data, int32_t rtp_time); |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | class TransportSequenceNumber { |
| 61 | public: |
| 62 | static constexpr RTPExtensionType kId = kRtpExtensionTransportSequenceNumber; |
| 63 | static constexpr uint8_t kValueSizeBytes = 2; |
danilchap | 6ba58d6 | 2016-11-09 05:46:39 -0800 | [diff] [blame] | 64 | static constexpr const char* kUri = |
| 65 | "http://www.ietf.org/id/" |
| 66 | "draft-holmer-rmcat-transport-wide-cc-extensions-01"; |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 67 | static bool Parse(rtc::ArrayView<const uint8_t> data, uint16_t* value); |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 68 | static bool Write(uint8_t* data, uint16_t value); |
| 69 | }; |
| 70 | |
| 71 | class VideoOrientation { |
| 72 | public: |
| 73 | static constexpr RTPExtensionType kId = kRtpExtensionVideoRotation; |
| 74 | static constexpr uint8_t kValueSizeBytes = 1; |
danilchap | 6ba58d6 | 2016-11-09 05:46:39 -0800 | [diff] [blame] | 75 | static constexpr const char* kUri = "urn:3gpp:video-orientation"; |
danilchap | e2a0177 | 2016-10-28 07:08:58 -0700 | [diff] [blame] | 76 | |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 77 | static bool Parse(rtc::ArrayView<const uint8_t> data, VideoRotation* value); |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 78 | static bool Write(uint8_t* data, VideoRotation value); |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 79 | static bool Parse(rtc::ArrayView<const uint8_t> data, uint8_t* value); |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 80 | static bool Write(uint8_t* data, uint8_t value); |
| 81 | }; |
| 82 | |
Danil Chapovalov | 08b0351 | 2016-09-07 15:08:13 +0200 | [diff] [blame] | 83 | class PlayoutDelayLimits { |
| 84 | public: |
| 85 | static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay; |
| 86 | static constexpr uint8_t kValueSizeBytes = 3; |
danilchap | 6ba58d6 | 2016-11-09 05:46:39 -0800 | [diff] [blame] | 87 | static constexpr const char* kUri = |
| 88 | "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; |
danilchap | e2a0177 | 2016-10-28 07:08:58 -0700 | [diff] [blame] | 89 | |
Danil Chapovalov | 08b0351 | 2016-09-07 15:08:13 +0200 | [diff] [blame] | 90 | // Playout delay in milliseconds. A playout delay limit (min or max) |
| 91 | // has 12 bits allocated. This allows a range of 0-4095 values which |
| 92 | // translates to a range of 0-40950 in milliseconds. |
| 93 | static constexpr int kGranularityMs = 10; |
| 94 | // Maximum playout delay value in milliseconds. |
| 95 | static constexpr int kMaxMs = 0xfff * kGranularityMs; // 40950. |
| 96 | |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 97 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
| 98 | PlayoutDelay* playout_delay); |
Danil Chapovalov | 08b0351 | 2016-09-07 15:08:13 +0200 | [diff] [blame] | 99 | static bool Write(uint8_t* data, const PlayoutDelay& playout_delay); |
| 100 | }; |
| 101 | |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame^] | 102 | class VideoContentTypeExtension { |
| 103 | public: |
| 104 | static constexpr RTPExtensionType kId = kRtpExtensionVideoContentType; |
| 105 | static constexpr uint8_t kValueSizeBytes = 1; |
| 106 | static constexpr const char* kUri = |
| 107 | "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"; |
| 108 | |
| 109 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
| 110 | VideoContentType* content_type); |
| 111 | static bool Write(uint8_t* data, VideoContentType content_type); |
| 112 | }; |
| 113 | |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 114 | } // namespace webrtc |
| 115 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ |