blob: d9caeb0e6bcecffe199c63b3e533281c29a125d6 [file] [log] [blame]
Stefan Holmer1acbd682017-09-01 15:29:28 +02001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef CALL_RTP_CONFIG_H_
12#define CALL_RTP_CONFIG_H_
Stefan Holmer1acbd682017-09-01 15:29:28 +020013
Yves Gerey988cc082018-10-23 12:03:01 +020014#include <stddef.h>
15#include <stdint.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020016
Stefan Holmer1acbd682017-09-01 15:29:28 +020017#include <string>
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020018#include <vector>
19
Henrik Boströmf45ca372020-03-24 13:30:50 +010020#include "absl/types/optional.h"
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020021#include "api/rtp_headers.h"
Steve Anton10542f22019-01-11 09:11:00 -080022#include "api/rtp_parameters.h"
Stefan Holmer1acbd682017-09-01 15:29:28 +020023
24namespace webrtc {
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020025// Currently only VP8/VP9 specific.
26struct RtpPayloadState {
27 int16_t picture_id = -1;
28 uint8_t tl0_pic_idx = 0;
philipel25d31ec2018-08-08 16:33:01 +020029 int64_t shared_frame_id = 0;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020030};
Elad Alonfadb1812019-05-24 13:40:02 +020031
32// Settings for LNTF (LossNotification). Still highly experimental.
33struct LntfConfig {
34 std::string ToString() const;
35
Elad Alona0e99432019-05-24 13:50:56 +020036 bool enabled{false};
Elad Alonfadb1812019-05-24 13:40:02 +020037};
38
Stefan Holmer1acbd682017-09-01 15:29:28 +020039// Settings for NACK, see RFC 4585 for details.
40struct NackConfig {
41 NackConfig() : rtp_history_ms(0) {}
42 std::string ToString() const;
43 // Send side: the time RTP packets are stored for retransmissions.
44 // Receive side: the time the receiver is prepared to wait for
45 // retransmissions.
46 // Set to '0' to disable.
47 int rtp_history_ms;
48};
49
50// Settings for ULPFEC forward error correction.
51// Set the payload types to '-1' to disable.
52struct UlpfecConfig {
53 UlpfecConfig()
54 : ulpfec_payload_type(-1),
55 red_payload_type(-1),
56 red_rtx_payload_type(-1) {}
57 std::string ToString() const;
58 bool operator==(const UlpfecConfig& other) const;
59
60 // Payload type used for ULPFEC packets.
61 int ulpfec_payload_type;
62
63 // Payload type used for RED packets.
64 int red_payload_type;
65
66 // RTX payload type for RED payload.
67 int red_rtx_payload_type;
68};
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020069
70static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4.
71struct RtpConfig {
72 RtpConfig();
73 RtpConfig(const RtpConfig&);
74 ~RtpConfig();
75 std::string ToString() const;
76
77 std::vector<uint32_t> ssrcs;
78
Amit Hilbuch77938e62018-12-21 09:23:38 -080079 // The Rtp Stream Ids (aka RIDs) to send in the RID RTP header extension
80 // if the extension is included in the list of extensions.
81 // If rids are specified, they should correspond to the |ssrcs| vector.
82 // This means that:
83 // 1. rids.size() == 0 || rids.size() == ssrcs.size().
84 // 2. If rids is not empty, then |rids[i]| should use |ssrcs[i]|.
85 std::vector<std::string> rids;
86
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020087 // The value to send in the MID RTP header extension if the extension is
88 // included in the list of extensions.
89 std::string mid;
90
91 // See RtcpMode for description.
92 RtcpMode rtcp_mode = RtcpMode::kCompound;
93
94 // Max RTP packet size delivered to send transport from VideoEngine.
95 size_t max_packet_size = kDefaultMaxPacketSize;
96
Johannes Kron9190b822018-10-29 11:22:05 +010097 // Corresponds to the SDP attribute extmap-allow-mixed.
98 bool extmap_allow_mixed = false;
99
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200100 // RTP header extensions to use for this send stream.
101 std::vector<RtpExtension> extensions;
102
103 // TODO(nisse): For now, these are fixed, but we'd like to support
104 // changing codec without recreating the VideoSendStream. Then these
105 // fields must be removed, and association between payload type and codec
106 // must move above the per-stream level. Ownership could be with
107 // RtpTransportControllerSend, with a reference from PayloadRouter, where
108 // the latter would be responsible for mapping the codec type of encoded
109 // images to the right payload type.
110 std::string payload_name;
111 int payload_type = -1;
Mirta Dvornicicfe68daa2019-05-23 13:21:12 +0200112 // Payload should be packetized using raw packetizer (payload header will
113 // not be added, additional meta data is expected to be present in generic
114 // frame descriptor RTP header extension).
115 bool raw_payload = false;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200116
Elad Alonfadb1812019-05-24 13:40:02 +0200117 // See LntfConfig for description.
118 LntfConfig lntf;
119
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200120 // See NackConfig for description.
121 NackConfig nack;
122
123 // See UlpfecConfig for description.
124 UlpfecConfig ulpfec;
125
126 struct Flexfec {
127 Flexfec();
128 Flexfec(const Flexfec&);
129 ~Flexfec();
130 // Payload type of FlexFEC. Set to -1 to disable sending FlexFEC.
131 int payload_type = -1;
132
133 // SSRC of FlexFEC stream.
134 uint32_t ssrc = 0;
135
136 // Vector containing a single element, corresponding to the SSRC of the
137 // media stream being protected by this FlexFEC stream.
138 // The vector MUST have size 1.
139 //
140 // TODO(brandtr): Update comment above when we support
141 // multistream protection.
142 std::vector<uint32_t> protected_media_ssrcs;
143 } flexfec;
144
145 // Settings for RTP retransmission payload format, see RFC 4588 for
146 // details.
147 struct Rtx {
148 Rtx();
149 Rtx(const Rtx&);
150 ~Rtx();
151 std::string ToString() const;
152 // SSRCs to use for the RTX streams.
153 std::vector<uint32_t> ssrcs;
154
155 // Payload type to use for the RTX stream.
156 int payload_type = -1;
157 } rtx;
158
159 // RTCP CNAME, see RFC 3550.
160 std::string c_name;
Henrik Boströmf45ca372020-03-24 13:30:50 +0100161
162 bool IsMediaSsrc(uint32_t ssrc) const;
163 bool IsRtxSsrc(uint32_t ssrc) const;
164 bool IsFlexfecSsrc(uint32_t ssrc) const;
165 absl::optional<uint32_t> GetRtxSsrcAssociatedWithMediaSsrc(
166 uint32_t media_ssrc) const;
167 uint32_t GetMediaSsrcAssociatedWithRtxSsrc(uint32_t rtx_ssrc) const;
168 uint32_t GetMediaSsrcAssociatedWithFlexfecSsrc(uint32_t flexfec_ssrc) const;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200169};
Stefan Holmer1acbd682017-09-01 15:29:28 +0200170} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200171#endif // CALL_RTP_CONFIG_H_