blob: ec712163da23d20e02e22e352817ca34cb2095fa [file] [log] [blame]
deadbeefe814a0d2017-02-25 18:15:09 -08001/*
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 Anton10542f22019-01-11 09:11:00 -080011#ifndef API_ORTC_RTP_TRANSPORT_INTERFACE_H_
12#define API_ORTC_RTP_TRANSPORT_INTERFACE_H_
deadbeefe814a0d2017-02-25 18:15:09 -080013
14#include <string>
15
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020016#include "absl/types/optional.h"
Steve Anton10542f22019-01-11 09:11:00 -080017#include "api/ortc/packet_transport_interface.h"
18#include "api/rtc_error.h"
Patrik Höglund3e113432017-12-15 14:40:10 +010019#include "api/rtp_headers.h"
Steve Anton10542f22019-01-11 09:11:00 -080020#include "api/rtp_parameters.h"
deadbeefe814a0d2017-02-25 18:15:09 -080021
22namespace webrtc {
23
24class RtpTransportAdapter;
25
sprangdb2a9fc2017-08-09 06:42:32 -070026struct 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
deadbeefe814a0d2017-02-25 18:15:09 -080041// 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
53class 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
sprangdb2a9fc2017-08-09 06:42:32 -070064 // Set/get RTP/RTCP transport params. Can be used to enable RTCP muxing or
65 // reduced-size RTCP if initially not enabled.
deadbeefe814a0d2017-02-25 18:15:09 -080066 //
67 // Changing |mux| from "true" to "false" is not allowed, and changing the
68 // CNAME is currently unsupported.
sprangdb2a9fc2017-08-09 06:42:32 -070069 // 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;
deadbeefe814a0d2017-02-25 18:15:09 -080074 // 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).
sprangdb2a9fc2017-08-09 06:42:32 -070077 virtual RtpTransportParameters GetParameters() const = 0;
deadbeefe814a0d2017-02-25 18:15:09 -080078
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 Anton10542f22019-01-11 09:11:00 -080094#endif // API_ORTC_RTP_TRANSPORT_INTERFACE_H_