blob: 44972ecb085e1c6e70cc7fda0a42024e7b3e8ff8 [file] [log] [blame]
Patrik Höglund3e113432017-12-15 14:40:10 +01001/*
2 * Copyright (c) 2017 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
11#ifndef API_RTP_HEADERS_H_
12#define API_RTP_HEADERS_H_
13
14#include <stddef.h>
Yves Gerey988cc082018-10-23 12:03:01 +020015#include <stdint.h>
Niels Möllerd57efc12019-03-22 14:02:11 +010016#include <string>
Patrik Höglund3e113432017-12-15 14:40:10 +010017
Johannes Kronad1d9f02018-11-09 11:12:36 +010018#include "absl/types/optional.h"
Patrik Höglund3e113432017-12-15 14:40:10 +010019#include "api/array_view.h"
Johannes Kron09d65882018-11-27 14:36:41 +010020#include "api/video/color_space.h"
Patrik Höglund3e113432017-12-15 14:40:10 +010021#include "api/video/video_content_type.h"
Johnny Leee0c8b232018-09-11 16:50:49 -040022#include "api/video/video_frame_marking.h"
Patrik Höglund3e113432017-12-15 14:40:10 +010023#include "api/video/video_rotation.h"
24#include "api/video/video_timing.h"
Yves Gerey665174f2018-06-19 15:03:05 +020025#include "common_types.h" // NOLINT(build/include)
Patrik Höglund3e113432017-12-15 14:40:10 +010026
27namespace webrtc {
28
Johannes Kron075f6872019-02-14 14:41:05 +010029struct FeedbackRequest {
30 // Determines whether the recv delta as specified in
31 // https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01
32 // should be included.
33 bool include_timestamps;
34 // Include feedback of received packets in the range [sequence_number -
Johannes Kron0da25a12019-03-06 09:34:13 +010035 // sequence_count + 1, sequence_number]. That is, no feedback will be sent if
36 // sequence_count is zero.
Johannes Kron075f6872019-02-14 14:41:05 +010037 int sequence_count;
38};
39
Patrik Höglund3e113432017-12-15 14:40:10 +010040struct RTPHeaderExtension {
41 RTPHeaderExtension();
42 RTPHeaderExtension(const RTPHeaderExtension& other);
43 RTPHeaderExtension& operator=(const RTPHeaderExtension& other);
44
45 bool hasTransmissionTimeOffset;
46 int32_t transmissionTimeOffset;
47 bool hasAbsoluteSendTime;
48 uint32_t absoluteSendTime;
49 bool hasTransportSequenceNumber;
50 uint16_t transportSequenceNumber;
Johannes Kron075f6872019-02-14 14:41:05 +010051 absl::optional<FeedbackRequest> feedback_request;
Patrik Höglund3e113432017-12-15 14:40:10 +010052
53 // Audio Level includes both level in dBov and voiced/unvoiced bit. See:
54 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/
55 bool hasAudioLevel;
56 bool voiceActivity;
57 uint8_t audioLevel;
58
59 // For Coordination of Video Orientation. See
60 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
61 // ts_126114v120700p.pdf
62 bool hasVideoRotation;
63 VideoRotation videoRotation;
64
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020065 // TODO(ilnik): Refactor this and one above to be absl::optional() and remove
Patrik Höglund3e113432017-12-15 14:40:10 +010066 // a corresponding bool flag.
67 bool hasVideoContentType;
68 VideoContentType videoContentType;
69
70 bool has_video_timing;
71 VideoSendTiming video_timing;
72
Johnny Leee0c8b232018-09-11 16:50:49 -040073 bool has_frame_marking;
74 FrameMarking frame_marking;
75
Patrik Höglund3e113432017-12-15 14:40:10 +010076 PlayoutDelay playout_delay = {-1, -1};
77
78 // For identification of a stream when ssrc is not signaled. See
79 // https://tools.ietf.org/html/draft-ietf-avtext-rid-09
80 // TODO(danilchap): Update url from draft to release version.
Niels Möllerd57efc12019-03-22 14:02:11 +010081 std::string stream_id;
82 std::string repaired_stream_id;
Patrik Höglund3e113432017-12-15 14:40:10 +010083
84 // For identifying the media section used to interpret this RTP packet. See
85 // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-38
Niels Möllerd57efc12019-03-22 14:02:11 +010086 std::string mid;
Johannes Kronad1d9f02018-11-09 11:12:36 +010087
Johannes Kron09d65882018-11-27 14:36:41 +010088 absl::optional<ColorSpace> color_space;
Patrik Höglund3e113432017-12-15 14:40:10 +010089};
90
Niels Möller418f5802019-05-08 14:24:15 +020091enum { kRtpCsrcSize = 15 }; // RFC 3550 page 13
92
Patrik Höglund3e113432017-12-15 14:40:10 +010093struct RTPHeader {
94 RTPHeader();
95 RTPHeader(const RTPHeader& other);
96 RTPHeader& operator=(const RTPHeader& other);
97
98 bool markerBit;
99 uint8_t payloadType;
100 uint16_t sequenceNumber;
101 uint32_t timestamp;
102 uint32_t ssrc;
103 uint8_t numCSRCs;
104 uint32_t arrOfCSRCs[kRtpCsrcSize];
105 size_t paddingLength;
106 size_t headerLength;
107 int payload_type_frequency;
108 RTPHeaderExtension extension;
109};
110
111// RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size
112// RTCP mode is described by RFC 5506.
113enum class RtcpMode { kOff, kCompound, kReducedSize };
114
115enum NetworkState {
116 kNetworkUp,
117 kNetworkDown,
118};
119
Patrik Höglund3e113432017-12-15 14:40:10 +0100120} // namespace webrtc
121
122#endif // API_RTP_HEADERS_H_