blob: ec76d42c01ae7de5996d6a384a9a266a6387bd76 [file] [log] [blame]
Stefan Holmer1acbd682017-09-01 13:29:281/*
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 04:47:3111#ifndef CALL_RTP_CONFIG_H_
12#define CALL_RTP_CONFIG_H_
Stefan Holmer1acbd682017-09-01 13:29:2813
Yves Gerey988cc082018-10-23 10:03:0114#include <stddef.h>
15#include <stdint.h>
Jonas Olssona4d87372019-07-05 17:08:3316
Stefan Holmer1acbd682017-09-01 13:29:2817#include <string>
Stefan Holmerdbdb3a02018-07-17 14:03:4618#include <vector>
19
Henrik Boströmf45ca372020-03-24 12:30:5020#include "absl/types/optional.h"
Stefan Holmerdbdb3a02018-07-17 14:03:4621#include "api/rtp_headers.h"
Steve Anton10542f22019-01-11 17:11:0022#include "api/rtp_parameters.h"
Stefan Holmer1acbd682017-09-01 13:29:2823
24namespace webrtc {
Stefan Holmerdbdb3a02018-07-17 14:03:4625// Currently only VP8/VP9 specific.
26struct RtpPayloadState {
27 int16_t picture_id = -1;
28 uint8_t tl0_pic_idx = 0;
philipel25d31ec2018-08-08 14:33:0129 int64_t shared_frame_id = 0;
philipel626edea2024-03-19 08:38:0130 int64_t frame_id = 0;
Stefan Holmerdbdb3a02018-07-17 14:03:4631};
Elad Alonfadb1812019-05-24 11:40:0232
33// Settings for LNTF (LossNotification). Still highly experimental.
34struct LntfConfig {
35 std::string ToString() const;
36
Elad Alona0e99432019-05-24 11:50:5637 bool enabled{false};
Elad Alonfadb1812019-05-24 11:40:0238};
39
Stefan Holmer1acbd682017-09-01 13:29:2840// Settings for NACK, see RFC 4585 for details.
41struct NackConfig {
42 NackConfig() : rtp_history_ms(0) {}
43 std::string ToString() const;
44 // Send side: the time RTP packets are stored for retransmissions.
45 // Receive side: the time the receiver is prepared to wait for
46 // retransmissions.
47 // Set to '0' to disable.
48 int rtp_history_ms;
49};
50
51// Settings for ULPFEC forward error correction.
52// Set the payload types to '-1' to disable.
53struct UlpfecConfig {
54 UlpfecConfig()
55 : ulpfec_payload_type(-1),
56 red_payload_type(-1),
57 red_rtx_payload_type(-1) {}
58 std::string ToString() const;
59 bool operator==(const UlpfecConfig& other) const;
60
61 // Payload type used for ULPFEC packets.
62 int ulpfec_payload_type;
63
64 // Payload type used for RED packets.
65 int red_payload_type;
66
67 // RTX payload type for RED payload.
68 int red_rtx_payload_type;
69};
Stefan Holmerdbdb3a02018-07-17 14:03:4670
71static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4.
72struct RtpConfig {
73 RtpConfig();
74 RtpConfig(const RtpConfig&);
75 ~RtpConfig();
76 std::string ToString() const;
77
78 std::vector<uint32_t> ssrcs;
79
Amit Hilbuch77938e62018-12-21 17:23:3880 // The Rtp Stream Ids (aka RIDs) to send in the RID RTP header extension
81 // if the extension is included in the list of extensions.
Artem Titovea240272021-07-26 10:40:2182 // If rids are specified, they should correspond to the `ssrcs` vector.
Amit Hilbuch77938e62018-12-21 17:23:3883 // This means that:
84 // 1. rids.size() == 0 || rids.size() == ssrcs.size().
Artem Titovcfea2182021-08-09 23:22:3185 // 2. If rids is not empty, then `rids[i]` should use `ssrcs[i]`.
Amit Hilbuch77938e62018-12-21 17:23:3886 std::vector<std::string> rids;
87
Stefan Holmerdbdb3a02018-07-17 14:03:4688 // The value to send in the MID RTP header extension if the extension is
89 // included in the list of extensions.
90 std::string mid;
91
92 // See RtcpMode for description.
93 RtcpMode rtcp_mode = RtcpMode::kCompound;
94
95 // Max RTP packet size delivered to send transport from VideoEngine.
96 size_t max_packet_size = kDefaultMaxPacketSize;
97
Johannes Kron9190b822018-10-29 10:22:0598 // Corresponds to the SDP attribute extmap-allow-mixed.
99 bool extmap_allow_mixed = false;
100
Stefan Holmerdbdb3a02018-07-17 14:03:46101 // RTP header extensions to use for this send stream.
102 std::vector<RtpExtension> extensions;
103
104 // TODO(nisse): For now, these are fixed, but we'd like to support
105 // changing codec without recreating the VideoSendStream. Then these
106 // fields must be removed, and association between payload type and codec
107 // must move above the per-stream level. Ownership could be with
Niels Möller6939f632022-07-05 06:55:19108 // RtpTransportControllerSend, with a reference from RtpVideoSender, where
Stefan Holmerdbdb3a02018-07-17 14:03:46109 // the latter would be responsible for mapping the codec type of encoded
110 // images to the right payload type.
111 std::string payload_name;
112 int payload_type = -1;
Mirta Dvornicicfe68daa2019-05-23 11:21:12113 // Payload should be packetized using raw packetizer (payload header will
114 // not be added, additional meta data is expected to be present in generic
115 // frame descriptor RTP header extension).
116 bool raw_payload = false;
Stefan Holmerdbdb3a02018-07-17 14:03:46117
Elad Alonfadb1812019-05-24 11:40:02118 // See LntfConfig for description.
119 LntfConfig lntf;
120
Stefan Holmerdbdb3a02018-07-17 14:03:46121 // See NackConfig for description.
122 NackConfig nack;
123
124 // See UlpfecConfig for description.
125 UlpfecConfig ulpfec;
126
127 struct Flexfec {
128 Flexfec();
129 Flexfec(const Flexfec&);
130 ~Flexfec();
131 // Payload type of FlexFEC. Set to -1 to disable sending FlexFEC.
132 int payload_type = -1;
133
134 // SSRC of FlexFEC stream.
135 uint32_t ssrc = 0;
136
137 // Vector containing a single element, corresponding to the SSRC of the
138 // media stream being protected by this FlexFEC stream.
139 // The vector MUST have size 1.
140 //
141 // TODO(brandtr): Update comment above when we support
142 // multistream protection.
143 std::vector<uint32_t> protected_media_ssrcs;
144 } flexfec;
145
146 // Settings for RTP retransmission payload format, see RFC 4588 for
147 // details.
148 struct Rtx {
149 Rtx();
150 Rtx(const Rtx&);
151 ~Rtx();
152 std::string ToString() const;
153 // SSRCs to use for the RTX streams.
154 std::vector<uint32_t> ssrcs;
155
156 // Payload type to use for the RTX stream.
157 int payload_type = -1;
158 } rtx;
159
160 // RTCP CNAME, see RFC 3550.
161 std::string c_name;
Henrik Boströmf45ca372020-03-24 12:30:50162
Markus Handellc8c4a282023-05-08 14:46:21163 // Enables send packet batching from the egress RTP sender.
164 bool enable_send_packet_batching = false;
165
Henrik Boströmf45ca372020-03-24 12:30:50166 bool IsMediaSsrc(uint32_t ssrc) const;
167 bool IsRtxSsrc(uint32_t ssrc) const;
168 bool IsFlexfecSsrc(uint32_t ssrc) const;
169 absl::optional<uint32_t> GetRtxSsrcAssociatedWithMediaSsrc(
170 uint32_t media_ssrc) const;
171 uint32_t GetMediaSsrcAssociatedWithRtxSsrc(uint32_t rtx_ssrc) const;
172 uint32_t GetMediaSsrcAssociatedWithFlexfecSsrc(uint32_t flexfec_ssrc) const;
Henrik Boströma0ff50c2020-05-05 13:54:46173 absl::optional<std::string> GetRidForSsrc(uint32_t ssrc) const;
Stefan Holmerdbdb3a02018-07-17 14:03:46174};
Stefan Holmer1acbd682017-09-01 13:29:28175} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 04:47:31176#endif // CALL_RTP_CONFIG_H_