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> |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 16 | #include <string> |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
| 19 | #include "api/rtp_headers.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 20 | #include "api/rtp_parameters.h" |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 23 | // Currently only VP8/VP9 specific. |
| 24 | struct RtpPayloadState { |
| 25 | int16_t picture_id = -1; |
| 26 | uint8_t tl0_pic_idx = 0; |
philipel | 25d31ec | 2018-08-08 16:33:01 +0200 | [diff] [blame] | 27 | int64_t shared_frame_id = 0; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 28 | }; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 29 | // Settings for NACK, see RFC 4585 for details. |
| 30 | struct NackConfig { |
| 31 | NackConfig() : rtp_history_ms(0) {} |
| 32 | std::string ToString() const; |
| 33 | // Send side: the time RTP packets are stored for retransmissions. |
| 34 | // Receive side: the time the receiver is prepared to wait for |
| 35 | // retransmissions. |
| 36 | // Set to '0' to disable. |
| 37 | int rtp_history_ms; |
| 38 | }; |
| 39 | |
| 40 | // Settings for ULPFEC forward error correction. |
| 41 | // Set the payload types to '-1' to disable. |
| 42 | struct UlpfecConfig { |
| 43 | UlpfecConfig() |
| 44 | : ulpfec_payload_type(-1), |
| 45 | red_payload_type(-1), |
| 46 | red_rtx_payload_type(-1) {} |
| 47 | std::string ToString() const; |
| 48 | bool operator==(const UlpfecConfig& other) const; |
| 49 | |
| 50 | // Payload type used for ULPFEC packets. |
| 51 | int ulpfec_payload_type; |
| 52 | |
| 53 | // Payload type used for RED packets. |
| 54 | int red_payload_type; |
| 55 | |
| 56 | // RTX payload type for RED payload. |
| 57 | int red_rtx_payload_type; |
| 58 | }; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 59 | |
| 60 | static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4. |
| 61 | struct RtpConfig { |
| 62 | RtpConfig(); |
| 63 | RtpConfig(const RtpConfig&); |
| 64 | ~RtpConfig(); |
| 65 | std::string ToString() const; |
| 66 | |
| 67 | std::vector<uint32_t> ssrcs; |
| 68 | |
Amit Hilbuch | 77938e6 | 2018-12-21 09:23:38 -0800 | [diff] [blame] | 69 | // The Rtp Stream Ids (aka RIDs) to send in the RID RTP header extension |
| 70 | // if the extension is included in the list of extensions. |
| 71 | // If rids are specified, they should correspond to the |ssrcs| vector. |
| 72 | // This means that: |
| 73 | // 1. rids.size() == 0 || rids.size() == ssrcs.size(). |
| 74 | // 2. If rids is not empty, then |rids[i]| should use |ssrcs[i]|. |
| 75 | std::vector<std::string> rids; |
| 76 | |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 77 | // The value to send in the MID RTP header extension if the extension is |
| 78 | // included in the list of extensions. |
| 79 | std::string mid; |
| 80 | |
| 81 | // See RtcpMode for description. |
| 82 | RtcpMode rtcp_mode = RtcpMode::kCompound; |
| 83 | |
| 84 | // Max RTP packet size delivered to send transport from VideoEngine. |
| 85 | size_t max_packet_size = kDefaultMaxPacketSize; |
| 86 | |
Johannes Kron | 9190b82 | 2018-10-29 11:22:05 +0100 | [diff] [blame] | 87 | // Corresponds to the SDP attribute extmap-allow-mixed. |
| 88 | bool extmap_allow_mixed = false; |
| 89 | |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 90 | // RTP header extensions to use for this send stream. |
| 91 | std::vector<RtpExtension> extensions; |
| 92 | |
| 93 | // TODO(nisse): For now, these are fixed, but we'd like to support |
| 94 | // changing codec without recreating the VideoSendStream. Then these |
| 95 | // fields must be removed, and association between payload type and codec |
| 96 | // must move above the per-stream level. Ownership could be with |
| 97 | // RtpTransportControllerSend, with a reference from PayloadRouter, where |
| 98 | // the latter would be responsible for mapping the codec type of encoded |
| 99 | // images to the right payload type. |
| 100 | std::string payload_name; |
| 101 | int payload_type = -1; |
Mirta Dvornicic | fe68daa | 2019-05-23 13:21:12 +0200 | [diff] [blame] | 102 | // Payload should be packetized using raw packetizer (payload header will |
| 103 | // not be added, additional meta data is expected to be present in generic |
| 104 | // frame descriptor RTP header extension). |
| 105 | bool raw_payload = false; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 106 | |
| 107 | // See NackConfig for description. |
| 108 | NackConfig nack; |
| 109 | |
| 110 | // See UlpfecConfig for description. |
| 111 | UlpfecConfig ulpfec; |
| 112 | |
| 113 | struct Flexfec { |
| 114 | Flexfec(); |
| 115 | Flexfec(const Flexfec&); |
| 116 | ~Flexfec(); |
| 117 | // Payload type of FlexFEC. Set to -1 to disable sending FlexFEC. |
| 118 | int payload_type = -1; |
| 119 | |
| 120 | // SSRC of FlexFEC stream. |
| 121 | uint32_t ssrc = 0; |
| 122 | |
| 123 | // Vector containing a single element, corresponding to the SSRC of the |
| 124 | // media stream being protected by this FlexFEC stream. |
| 125 | // The vector MUST have size 1. |
| 126 | // |
| 127 | // TODO(brandtr): Update comment above when we support |
| 128 | // multistream protection. |
| 129 | std::vector<uint32_t> protected_media_ssrcs; |
| 130 | } flexfec; |
| 131 | |
| 132 | // Settings for RTP retransmission payload format, see RFC 4588 for |
| 133 | // details. |
| 134 | struct Rtx { |
| 135 | Rtx(); |
| 136 | Rtx(const Rtx&); |
| 137 | ~Rtx(); |
| 138 | std::string ToString() const; |
| 139 | // SSRCs to use for the RTX streams. |
| 140 | std::vector<uint32_t> ssrcs; |
| 141 | |
| 142 | // Payload type to use for the RTX stream. |
| 143 | int payload_type = -1; |
| 144 | } rtx; |
| 145 | |
| 146 | // RTCP CNAME, see RFC 3550. |
| 147 | std::string c_name; |
| 148 | }; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 149 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 150 | #endif // CALL_RTP_CONFIG_H_ |