OLD | NEW |
---|---|
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" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 &native_video_constraints).get()); | 295 &native_video_constraints).get()); |
296 source_observer->AddSource(source_data->video_source()); | 296 source_observer->AddSource(source_data->video_source()); |
297 } | 297 } |
298 | 298 |
299 // Do additional source initialization if the audio source is a valid | 299 // Do additional source initialization if the audio source is a valid |
300 // microphone or tab audio. | 300 // microphone or tab audio. |
301 RTCMediaConstraints native_audio_constraints(audio_constraints); | 301 RTCMediaConstraints native_audio_constraints(audio_constraints); |
302 ApplyFixedAudioConstraints(&native_audio_constraints); | 302 ApplyFixedAudioConstraints(&native_audio_constraints); |
303 WebKit::WebVector<WebKit::WebMediaStreamTrack> audio_tracks; | 303 WebKit::WebVector<WebKit::WebMediaStreamTrack> audio_tracks; |
304 web_stream->audioTracks(audio_tracks); | 304 web_stream->audioTracks(audio_tracks); |
305 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
306 if (command_line.HasSwitch(switches::kEnableWebRtcAecRecordings)) { | |
307 native_audio_constraints.AddOptional( | |
308 RTCMediaConstraints::kInternalAecDump, "true"); | |
309 } | |
310 for (size_t i = 0; i < audio_tracks.size(); ++i) { | 305 for (size_t i = 0; i < audio_tracks.size(); ++i) { |
311 const WebKit::WebMediaStreamSource& source = audio_tracks[i].source(); | 306 const WebKit::WebMediaStreamSource& source = audio_tracks[i].source(); |
312 MediaStreamSourceExtraData* source_data = | 307 MediaStreamSourceExtraData* source_data = |
313 static_cast<MediaStreamSourceExtraData*>(source.extraData()); | 308 static_cast<MediaStreamSourceExtraData*>(source.extraData()); |
314 if (!source_data) { | 309 if (!source_data) { |
315 // TODO(henrika): Implement support for sources from remote MediaStreams. | 310 // TODO(henrika): Implement support for sources from remote MediaStreams. |
316 NOTIMPLEMENTED(); | 311 NOTIMPLEMENTED(); |
317 continue; | 312 continue; |
318 } | 313 } |
319 | 314 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 WebKit::WebMediaStreamTrack writable_track = track; | 499 WebKit::WebMediaStreamTrack writable_track = track; |
505 writable_track.setSourceProvider(NULL); | 500 writable_track.setSourceProvider(NULL); |
506 return native_stream->RemoveTrack(native_stream->FindAudioTrack(track_id)); | 501 return native_stream->RemoveTrack(native_stream->FindAudioTrack(track_id)); |
507 } | 502 } |
508 | 503 |
509 CHECK_EQ(type, WebKit::WebMediaStreamSource::TypeVideo); | 504 CHECK_EQ(type, WebKit::WebMediaStreamSource::TypeVideo); |
510 return native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); | 505 return native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); |
511 } | 506 } |
512 | 507 |
513 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { | 508 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { |
509 DCHECK(!pc_factory_.get()); | |
510 DCHECK(!audio_device_.get()); | |
514 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; | 511 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; |
515 if (!pc_factory_.get()) { | |
516 DCHECK(!audio_device_.get()); | |
517 audio_device_ = new WebRtcAudioDeviceImpl(); | |
518 | 512 |
519 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; | 513 audio_device_ = new WebRtcAudioDeviceImpl(); |
Ami GONE FROM CHROMIUM
2013/10/23 21:33:11
nit: it would be clearer in my opinion to make thi
perkj_chrome
2013/11/01 09:12:54
good points. Done.
| |
520 scoped_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory; | |
521 | 514 |
522 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 515 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; |
523 scoped_refptr<RendererGpuVideoAcceleratorFactories> gpu_factories = | 516 scoped_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory; |
524 RenderThreadImpl::current()->GetGpuFactories(); | 517 |
518 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | |
519 scoped_refptr<RendererGpuVideoAcceleratorFactories> gpu_factories = | |
520 RenderThreadImpl::current()->GetGpuFactories(); | |
525 #if !defined(GOOGLE_TV) | 521 #if !defined(GOOGLE_TV) |
526 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWDecoding)) { | 522 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWDecoding)) { |
527 if (gpu_factories) | 523 if (gpu_factories) |
528 decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories)); | 524 decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories)); |
529 } | 525 } |
530 #else | 526 #else |
531 // PeerConnectionFactory will hold the ownership of this | 527 // PeerConnectionFactory will hold the ownership of this |
532 // VideoDecoderFactory. | 528 // VideoDecoderFactory. |
533 decoder_factory.reset(decoder_factory_tv_ = new RTCVideoDecoderFactoryTv()); | 529 decoder_factory.reset(decoder_factory_tv_ = new RTCVideoDecoderFactoryTv()); |
534 #endif | 530 #endif |
535 | 531 |
536 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) { | 532 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) { |
537 if (gpu_factories) | 533 if (gpu_factories) |
538 encoder_factory.reset(new RTCVideoEncoderFactory(gpu_factories)); | 534 encoder_factory.reset(new RTCVideoEncoderFactory(gpu_factories)); |
539 } | 535 } |
540 | 536 |
541 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( | 537 |
Ami GONE FROM CHROMIUM
2013/10/23 21:33:11
delete extra \n ?
perkj_chrome
2013/11/01 09:12:54
Done.
| |
542 webrtc::CreatePeerConnectionFactory(worker_thread_, | 538 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( |
543 signaling_thread_, | 539 webrtc::CreatePeerConnectionFactory(worker_thread_, |
544 audio_device_.get(), | 540 signaling_thread_, |
545 encoder_factory.release(), | 541 audio_device_.get(), |
546 decoder_factory.release())); | 542 encoder_factory.release(), |
547 if (factory.get()) | 543 decoder_factory.release())); |
548 pc_factory_ = factory; | 544 if (!factory.get()) { |
549 else | 545 audio_device_ = NULL; |
550 audio_device_ = NULL; | 546 return false; |
551 } | 547 } |
552 return pc_factory_.get() != NULL; | 548 |
549 pc_factory_ = factory; | |
550 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
551 PeerConnectionFactoryInterface::Options factory_options; | |
Ami GONE FROM CHROMIUM
2013/10/23 21:33:11
Probably obvious but this can't land until 5526392
perkj_chrome
2013/11/01 09:12:54
Done.
| |
552 factory_options.enable_aec_dump = | |
553 cmd_line->HasSwitch(switches::kEnableWebRtcAecRecordings); | |
554 factory_options.disable_sctp_data_channels= | |
Ami GONE FROM CHROMIUM
2013/10/23 21:33:11
s/=/ =/
perkj_chrome
2013/11/01 09:12:54
Done.
| |
555 cmd_line->HasSwitch(switches::kDisableSCTPDataChannels); | |
556 pc_factory_->SetOptions(factory_options); | |
557 return true; | |
553 } | 558 } |
554 | 559 |
555 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { | 560 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { |
556 return pc_factory_.get() != NULL; | 561 return pc_factory_.get() != NULL; |
557 } | 562 } |
558 | 563 |
559 scoped_refptr<webrtc::PeerConnectionInterface> | 564 scoped_refptr<webrtc::PeerConnectionInterface> |
560 MediaStreamDependencyFactory::CreatePeerConnection( | 565 MediaStreamDependencyFactory::CreatePeerConnection( |
561 const webrtc::PeerConnectionInterface::IceServers& ice_servers, | 566 const webrtc::PeerConnectionInterface::IceServers& ice_servers, |
562 const webrtc::MediaConstraintsInterface* constraints, | 567 const webrtc::MediaConstraintsInterface* constraints, |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 } | 840 } |
836 | 841 |
837 // Add the capturer to the WebRtcAudioDeviceImpl if it is a new capturer. | 842 // Add the capturer to the WebRtcAudioDeviceImpl if it is a new capturer. |
838 if (is_new_capturer) | 843 if (is_new_capturer) |
839 GetWebRtcAudioDevice()->AddAudioCapturer(capturer); | 844 GetWebRtcAudioDevice()->AddAudioCapturer(capturer); |
840 | 845 |
841 return capturer; | 846 return capturer; |
842 } | 847 } |
843 | 848 |
844 } // namespace content | 849 } // namespace content |
OLD | NEW |