xref: /aosp_15_r20/external/webrtc/pc/peer_connection_proxy.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2012 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_PEER_CONNECTION_PROXY_H_
12 #define PC_PEER_CONNECTION_PROXY_H_
13 
14 #include <memory>
15 #include <string>
16 #include <vector>
17 
18 #include "api/peer_connection_interface.h"
19 #include "pc/proxy.h"
20 
21 namespace webrtc {
22 
23 // PeerConnection proxy objects will be constructed with two thread pointers,
24 // signaling and network. The proxy macros don't have 'network' specific macros
25 // and support for a secondary thread is provided via 'SECONDARY' macros.
26 // TODO(deadbeef): Move this to .cc file. What threads methods are called on is
27 // an implementation detail.
28 BEGIN_PROXY_MAP(PeerConnection)
29 PROXY_PRIMARY_THREAD_DESTRUCTOR()
30 PROXY_METHOD0(rtc::scoped_refptr<StreamCollectionInterface>, local_streams)
31 PROXY_METHOD0(rtc::scoped_refptr<StreamCollectionInterface>, remote_streams)
32 PROXY_METHOD1(bool, AddStream, MediaStreamInterface*)
33 PROXY_METHOD1(void, RemoveStream, MediaStreamInterface*)
34 PROXY_METHOD2(RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>,
35               AddTrack,
36               rtc::scoped_refptr<MediaStreamTrackInterface>,
37               const std::vector<std::string>&)
38 PROXY_METHOD3(RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>>,
39               AddTrack,
40               rtc::scoped_refptr<MediaStreamTrackInterface>,
41               const std::vector<std::string>&,
42               const std::vector<RtpEncodingParameters>&)
43 PROXY_METHOD1(RTCError,
44               RemoveTrackOrError,
45               rtc::scoped_refptr<RtpSenderInterface>)
46 PROXY_METHOD1(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
47               AddTransceiver,
48               rtc::scoped_refptr<MediaStreamTrackInterface>)
49 PROXY_METHOD2(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
50               AddTransceiver,
51               rtc::scoped_refptr<MediaStreamTrackInterface>,
52               const RtpTransceiverInit&)
53 PROXY_METHOD1(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
54               AddTransceiver,
55               cricket::MediaType)
56 PROXY_METHOD2(RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>,
57               AddTransceiver,
58               cricket::MediaType,
59               const RtpTransceiverInit&)
60 PROXY_METHOD2(rtc::scoped_refptr<RtpSenderInterface>,
61               CreateSender,
62               const std::string&,
63               const std::string&)
64 PROXY_CONSTMETHOD0(std::vector<rtc::scoped_refptr<RtpSenderInterface>>,
65                    GetSenders)
66 PROXY_CONSTMETHOD0(std::vector<rtc::scoped_refptr<RtpReceiverInterface>>,
67                    GetReceivers)
68 PROXY_CONSTMETHOD0(std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>,
69                    GetTransceivers)
70 PROXY_METHOD3(bool,
71               GetStats,
72               StatsObserver*,
73               MediaStreamTrackInterface*,
74               StatsOutputLevel)
75 PROXY_METHOD1(void, GetStats, RTCStatsCollectorCallback*)
76 PROXY_METHOD2(void,
77               GetStats,
78               rtc::scoped_refptr<RtpSenderInterface>,
79               rtc::scoped_refptr<RTCStatsCollectorCallback>)
80 PROXY_METHOD2(void,
81               GetStats,
82               rtc::scoped_refptr<RtpReceiverInterface>,
83               rtc::scoped_refptr<RTCStatsCollectorCallback>)
84 PROXY_METHOD0(void, ClearStatsCache)
85 PROXY_METHOD2(RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>>,
86               CreateDataChannelOrError,
87               const std::string&,
88               const DataChannelInit*)
89 PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, local_description)
90 PROXY_CONSTMETHOD0(const SessionDescriptionInterface*, remote_description)
91 PROXY_CONSTMETHOD0(const SessionDescriptionInterface*,
92                    current_local_description)
93 PROXY_CONSTMETHOD0(const SessionDescriptionInterface*,
94                    current_remote_description)
95 PROXY_CONSTMETHOD0(const SessionDescriptionInterface*,
96                    pending_local_description)
97 PROXY_CONSTMETHOD0(const SessionDescriptionInterface*,
98                    pending_remote_description)
99 PROXY_METHOD0(void, RestartIce)
100 PROXY_METHOD2(void,
101               CreateOffer,
102               CreateSessionDescriptionObserver*,
103               const RTCOfferAnswerOptions&)
104 PROXY_METHOD2(void,
105               CreateAnswer,
106               CreateSessionDescriptionObserver*,
107               const RTCOfferAnswerOptions&)
108 PROXY_METHOD2(void,
109               SetLocalDescription,
110               std::unique_ptr<SessionDescriptionInterface>,
111               rtc::scoped_refptr<SetLocalDescriptionObserverInterface>)
112 PROXY_METHOD1(void,
113               SetLocalDescription,
114               rtc::scoped_refptr<SetLocalDescriptionObserverInterface>)
115 PROXY_METHOD2(void,
116               SetLocalDescription,
117               SetSessionDescriptionObserver*,
118               SessionDescriptionInterface*)
119 PROXY_METHOD1(void, SetLocalDescription, SetSessionDescriptionObserver*)
120 PROXY_METHOD2(void,
121               SetRemoteDescription,
122               std::unique_ptr<SessionDescriptionInterface>,
123               rtc::scoped_refptr<SetRemoteDescriptionObserverInterface>)
124 PROXY_METHOD2(void,
125               SetRemoteDescription,
126               SetSessionDescriptionObserver*,
127               SessionDescriptionInterface*)
128 PROXY_METHOD1(bool, ShouldFireNegotiationNeededEvent, uint32_t)
129 PROXY_METHOD0(PeerConnectionInterface::RTCConfiguration, GetConfiguration)
130 PROXY_METHOD1(RTCError,
131               SetConfiguration,
132               const PeerConnectionInterface::RTCConfiguration&)
133 PROXY_METHOD1(bool, AddIceCandidate, const IceCandidateInterface*)
134 PROXY_METHOD2(void,
135               AddIceCandidate,
136               std::unique_ptr<IceCandidateInterface>,
137               std::function<void(RTCError)>)
138 PROXY_METHOD1(bool, RemoveIceCandidates, const std::vector<cricket::Candidate>&)
139 PROXY_METHOD1(RTCError, SetBitrate, const BitrateSettings&)
140 PROXY_METHOD1(void, SetAudioPlayout, bool)
141 PROXY_METHOD1(void, SetAudioRecording, bool)
142 // This method will be invoked on the network thread. See
143 // PeerConnectionFactory::CreatePeerConnectionOrError for more details.
144 PROXY_SECONDARY_METHOD1(rtc::scoped_refptr<DtlsTransportInterface>,
145                         LookupDtlsTransportByMid,
146                         const std::string&)
147 // This method will be invoked on the network thread. See
148 // PeerConnectionFactory::CreatePeerConnectionOrError for more details.
149 PROXY_SECONDARY_CONSTMETHOD0(rtc::scoped_refptr<SctpTransportInterface>,
150                              GetSctpTransport)
151 PROXY_METHOD0(SignalingState, signaling_state)
152 PROXY_METHOD0(IceConnectionState, ice_connection_state)
153 PROXY_METHOD0(IceConnectionState, standardized_ice_connection_state)
154 PROXY_METHOD0(PeerConnectionState, peer_connection_state)
155 PROXY_METHOD0(IceGatheringState, ice_gathering_state)
156 PROXY_METHOD0(absl::optional<bool>, can_trickle_ice_candidates)
157 PROXY_METHOD1(void, AddAdaptationResource, rtc::scoped_refptr<Resource>)
158 PROXY_METHOD2(bool,
159               StartRtcEventLog,
160               std::unique_ptr<RtcEventLogOutput>,
161               int64_t)
162 PROXY_METHOD1(bool, StartRtcEventLog, std::unique_ptr<RtcEventLogOutput>)
163 PROXY_METHOD0(void, StopRtcEventLog)
164 PROXY_METHOD0(void, Close)
165 BYPASS_PROXY_CONSTMETHOD0(rtc::Thread*, signaling_thread)
166 END_PROXY_MAP(PeerConnection)
167 
168 }  // namespace webrtc
169 
170 #endif  // PC_PEER_CONNECTION_PROXY_H_
171