blob: dfcdbbfc610e2f303e148739c7c9bc98b8cb2127 [file] [log] [blame]
zstein398c3fd2017-07-19 13:38:02 -07001/*
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 PC_RTP_TRANSPORT_INTERNAL_H_
12#define PC_RTP_TRANSPORT_INTERNAL_H_
zstein398c3fd2017-07-19 13:38:02 -070013
Zhi Huang942bc2e2017-11-13 13:26:07 -080014#include <string>
15
Zhi Huang365381f2018-04-13 16:44:34 -070016#include "call/rtp_demuxer.h"
Steve Anton10542f22019-01-11 09:11:00 -080017#include "p2p/base/ice_transport_internal.h"
18#include "pc/session_description.h"
19#include "rtc_base/network_route.h"
20#include "rtc_base/ssl_stream_adapter.h"
Artem Titove41c4332018-07-25 15:04:28 +020021#include "rtc_base/third_party/sigslot/sigslot.h"
zstein398c3fd2017-07-19 13:38:02 -070022
23namespace rtc {
24class CopyOnWriteBuffer;
25struct PacketOptions;
zstein398c3fd2017-07-19 13:38:02 -070026} // namespace rtc
27
28namespace webrtc {
29
Zhi Huange830e682018-03-30 10:48:35 -070030// This represents the internal interface beneath SrtpTransportInterface;
zstein398c3fd2017-07-19 13:38:02 -070031// it is not accessible to API consumers but is accessible to internal classes
32// in order to send and receive RTP and RTCP packets belonging to a single RTP
33// session. Additional convenience and configuration methods are also provided.
Bjorn A Mellem34cd4852019-05-24 10:13:10 -070034class RtpTransportInternal : public sigslot::has_slots<> {
zstein398c3fd2017-07-19 13:38:02 -070035 public:
Bjorn A Mellem34cd4852019-05-24 10:13:10 -070036 virtual ~RtpTransportInternal() = default;
37
zstein398c3fd2017-07-19 13:38:02 -070038 virtual void SetRtcpMuxEnabled(bool enable) = 0;
39
Bjorn A Mellem3a1b9272019-05-24 16:13:08 -070040 virtual const std::string& transport_name() const = 0;
41
42 // Sets socket options on the underlying RTP or RTCP transports.
43 virtual int SetRtpOption(rtc::Socket::Option opt, int value) = 0;
44 virtual int SetRtcpOption(rtc::Socket::Option opt, int value) = 0;
45
Zhi Huangf2d7beb2017-11-20 14:35:11 -080046 virtual bool rtcp_mux_enabled() const = 0;
zstein398c3fd2017-07-19 13:38:02 -070047
Zhi Huange830e682018-03-30 10:48:35 -070048 virtual bool IsReadyToSend() const = 0;
49
zstein398c3fd2017-07-19 13:38:02 -070050 // Called whenever a transport's ready-to-send state changes. The argument
51 // is true if all used transports are ready to send. This is more specific
52 // than just "writable"; it means the last send didn't return ENOTCONN.
53 sigslot::signal1<bool> SignalReadyToSend;
54
Zhi Huang365381f2018-04-13 16:44:34 -070055 // Called whenever an RTCP packet is received. There is no equivalent signal
56 // for RTP packets because they would be forwarded to the BaseChannel through
57 // the RtpDemuxer callback.
Niels Möllere6933812018-11-05 13:01:41 +010058 sigslot::signal2<rtc::CopyOnWriteBuffer*, int64_t> SignalRtcpPacketReceived;
zstein398c3fd2017-07-19 13:38:02 -070059
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080060 // Called whenever the network route of the P2P layer transport changes.
61 // The argument is an optional network route.
Danil Chapovalov66cadcc2018-06-19 16:47:43 +020062 sigslot::signal1<absl::optional<rtc::NetworkRoute>> SignalNetworkRouteChanged;
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080063
Zhi Huangf2d7beb2017-11-20 14:35:11 -080064 // Called whenever a transport's writable state might change. The argument is
65 // true if the transport is writable, otherwise it is false.
66 sigslot::signal1<bool> SignalWritableState;
67
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080068 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket;
Zhi Huang942bc2e2017-11-13 13:26:07 -080069
zstein398c3fd2017-07-19 13:38:02 -070070 virtual bool IsWritable(bool rtcp) const = 0;
71
Zhi Huangf2d7beb2017-11-20 14:35:11 -080072 // TODO(zhihuang): Pass the |packet| by copy so that the original data
73 // wouldn't be modified.
Zhi Huangcf990f52017-09-22 12:12:30 -070074 virtual bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet,
75 const rtc::PacketOptions& options,
76 int flags) = 0;
77
78 virtual bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet,
79 const rtc::PacketOptions& options,
80 int flags) = 0;
zstein398c3fd2017-07-19 13:38:02 -070081
Zhi Huang365381f2018-04-13 16:44:34 -070082 // This method updates the RTP header extension map so that the RTP transport
83 // can parse the received packets and identify the MID. This is called by the
84 // BaseChannel when setting the content description.
85 //
86 // TODO(zhihuang): Merging and replacing following methods handling header
87 // extensions with SetParameters:
88 // UpdateRtpHeaderExtensionMap,
89 // UpdateSendEncryptedHeaderExtensionIds,
90 // UpdateRecvEncryptedHeaderExtensionIds,
91 // CacheRtpAbsSendTimeHeaderExtension,
92 virtual void UpdateRtpHeaderExtensionMap(
93 const cricket::RtpHeaderExtensions& header_extensions) = 0;
94
Zhi Huange830e682018-03-30 10:48:35 -070095 virtual bool IsSrtpActive() const = 0;
Steve Antondb67ba12018-03-19 17:41:42 -070096
Zhi Huang365381f2018-04-13 16:44:34 -070097 virtual bool RegisterRtpDemuxerSink(const RtpDemuxerCriteria& criteria,
98 RtpPacketSinkInterface* sink) = 0;
99
100 virtual bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) = 0;
zstein398c3fd2017-07-19 13:38:02 -0700101};
102
103} // namespace webrtc
104
Steve Anton10542f22019-01-11 09:11:00 -0800105#endif // PC_RTP_TRANSPORT_INTERNAL_H_