blob: 53b0a5319586d9ed3ba42dacb517193fe491771a [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "api/optional.h"
17#include "api/ortc/packettransportinterface.h"
18#include "api/rtcerror.h"
19#include "common_types.h"
deadbeefe814a0d2017-02-25 18:15:09 -080020
21namespace webrtc {
22
23class RtpTransportAdapter;
24
sprangdb2a9fc2017-08-09 06:42:32 -070025struct RtcpParameters final {
deadbeefe814a0d2017-02-25 18:15:09 -080026 // 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 //
sprangdb2a9fc2017-08-09 06:42:32 -070038 // If empty when passed into SetParameters, the CNAME simply won't be
deadbeefe814a0d2017-02-25 18:15:09 -080039 // 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
sprangdb2a9fc2017-08-09 06:42:32 -070055struct 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
deadbeefe814a0d2017-02-25 18:15:09 -080070// 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
82class 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
sprangdb2a9fc2017-08-09 06:42:32 -070093 // Set/get RTP/RTCP transport params. Can be used to enable RTCP muxing or
94 // reduced-size RTCP if initially not enabled.
deadbeefe814a0d2017-02-25 18:15:09 -080095 //
96 // Changing |mux| from "true" to "false" is not allowed, and changing the
97 // CNAME is currently unsupported.
sprangdb2a9fc2017-08-09 06:42:32 -070098 // 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;
deadbeefe814a0d2017-02-25 18:15:09 -0800103 // 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).
sprangdb2a9fc2017-08-09 06:42:32 -0700106 virtual RtpTransportParameters GetParameters() const = 0;
deadbeefe814a0d2017-02-25 18:15:09 -0800107
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200123#endif // API_ORTC_RTPTRANSPORTINTERFACE_H_