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

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

Issue 30983002: Switch from using internal constraints to use explicit PeerConnectionFactoryInterface::SetOptions t… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@track_stop
Patch Set: Addressed fishmans comments. Created 7 years, 1 month 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 | content/renderer/media/rtc_media_constraints.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 &native_video_constraints).get()); 298 &native_video_constraints).get());
299 source_observer->AddSource(source_data->video_source()); 299 source_observer->AddSource(source_data->video_source());
300 } 300 }
301 301
302 // Do additional source initialization if the audio source is a valid 302 // Do additional source initialization if the audio source is a valid
303 // microphone or tab audio. 303 // microphone or tab audio.
304 RTCMediaConstraints native_audio_constraints(audio_constraints); 304 RTCMediaConstraints native_audio_constraints(audio_constraints);
305 ApplyFixedAudioConstraints(&native_audio_constraints); 305 ApplyFixedAudioConstraints(&native_audio_constraints);
306 WebKit::WebVector<WebKit::WebMediaStreamTrack> audio_tracks; 306 WebKit::WebVector<WebKit::WebMediaStreamTrack> audio_tracks;
307 web_stream->audioTracks(audio_tracks); 307 web_stream->audioTracks(audio_tracks);
308 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
309 if (command_line.HasSwitch(switches::kEnableWebRtcAecRecordings)) {
310 native_audio_constraints.AddOptional(
311 RTCMediaConstraints::kInternalAecDump, "true");
312 }
313 for (size_t i = 0; i < audio_tracks.size(); ++i) { 308 for (size_t i = 0; i < audio_tracks.size(); ++i) {
314 const WebKit::WebMediaStreamSource& source = audio_tracks[i].source(); 309 const WebKit::WebMediaStreamSource& source = audio_tracks[i].source();
315 MediaStreamSourceExtraData* source_data = 310 MediaStreamSourceExtraData* source_data =
316 static_cast<MediaStreamSourceExtraData*>(source.extraData()); 311 static_cast<MediaStreamSourceExtraData*>(source.extraData());
317 312
318 // Check if the source has already been created. This happens when the same 313 // Check if the source has already been created. This happens when the same
319 // source is used in multiple MediaStreams as a result of calling 314 // source is used in multiple MediaStreams as a result of calling
320 // getUserMedia. 315 // getUserMedia.
321 if (source_data->local_audio_source()) 316 if (source_data->local_audio_source())
322 continue; 317 continue;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // Remove the source provider as the track is going away. 511 // Remove the source provider as the track is going away.
517 writable_track.setSourceProvider(NULL); 512 writable_track.setSourceProvider(NULL);
518 return native_stream->RemoveTrack(native_stream->FindAudioTrack(track_id)); 513 return native_stream->RemoveTrack(native_stream->FindAudioTrack(track_id));
519 } 514 }
520 515
521 CHECK_EQ(type, WebKit::WebMediaStreamSource::TypeVideo); 516 CHECK_EQ(type, WebKit::WebMediaStreamSource::TypeVideo);
522 return native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id)); 517 return native_stream->RemoveTrack(native_stream->FindVideoTrack(track_id));
523 } 518 }
524 519
525 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { 520 bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() {
521 DCHECK(!pc_factory_.get());
522 DCHECK(!audio_device_.get());
526 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; 523 DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()";
527 if (!pc_factory_.get()) {
528 DCHECK(!audio_device_.get());
529 audio_device_ = new WebRtcAudioDeviceImpl();
530 524
531 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory; 525 scoped_ptr<cricket::WebRtcVideoDecoderFactory> decoder_factory;
532 scoped_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory; 526 scoped_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory;
533 527
534 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 528 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
535 scoped_refptr<RendererGpuVideoAcceleratorFactories> gpu_factories = 529 scoped_refptr<RendererGpuVideoAcceleratorFactories> gpu_factories =
536 RenderThreadImpl::current()->GetGpuFactories(); 530 RenderThreadImpl::current()->GetGpuFactories();
537 #if !defined(GOOGLE_TV) 531 #if !defined(GOOGLE_TV)
538 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWDecoding)) { 532 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWDecoding)) {
539 if (gpu_factories) 533 if (gpu_factories)
540 decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories)); 534 decoder_factory.reset(new RTCVideoDecoderFactory(gpu_factories));
541 } 535 }
542 #else 536 #else
543 // PeerConnectionFactory will hold the ownership of this 537 // PeerConnectionFactory will hold the ownership of this
544 // VideoDecoderFactory. 538 // VideoDecoderFactory.
545 decoder_factory.reset(decoder_factory_tv_ = new RTCVideoDecoderFactoryTv()); 539 decoder_factory.reset(decoder_factory_tv_ = new RTCVideoDecoderFactoryTv());
546 #endif 540 #endif
547 541
548 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) { 542 if (!cmd_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) {
549 if (gpu_factories) 543 if (gpu_factories)
550 encoder_factory.reset(new RTCVideoEncoderFactory(gpu_factories)); 544 encoder_factory.reset(new RTCVideoEncoderFactory(gpu_factories));
551 } 545 }
552 546
553 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory( 547 scoped_refptr<WebRtcAudioDeviceImpl> audio_device(
554 webrtc::CreatePeerConnectionFactory(worker_thread_, 548 new WebRtcAudioDeviceImpl());
555 signaling_thread_, 549
556 audio_device_.get(), 550 scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory(
557 encoder_factory.release(), 551 webrtc::CreatePeerConnectionFactory(worker_thread_,
558 decoder_factory.release())); 552 signaling_thread_,
559 if (factory.get()) 553 audio_device.get(),
560 pc_factory_ = factory; 554 encoder_factory.release(),
561 else 555 decoder_factory.release()));
562 audio_device_ = NULL; 556 if (!factory.get()) {
557 return false;
563 } 558 }
564 return pc_factory_.get() != NULL; 559
560 audio_device_ = audio_device;
561 pc_factory_ = factory;
562 webrtc::PeerConnectionFactoryInterface::Options factory_options;
563 factory_options.enable_aec_dump =
564 cmd_line->HasSwitch(switches::kEnableWebRtcAecRecordings);
565 factory_options.disable_sctp_data_channels =
566 cmd_line->HasSwitch(switches::kDisableSCTPDataChannels);
567 pc_factory_->SetOptions(factory_options);
568 return true;
565 } 569 }
566 570
567 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() { 571 bool MediaStreamDependencyFactory::PeerConnectionFactoryCreated() {
568 return pc_factory_.get() != NULL; 572 return pc_factory_.get() != NULL;
569 } 573 }
570 574
571 scoped_refptr<webrtc::PeerConnectionInterface> 575 scoped_refptr<webrtc::PeerConnectionInterface>
572 MediaStreamDependencyFactory::CreatePeerConnection( 576 MediaStreamDependencyFactory::CreatePeerConnection(
573 const webrtc::PeerConnectionInterface::IceServers& ice_servers, 577 const webrtc::PeerConnectionInterface::IceServers& ice_servers,
574 const webrtc::MediaConstraintsInterface* constraints, 578 const webrtc::MediaConstraintsInterface* constraints,
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 MediaStreamDependencyFactory::GetNativeMediaStreamTrack( 879 MediaStreamDependencyFactory::GetNativeMediaStreamTrack(
876 const WebKit::WebMediaStreamTrack& track) { 880 const WebKit::WebMediaStreamTrack& track) {
877 if (track.isNull()) 881 if (track.isNull())
878 return NULL; 882 return NULL;
879 MediaStreamTrackExtraData* extra_data = 883 MediaStreamTrackExtraData* extra_data =
880 static_cast<MediaStreamTrackExtraData*>(track.extraData()); 884 static_cast<MediaStreamTrackExtraData*>(track.extraData());
881 return extra_data ? extra_data->track().get() : NULL; 885 return extra_data ? extra_data->track().get() : NULL;
882 } 886 }
883 887
884 } // namespace content 888 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/rtc_media_constraints.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698