blob: 942dc506f01781768780ae5b4aad82bd7f8cb8e1 [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
11#ifndef WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_
12#define WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_
13
14#include <string>
15
16#include "webrtc/api/ortc/packettransportinterface.h"
17#include "webrtc/api/rtcerror.h"
18#include "webrtc/base/optional.h"
19
20namespace webrtc {
21
22class RtpTransportAdapter;
23
24struct RtcpParameters {
25 // The SSRC to be used in the "SSRC of packet sender" field. If not set, one
26 // will be chosen by the implementation.
27 // TODO(deadbeef): Not implemented.
28 rtc::Optional<uint32_t> ssrc;
29
30 // The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages).
31 //
32 // If empty in the construction of the RtpTransport, one will be generated by
33 // the implementation, and returned in GetRtcpParameters. Multiple
34 // RtpTransports created by the same OrtcFactory will use the same generated
35 // CNAME.
36 //
37 // If empty when passed into SetRtcpParameters, the CNAME simply won't be
38 // modified.
39 std::string cname;
40
41 // Send reduced-size RTCP?
42 bool reduced_size = false;
43
44 // Send RTCP multiplexed on the RTP transport?
45 bool mux = true;
46
47 bool operator==(const RtcpParameters& o) const {
48 return ssrc == o.ssrc && cname == o.cname &&
49 reduced_size == o.reduced_size && mux == o.mux;
50 }
51 bool operator!=(const RtcpParameters& o) const { return !(*this == o); }
52};
53
54// Base class for different types of RTP transports that can be created by an
55// OrtcFactory. Used by RtpSenders/RtpReceivers.
56//
57// This is not present in the standard ORTC API, but exists here for a few
58// reasons. Firstly, it allows different types of RTP transports to be used:
59// DTLS-SRTP (which is required for the web), but also SDES-SRTP and
60// unencrypted RTP. It also simplifies the handling of RTCP muxing, and
61// provides a better API point for it.
62//
63// Note that Edge's implementation of ORTC provides a similar API point, called
64// RTCSrtpSdesTransport:
65// https://msdn.microsoft.com/en-us/library/mt502527(v=vs.85).aspx
66class RtpTransportInterface {
67 public:
68 virtual ~RtpTransportInterface() {}
69
70 // Returns packet transport that's used to send RTP packets.
71 virtual PacketTransportInterface* GetRtpPacketTransport() const = 0;
72
73 // Returns separate packet transport that's used to send RTCP packets. If
74 // RTCP multiplexing is being used, returns null.
75 virtual PacketTransportInterface* GetRtcpPacketTransport() const = 0;
76
77 // Set/get RTCP params. Can be used to enable RTCP muxing or reduced-size
78 // RTCP if initially not enabled.
79 //
80 // Changing |mux| from "true" to "false" is not allowed, and changing the
81 // CNAME is currently unsupported.
82 virtual RTCError SetRtcpParameters(const RtcpParameters& parameters) = 0;
83 // Returns last set or constructed-with parameters. If |cname| was empty in
84 // construction, the generated CNAME will be present in the returned
85 // parameters (see above).
86 virtual RtcpParameters GetRtcpParameters() const = 0;
87
88 protected:
89 // Only for internal use. Returns a pointer to an internal interface, for use
90 // by the implementation.
91 virtual RtpTransportAdapter* GetInternal() = 0;
92
93 // Classes that can use this internal interface.
94 friend class OrtcFactory;
95 friend class OrtcRtpSenderAdapter;
96 friend class OrtcRtpReceiverAdapter;
97 friend class RtpTransportControllerAdapter;
98 friend class RtpTransportAdapter;
99};
100
101} // namespace webrtc
102
103#endif // WEBRTC_API_ORTC_RTPTRANSPORTINTERFACE_H_