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 | |
Zhi Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 16 | #include "call/rtp_demuxer.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 17 | #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 Titov | e41c433 | 2018-07-25 15:04:28 +0200 | [diff] [blame] | 21 | #include "rtc_base/third_party/sigslot/sigslot.h" |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 22 | |
| 23 | namespace rtc { |
| 24 | class CopyOnWriteBuffer; |
| 25 | struct PacketOptions; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 26 | } // namespace rtc |
| 27 | |
| 28 | namespace webrtc { |
| 29 | |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 30 | // This represents the internal interface beneath SrtpTransportInterface; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 31 | // 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 Mellem | 34cd485 | 2019-05-24 10:13:10 -0700 | [diff] [blame] | 34 | class RtpTransportInternal : public sigslot::has_slots<> { |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 35 | public: |
Bjorn A Mellem | 34cd485 | 2019-05-24 10:13:10 -0700 | [diff] [blame] | 36 | virtual ~RtpTransportInternal() = default; |
| 37 | |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 38 | virtual void SetRtcpMuxEnabled(bool enable) = 0; |
| 39 | |
Bjorn A Mellem | 3a1b927 | 2019-05-24 16:13:08 -0700 | [diff] [blame] | 40 | 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 Huang | f2d7beb | 2017-11-20 14:35:11 -0800 | [diff] [blame] | 46 | virtual bool rtcp_mux_enabled() const = 0; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 47 | |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 48 | virtual bool IsReadyToSend() const = 0; |
| 49 | |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 50 | // 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 Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 55 | // 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öller | e693381 | 2018-11-05 13:01:41 +0100 | [diff] [blame] | 58 | sigslot::signal2<rtc::CopyOnWriteBuffer*, int64_t> SignalRtcpPacketReceived; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 59 | |
Zhi Huang | cd3fc5d | 2017-11-29 10:41:57 -0800 | [diff] [blame] | 60 | // Called whenever the network route of the P2P layer transport changes. |
| 61 | // The argument is an optional network route. |
Danil Chapovalov | 66cadcc | 2018-06-19 16:47:43 +0200 | [diff] [blame] | 62 | sigslot::signal1<absl::optional<rtc::NetworkRoute>> SignalNetworkRouteChanged; |
Zhi Huang | cd3fc5d | 2017-11-29 10:41:57 -0800 | [diff] [blame] | 63 | |
Zhi Huang | f2d7beb | 2017-11-20 14:35:11 -0800 | [diff] [blame] | 64 | // 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 Huang | cd3fc5d | 2017-11-29 10:41:57 -0800 | [diff] [blame] | 68 | sigslot::signal1<const rtc::SentPacket&> SignalSentPacket; |
Zhi Huang | 942bc2e | 2017-11-13 13:26:07 -0800 | [diff] [blame] | 69 | |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 70 | virtual bool IsWritable(bool rtcp) const = 0; |
| 71 | |
Zhi Huang | f2d7beb | 2017-11-20 14:35:11 -0800 | [diff] [blame] | 72 | // TODO(zhihuang): Pass the |packet| by copy so that the original data |
| 73 | // wouldn't be modified. |
Zhi Huang | cf990f5 | 2017-09-22 12:12:30 -0700 | [diff] [blame] | 74 | 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; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 81 | |
Zhi Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 82 | // 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 Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 95 | virtual bool IsSrtpActive() const = 0; |
Steve Anton | db67ba1 | 2018-03-19 17:41:42 -0700 | [diff] [blame] | 96 | |
Zhi Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 97 | virtual bool RegisterRtpDemuxerSink(const RtpDemuxerCriteria& criteria, |
| 98 | RtpPacketSinkInterface* sink) = 0; |
| 99 | |
| 100 | virtual bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) = 0; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | } // namespace webrtc |
| 104 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 105 | #endif // PC_RTP_TRANSPORT_INTERNAL_H_ |