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 11 #ifndef PC_RTP_TRANSPORT_INTERNAL_H_ 12 #define PC_RTP_TRANSPORT_INTERNAL_H_ 13 14 #include <string> 15 16 #include "call/rtp_demuxer.h" 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" 21 #include "rtc_base/third_party/sigslot/sigslot.h" 22 23 namespace rtc { 24 class CopyOnWriteBuffer; 25 struct PacketOptions; 26 } // namespace rtc 27 28 namespace webrtc { 29 30 // This represents the internal interface beneath SrtpTransportInterface; 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. 34 class RtpTransportInternal : public sigslot::has_slots<> { 35 public: 36 virtual ~RtpTransportInternal() = default; 37 38 virtual void SetRtcpMuxEnabled(bool enable) = 0; 39 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 46 virtual bool rtcp_mux_enabled() const = 0; 47 48 virtual bool IsReadyToSend() const = 0; 49 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 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. 58 sigslot::signal2<rtc::CopyOnWriteBuffer*, int64_t> SignalRtcpPacketReceived; 59 60 // Called whenever the network route of the P2P layer transport changes. 61 // The argument is an optional network route. 62 sigslot::signal1<absl::optional<rtc::NetworkRoute>> SignalNetworkRouteChanged; 63 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 68 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket; 69 70 virtual bool IsWritable(bool rtcp) const = 0; 71 72 // TODO(zhihuang): Pass the |packet| by copy so that the original data 73 // wouldn't be modified. 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; 81 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 95 virtual bool IsSrtpActive() const = 0; 96 97 virtual bool RegisterRtpDemuxerSink(const RtpDemuxerCriteria& criteria, 98 RtpPacketSinkInterface* sink) = 0; 99 100 virtual bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) = 0; 101 }; 102 103 } // namespace webrtc 104 105 #endif // PC_RTP_TRANSPORT_INTERNAL_H_ 106