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