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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "api/ortc/rtptransportinterface.h" |
Zhi Huang | 942bc2e | 2017-11-13 13:26:07 -0800 | [diff] [blame] | 17 | #include "p2p/base/icetransportinternal.h" |
| 18 | #include "rtc_base/networkroute.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "rtc_base/sigslot.h" |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 20 | |
| 21 | namespace rtc { |
| 22 | class CopyOnWriteBuffer; |
| 23 | struct PacketOptions; |
| 24 | struct PacketTime; |
| 25 | } // namespace rtc |
| 26 | |
| 27 | namespace webrtc { |
| 28 | |
| 29 | // This represents the internal interface beneath RtpTransportInterface; |
| 30 | // it is not accessible to API consumers but is accessible to internal classes |
| 31 | // in order to send and receive RTP and RTCP packets belonging to a single RTP |
| 32 | // session. Additional convenience and configuration methods are also provided. |
| 33 | class RtpTransportInternal : public RtpTransportInterface, |
| 34 | public sigslot::has_slots<> { |
| 35 | public: |
| 36 | virtual void SetRtcpMuxEnabled(bool enable) = 0; |
| 37 | |
| 38 | // TODO(zstein): Remove PacketTransport setters. Clients should pass these |
| 39 | // in to constructors instead and construct a new RtpTransportInternal instead |
| 40 | // of updating them. |
Zhi Huang | f2d7beb | 2017-11-20 14:35:11 -0800 | [diff] [blame] | 41 | virtual bool rtcp_mux_enabled() const = 0; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 42 | |
| 43 | virtual rtc::PacketTransportInternal* rtp_packet_transport() const = 0; |
| 44 | virtual void SetRtpPacketTransport(rtc::PacketTransportInternal* rtp) = 0; |
| 45 | |
| 46 | virtual rtc::PacketTransportInternal* rtcp_packet_transport() const = 0; |
| 47 | virtual void SetRtcpPacketTransport(rtc::PacketTransportInternal* rtcp) = 0; |
| 48 | |
| 49 | // Called whenever a transport's ready-to-send state changes. The argument |
| 50 | // is true if all used transports are ready to send. This is more specific |
| 51 | // than just "writable"; it means the last send didn't return ENOTCONN. |
| 52 | sigslot::signal1<bool> SignalReadyToSend; |
| 53 | |
| 54 | // TODO(zstein): Consider having two signals - RtpPacketReceived and |
| 55 | // RtcpPacketReceived. |
| 56 | // The first argument is true for RTCP packets and false for RTP packets. |
| 57 | sigslot::signal3<bool, rtc::CopyOnWriteBuffer*, const rtc::PacketTime&> |
| 58 | SignalPacketReceived; |
| 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. |
| 62 | sigslot::signal1<rtc::Optional<rtc::NetworkRoute>> SignalNetworkRouteChanged; |
| 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 | |
| 82 | virtual bool HandlesPayloadType(int payload_type) const = 0; |
| 83 | |
| 84 | virtual void AddHandledPayloadType(int payload_type) = 0; |
| 85 | }; |
| 86 | |
| 87 | } // namespace webrtc |
| 88 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 89 | #endif // PC_RTPTRANSPORTINTERNAL_H_ |