zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef PC_RTPTRANSPORTINTERNAL_H_ |
| 12 | #define PC_RTPTRANSPORTINTERNAL_H_ |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 13 | |
Zhi Huang | 942bc2e | 2017-11-13 13:26:07 -0800 | [diff] [blame] | 14 | #include <string> |
| 15 | |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 16 | #include "api/ortc/srtptransportinterface.h" |
Steve Anton | db67ba1 | 2018-03-19 17:41:42 -0700 | [diff] [blame] | 17 | #include "api/umametrics.h" |
Zhi Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 18 | #include "call/rtp_demuxer.h" |
Zhi Huang | 942bc2e | 2017-11-13 13:26:07 -0800 | [diff] [blame] | 19 | #include "p2p/base/icetransportinternal.h" |
Zhi Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 20 | #include "pc/sessiondescription.h" |
Zhi Huang | 942bc2e | 2017-11-13 13:26:07 -0800 | [diff] [blame] | 21 | #include "rtc_base/networkroute.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "rtc_base/sigslot.h" |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 23 | #include "rtc_base/sslstreamadapter.h" |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 24 | |
| 25 | namespace rtc { |
| 26 | class CopyOnWriteBuffer; |
| 27 | struct PacketOptions; |
| 28 | struct PacketTime; |
| 29 | } // namespace rtc |
| 30 | |
| 31 | namespace webrtc { |
| 32 | |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 33 | // This represents the internal interface beneath SrtpTransportInterface; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 34 | // it is not accessible to API consumers but is accessible to internal classes |
| 35 | // in order to send and receive RTP and RTCP packets belonging to a single RTP |
| 36 | // session. Additional convenience and configuration methods are also provided. |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 37 | class RtpTransportInternal : public SrtpTransportInterface, |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 38 | public sigslot::has_slots<> { |
| 39 | public: |
| 40 | virtual void SetRtcpMuxEnabled(bool enable) = 0; |
| 41 | |
| 42 | // TODO(zstein): Remove PacketTransport setters. Clients should pass these |
| 43 | // in to constructors instead and construct a new RtpTransportInternal instead |
| 44 | // of updating them. |
Zhi Huang | f2d7beb | 2017-11-20 14:35:11 -0800 | [diff] [blame] | 45 | virtual bool rtcp_mux_enabled() const = 0; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 46 | |
| 47 | virtual rtc::PacketTransportInternal* rtp_packet_transport() const = 0; |
| 48 | virtual void SetRtpPacketTransport(rtc::PacketTransportInternal* rtp) = 0; |
| 49 | |
| 50 | virtual rtc::PacketTransportInternal* rtcp_packet_transport() const = 0; |
| 51 | virtual void SetRtcpPacketTransport(rtc::PacketTransportInternal* rtcp) = 0; |
| 52 | |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 53 | virtual bool IsReadyToSend() const = 0; |
| 54 | |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 55 | // Called whenever a transport's ready-to-send state changes. The argument |
| 56 | // is true if all used transports are ready to send. This is more specific |
| 57 | // than just "writable"; it means the last send didn't return ENOTCONN. |
| 58 | sigslot::signal1<bool> SignalReadyToSend; |
| 59 | |
Zhi Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 60 | // Called whenever an RTCP packet is received. There is no equivalent signal |
| 61 | // for RTP packets because they would be forwarded to the BaseChannel through |
| 62 | // the RtpDemuxer callback. |
| 63 | sigslot::signal2<rtc::CopyOnWriteBuffer*, const rtc::PacketTime&> |
| 64 | SignalRtcpPacketReceived; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 65 | |
Zhi Huang | cd3fc5d | 2017-11-29 10:41:57 -0800 | [diff] [blame] | 66 | // Called whenever the network route of the P2P layer transport changes. |
| 67 | // The argument is an optional network route. |
| 68 | sigslot::signal1<rtc::Optional<rtc::NetworkRoute>> SignalNetworkRouteChanged; |
| 69 | |
Zhi Huang | f2d7beb | 2017-11-20 14:35:11 -0800 | [diff] [blame] | 70 | // Called whenever a transport's writable state might change. The argument is |
| 71 | // true if the transport is writable, otherwise it is false. |
| 72 | sigslot::signal1<bool> SignalWritableState; |
| 73 | |
Zhi Huang | cd3fc5d | 2017-11-29 10:41:57 -0800 | [diff] [blame] | 74 | sigslot::signal1<const rtc::SentPacket&> SignalSentPacket; |
Zhi Huang | 942bc2e | 2017-11-13 13:26:07 -0800 | [diff] [blame] | 75 | |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 76 | virtual bool IsWritable(bool rtcp) const = 0; |
| 77 | |
Zhi Huang | f2d7beb | 2017-11-20 14:35:11 -0800 | [diff] [blame] | 78 | // TODO(zhihuang): Pass the |packet| by copy so that the original data |
| 79 | // wouldn't be modified. |
Zhi Huang | cf990f5 | 2017-09-22 12:12:30 -0700 | [diff] [blame] | 80 | virtual bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet, |
| 81 | const rtc::PacketOptions& options, |
| 82 | int flags) = 0; |
| 83 | |
| 84 | virtual bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet, |
| 85 | const rtc::PacketOptions& options, |
| 86 | int flags) = 0; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 87 | |
Zhi Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 88 | // This method updates the RTP header extension map so that the RTP transport |
| 89 | // can parse the received packets and identify the MID. This is called by the |
| 90 | // BaseChannel when setting the content description. |
| 91 | // |
| 92 | // TODO(zhihuang): Merging and replacing following methods handling header |
| 93 | // extensions with SetParameters: |
| 94 | // UpdateRtpHeaderExtensionMap, |
| 95 | // UpdateSendEncryptedHeaderExtensionIds, |
| 96 | // UpdateRecvEncryptedHeaderExtensionIds, |
| 97 | // CacheRtpAbsSendTimeHeaderExtension, |
| 98 | virtual void UpdateRtpHeaderExtensionMap( |
| 99 | const cricket::RtpHeaderExtensions& header_extensions) = 0; |
| 100 | |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 101 | virtual bool IsSrtpActive() const = 0; |
Steve Anton | db67ba1 | 2018-03-19 17:41:42 -0700 | [diff] [blame] | 102 | |
| 103 | virtual void SetMetricsObserver( |
| 104 | rtc::scoped_refptr<MetricsObserverInterface> metrics_observer) = 0; |
Zhi Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 105 | |
| 106 | virtual bool RegisterRtpDemuxerSink(const RtpDemuxerCriteria& criteria, |
| 107 | RtpPacketSinkInterface* sink) = 0; |
| 108 | |
| 109 | virtual bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) = 0; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | } // namespace webrtc |
| 113 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 114 | #endif // PC_RTPTRANSPORTINTERNAL_H_ |