OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include <memory> | 34 #include <memory> |
35 #include "bindings/core/v8/ActiveScriptWrappable.h" | 35 #include "bindings/core/v8/ActiveScriptWrappable.h" |
36 #include "bindings/core/v8/ScriptPromise.h" | 36 #include "bindings/core/v8/ScriptPromise.h" |
37 #include "core/dom/SuspendableObject.h" | 37 #include "core/dom/SuspendableObject.h" |
38 #include "modules/EventTargetModules.h" | 38 #include "modules/EventTargetModules.h" |
39 #include "modules/crypto/NormalizeAlgorithm.h" | 39 #include "modules/crypto/NormalizeAlgorithm.h" |
40 #include "modules/mediastream/MediaStream.h" | 40 #include "modules/mediastream/MediaStream.h" |
41 #include "modules/peerconnection/RTCIceCandidate.h" | 41 #include "modules/peerconnection/RTCIceCandidate.h" |
42 #include "platform/AsyncMethodRunner.h" | 42 #include "platform/AsyncMethodRunner.h" |
43 #include "platform/WebFrameScheduler.h" | 43 #include "platform/WebFrameScheduler.h" |
| 44 #include "platform/heap/HeapAllocator.h" |
44 #include "public/platform/WebMediaConstraints.h" | 45 #include "public/platform/WebMediaConstraints.h" |
45 #include "public/platform/WebRTCPeerConnectionHandler.h" | 46 #include "public/platform/WebRTCPeerConnectionHandler.h" |
46 #include "public/platform/WebRTCPeerConnectionHandlerClient.h" | 47 #include "public/platform/WebRTCPeerConnectionHandlerClient.h" |
47 | 48 |
48 namespace blink { | 49 namespace blink { |
49 class ExceptionState; | 50 class ExceptionState; |
50 class MediaStreamTrack; | 51 class MediaStreamTrack; |
51 class RTCAnswerOptions; | 52 class RTCAnswerOptions; |
52 class RTCConfiguration; | 53 class RTCConfiguration; |
53 class RTCDTMFSender; | 54 class RTCDTMFSender; |
54 class RTCDataChannel; | 55 class RTCDataChannel; |
55 class RTCIceCandidateInitOrRTCIceCandidate; | 56 class RTCIceCandidateInitOrRTCIceCandidate; |
56 class RTCOfferOptions; | 57 class RTCOfferOptions; |
57 class RTCPeerConnectionErrorCallback; | 58 class RTCPeerConnectionErrorCallback; |
| 59 class RTCRtpReceiver; |
58 class RTCSessionDescription; | 60 class RTCSessionDescription; |
59 class RTCSessionDescriptionCallback; | 61 class RTCSessionDescriptionCallback; |
60 class RTCSessionDescriptionInit; | 62 class RTCSessionDescriptionInit; |
61 class RTCStatsCallback; | 63 class RTCStatsCallback; |
62 class ScriptState; | 64 class ScriptState; |
63 class VoidCallback; | 65 class VoidCallback; |
64 struct WebRTCConfiguration; | 66 struct WebRTCConfiguration; |
65 | 67 |
66 class RTCPeerConnection final : public EventTargetWithInlineData, | 68 class RTCPeerConnection final : public EventTargetWithInlineData, |
67 public WebRTCPeerConnectionHandlerClient, | 69 public WebRTCPeerConnectionHandlerClient, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 const Dictionary& mediaConstraints, | 142 const Dictionary& mediaConstraints, |
141 ExceptionState&); | 143 ExceptionState&); |
142 | 144 |
143 void removeStream(MediaStream*, ExceptionState&); | 145 void removeStream(MediaStream*, ExceptionState&); |
144 | 146 |
145 ScriptPromise getStats(ScriptState*, | 147 ScriptPromise getStats(ScriptState*, |
146 RTCStatsCallback* successCallback, | 148 RTCStatsCallback* successCallback, |
147 MediaStreamTrack* selector = nullptr); | 149 MediaStreamTrack* selector = nullptr); |
148 ScriptPromise getStats(ScriptState*); | 150 ScriptPromise getStats(ScriptState*); |
149 | 151 |
| 152 HeapVector<Member<RTCRtpReceiver>> getReceivers(); |
| 153 |
150 RTCDataChannel* createDataChannel(ScriptState*, | 154 RTCDataChannel* createDataChannel(ScriptState*, |
151 String label, | 155 String label, |
152 const Dictionary& dataChannelDict, | 156 const Dictionary& dataChannelDict, |
153 ExceptionState&); | 157 ExceptionState&); |
154 | 158 |
155 RTCDTMFSender* createDTMFSender(MediaStreamTrack*, ExceptionState&); | 159 RTCDTMFSender* createDTMFSender(MediaStreamTrack*, ExceptionState&); |
156 | 160 |
157 void close(ExceptionState&); | 161 void close(ExceptionState&); |
158 | 162 |
159 // We allow getStats after close, but not other calls or callbacks. | 163 // We allow getStats after close, but not other calls or callbacks. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 RTCPeerConnection(ExecutionContext*, | 220 RTCPeerConnection(ExecutionContext*, |
217 const WebRTCConfiguration&, | 221 const WebRTCConfiguration&, |
218 WebMediaConstraints, | 222 WebMediaConstraints, |
219 ExceptionState&); | 223 ExceptionState&); |
220 void dispose(); | 224 void dispose(); |
221 | 225 |
222 void scheduleDispatchEvent(Event*); | 226 void scheduleDispatchEvent(Event*); |
223 void scheduleDispatchEvent(Event*, std::unique_ptr<BoolFunction>); | 227 void scheduleDispatchEvent(Event*, std::unique_ptr<BoolFunction>); |
224 void dispatchScheduledEvent(); | 228 void dispatchScheduledEvent(); |
225 bool hasLocalStreamWithTrackId(const String& trackId); | 229 bool hasLocalStreamWithTrackId(const String& trackId); |
| 230 MediaStreamTrack* getRemoteTrackById(const String& trackId) const; |
| 231 // Receivers returned by the handler are in use by the peer connection, a |
| 232 // receiver that is no longer in use is permanently inactive and does not need |
| 233 // to be referenced anymore. Removes such receivers from |m_rtpReceivers|. |
| 234 void removeInactiveReceivers(); |
226 | 235 |
227 void changeSignalingState(WebRTCPeerConnectionHandlerClient::SignalingState); | 236 void changeSignalingState(WebRTCPeerConnectionHandlerClient::SignalingState); |
228 void changeIceGatheringState( | 237 void changeIceGatheringState( |
229 WebRTCPeerConnectionHandlerClient::ICEGatheringState); | 238 WebRTCPeerConnectionHandlerClient::ICEGatheringState); |
230 // Changes the state immediately; does not fire an event. | 239 // Changes the state immediately; does not fire an event. |
231 // Returns true if the state was changed. | 240 // Returns true if the state was changed. |
232 bool setIceConnectionState( | 241 bool setIceConnectionState( |
233 WebRTCPeerConnectionHandlerClient::ICEConnectionState); | 242 WebRTCPeerConnectionHandlerClient::ICEConnectionState); |
234 // Changes the state asynchronously and fires an event immediately after | 243 // Changes the state asynchronously and fires an event immediately after |
235 // changing the state. | 244 // changing the state. |
236 void changeIceConnectionState( | 245 void changeIceConnectionState( |
237 WebRTCPeerConnectionHandlerClient::ICEConnectionState); | 246 WebRTCPeerConnectionHandlerClient::ICEConnectionState); |
238 | 247 |
239 void closeInternal(); | 248 void closeInternal(); |
240 | 249 |
241 void recordRapporMetrics(); | 250 void recordRapporMetrics(); |
242 | 251 |
243 SignalingState m_signalingState; | 252 SignalingState m_signalingState; |
244 ICEGatheringState m_iceGatheringState; | 253 ICEGatheringState m_iceGatheringState; |
245 ICEConnectionState m_iceConnectionState; | 254 ICEConnectionState m_iceConnectionState; |
246 | 255 |
| 256 // TODO(hbos): Move away from "addStream" and "removeStream" in favor of |
| 257 // "addTrack" and "removeTrack". Update tracks, senders and receivers on |
| 258 // relevant events. https://crbug.com/705901 |
247 MediaStreamVector m_localStreams; | 259 MediaStreamVector m_localStreams; |
248 MediaStreamVector m_remoteStreams; | 260 MediaStreamVector m_remoteStreams; |
| 261 HeapHashMap<uintptr_t, Member<RTCRtpReceiver>> m_rtpReceivers; |
249 | 262 |
250 std::unique_ptr<WebRTCPeerConnectionHandler> m_peerHandler; | 263 std::unique_ptr<WebRTCPeerConnectionHandler> m_peerHandler; |
251 | 264 |
252 Member<AsyncMethodRunner<RTCPeerConnection>> m_dispatchScheduledEventRunner; | 265 Member<AsyncMethodRunner<RTCPeerConnection>> m_dispatchScheduledEventRunner; |
253 HeapVector<Member<EventWrapper>> m_scheduledEvents; | 266 HeapVector<Member<EventWrapper>> m_scheduledEvents; |
254 | 267 |
255 // This handle notifies scheduler about an active connection associated | 268 // This handle notifies scheduler about an active connection associated |
256 // with a frame. Handle should be destroyed when connection is closed. | 269 // with a frame. Handle should be destroyed when connection is closed. |
257 std::unique_ptr<WebFrameScheduler::ActiveConnectionHandle> | 270 std::unique_ptr<WebFrameScheduler::ActiveConnectionHandle> |
258 m_connectionHandleForScheduler; | 271 m_connectionHandleForScheduler; |
259 | 272 |
260 bool m_stopped; | 273 bool m_stopped; |
261 bool m_closed; | 274 bool m_closed; |
262 | 275 |
263 bool m_hasDataChannels; // For RAPPOR metrics | 276 bool m_hasDataChannels; // For RAPPOR metrics |
264 }; | 277 }; |
265 | 278 |
266 } // namespace blink | 279 } // namespace blink |
267 | 280 |
268 #endif // RTCPeerConnection_h | 281 #endif // RTCPeerConnection_h |
OLD | NEW |