blob: ca0568071086ce51ad1680b62cf29e7ec0e59edd [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef PC_RTPTRANSPORTINTERNAL_H_
12#define PC_RTPTRANSPORTINTERNAL_H_
zstein398c3fd2017-07-19 13:38:02 -070013
Zhi Huang942bc2e2017-11-13 13:26:07 -080014#include <string>
15
Zhi Huange830e682018-03-30 10:48:35 -070016#include "api/ortc/srtptransportinterface.h"
Zhi Huang365381f2018-04-13 16:44:34 -070017#include "call/rtp_demuxer.h"
Zhi Huang942bc2e2017-11-13 13:26:07 -080018#include "p2p/base/icetransportinternal.h"
Zhi Huang365381f2018-04-13 16:44:34 -070019#include "pc/sessiondescription.h"
Zhi Huang942bc2e2017-11-13 13:26:07 -080020#include "rtc_base/networkroute.h"
Zhi Huange830e682018-03-30 10:48:35 -070021#include "rtc_base/sslstreamadapter.h"
Artem Titove41c4332018-07-25 15:04:28 +020022#include "rtc_base/third_party/sigslot/sigslot.h"
zstein398c3fd2017-07-19 13:38:02 -070023
24namespace rtc {
25class CopyOnWriteBuffer;
26struct PacketOptions;
27struct PacketTime;
28} // namespace rtc
29
30namespace webrtc {
31
Zhi Huange830e682018-03-30 10:48:35 -070032// This represents the internal interface beneath SrtpTransportInterface;
zstein398c3fd2017-07-19 13:38:02 -070033// it is not accessible to API consumers but is accessible to internal classes
34// in order to send and receive RTP and RTCP packets belonging to a single RTP
35// session. Additional convenience and configuration methods are also provided.
Zhi Huange830e682018-03-30 10:48:35 -070036class RtpTransportInternal : public SrtpTransportInterface,
zstein398c3fd2017-07-19 13:38:02 -070037 public sigslot::has_slots<> {
38 public:
39 virtual void SetRtcpMuxEnabled(bool enable) = 0;
40
41 // TODO(zstein): Remove PacketTransport setters. Clients should pass these
42 // in to constructors instead and construct a new RtpTransportInternal instead
43 // of updating them.
Zhi Huangf2d7beb2017-11-20 14:35:11 -080044 virtual bool rtcp_mux_enabled() const = 0;
zstein398c3fd2017-07-19 13:38:02 -070045
46 virtual rtc::PacketTransportInternal* rtp_packet_transport() const = 0;
47 virtual void SetRtpPacketTransport(rtc::PacketTransportInternal* rtp) = 0;
48
49 virtual rtc::PacketTransportInternal* rtcp_packet_transport() const = 0;
50 virtual void SetRtcpPacketTransport(rtc::PacketTransportInternal* rtcp) = 0;
51
Zhi Huange830e682018-03-30 10:48:35 -070052 virtual bool IsReadyToSend() const = 0;
53
zstein398c3fd2017-07-19 13:38:02 -070054 // Called whenever a transport's ready-to-send state changes. The argument
55 // is true if all used transports are ready to send. This is more specific
56 // than just "writable"; it means the last send didn't return ENOTCONN.
57 sigslot::signal1<bool> SignalReadyToSend;
58
Zhi Huang365381f2018-04-13 16:44:34 -070059 // Called whenever an RTCP packet is received. There is no equivalent signal
60 // for RTP packets because they would be forwarded to the BaseChannel through
61 // the RtpDemuxer callback.
62 sigslot::signal2<rtc::CopyOnWriteBuffer*, const rtc::PacketTime&>
63 SignalRtcpPacketReceived;
zstein398c3fd2017-07-19 13:38:02 -070064
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080065 // Called whenever the network route of the P2P layer transport changes.
66 // The argument is an optional network route.
Danil Chapovalov66cadcc2018-06-19 16:47:43 +020067 sigslot::signal1<absl::optional<rtc::NetworkRoute>> SignalNetworkRouteChanged;
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080068
Zhi Huangf2d7beb2017-11-20 14:35:11 -080069 // Called whenever a transport's writable state might change. The argument is
70 // true if the transport is writable, otherwise it is false.
71 sigslot::signal1<bool> SignalWritableState;
72
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080073 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket;
Zhi Huang942bc2e2017-11-13 13:26:07 -080074
zstein398c3fd2017-07-19 13:38:02 -070075 virtual bool IsWritable(bool rtcp) const = 0;
76
Zhi Huangf2d7beb2017-11-20 14:35:11 -080077 // TODO(zhihuang): Pass the |packet| by copy so that the original data
78 // wouldn't be modified.
Zhi Huangcf990f52017-09-22 12:12:30 -070079 virtual bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet,
80 const rtc::PacketOptions& options,
81 int flags) = 0;
82
83 virtual bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet,
84 const rtc::PacketOptions& options,
85 int flags) = 0;
zstein398c3fd2017-07-19 13:38:02 -070086
Zhi Huang365381f2018-04-13 16:44:34 -070087 // This method updates the RTP header extension map so that the RTP transport
88 // can parse the received packets and identify the MID. This is called by the
89 // BaseChannel when setting the content description.
90 //
91 // TODO(zhihuang): Merging and replacing following methods handling header
92 // extensions with SetParameters:
93 // UpdateRtpHeaderExtensionMap,
94 // UpdateSendEncryptedHeaderExtensionIds,
95 // UpdateRecvEncryptedHeaderExtensionIds,
96 // CacheRtpAbsSendTimeHeaderExtension,
97 virtual void UpdateRtpHeaderExtensionMap(
98 const cricket::RtpHeaderExtensions& header_extensions) = 0;
99
Zhi Huange830e682018-03-30 10:48:35 -0700100 virtual bool IsSrtpActive() const = 0;
Steve Antondb67ba12018-03-19 17:41:42 -0700101
Zhi Huang365381f2018-04-13 16:44:34 -0700102 virtual bool RegisterRtpDemuxerSink(const RtpDemuxerCriteria& criteria,
103 RtpPacketSinkInterface* sink) = 0;
104
105 virtual bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) = 0;
zstein398c3fd2017-07-19 13:38:02 -0700106};
107
108} // namespace webrtc
109
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200110#endif // PC_RTPTRANSPORTINTERNAL_H_