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

Side by Side Diff: content/renderer/media/media_stream_dependency_factory.cc

Issue 131763002: Adds MediaStreamSource, MediaStreamAudioSource and MediaStreamVideoCaptureDeviceSource (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unused file. Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/media_stream_dependency_factory.h" 5 #include "content/renderer/media/media_stream_dependency_factory.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "content/common/media/media_stream_messages.h" 12 #include "content/common/media/media_stream_messages.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/renderer/media/media_stream_audio_processor_options.h" 14 #include "content/renderer/media/media_stream_audio_processor_options.h"
15 #include "content/renderer/media/media_stream_source_extra_data.h" 15 #include "content/renderer/media/media_stream_audio_source.h"
16 #include "content/renderer/media/media_stream_track_extra_data.h" 16 #include "content/renderer/media/media_stream_track_extra_data.h"
17 #include "content/renderer/media/media_stream_video_source.h"
17 #include "content/renderer/media/media_stream_video_track.h" 18 #include "content/renderer/media/media_stream_video_track.h"
18 #include "content/renderer/media/peer_connection_identity_service.h" 19 #include "content/renderer/media/peer_connection_identity_service.h"
19 #include "content/renderer/media/rtc_media_constraints.h" 20 #include "content/renderer/media/rtc_media_constraints.h"
20 #include "content/renderer/media/rtc_peer_connection_handler.h" 21 #include "content/renderer/media/rtc_peer_connection_handler.h"
21 #include "content/renderer/media/rtc_video_capturer.h" 22 #include "content/renderer/media/rtc_video_capturer.h"
22 #include "content/renderer/media/rtc_video_decoder_factory.h" 23 #include "content/renderer/media/rtc_video_decoder_factory.h"
23 #include "content/renderer/media/rtc_video_encoder_factory.h" 24 #include "content/renderer/media/rtc_video_encoder_factory.h"
24 #include "content/renderer/media/webaudio_capturer_source.h" 25 #include "content/renderer/media/webaudio_capturer_source.h"
25 #include "content/renderer/media/webrtc_audio_device_impl.h" 26 #include "content/renderer/media/webrtc_audio_device_impl.h"
26 #include "content/renderer/media/webrtc_local_audio_track.h" 27 #include "content/renderer/media/webrtc_local_audio_track.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 private: 117 private:
117 scoped_refptr<P2PSocketDispatcher> socket_dispatcher_; 118 scoped_refptr<P2PSocketDispatcher> socket_dispatcher_;
118 // |network_manager_| and |socket_factory_| are a weak references, owned by 119 // |network_manager_| and |socket_factory_| are a weak references, owned by
119 // MediaStreamDependencyFactory. 120 // MediaStreamDependencyFactory.
120 talk_base::NetworkManager* network_manager_; 121 talk_base::NetworkManager* network_manager_;
121 talk_base::PacketSocketFactory* socket_factory_; 122 talk_base::PacketSocketFactory* socket_factory_;
122 // Raw ptr to the WebFrame that created the P2PPortAllocatorFactory. 123 // Raw ptr to the WebFrame that created the P2PPortAllocatorFactory.
123 blink::WebFrame* web_frame_; 124 blink::WebFrame* web_frame_;
124 }; 125 };
125 126
126 // SourceStateObserver is a help class used for observing the startup state
127 // transition of webrtc media sources such as a camera or microphone.
128 // An instance of the object deletes itself after use.
129 // Usage:
130 // 1. Create an instance of the object with the blink::WebMediaStream
131 // the observed sources belongs to a callback.
132 // 2. Add the sources to the observer using AddSource.
133 // 3. Call StartObserving()
134 // 4. The callback will be triggered when all sources have transitioned from
135 // webrtc::MediaSourceInterface::kInitializing.
136 class SourceStateObserver : public webrtc::ObserverInterface,
137 public base::NonThreadSafe {
138 public:
139 SourceStateObserver(
140 blink::WebMediaStream* web_stream,
141 const MediaStreamDependencyFactory::MediaSourcesCreatedCallback& callback)
142 : web_stream_(web_stream),
143 ready_callback_(callback),
144 live_(true) {
145 }
146
147 void AddSource(webrtc::MediaSourceInterface* source) {
148 DCHECK(CalledOnValidThread());
149 switch (source->state()) {
150 case webrtc::MediaSourceInterface::kInitializing:
151 sources_.push_back(source);
152 source->RegisterObserver(this);
153 break;
154 case webrtc::MediaSourceInterface::kLive:
155 // The source is already live so we don't need to wait for it.
156 break;
157 case webrtc::MediaSourceInterface::kEnded:
158 // The source have already failed.
159 live_ = false;
160 break;
161 default:
162 NOTREACHED();
163 }
164 }
165
166 void StartObservering() {
167 DCHECK(CalledOnValidThread());
168 CheckIfSourcesAreLive();
169 }
170
171 virtual void OnChanged() OVERRIDE {
172 DCHECK(CalledOnValidThread());
173 CheckIfSourcesAreLive();
174 }
175
176 private:
177 void CheckIfSourcesAreLive() {
178 ObservedSources::iterator it = sources_.begin();
179 while (it != sources_.end()) {
180 if ((*it)->state() != webrtc::MediaSourceInterface::kInitializing) {
181 live_ &= (*it)->state() == webrtc::MediaSourceInterface::kLive;
182 (*it)->UnregisterObserver(this);
183 it = sources_.erase(it);
184 } else {
185 ++it;
186 }
187 }
188 if (sources_.empty()) {
189 ready_callback_.Run(web_stream_, live_);
190 delete this;
191 }
192 }
193
194 blink::WebMediaStream* web_stream_;
195 MediaStreamDependencyFactory::MediaSourcesCreatedCallback ready_callback_;
196 bool live_;
197 typedef std::vector<scoped_refptr<webrtc::MediaSourceInterface> >
198 ObservedSources;
199 ObservedSources sources_;
200 };
201
202 MediaStreamDependencyFactory::MediaStreamDependencyFactory( 127 MediaStreamDependencyFactory::MediaStreamDependencyFactory(
203 P2PSocketDispatcher* p2p_socket_dispatcher) 128 P2PSocketDispatcher* p2p_socket_dispatcher)
204 : network_manager_(NULL), 129 : network_manager_(NULL),
205 #if defined(GOOGLE_TV) 130 #if defined(GOOGLE_TV)
206 decoder_factory_tv_(NULL), 131 decoder_factory_tv_(NULL),
207 #endif 132 #endif
208 p2p_socket_dispatcher_(p2p_socket_dispatcher), 133 p2p_socket_dispatcher_(p2p_socket_dispatcher),
209 signaling_thread_(NULL), 134 signaling_thread_(NULL),
210 worker_thread_(NULL), 135 worker_thread_(NULL),
211 chrome_worker_thread_("Chrome_libJingle_WorkerThread"), 136 chrome_worker_thread_("Chrome_libJingle_WorkerThread"),
(...skipping 13 matching lines...) Expand all
225 // The histogram counts the number of calls to the JS API 150 // The histogram counts the number of calls to the JS API
226 // webKitRTCPeerConnection. 151 // webKitRTCPeerConnection.
227 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION); 152 UpdateWebRTCMethodCount(WEBKIT_RTC_PEER_CONNECTION);
228 153
229 if (!EnsurePeerConnectionFactory()) 154 if (!EnsurePeerConnectionFactory())
230 return NULL; 155 return NULL;
231 156
232 return new RTCPeerConnectionHandler(client, this); 157 return new RTCPeerConnectionHandler(client, this);
233 } 158 }
234 159
235 void MediaStreamDependencyFactory::CreateNativeMediaSources( 160 bool MediaStreamDependencyFactory::CreateNativeMediaStreamAudioSources(
236 int render_view_id, 161 int render_view_id,
237 const blink::WebMediaConstraints& audio_constraints, 162 const blink::WebMediaConstraints& audio_constraints,
238 const blink::WebMediaConstraints& video_constraints, 163 const blink::WebVector<blink::WebMediaStreamSource>& audio_sources) {
239 blink::WebMediaStream* web_stream, 164 DVLOG(1) << "CreateNativeMediaStreamAudioSources()";
240 const MediaSourcesCreatedCallback& sources_created) {
241 DVLOG(1) << "MediaStreamDependencyFactory::CreateNativeMediaSources()";
242 if (!EnsurePeerConnectionFactory()) { 165 if (!EnsurePeerConnectionFactory()) {
243 sources_created.Run(web_stream, false); 166 return false;
244 return;
245 }
246
247 // |source_observer| clean up itself when it has completed
248 // source_observer->StartObservering.
249 SourceStateObserver* source_observer =
250 new SourceStateObserver(web_stream, sources_created);
251
252 // Create local video sources.
253 RTCMediaConstraints native_video_constraints(video_constraints);
254 blink::WebVector<blink::WebMediaStreamTrack> video_tracks;
255 web_stream->videoTracks(video_tracks);
256 for (size_t i = 0; i < video_tracks.size(); ++i) {
257 const blink::WebMediaStreamSource& source = video_tracks[i].source();
258 MediaStreamSourceExtraData* source_data =
259 static_cast<MediaStreamSourceExtraData*>(source.extraData());
260
261 // Check if the source has already been created. This happens when the same
262 // source is used in multiple MediaStreams as a result of calling
263 // getUserMedia.
264 if (source_data->video_source())
265 continue;
266
267 const bool is_screencast =
268 source_data->device_info().device.type == MEDIA_TAB_VIDEO_CAPTURE ||
269 source_data->device_info().device.type == MEDIA_DESKTOP_VIDEO_CAPTURE;
270 source_data->SetVideoSource(
271 CreateLocalVideoSource(source_data->device_info().session_id,
272 is_screencast,
273 &native_video_constraints).get());
274 source_observer->AddSource(source_data->video_source());
275 } 167 }
276 168
277 // Do additional source initialization if the audio source is a valid 169 // Do additional source initialization if the audio source is a valid
278 // microphone or tab audio. 170 // microphone or tab audio.
279 RTCMediaConstraints native_audio_constraints(audio_constraints); 171 RTCMediaConstraints native_audio_constraints(audio_constraints);
280 ApplyFixedAudioConstraints(&native_audio_constraints); 172 ApplyFixedAudioConstraints(&native_audio_constraints);
281 blink::WebVector<blink::WebMediaStreamTrack> audio_tracks; 173 for (size_t i = 0; i < audio_sources.size(); ++i) {
282 web_stream->audioTracks(audio_tracks); 174 const blink::WebMediaStreamSource& source = audio_sources[i];
283 for (size_t i = 0; i < audio_tracks.size(); ++i) { 175 MediaStreamAudioSource* source_data =
284 const blink::WebMediaStreamSource& source = audio_tracks[i].source(); 176 static_cast<MediaStreamAudioSource*>(source.extraData());
285 MediaStreamSourceExtraData* source_data =
286 static_cast<MediaStreamSourceExtraData*>(source.extraData());
287 177
288 // Check if the source has already been created. This happens when the same 178 // Check if the source has already been created. This happens when the same
289 // source is used in multiple MediaStreams as a result of calling 179 // source is used in multiple MediaStreams as a result of calling
290 // getUserMedia. 180 // getUserMedia.
291 if (source_data->local_audio_source()) 181 if (source_data->local_audio_source())
292 continue; 182 continue;
293 183
294 // TODO(xians): Create a new capturer for difference microphones when we 184 // TODO(xians): Create a new capturer for difference microphones when we
295 // support multiple microphones. See issue crbug/262117 . 185 // support multiple microphones. See issue crbug/262117 .
296 StreamDeviceInfo device_info = source_data->device_info(); 186 StreamDeviceInfo device_info = source_data->device_info();
(...skipping 25 matching lines...) Expand all
322 } 212 }
323 device_info.device.input.effects = effects; 213 device_info.device.input.effects = effects;
324 } 214 }
325 215
326 scoped_refptr<WebRtcAudioCapturer> capturer( 216 scoped_refptr<WebRtcAudioCapturer> capturer(
327 MaybeCreateAudioCapturer(render_view_id, device_info, 217 MaybeCreateAudioCapturer(render_view_id, device_info,
328 audio_constraints)); 218 audio_constraints));
329 if (!capturer.get()) { 219 if (!capturer.get()) {
330 DLOG(WARNING) << "Failed to create the capturer for device " 220 DLOG(WARNING) << "Failed to create the capturer for device "
331 << device_info.device.id; 221 << device_info.device.id;
332 sources_created.Run(web_stream, false);
333 // TODO(xians): Don't we need to check if source_observer is observing 222 // TODO(xians): Don't we need to check if source_observer is observing
334 // something? If not, then it looks like we have a leak here. 223 // something? If not, then it looks like we have a leak here.
335 // OTOH, if it _is_ observing something, then the callback might 224 // OTOH, if it _is_ observing something, then the callback might
336 // be called multiple times which is likely also a bug. 225 // be called multiple times which is likely also a bug.
337 return; 226 return false;
338 } 227 }
339 source_data->SetAudioCapturer(capturer); 228 source_data->SetAudioCapturer(capturer);
340 229
341 // Creates a LocalAudioSource object which holds audio options. 230 // Creates a LocalAudioSource object which holds audio options.
342 // TODO(xians): The option should apply to the track instead of the source. 231 // TODO(xians): The option should apply to the track instead of the source.
343 source_data->SetLocalAudioSource( 232 source_data->SetLocalAudioSource(
344 CreateLocalAudioSource(&constraints).get()); 233 CreateLocalAudioSource(&constraints).get());
345 source_observer->AddSource(source_data->local_audio_source());
346 } 234 }
235 return true;
236 }
347 237
348 source_observer->StartObservering(); 238 cricket::VideoCapturer* MediaStreamDependencyFactory::CreateVideoCapturer(
239 const StreamDeviceInfo& info) {
240 bool is_screeencast =
241 info.device.type == MEDIA_TAB_VIDEO_CAPTURE ||
242 info.device.type == MEDIA_DESKTOP_VIDEO_CAPTURE;
243 return new RtcVideoCapturer(info.session_id, is_screeencast);
349 } 244 }
350 245
351 void MediaStreamDependencyFactory::CreateNativeLocalMediaStream( 246 void MediaStreamDependencyFactory::CreateNativeLocalMediaStream(
352 blink::WebMediaStream* web_stream) { 247 blink::WebMediaStream* web_stream) {
353 DVLOG(1) << "MediaStreamDependencyFactory::CreateNativeLocalMediaStream()"; 248 DVLOG(1) << "MediaStreamDependencyFactory::CreateNativeLocalMediaStream()";
354 if (!EnsurePeerConnectionFactory()) { 249 if (!EnsurePeerConnectionFactory()) {
355 DVLOG(1) << "EnsurePeerConnectionFactory() failed!"; 250 DVLOG(1) << "EnsurePeerConnectionFactory() failed!";
356 return; 251 return;
357 } 252 }
358 253
(...skipping 27 matching lines...) Expand all
386 MediaStreamExtraData* extra_data = 281 MediaStreamExtraData* extra_data =
387 static_cast<MediaStreamExtraData*>(web_stream->extraData()); 282 static_cast<MediaStreamExtraData*>(web_stream->extraData());
388 extra_data->SetLocalStreamStopCallback(stream_stop); 283 extra_data->SetLocalStreamStopCallback(stream_stop);
389 } 284 }
390 285
391 scoped_refptr<webrtc::AudioTrackInterface> 286 scoped_refptr<webrtc::AudioTrackInterface>
392 MediaStreamDependencyFactory::CreateNativeAudioMediaStreamTrack( 287 MediaStreamDependencyFactory::CreateNativeAudioMediaStreamTrack(
393 const blink::WebMediaStreamTrack& track) { 288 const blink::WebMediaStreamTrack& track) {
394 blink::WebMediaStreamSource source = track.source(); 289 blink::WebMediaStreamSource source = track.source();
395 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeAudio); 290 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeAudio);
396 MediaStreamSourceExtraData* source_data = 291 MediaStreamAudioSource* source_data =
397 static_cast<MediaStreamSourceExtraData*>(source.extraData()); 292 static_cast<MediaStreamAudioSource*>(source.extraData());
398 293
399 // In the future the constraints will belong to the track itself, but 294 // In the future the constraints will belong to the track itself, but
400 // right now they're on the source, so we fetch them from there. 295 // right now they're on the source, so we fetch them from there.
401 RTCMediaConstraints track_constraints(source.constraints()); 296 RTCMediaConstraints track_constraints(source.constraints());
402 297
403 // Apply default audio constraints that enable echo cancellation, 298 // Apply default audio constraints that enable echo cancellation,
404 // automatic gain control, noise suppression and high-pass filter. 299 // automatic gain control, noise suppression and high-pass filter.
405 ApplyFixedAudioConstraints(&track_constraints); 300 ApplyFixedAudioConstraints(&track_constraints);
406 301
407 scoped_refptr<WebAudioCapturerSource> webaudio_source; 302 scoped_refptr<WebAudioCapturerSource> webaudio_source;
408 if (!source_data) { 303 if (!source_data) {
409 if (source.requiresAudioConsumer()) { 304 if (source.requiresAudioConsumer()) {
410 // We're adding a WebAudio MediaStream. 305 // We're adding a WebAudio MediaStream.
411 // Create a specific capturer for each WebAudio consumer. 306 // Create a specific capturer for each WebAudio consumer.
412 webaudio_source = CreateWebAudioSource(&source, track_constraints); 307 webaudio_source = CreateWebAudioSource(&source, track_constraints);
413 source_data = 308 source_data =
414 static_cast<MediaStreamSourceExtraData*>(source.extraData()); 309 static_cast<MediaStreamAudioSource*>(source.extraData());
415 } else { 310 } else {
416 // TODO(perkj): Implement support for sources from 311 // TODO(perkj): Implement support for sources from
417 // remote MediaStreams. 312 // remote MediaStreams.
418 NOTIMPLEMENTED(); 313 NOTIMPLEMENTED();
419 return NULL; 314 return NULL;
420 } 315 }
421 } 316 }
422 317
423 std::string track_id = base::UTF16ToUTF8(track.id()); 318 std::string track_id = base::UTF16ToUTF8(track.id());
424 scoped_refptr<WebRtcAudioCapturer> capturer; 319 scoped_refptr<WebRtcAudioCapturer> capturer;
(...skipping 13 matching lines...) Expand all
438 blink::WebMediaStreamTrack writable_track = track; 333 blink::WebMediaStreamTrack writable_track = track;
439 writable_track.setSourceProvider(static_cast<WebRtcLocalAudioTrack*>( 334 writable_track.setSourceProvider(static_cast<WebRtcLocalAudioTrack*>(
440 audio_track.get())->audio_source_provider()); 335 audio_track.get())->audio_source_provider());
441 336
442 return audio_track; 337 return audio_track;
443 } 338 }
444 339
445 scoped_refptr<webrtc::VideoTrackInterface> 340 scoped_refptr<webrtc::VideoTrackInterface>
446 MediaStreamDependencyFactory::CreateNativeVideoMediaStreamTrack( 341 MediaStreamDependencyFactory::CreateNativeVideoMediaStreamTrack(
447 const blink::WebMediaStreamTrack& track) { 342 const blink::WebMediaStreamTrack& track) {
343 DCHECK(track.extraData() == NULL);
Ronghua Wu (Left Chromium) 2014/01/16 23:02:37 add comment saying this is to check if native trac
448 blink::WebMediaStreamSource source = track.source(); 344 blink::WebMediaStreamSource source = track.source();
449 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeVideo); 345 DCHECK_EQ(source.type(), blink::WebMediaStreamSource::TypeVideo);
450 MediaStreamSourceExtraData* source_data = 346
451 static_cast<MediaStreamSourceExtraData*>(source.extraData()); 347 MediaStreamVideoSource* source_data =
348 static_cast<MediaStreamVideoSource*>(source.extraData());
452 349
453 if (!source_data) { 350 if (!source_data) {
454 // TODO(perkj): Implement support for sources from 351 // TODO(perkj): Implement support for sources from
455 // remote MediaStreams. 352 // remote MediaStreams.
456 NOTIMPLEMENTED(); 353 NOTIMPLEMENTED();
457 return NULL; 354 return NULL;
458 } 355 }
459 356
460 std::string track_id = base::UTF16ToUTF8(track.id()); 357 // Create native track from the source.
461 scoped_refptr<webrtc::VideoTrackInterface> video_track( 358 scoped_refptr<webrtc::VideoTrackInterface> webrtc_track =
462 CreateLocalVideoTrack(track_id, source_data->video_source())); 359 CreateLocalVideoTrack(track.id().utf8(), source_data->GetAdapter());
463 AddNativeTrackToBlinkTrack(video_track.get(), track, true);
464 360
465 video_track->set_enabled(track.isEnabled()); 361 AddNativeTrackToBlinkTrack(webrtc_track, track, true);
466 362
467 return video_track; 363 webrtc_track->set_enabled(track.isEnabled());
364
365 return webrtc_track;
468 } 366 }
469 367
470 void MediaStreamDependencyFactory::CreateNativeMediaStreamTrack( 368 void MediaStreamDependencyFactory::CreateNativeMediaStreamTrack(
471 const blink::WebMediaStreamTrack& track) { 369 const blink::WebMediaStreamTrack& track) {
472 DCHECK(!track.isNull() && !track.extraData()); 370 DCHECK(!track.isNull() && !track.extraData());
473 DCHECK(!track.source().isNull()); 371 DCHECK(!track.source().isNull());
474 372
475 switch (track.source().type()) { 373 switch (track.source().type()) {
476 case blink::WebMediaStreamSource::TypeAudio: 374 case blink::WebMediaStreamSource::TypeAudio:
477 CreateNativeAudioMediaStreamTrack(track); 375 CreateNativeAudioMediaStreamTrack(track);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 return native_stream->RemoveTrack( 466 return native_stream->RemoveTrack(
569 native_stream->FindVideoTrack(track_id)); 467 native_stream->FindVideoTrack(track_id));
570 } 468 }
571 return false; 469 return false;
572 } 470 }
573 471
574 scoped_refptr<webrtc::VideoSourceInterface> 472 scoped_refptr<webrtc::VideoSourceInterface>
575 MediaStreamDependencyFactory::CreateVideoSource( 473 MediaStreamDependencyFactory::CreateVideoSource(
576 cricket::VideoCapturer* capturer, 474 cricket::VideoCapturer* capturer,
577 const webrtc::MediaConstraintsInterface* constraints) { 475 const webrtc::MediaConstraintsInterface* constraints) {
476 if (!EnsurePeerConnectionFactory()) {
477 return NULL;
478 }
578 scoped_refptr<webrtc::VideoSourceInterface> source = 479 scoped_refptr<webrtc::VideoSourceInterface> source =
579 pc_factory_->CreateVideoSource(capturer, constraints).get(); 480 pc_factory_->CreateVideoSource(capturer, constraints).get();
580 return source; 481 return source;
581 } 482 }
582 483
583 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { 484 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() {
584 DCHECK(!pc_factory_.get()); 485 DCHECK(!pc_factory_.get());
585 DCHECK(!audio_device_.get()); 486 DCHECK(!audio_device_.get());
586 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; 487 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()";
587 488
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 584 }
684 585
685 scoped_refptr<webrtc::AudioSourceInterface> 586 scoped_refptr<webrtc::AudioSourceInterface>
686 MediaStreamDependencyFactory::CreateLocalAudioSource( 587 MediaStreamDependencyFactory::CreateLocalAudioSource(
687 const webrtc::MediaConstraintsInterface* constraints) { 588 const webrtc::MediaConstraintsInterface* constraints) {
688 scoped_refptr<webrtc::AudioSourceInterface> source = 589 scoped_refptr<webrtc::AudioSourceInterface> source =
689 pc_factory_->CreateAudioSource(constraints).get(); 590 pc_factory_->CreateAudioSource(constraints).get();
690 return source; 591 return source;
691 } 592 }
692 593
693 scoped_refptr<webrtc::VideoSourceInterface>
694 MediaStreamDependencyFactory::CreateLocalVideoSource(
695 int video_session_id,
696 bool is_screencast,
697 const webrtc::MediaConstraintsInterface* constraints) {
698 RtcVideoCapturer* capturer = new RtcVideoCapturer(
699 video_session_id, is_screencast);
700
701 // The video source takes ownership of |capturer|.
702 scoped_refptr<webrtc::VideoSourceInterface> source =
703 CreateVideoSource(capturer, constraints);
704 return source;
705 }
706
707 scoped_refptr<WebAudioCapturerSource> 594 scoped_refptr<WebAudioCapturerSource>
708 MediaStreamDependencyFactory::CreateWebAudioSource( 595 MediaStreamDependencyFactory::CreateWebAudioSource(
709 blink::WebMediaStreamSource* source, 596 blink::WebMediaStreamSource* source,
710 const RTCMediaConstraints& constraints) { 597 const RTCMediaConstraints& constraints) {
711 DVLOG(1) << "MediaStreamDependencyFactory::CreateWebAudioSource()"; 598 DVLOG(1) << "MediaStreamDependencyFactory::CreateWebAudioSource()";
712 DCHECK(GetWebRtcAudioDevice()); 599 DCHECK(GetWebRtcAudioDevice());
713 600
714 scoped_refptr<WebAudioCapturerSource> 601 scoped_refptr<WebAudioCapturerSource>
715 webaudio_capturer_source(new WebAudioCapturerSource()); 602 webaudio_capturer_source(new WebAudioCapturerSource());
716 MediaStreamSourceExtraData* source_data = new MediaStreamSourceExtraData(); 603 MediaStreamAudioSource* source_data = new MediaStreamAudioSource();
717 604
718 // Create a LocalAudioSource object which holds audio options. 605 // Create a LocalAudioSource object which holds audio options.
719 // SetLocalAudioSource() affects core audio parts in third_party/Libjingle. 606 // SetLocalAudioSource() affects core audio parts in third_party/Libjingle.
720 source_data->SetLocalAudioSource(CreateLocalAudioSource(&constraints).get()); 607 source_data->SetLocalAudioSource(CreateLocalAudioSource(&constraints).get());
721 source->setExtraData(source_data); 608 source->setExtraData(source_data);
722 609
723 // Replace the default source with WebAudio as source instead. 610 // Replace the default source with WebAudio as source instead.
724 source->addAudioConsumer(webaudio_capturer_source.get()); 611 source->addAudioConsumer(webaudio_capturer_source.get());
725 612
726 return webaudio_capturer_source; 613 return webaudio_capturer_source;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 if (!aec_dump_file_stream) { 896 if (!aec_dump_file_stream) {
1010 VLOG(1) << "Could not open AEC dump file."; 897 VLOG(1) << "Could not open AEC dump file.";
1011 base::ClosePlatformFile(aec_dump_file); 898 base::ClosePlatformFile(aec_dump_file);
1012 } else { 899 } else {
1013 // |pc_factory_| takes ownership of |aec_dump_file_stream|. 900 // |pc_factory_| takes ownership of |aec_dump_file_stream|.
1014 pc_factory_->StartAecDump(aec_dump_file_stream); 901 pc_factory_->StartAecDump(aec_dump_file_stream);
1015 } 902 }
1016 } 903 }
1017 904
1018 } // namespace content 905 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698