blob: a3549361881434d4015bdaebd43ad62786e0a5ee [file] [log] [blame]
zstein398c3fd2017-07-19 13:38:02 -07001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef PC_RTPTRANSPORTINTERNAL_H_
12#define PC_RTPTRANSPORTINTERNAL_H_
zstein398c3fd2017-07-19 13:38:02 -070013
Zhi Huang942bc2e2017-11-13 13:26:07 -080014#include <string>
15
Zhi Huange830e682018-03-30 10:48:35 -070016#include "api/ortc/srtptransportinterface.h"
Steve Antondb67ba12018-03-19 17:41:42 -070017#include "api/umametrics.h"
Zhi Huang942bc2e2017-11-13 13:26:07 -080018#include "p2p/base/icetransportinternal.h"
19#include "rtc_base/networkroute.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "rtc_base/sigslot.h"
Zhi Huange830e682018-03-30 10:48:35 -070021#include "rtc_base/sslstreamadapter.h"
zstein398c3fd2017-07-19 13:38:02 -070022
23namespace rtc {
24class CopyOnWriteBuffer;
25struct PacketOptions;
26struct PacketTime;
27} // namespace rtc
28
29namespace webrtc {
30
Zhi Huange830e682018-03-30 10:48:35 -070031// This represents the internal interface beneath SrtpTransportInterface;
zstein398c3fd2017-07-19 13:38:02 -070032// 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 Huange830e682018-03-30 10:48:35 -070035class RtpTransportInternal : public SrtpTransportInterface,
zstein398c3fd2017-07-19 13:38:02 -070036 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 Huangf2d7beb2017-11-20 14:35:11 -080043 virtual bool rtcp_mux_enabled() const = 0;
zstein398c3fd2017-07-19 13:38:02 -070044
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 Huange830e682018-03-30 10:48:35 -070051 virtual bool IsReadyToSend() const = 0;
52
zstein398c3fd2017-07-19 13:38:02 -070053 // 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 Huang95e7dbb2018-03-29 00:08:03 +000058 // TODO(zstein): Consider having two signals - RtpPacketReceived and
59 // RtcpPacketReceived.
60 // The first argument is true for RTCP packets and false for RTP packets.
61 sigslot::signal3<bool, rtc::CopyOnWriteBuffer*, const rtc::PacketTime&>
62 SignalPacketReceived;
zstein398c3fd2017-07-19 13:38:02 -070063
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080064 // Called whenever the network route of the P2P layer transport changes.
65 // The argument is an optional network route.
66 sigslot::signal1<rtc::Optional<rtc::NetworkRoute>> SignalNetworkRouteChanged;
67
Zhi Huangf2d7beb2017-11-20 14:35:11 -080068 // Called whenever a transport's writable state might change. The argument is
69 // true if the transport is writable, otherwise it is false.
70 sigslot::signal1<bool> SignalWritableState;
71
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080072 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket;
Zhi Huang942bc2e2017-11-13 13:26:07 -080073
zstein398c3fd2017-07-19 13:38:02 -070074 virtual bool IsWritable(bool rtcp) const = 0;
75
Zhi Huangf2d7beb2017-11-20 14:35:11 -080076 // TODO(zhihuang): Pass the |packet| by copy so that the original data
77 // wouldn't be modified.
Zhi Huangcf990f52017-09-22 12:12:30 -070078 virtual bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet,
79 const rtc::PacketOptions& options,
80 int flags) = 0;
81
82 virtual bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet,
83 const rtc::PacketOptions& options,
84 int flags) = 0;
zstein398c3fd2017-07-19 13:38:02 -070085
Zhi Huange830e682018-03-30 10:48:35 -070086 virtual bool IsSrtpActive() const = 0;
Steve Antondb67ba12018-03-19 17:41:42 -070087
88 virtual void SetMetricsObserver(
89 rtc::scoped_refptr<MetricsObserverInterface> metrics_observer) = 0;
zstein398c3fd2017-07-19 13:38:02 -070090};
91
92} // namespace webrtc
93
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020094#endif // PC_RTPTRANSPORTINTERNAL_H_