blob: 2e168858dca251efface58badde269090e2336ef [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
sprangdb2a9fc2017-08-09 06:42:32 -070024struct RtpTransportParameters final {
25 RtcpParameters rtcp;
26
sprangdb2a9fc2017-08-09 06:42:32 -070027 bool operator==(const RtpTransportParameters& o) const {
Sebastian Janssond155d682019-03-04 18:59:32 +010028 return rtcp == o.rtcp;
sprangdb2a9fc2017-08-09 06:42:32 -070029 }
30 bool operator!=(const RtpTransportParameters& o) const {
31 return !(*this == o);
32 }
33};
34
deadbeefe814a0d2017-02-25 18:15:09 -080035// Base class for different types of RTP transports that can be created by an
36// OrtcFactory. Used by RtpSenders/RtpReceivers.
37//
38// This is not present in the standard ORTC API, but exists here for a few
39// reasons. Firstly, it allows different types of RTP transports to be used:
40// DTLS-SRTP (which is required for the web), but also SDES-SRTP and
41// unencrypted RTP. It also simplifies the handling of RTCP muxing, and
42// provides a better API point for it.
43//
44// Note that Edge's implementation of ORTC provides a similar API point, called
45// RTCSrtpSdesTransport:
46// https://msdn.microsoft.com/en-us/library/mt502527(v=vs.85).aspx
47class RtpTransportInterface {
48 public:
49 virtual ~RtpTransportInterface() {}
50
51 // Returns packet transport that's used to send RTP packets.
52 virtual PacketTransportInterface* GetRtpPacketTransport() const = 0;
53
54 // Returns separate packet transport that's used to send RTCP packets. If
55 // RTCP multiplexing is being used, returns null.
56 virtual PacketTransportInterface* GetRtcpPacketTransport() const = 0;
57
sprangdb2a9fc2017-08-09 06:42:32 -070058 // Set/get RTP/RTCP transport params. Can be used to enable RTCP muxing or
59 // reduced-size RTCP if initially not enabled.
deadbeefe814a0d2017-02-25 18:15:09 -080060 //
61 // Changing |mux| from "true" to "false" is not allowed, and changing the
62 // CNAME is currently unsupported.
sprangdb2a9fc2017-08-09 06:42:32 -070063 // RTP keep-alive settings need to be set before before an RtpSender has
64 // started sending, altering the payload type or timeout interval after this
65 // point is not supported. The parameters must also match across all RTP
66 // transports for a given RTP transport controller.
67 virtual RTCError SetParameters(const RtpTransportParameters& parameters) = 0;
deadbeefe814a0d2017-02-25 18:15:09 -080068 // Returns last set or constructed-with parameters. If |cname| was empty in
69 // construction, the generated CNAME will be present in the returned
70 // parameters (see above).
sprangdb2a9fc2017-08-09 06:42:32 -070071 virtual RtpTransportParameters GetParameters() const = 0;
deadbeefe814a0d2017-02-25 18:15:09 -080072
73 protected:
deadbeefe814a0d2017-02-25 18:15:09 -080074 // Classes that can use this internal interface.
75 friend class OrtcFactory;
76 friend class OrtcRtpSenderAdapter;
77 friend class OrtcRtpReceiverAdapter;
78 friend class RtpTransportControllerAdapter;
deadbeefe814a0d2017-02-25 18:15:09 -080079};
80
81} // namespace webrtc
82
Steve Anton10542f22019-01-11 09:11:00 -080083#endif // API_ORTC_RTP_TRANSPORT_INTERFACE_H_