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 | 95e7dbb | 2018-03-29 00:08:03 +0000 | [diff] [blame] | 16 | #include "api/ortc/rtptransportinterface.h" |
Steve Anton | db67ba1 | 2018-03-19 17:41:42 -0700 | [diff] [blame] | 17 | #include "api/umametrics.h" |
Zhi Huang | 942bc2e | 2017-11-13 13:26:07 -0800 | [diff] [blame] | 18 | #include "p2p/base/icetransportinternal.h" |
| 19 | #include "rtc_base/networkroute.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "rtc_base/sigslot.h" |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 21 | |
| 22 | namespace rtc { |
| 23 | class CopyOnWriteBuffer; |
| 24 | struct PacketOptions; |
| 25 | struct PacketTime; |
| 26 | } // namespace rtc |
| 27 | |
| 28 | namespace webrtc { |
| 29 | |
Zhi Huang | 95e7dbb | 2018-03-29 00:08:03 +0000 | [diff] [blame] | 30 | // This represents the internal interface beneath RtpTransportInterface; |
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. |
Zhi Huang | 95e7dbb | 2018-03-29 00:08:03 +0000 | [diff] [blame] | 34 | class RtpTransportInternal : public RtpTransportInterface, |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 35 | public sigslot::has_slots<> { |
| 36 | public: |
| 37 | virtual void SetRtcpMuxEnabled(bool enable) = 0; |
| 38 | |
| 39 | // TODO(zstein): Remove PacketTransport setters. Clients should pass these |
| 40 | // in to constructors instead and construct a new RtpTransportInternal instead |
| 41 | // of updating them. |
Zhi Huang | f2d7beb | 2017-11-20 14:35:11 -0800 | [diff] [blame] | 42 | virtual bool rtcp_mux_enabled() const = 0; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 43 | |
| 44 | virtual rtc::PacketTransportInternal* rtp_packet_transport() const = 0; |
| 45 | virtual void SetRtpPacketTransport(rtc::PacketTransportInternal* rtp) = 0; |
| 46 | |
| 47 | virtual rtc::PacketTransportInternal* rtcp_packet_transport() const = 0; |
| 48 | virtual void SetRtcpPacketTransport(rtc::PacketTransportInternal* rtcp) = 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 | |
Zhi Huang | 95e7dbb | 2018-03-29 00:08:03 +0000 | [diff] [blame] | 55 | // TODO(zstein): Consider having two signals - RtpPacketReceived and |
| 56 | // RtcpPacketReceived. |
| 57 | // The first argument is true for RTCP packets and false for RTP packets. |
| 58 | sigslot::signal3<bool, rtc::CopyOnWriteBuffer*, const rtc::PacketTime&> |
| 59 | SignalPacketReceived; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 60 | |
Zhi Huang | cd3fc5d | 2017-11-29 10:41:57 -0800 | [diff] [blame] | 61 | // Called whenever the network route of the P2P layer transport changes. |
| 62 | // The argument is an optional network route. |
| 63 | sigslot::signal1<rtc::Optional<rtc::NetworkRoute>> SignalNetworkRouteChanged; |
| 64 | |
Zhi Huang | f2d7beb | 2017-11-20 14:35:11 -0800 | [diff] [blame] | 65 | // Called whenever a transport's writable state might change. The argument is |
| 66 | // true if the transport is writable, otherwise it is false. |
| 67 | sigslot::signal1<bool> SignalWritableState; |
| 68 | |
Zhi Huang | cd3fc5d | 2017-11-29 10:41:57 -0800 | [diff] [blame] | 69 | sigslot::signal1<const rtc::SentPacket&> SignalSentPacket; |
Zhi Huang | 942bc2e | 2017-11-13 13:26:07 -0800 | [diff] [blame] | 70 | |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 71 | virtual bool IsWritable(bool rtcp) const = 0; |
| 72 | |
Zhi Huang | f2d7beb | 2017-11-20 14:35:11 -0800 | [diff] [blame] | 73 | // TODO(zhihuang): Pass the |packet| by copy so that the original data |
| 74 | // wouldn't be modified. |
Zhi Huang | cf990f5 | 2017-09-22 12:12:30 -0700 | [diff] [blame] | 75 | virtual bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet, |
| 76 | const rtc::PacketOptions& options, |
| 77 | int flags) = 0; |
| 78 | |
| 79 | virtual bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet, |
| 80 | const rtc::PacketOptions& options, |
| 81 | int flags) = 0; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 82 | |
Zhi Huang | 95e7dbb | 2018-03-29 00:08:03 +0000 | [diff] [blame] | 83 | virtual bool HandlesPayloadType(int payload_type) const = 0; |
| 84 | |
| 85 | virtual void AddHandledPayloadType(int payload_type) = 0; |
Steve Anton | db67ba1 | 2018-03-19 17:41:42 -0700 | [diff] [blame] | 86 | |
| 87 | virtual void SetMetricsObserver( |
| 88 | rtc::scoped_refptr<MetricsObserverInterface> metrics_observer) = 0; |
zstein | 398c3fd | 2017-07-19 13:38:02 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | } // namespace webrtc |
| 92 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 93 | #endif // PC_RTPTRANSPORTINTERNAL_H_ |