deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_ |
| 12 | #define WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_ |
| 13 | |
| 14 | #include <string> |
| 15 | |
kwiberg | 84f6a3f | 2017-09-05 08:43:13 -0700 | [diff] [blame^] | 16 | #include "webrtc/api/optional.h" |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 17 | #include "webrtc/api/ortc/packettransportinterface.h" |
| 18 | #include "webrtc/api/rtcerror.h" |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 19 | #include "webrtc/common_types.h" |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | class RtpTransportAdapter; |
| 24 | |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 25 | struct RtcpParameters final { |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 26 | // The SSRC to be used in the "SSRC of packet sender" field. If not set, one |
| 27 | // will be chosen by the implementation. |
| 28 | // TODO(deadbeef): Not implemented. |
| 29 | rtc::Optional<uint32_t> ssrc; |
| 30 | |
| 31 | // The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages). |
| 32 | // |
| 33 | // If empty in the construction of the RtpTransport, one will be generated by |
| 34 | // the implementation, and returned in GetRtcpParameters. Multiple |
| 35 | // RtpTransports created by the same OrtcFactory will use the same generated |
| 36 | // CNAME. |
| 37 | // |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 38 | // If empty when passed into SetParameters, the CNAME simply won't be |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 39 | // modified. |
| 40 | std::string cname; |
| 41 | |
| 42 | // Send reduced-size RTCP? |
| 43 | bool reduced_size = false; |
| 44 | |
| 45 | // Send RTCP multiplexed on the RTP transport? |
| 46 | bool mux = true; |
| 47 | |
| 48 | bool operator==(const RtcpParameters& o) const { |
| 49 | return ssrc == o.ssrc && cname == o.cname && |
| 50 | reduced_size == o.reduced_size && mux == o.mux; |
| 51 | } |
| 52 | bool operator!=(const RtcpParameters& o) const { return !(*this == o); } |
| 53 | }; |
| 54 | |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 55 | struct RtpTransportParameters final { |
| 56 | RtcpParameters rtcp; |
| 57 | |
| 58 | // Enabled periodic sending of keep-alive packets, that help prevent timeouts |
| 59 | // on the network level, such as NAT bindings. See RFC6263 section 4.6. |
| 60 | RtpKeepAliveConfig keepalive; |
| 61 | |
| 62 | bool operator==(const RtpTransportParameters& o) const { |
| 63 | return rtcp == o.rtcp && keepalive == o.keepalive; |
| 64 | } |
| 65 | bool operator!=(const RtpTransportParameters& o) const { |
| 66 | return !(*this == o); |
| 67 | } |
| 68 | }; |
| 69 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 70 | // Base class for different types of RTP transports that can be created by an |
| 71 | // OrtcFactory. Used by RtpSenders/RtpReceivers. |
| 72 | // |
| 73 | // This is not present in the standard ORTC API, but exists here for a few |
| 74 | // reasons. Firstly, it allows different types of RTP transports to be used: |
| 75 | // DTLS-SRTP (which is required for the web), but also SDES-SRTP and |
| 76 | // unencrypted RTP. It also simplifies the handling of RTCP muxing, and |
| 77 | // provides a better API point for it. |
| 78 | // |
| 79 | // Note that Edge's implementation of ORTC provides a similar API point, called |
| 80 | // RTCSrtpSdesTransport: |
| 81 | // https://msdn.microsoft.com/en-us/library/mt502527(v=vs.85).aspx |
| 82 | class RtpTransportInterface { |
| 83 | public: |
| 84 | virtual ~RtpTransportInterface() {} |
| 85 | |
| 86 | // Returns packet transport that's used to send RTP packets. |
| 87 | virtual PacketTransportInterface* GetRtpPacketTransport() const = 0; |
| 88 | |
| 89 | // Returns separate packet transport that's used to send RTCP packets. If |
| 90 | // RTCP multiplexing is being used, returns null. |
| 91 | virtual PacketTransportInterface* GetRtcpPacketTransport() const = 0; |
| 92 | |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 93 | // Set/get RTP/RTCP transport params. Can be used to enable RTCP muxing or |
| 94 | // reduced-size RTCP if initially not enabled. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 95 | // |
| 96 | // Changing |mux| from "true" to "false" is not allowed, and changing the |
| 97 | // CNAME is currently unsupported. |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 98 | // RTP keep-alive settings need to be set before before an RtpSender has |
| 99 | // started sending, altering the payload type or timeout interval after this |
| 100 | // point is not supported. The parameters must also match across all RTP |
| 101 | // transports for a given RTP transport controller. |
| 102 | virtual RTCError SetParameters(const RtpTransportParameters& parameters) = 0; |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 103 | // Returns last set or constructed-with parameters. If |cname| was empty in |
| 104 | // construction, the generated CNAME will be present in the returned |
| 105 | // parameters (see above). |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 106 | virtual RtpTransportParameters GetParameters() const = 0; |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 107 | |
| 108 | protected: |
| 109 | // Only for internal use. Returns a pointer to an internal interface, for use |
| 110 | // by the implementation. |
| 111 | virtual RtpTransportAdapter* GetInternal() = 0; |
| 112 | |
| 113 | // Classes that can use this internal interface. |
| 114 | friend class OrtcFactory; |
| 115 | friend class OrtcRtpSenderAdapter; |
| 116 | friend class OrtcRtpReceiverAdapter; |
| 117 | friend class RtpTransportControllerAdapter; |
| 118 | friend class RtpTransportAdapter; |
| 119 | }; |
| 120 | |
| 121 | } // namespace webrtc |
| 122 | |
| 123 | #endif // WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_ |