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 11 #ifndef CALL_RTP_CONFIG_H_ 12 #define CALL_RTP_CONFIG_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include <string> 18 #include <vector> 19 20 #include "absl/types/optional.h" 21 #include "api/rtp_headers.h" 22 #include "api/rtp_parameters.h" 23 24 namespace webrtc { 25 // Currently only VP8/VP9 specific. 26 struct RtpPayloadState { 27 int16_t picture_id = -1; 28 uint8_t tl0_pic_idx = 0; 29 int64_t shared_frame_id = 0; 30 }; 31 32 // Settings for LNTF (LossNotification). Still highly experimental. 33 struct LntfConfig { 34 std::string ToString() const; 35 36 bool enabled{false}; 37 }; 38 39 // Settings for NACK, see RFC 4585 for details. 40 struct NackConfig { NackConfigNackConfig41 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 { UlpfecConfigUlpfecConfig53 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 }; 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 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 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 97 // Corresponds to the SDP attribute extmap-allow-mixed. 98 bool extmap_allow_mixed = false; 99 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; 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; 116 117 // See LntfConfig for description. 118 LntfConfig lntf; 119 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; 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; 169 absl::optional<std::string> GetRidForSsrc(uint32_t ssrc) const; 170 }; 171 } // namespace webrtc 172 #endif // CALL_RTP_CONFIG_H_ 173