blob: f8a5f2bb1a07a508cd4b854bfc5f58da91c722f3 [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
Steve Anton10542f22019-01-11 09:11:00 -080011#ifndef PC_RTP_TRANSPORT_INTERNAL_H_
12#define PC_RTP_TRANSPORT_INTERNAL_H_
zstein398c3fd2017-07-19 13:38:02 -070013
Zhi Huang942bc2e2017-11-13 13:26:07 -080014#include <string>
15
Steve Anton10542f22019-01-11 09:11:00 -080016#include "api/ortc/srtp_transport_interface.h"
Zhi Huang365381f2018-04-13 16:44:34 -070017#include "call/rtp_demuxer.h"
Steve Anton10542f22019-01-11 09:11:00 -080018#include "p2p/base/ice_transport_internal.h"
19#include "pc/session_description.h"
20#include "rtc_base/network_route.h"
21#include "rtc_base/ssl_stream_adapter.h"
Artem Titove41c4332018-07-25 15:04:28 +020022#include "rtc_base/third_party/sigslot/sigslot.h"
zstein398c3fd2017-07-19 13:38:02 -070023
24namespace rtc {
25class CopyOnWriteBuffer;
26struct PacketOptions;
zstein398c3fd2017-07-19 13:38:02 -070027} // 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 Huang365381f2018-04-13 16:44:34 -070058 // Called whenever an RTCP packet is received. There is no equivalent signal
59 // for RTP packets because they would be forwarded to the BaseChannel through
60 // the RtpDemuxer callback.
Niels Möllere6933812018-11-05 13:01:41 +010061 sigslot::signal2<rtc::CopyOnWriteBuffer*, int64_t> SignalRtcpPacketReceived;
zstein398c3fd2017-07-19 13:38:02 -070062
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080063 // Called whenever the network route of the P2P layer transport changes.
64 // The argument is an optional network route.
Danil Chapovalov66cadcc2018-06-19 16:47:43 +020065 sigslot::signal1<absl::optional<rtc::NetworkRoute>> SignalNetworkRouteChanged;
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080066
Zhi Huangf2d7beb2017-11-20 14:35:11 -080067 // Called whenever a transport's writable state might change. The argument is
68 // true if the transport is writable, otherwise it is false.
69 sigslot::signal1<bool> SignalWritableState;
70
Zhi Huangcd3fc5d2017-11-29 10:41:57 -080071 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket;
Zhi Huang942bc2e2017-11-13 13:26:07 -080072
zstein398c3fd2017-07-19 13:38:02 -070073 virtual bool IsWritable(bool rtcp) const = 0;
74
Zhi Huangf2d7beb2017-11-20 14:35:11 -080075 // TODO(zhihuang): Pass the |packet| by copy so that the original data
76 // wouldn't be modified.
Zhi Huangcf990f52017-09-22 12:12:30 -070077 virtual bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet,
78 const rtc::PacketOptions& options,
79 int flags) = 0;
80
81 virtual bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet,
82 const rtc::PacketOptions& options,
83 int flags) = 0;
zstein398c3fd2017-07-19 13:38:02 -070084
Zhi Huang365381f2018-04-13 16:44:34 -070085 // This method updates the RTP header extension map so that the RTP transport
86 // can parse the received packets and identify the MID. This is called by the
87 // BaseChannel when setting the content description.
88 //
89 // TODO(zhihuang): Merging and replacing following methods handling header
90 // extensions with SetParameters:
91 // UpdateRtpHeaderExtensionMap,
92 // UpdateSendEncryptedHeaderExtensionIds,
93 // UpdateRecvEncryptedHeaderExtensionIds,
94 // CacheRtpAbsSendTimeHeaderExtension,
95 virtual void UpdateRtpHeaderExtensionMap(
96 const cricket::RtpHeaderExtensions& header_extensions) = 0;
97
Zhi Huange830e682018-03-30 10:48:35 -070098 virtual bool IsSrtpActive() const = 0;
Steve Antondb67ba12018-03-19 17:41:42 -070099
Zhi Huang365381f2018-04-13 16:44:34 -0700100 virtual bool RegisterRtpDemuxerSink(const RtpDemuxerCriteria& criteria,
101 RtpPacketSinkInterface* sink) = 0;
102
103 virtual bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) = 0;
zstein398c3fd2017-07-19 13:38:02 -0700104};
105
106} // namespace webrtc
107
Steve Anton10542f22019-01-11 09:11:00 -0800108#endif // PC_RTP_TRANSPORT_INTERNAL_H_