Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: webrtc/api/peerconnection.h

Issue 1713043002: Late initialize MediaController, for less resource i.e. ProcessThread, usage by PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: some comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/api/peerconnection.cc » ('j') | webrtc/api/peerconnection.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_API_PEERCONNECTION_H_ 11 #ifndef WEBRTC_API_PEERCONNECTION_H_
12 #define WEBRTC_API_PEERCONNECTION_H_ 12 #define WEBRTC_API_PEERCONNECTION_H_
13 13
14 #include <string> 14 #include <string>
15 15
16 #include "webrtc/api/dtlsidentitystore.h" 16 #include "webrtc/api/dtlsidentitystore.h"
17 #include "webrtc/api/mediaconstraintsinterface.h"
17 #include "webrtc/api/peerconnectionfactory.h" 18 #include "webrtc/api/peerconnectionfactory.h"
18 #include "webrtc/api/peerconnectioninterface.h" 19 #include "webrtc/api/peerconnectioninterface.h"
19 #include "webrtc/api/rtpreceiverinterface.h" 20 #include "webrtc/api/rtpreceiverinterface.h"
20 #include "webrtc/api/rtpsenderinterface.h" 21 #include "webrtc/api/rtpsenderinterface.h"
21 #include "webrtc/api/statscollector.h" 22 #include "webrtc/api/statscollector.h"
22 #include "webrtc/api/streamcollection.h" 23 #include "webrtc/api/streamcollection.h"
23 #include "webrtc/api/webrtcsession.h" 24 #include "webrtc/api/webrtcsession.h"
25 #include "webrtc/base/constructormagic.h"
24 #include "webrtc/base/scoped_ptr.h" 26 #include "webrtc/base/scoped_ptr.h"
25 27
26 namespace webrtc { 28 namespace webrtc {
27 29
28 class MediaStreamObserver; 30 class MediaStreamObserver;
29 class RemoteMediaStreamFactory; 31 class RemoteMediaStreamFactory;
30 32
31 // Populates |session_options| from |rtc_options|, and returns true if options 33 // Populates |session_options| from |rtc_options|, and returns true if options
32 // are valid. 34 // are valid.
33 // |session_options|->transport_options map entries must exist in order for 35 // |session_options|->transport_options map entries must exist in order for
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 rtc::scoped_refptr<StreamCollectionInterface> local_streams() override; 69 rtc::scoped_refptr<StreamCollectionInterface> local_streams() override;
68 rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override; 70 rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override;
69 bool AddStream(MediaStreamInterface* local_stream) override; 71 bool AddStream(MediaStreamInterface* local_stream) override;
70 void RemoveStream(MediaStreamInterface* local_stream) override; 72 void RemoveStream(MediaStreamInterface* local_stream) override;
71 73
72 rtc::scoped_refptr<RtpSenderInterface> AddTrack( 74 rtc::scoped_refptr<RtpSenderInterface> AddTrack(
73 MediaStreamTrackInterface* track, 75 MediaStreamTrackInterface* track,
74 std::vector<MediaStreamInterface*> streams) override; 76 std::vector<MediaStreamInterface*> streams) override;
75 bool RemoveTrack(RtpSenderInterface* sender) override; 77 bool RemoveTrack(RtpSenderInterface* sender) override;
76 78
77 virtual WebRtcSession* session() { return session_.get(); } 79 // This is virtual so it can be mocked.
80 virtual WebRtcSession* session();
78 81
79 rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( 82 rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
80 AudioTrackInterface* track) override; 83 AudioTrackInterface* track) override;
81 84
82 rtc::scoped_refptr<RtpSenderInterface> CreateSender( 85 rtc::scoped_refptr<RtpSenderInterface> CreateSender(
83 const std::string& kind, 86 const std::string& kind,
84 const std::string& stream_id) override; 87 const std::string& stream_id) override;
85 88
86 std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders() 89 std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
87 const override; 90 const override;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 bool operator==(const TrackInfo& other) { 146 bool operator==(const TrackInfo& other) {
144 return this->stream_label == other.stream_label && 147 return this->stream_label == other.stream_label &&
145 this->track_id == other.track_id && this->ssrc == other.ssrc; 148 this->track_id == other.track_id && this->ssrc == other.ssrc;
146 } 149 }
147 std::string stream_label; 150 std::string stream_label;
148 std::string track_id; 151 std::string track_id;
149 uint32_t ssrc; 152 uint32_t ssrc;
150 }; 153 };
151 typedef std::vector<TrackInfo> TrackInfos; 154 typedef std::vector<TrackInfo> TrackInfos;
152 155
156 class StoredConstraints;
157 class LiveSession;
158
153 // Implements MessageHandler. 159 // Implements MessageHandler.
154 void OnMessage(rtc::Message* msg) override; 160 void OnMessage(rtc::Message* msg) override;
155 161
156 void CreateAudioReceiver(MediaStreamInterface* stream, 162 void CreateAudioReceiver(MediaStreamInterface* stream,
157 AudioTrackInterface* audio_track, 163 AudioTrackInterface* audio_track,
158 uint32_t ssrc); 164 uint32_t ssrc);
159 void CreateVideoReceiver(MediaStreamInterface* stream, 165 void CreateVideoReceiver(MediaStreamInterface* stream,
160 VideoTrackInterface* video_track, 166 VideoTrackInterface* video_track,
161 uint32_t ssrc); 167 uint32_t ssrc);
162 void DestroyAudioReceiver(MediaStreamInterface* stream, 168 void DestroyAudioReceiver(MediaStreamInterface* stream,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 TrackInfos* GetRemoteTracks(cricket::MediaType media_type); 328 TrackInfos* GetRemoteTracks(cricket::MediaType media_type);
323 TrackInfos* GetLocalTracks(cricket::MediaType media_type); 329 TrackInfos* GetLocalTracks(cricket::MediaType media_type);
324 const TrackInfo* FindTrackInfo(const TrackInfos& infos, 330 const TrackInfo* FindTrackInfo(const TrackInfos& infos,
325 const std::string& stream_label, 331 const std::string& stream_label,
326 const std::string track_id) const; 332 const std::string track_id) const;
327 333
328 // Returns the specified SCTP DataChannel in sctp_data_channels_, 334 // Returns the specified SCTP DataChannel in sctp_data_channels_,
329 // or nullptr if not found. 335 // or nullptr if not found.
330 DataChannel* FindDataChannelBySid(int sid) const; 336 DataChannel* FindDataChannelBySid(int sid) const;
331 337
338 void CreateLiveSession();
339 void DestroyLiveSession();
340 const WebRtcSession* session() const;
341 RemoteMediaStreamFactory* remote_stream_factory();
342 StatsCollector* stats();
343
332 // Storing the factory as a scoped reference pointer ensures that the memory 344 // Storing the factory as a scoped reference pointer ensures that the memory
333 // in the PeerConnectionFactoryImpl remains available as long as the 345 // in the PeerConnectionFactoryImpl remains available as long as the
334 // PeerConnection is running. It is passed to PeerConnection as a raw pointer. 346 // PeerConnection is running. It is passed to PeerConnection as a raw pointer.
335 // However, since the reference counting is done in the 347 // However, since the reference counting is done in the
336 // PeerConnectionFactoryInterface all instances created using the raw pointer 348 // PeerConnectionFactoryInterface all instances created using the raw pointer
337 // will refer to the same reference count. 349 // will refer to the same reference count.
338 rtc::scoped_refptr<PeerConnectionFactory> factory_; 350 rtc::scoped_refptr<PeerConnectionFactory> factory_;
339 PeerConnectionObserver* observer_; 351 PeerConnectionObserver* observer_;
340 UMAObserver* uma_observer_; 352 UMAObserver* uma_observer_;
341 SignalingState signaling_state_; 353 SignalingState signaling_state_;
342 // TODO(bemasc): Remove ice_state_. 354 // TODO(bemasc): Remove ice_state_.
343 IceState ice_state_; 355 IceState ice_state_;
344 IceConnectionState ice_connection_state_; 356 IceConnectionState ice_connection_state_;
345 IceGatheringState ice_gathering_state_; 357 IceGatheringState ice_gathering_state_;
346 358
347 rtc::scoped_ptr<cricket::PortAllocator> port_allocator_; 359 rtc::scoped_ptr<cricket::PortAllocator> port_allocator_;
348 rtc::scoped_ptr<MediaControllerInterface> media_controller_;
349 360
350 // Streams added via AddStream. 361 // Streams added via AddStream.
351 rtc::scoped_refptr<StreamCollection> local_streams_; 362 rtc::scoped_refptr<StreamCollection> local_streams_;
352 // Streams created as a result of SetRemoteDescription. 363 // Streams created as a result of SetRemoteDescription.
353 rtc::scoped_refptr<StreamCollection> remote_streams_; 364 rtc::scoped_refptr<StreamCollection> remote_streams_;
354 365
355 std::vector<rtc::scoped_ptr<MediaStreamObserver>> stream_observers_; 366 std::vector<rtc::scoped_ptr<MediaStreamObserver>> stream_observers_;
356 367
357 // These lists store track info seen in local/remote descriptions. 368 // These lists store track info seen in local/remote descriptions.
358 TrackInfos remote_audio_tracks_; 369 TrackInfos remote_audio_tracks_;
359 TrackInfos remote_video_tracks_; 370 TrackInfos remote_video_tracks_;
360 TrackInfos local_audio_tracks_; 371 TrackInfos local_audio_tracks_;
361 TrackInfos local_video_tracks_; 372 TrackInfos local_video_tracks_;
362 373
363 SctpSidAllocator sid_allocator_; 374 SctpSidAllocator sid_allocator_;
364 // label -> DataChannel 375 // label -> DataChannel
365 std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_; 376 std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_;
366 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_; 377 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_;
367 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_to_free_; 378 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_to_free_;
368 379
369 bool remote_peer_supports_msid_ = false; 380 bool remote_peer_supports_msid_ = false;
370 rtc::scoped_ptr<RemoteMediaStreamFactory> remote_stream_factory_;
371 381
372 std::vector<rtc::scoped_refptr<RtpSenderInterface>> senders_; 382 std::vector<rtc::scoped_refptr<RtpSenderInterface>> senders_;
373 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> receivers_; 383 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> receivers_;
374 384
375 // The session_ scoped_ptr is declared at the bottom of PeerConnection 385 cricket::MediaConfig media_config_;
386 PeerConnectionInterface::RTCConfiguration configuration_;
387 rtc::scoped_ptr<StoredConstraints> constraints_;
388 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store_;
389
390 // The live_session_ scoped_ptr is declared at the bottom of PeerConnection
376 // because its destruction fires signals (such as VoiceChannelDestroyed) 391 // because its destruction fires signals (such as VoiceChannelDestroyed)
377 // which will trigger some final actions in PeerConnection... 392 // which will trigger some final actions in PeerConnection...
378 rtc::scoped_ptr<WebRtcSession> session_; 393 rtc::scoped_ptr<LiveSession> live_session_;
379 // ... But stats_ depends on session_ so it should be destroyed even earlier. 394
380 rtc::scoped_ptr<StatsCollector> stats_; 395 RTC_DISALLOW_COPY_AND_ASSIGN(PeerConnection);
381 }; 396 };
382 397
383 } // namespace webrtc 398 } // namespace webrtc
384 399
385 #endif // WEBRTC_API_PEERCONNECTION_H_ 400 #endif // WEBRTC_API_PEERCONNECTION_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/peerconnection.cc » ('j') | webrtc/api/peerconnection.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698