Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef CALL_RTP_CONFIG_H_ |
| 12 | #define CALL_RTP_CONFIG_H_ |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 13 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 16 | |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 17 | #include <string> |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 18 | #include <vector> |
| 19 | |
Henrik Boström | f45ca37 | 2020-03-24 13:30:50 +0100 | [diff] [blame] | 20 | #include "absl/types/optional.h" |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 21 | #include "api/rtp_headers.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 22 | #include "api/rtp_parameters.h" |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 23 | |
| 24 | namespace webrtc { |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 25 | // Currently only VP8/VP9 specific. |
| 26 | struct RtpPayloadState { |
| 27 | int16_t picture_id = -1; |
| 28 | uint8_t tl0_pic_idx = 0; |
philipel | 25d31ec | 2018-08-08 16:33:01 +0200 | [diff] [blame] | 29 | int64_t shared_frame_id = 0; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 30 | }; |
Elad Alon | fadb181 | 2019-05-24 13:40:02 +0200 | [diff] [blame] | 31 | |
| 32 | // Settings for LNTF (LossNotification). Still highly experimental. |
| 33 | struct LntfConfig { |
| 34 | std::string ToString() const; |
| 35 | |
Elad Alon | a0e9943 | 2019-05-24 13:50:56 +0200 | [diff] [blame] | 36 | bool enabled{false}; |
Elad Alon | fadb181 | 2019-05-24 13:40:02 +0200 | [diff] [blame] | 37 | }; |
| 38 | |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 39 | // Settings for NACK, see RFC 4585 for details. |
| 40 | struct 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. |
| 52 | struct 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 Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 69 | |
| 70 | static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4. |
| 71 | struct RtpConfig { |
| 72 | RtpConfig(); |
| 73 | RtpConfig(const RtpConfig&); |
| 74 | ~RtpConfig(); |
| 75 | std::string ToString() const; |
| 76 | |
| 77 | std::vector<uint32_t> ssrcs; |
| 78 | |
Amit Hilbuch | 77938e6 | 2018-12-21 09:23:38 -0800 | [diff] [blame] | 79 | // 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 Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 87 | // 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 Kron | 9190b82 | 2018-10-29 11:22:05 +0100 | [diff] [blame] | 97 | // Corresponds to the SDP attribute extmap-allow-mixed. |
| 98 | bool extmap_allow_mixed = false; |
| 99 | |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 100 | // 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 Dvornicic | fe68daa | 2019-05-23 13:21:12 +0200 | [diff] [blame] | 112 | // 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 Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 116 | |
Elad Alon | fadb181 | 2019-05-24 13:40:02 +0200 | [diff] [blame] | 117 | // See LntfConfig for description. |
| 118 | LntfConfig lntf; |
| 119 | |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 120 | // 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öm | f45ca37 | 2020-03-24 13:30:50 +0100 | [diff] [blame] | 161 | |
| 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 Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 169 | }; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 170 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 171 | #endif // CALL_RTP_CONFIG_H_ |