blob: b0d30e8560e27a528ba67a5354afb32da0a2db64 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef API_ORTC_RTPTRANSPORTINTERFACE_H_
12#define API_ORTC_RTPTRANSPORTINTERFACE_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"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "api/ortc/packettransportinterface.h"
18#include "api/rtcerror.h"
Patrik Höglund3e113432017-12-15 14:40:10 +010019#include "api/rtp_headers.h"
Florent Castellidacec712018-05-24 16:24:21 +020020#include "api/rtpparameters.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020021#include "common_types.h" // NOLINT(build/include)
deadbeefe814a0d2017-02-25 18:15:09 -080022
23namespace webrtc {
24
25class RtpTransportAdapter;
26
sprangdb2a9fc2017-08-09 06:42:32 -070027struct RtpTransportParameters final {
28 RtcpParameters rtcp;
29
30 // Enabled periodic sending of keep-alive packets, that help prevent timeouts
31 // on the network level, such as NAT bindings. See RFC6263 section 4.6.
32 RtpKeepAliveConfig keepalive;
33
34 bool operator==(const RtpTransportParameters& o) const {
35 return rtcp == o.rtcp && keepalive == o.keepalive;
36 }
37 bool operator!=(const RtpTransportParameters& o) const {
38 return !(*this == o);
39 }
40};
41
deadbeefe814a0d2017-02-25 18:15:09 -080042// Base class for different types of RTP transports that can be created by an
43// OrtcFactory. Used by RtpSenders/RtpReceivers.
44//
45// This is not present in the standard ORTC API, but exists here for a few
46// reasons. Firstly, it allows different types of RTP transports to be used:
47// DTLS-SRTP (which is required for the web), but also SDES-SRTP and
48// unencrypted RTP. It also simplifies the handling of RTCP muxing, and
49// provides a better API point for it.
50//
51// Note that Edge's implementation of ORTC provides a similar API point, called
52// RTCSrtpSdesTransport:
53// https://msdn.microsoft.com/en-us/library/mt502527(v=vs.85).aspx
54class RtpTransportInterface {
55 public:
56 virtual ~RtpTransportInterface() {}
57
58 // Returns packet transport that's used to send RTP packets.
59 virtual PacketTransportInterface* GetRtpPacketTransport() const = 0;
60
61 // Returns separate packet transport that's used to send RTCP packets. If
62 // RTCP multiplexing is being used, returns null.
63 virtual PacketTransportInterface* GetRtcpPacketTransport() const = 0;
64
sprangdb2a9fc2017-08-09 06:42:32 -070065 // Set/get RTP/RTCP transport params. Can be used to enable RTCP muxing or
66 // reduced-size RTCP if initially not enabled.
deadbeefe814a0d2017-02-25 18:15:09 -080067 //
68 // Changing |mux| from "true" to "false" is not allowed, and changing the
69 // CNAME is currently unsupported.
sprangdb2a9fc2017-08-09 06:42:32 -070070 // RTP keep-alive settings need to be set before before an RtpSender has
71 // started sending, altering the payload type or timeout interval after this
72 // point is not supported. The parameters must also match across all RTP
73 // transports for a given RTP transport controller.
74 virtual RTCError SetParameters(const RtpTransportParameters& parameters) = 0;
deadbeefe814a0d2017-02-25 18:15:09 -080075 // Returns last set or constructed-with parameters. If |cname| was empty in
76 // construction, the generated CNAME will be present in the returned
77 // parameters (see above).
sprangdb2a9fc2017-08-09 06:42:32 -070078 virtual RtpTransportParameters GetParameters() const = 0;
deadbeefe814a0d2017-02-25 18:15:09 -080079
80 protected:
81 // Only for internal use. Returns a pointer to an internal interface, for use
82 // by the implementation.
83 virtual RtpTransportAdapter* GetInternal() = 0;
84
85 // Classes that can use this internal interface.
86 friend class OrtcFactory;
87 friend class OrtcRtpSenderAdapter;
88 friend class OrtcRtpReceiverAdapter;
89 friend class RtpTransportControllerAdapter;
90 friend class RtpTransportAdapter;
91};
92
93} // namespace webrtc
94
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020095#endif // API_ORTC_RTPTRANSPORTINTERFACE_H_