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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 11 | #ifndef API_ORTC_RTP_TRANSPORT_INTERFACE_H_ |
| 12 | #define API_ORTC_RTP_TRANSPORT_INTERFACE_H_ |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 13 | |
| 14 | #include <string> |
| 15 | |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 16 | #include "absl/types/optional.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 17 | #include "api/ortc/packet_transport_interface.h" |
| 18 | #include "api/rtc_error.h" |
Patrik Höglund | 3e11343 | 2017-12-15 14:40:10 +0100 | [diff] [blame] | 19 | #include "api/rtp_headers.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 20 | #include "api/rtp_parameters.h" |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | class RtpTransportAdapter; |
| 25 | |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 26 | struct RtpTransportParameters final { |
| 27 | RtcpParameters rtcp; |
| 28 | |
| 29 | // Enabled periodic sending of keep-alive packets, that help prevent timeouts |
| 30 | // on the network level, such as NAT bindings. See RFC6263 section 4.6. |
| 31 | RtpKeepAliveConfig keepalive; |
| 32 | |
| 33 | bool operator==(const RtpTransportParameters& o) const { |
| 34 | return rtcp == o.rtcp && keepalive == o.keepalive; |
| 35 | } |
| 36 | bool operator!=(const RtpTransportParameters& o) const { |
| 37 | return !(*this == o); |
| 38 | } |
| 39 | }; |
| 40 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 41 | // Base class for different types of RTP transports that can be created by an |
| 42 | // OrtcFactory. Used by RtpSenders/RtpReceivers. |
| 43 | // |
| 44 | // This is not present in the standard ORTC API, but exists here for a few |
| 45 | // reasons. Firstly, it allows different types of RTP transports to be used: |
| 46 | // DTLS-SRTP (which is required for the web), but also SDES-SRTP and |
| 47 | // unencrypted RTP. It also simplifies the handling of RTCP muxing, and |
| 48 | // provides a better API point for it. |
| 49 | // |
| 50 | // Note that Edge's implementation of ORTC provides a similar API point, called |
| 51 | // RTCSrtpSdesTransport: |
| 52 | // https://msdn.microsoft.com/en-us/library/mt502527(v=vs.85).aspx |
| 53 | class RtpTransportInterface { |
| 54 | public: |
| 55 | virtual ~RtpTransportInterface() {} |
| 56 | |
| 57 | // Returns packet transport that's used to send RTP packets. |
| 58 | virtual PacketTransportInterface* GetRtpPacketTransport() const = 0; |
| 59 | |
| 60 | // Returns separate packet transport that's used to send RTCP packets. If |
| 61 | // RTCP multiplexing is being used, returns null. |
| 62 | virtual PacketTransportInterface* GetRtcpPacketTransport() const = 0; |
| 63 | |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 64 | // Set/get RTP/RTCP transport params. Can be used to enable RTCP muxing or |
| 65 | // reduced-size RTCP if initially not enabled. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 66 | // |
| 67 | // Changing |mux| from "true" to "false" is not allowed, and changing the |
| 68 | // CNAME is currently unsupported. |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 69 | // RTP keep-alive settings need to be set before before an RtpSender has |
| 70 | // started sending, altering the payload type or timeout interval after this |
| 71 | // point is not supported. The parameters must also match across all RTP |
| 72 | // transports for a given RTP transport controller. |
| 73 | virtual RTCError SetParameters(const RtpTransportParameters& parameters) = 0; |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 74 | // Returns last set or constructed-with parameters. If |cname| was empty in |
| 75 | // construction, the generated CNAME will be present in the returned |
| 76 | // parameters (see above). |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 77 | virtual RtpTransportParameters GetParameters() const = 0; |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 78 | |
| 79 | protected: |
| 80 | // Only for internal use. Returns a pointer to an internal interface, for use |
| 81 | // by the implementation. |
| 82 | virtual RtpTransportAdapter* GetInternal() = 0; |
| 83 | |
| 84 | // Classes that can use this internal interface. |
| 85 | friend class OrtcFactory; |
| 86 | friend class OrtcRtpSenderAdapter; |
| 87 | friend class OrtcRtpReceiverAdapter; |
| 88 | friend class RtpTransportControllerAdapter; |
| 89 | friend class RtpTransportAdapter; |
| 90 | }; |
| 91 | |
| 92 | } // namespace webrtc |
| 93 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 94 | #endif // API_ORTC_RTP_TRANSPORT_INTERFACE_H_ |