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