blob: 7f06afed44cde15d9dc6cbf626f1adeb5dd71680 [file] [log] [blame]
Steve Anton2d8609c2018-01-23 16:38:46 -08001/*
2 * Copyright 2018 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_PEERCONNECTIONINTERNAL_H_
12#define PC_PEERCONNECTIONINTERNAL_H_
13
14#include <map>
15#include <memory>
16#include <string>
17#include <vector>
18
19#include "api/peerconnectioninterface.h"
20#include "pc/datachannel.h"
21#include "pc/rtptransceiver.h"
22
23namespace webrtc {
24
25// Statistics for all the transports of the session.
26// TODO(pthatcher): Think of a better name for this. We already have
27// a TransportStats in transport.h. Perhaps TransportsStats?
28struct SessionStats {
29 std::map<std::string, cricket::TransportStats> transport_stats;
30};
31
32struct ChannelNamePair {
33 ChannelNamePair(const std::string& content_name,
34 const std::string& transport_name)
35 : content_name(content_name), transport_name(transport_name) {}
36 std::string content_name;
37 std::string transport_name;
38};
39
40struct ChannelNamePairs {
41 rtc::Optional<ChannelNamePair> voice;
42 rtc::Optional<ChannelNamePair> video;
43 rtc::Optional<ChannelNamePair> data;
44};
45
46// Internal interface for extra PeerConnection methods.
47class PeerConnectionInternal : public PeerConnectionInterface {
48 public:
49 virtual rtc::Thread* network_thread() const = 0;
50 virtual rtc::Thread* worker_thread() const = 0;
51 virtual rtc::Thread* signaling_thread() const = 0;
52
53 // The SDP session ID as defined by RFC 3264.
Steve Antonbe5e2082018-01-24 15:29:17 -080054 virtual std::string session_id() const = 0;
Steve Anton2d8609c2018-01-23 16:38:46 -080055
56 // Returns true if we were the initial offerer.
57 virtual bool initial_offerer() const = 0;
58
59 // TODO(steveanton): Remove these.
60 virtual cricket::VoiceChannel* voice_channel() const = 0;
61 virtual cricket::VideoChannel* video_channel() const = 0;
62
63 // Exposed for tests.
64 virtual std::vector<
65 rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
66 GetTransceiversForTesting() const = 0;
67
68 // Get the id used as a media stream track's "id" field from ssrc.
69 virtual bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id) = 0;
70 virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id) = 0;
71
72 virtual sigslot::signal1<DataChannel*>& SignalDataChannelCreated() = 0;
73
74 // Only valid when using deprecated RTP data channels.
75 virtual cricket::RtpDataChannel* rtp_data_channel() const = 0;
76
Steve Antonbe5e2082018-01-24 15:29:17 -080077 virtual std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels()
78 const = 0;
Steve Anton2d8609c2018-01-23 16:38:46 -080079
80 virtual rtc::Optional<std::string> sctp_content_name() const = 0;
81 virtual rtc::Optional<std::string> sctp_transport_name() const = 0;
82
83 // Returns stats for all channels of all transports.
84 // This avoids exposing the internal structures used to track them.
85 // The parameterless version creates |ChannelNamePairs| from |voice_channel|,
86 // |video_channel| and |voice_channel| if available - this requires it to be
87 // called on the signaling thread - and invokes the other |GetStats|. The
88 // other |GetStats| can be invoked on any thread; if not invoked on the
89 // network thread a thread hop will happen.
90 virtual std::unique_ptr<SessionStats> GetSessionStats_s() = 0;
91 virtual std::unique_ptr<SessionStats> GetSessionStats(
92 const ChannelNamePairs& channel_name_pairs) = 0;
93
94 virtual Call::Stats GetCallStats() = 0;
95
96 virtual bool GetLocalCertificate(
97 const std::string& transport_name,
98 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) = 0;
99 virtual std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate(
100 const std::string& transport_name) = 0;
101
102 // Returns true if there was an ICE restart initiated by the remote offer.
103 virtual bool IceRestartPending(const std::string& content_name) const = 0;
104
105 // Returns true if the ICE restart flag above was set, and no ICE restart has
106 // occurred yet for this transport (by applying a local description with
107 // changed ufrag/password). If the transport has been deleted as a result of
108 // bundling, returns false.
109 virtual bool NeedsIceRestart(const std::string& content_name) const = 0;
110
111 // Get SSL role for an arbitrary m= section (handles bundling correctly).
112 virtual bool GetSslRole(const std::string& content_name,
113 rtc::SSLRole* role) = 0;
114};
115
116} // namespace webrtc
117
118#endif // PC_PEERCONNECTIONINTERNAL_H_