blob: ea6f9dbc9c140c24504ca3aaf98f40071e601216 [file] [log] [blame]
danilchap1edb7ab2016-04-20 05:25:10 -07001/*
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
pbosc7c26a02017-01-02 08:42:32 -080013#include <stdint.h>
14
nisseaf916892017-01-10 07:44:26 -080015#include "webrtc/api/video/video_rotation.h"
danilchap1edb7ab2016-04-20 05:25:10 -070016#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
17
18namespace webrtc {
19
20class AbsoluteSendTime {
21 public:
22 static constexpr RTPExtensionType kId = kRtpExtensionAbsoluteSendTime;
23 static constexpr uint8_t kValueSizeBytes = 3;
danilchap6ba58d62016-11-09 05:46:39 -080024 static constexpr const char* kUri =
25 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time";
danilchape2a01772016-10-28 07:08:58 -070026
danilchapa897f262016-08-26 05:42:41 -070027 static bool Parse(const uint8_t* data, uint32_t* time_24bits);
danilchap1edb7ab2016-04-20 05:25:10 -070028 static bool Write(uint8_t* data, int64_t time_ms);
danilchapa897f262016-08-26 05:42:41 -070029
30 static constexpr uint32_t MsTo24Bits(int64_t time_ms) {
31 return static_cast<uint32_t>(((time_ms << 18) + 500) / 1000) & 0x00FFFFFF;
32 }
danilchap1edb7ab2016-04-20 05:25:10 -070033};
34
35class AudioLevel {
36 public:
37 static constexpr RTPExtensionType kId = kRtpExtensionAudioLevel;
38 static constexpr uint8_t kValueSizeBytes = 1;
danilchap6ba58d62016-11-09 05:46:39 -080039 static constexpr const char* kUri =
40 "urn:ietf:params:rtp-hdrext:ssrc-audio-level";
danilchape2a01772016-10-28 07:08:58 -070041
danilchap1edb7ab2016-04-20 05:25:10 -070042 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
48class TransmissionOffset {
49 public:
50 static constexpr RTPExtensionType kId = kRtpExtensionTransmissionTimeOffset;
51 static constexpr uint8_t kValueSizeBytes = 3;
danilchap6ba58d62016-11-09 05:46:39 -080052 static constexpr const char* kUri = "urn:ietf:params:rtp-hdrext:toffset";
danilchape2a01772016-10-28 07:08:58 -070053
Danil Chapovalov31e4e802016-08-03 18:27:40 +020054 static bool Parse(const uint8_t* data, int32_t* rtp_time);
55 static bool Write(uint8_t* data, int32_t rtp_time);
danilchap1edb7ab2016-04-20 05:25:10 -070056};
57
58class TransportSequenceNumber {
59 public:
60 static constexpr RTPExtensionType kId = kRtpExtensionTransportSequenceNumber;
61 static constexpr uint8_t kValueSizeBytes = 2;
danilchap6ba58d62016-11-09 05:46:39 -080062 static constexpr const char* kUri =
63 "http://www.ietf.org/id/"
64 "draft-holmer-rmcat-transport-wide-cc-extensions-01";
danilchap1edb7ab2016-04-20 05:25:10 -070065 static bool Parse(const uint8_t* data, uint16_t* value);
66 static bool Write(uint8_t* data, uint16_t value);
67};
68
69class VideoOrientation {
70 public:
71 static constexpr RTPExtensionType kId = kRtpExtensionVideoRotation;
72 static constexpr uint8_t kValueSizeBytes = 1;
danilchap6ba58d62016-11-09 05:46:39 -080073 static constexpr const char* kUri = "urn:3gpp:video-orientation";
danilchape2a01772016-10-28 07:08:58 -070074
danilchap1edb7ab2016-04-20 05:25:10 -070075 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 Chapovalov08b03512016-09-07 15:08:13 +020081class PlayoutDelayLimits {
82 public:
83 static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay;
84 static constexpr uint8_t kValueSizeBytes = 3;
danilchap6ba58d62016-11-09 05:46:39 -080085 static constexpr const char* kUri =
86 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay";
danilchape2a01772016-10-28 07:08:58 -070087
Danil Chapovalov08b03512016-09-07 15:08:13 +020088 // 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
danilchap1edb7ab2016-04-20 05:25:10 -070099} // namespace webrtc
100#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_