| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 { webrtc::MediaConstraintsInterface::kEchoCancellation, | 58 { webrtc::MediaConstraintsInterface::kEchoCancellation, |
| 59 webrtc::MediaConstraintsInterface::kValueTrue }, | 59 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 60 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) | 60 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) |
| 61 // Enable the extended filter mode AEC on platforms with known echo issues. | 61 // Enable the extended filter mode AEC on platforms with known echo issues. |
| 62 { webrtc::MediaConstraintsInterface::kExperimentalEchoCancellation, | 62 { webrtc::MediaConstraintsInterface::kExperimentalEchoCancellation, |
| 63 webrtc::MediaConstraintsInterface::kValueTrue }, | 63 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 64 #endif | 64 #endif |
| 65 { webrtc::MediaConstraintsInterface::kAutoGainControl, | 65 { webrtc::MediaConstraintsInterface::kAutoGainControl, |
| 66 webrtc::MediaConstraintsInterface::kValueTrue }, | 66 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 67 { webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl, | 67 { webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl, |
| 68 webrtc::MediaConstraintsInterface::kValueTrue }, | 68 webrtc::MediaConstraintsInterface::kValueFalse }, |
| 69 { webrtc::MediaConstraintsInterface::kNoiseSuppression, | 69 { webrtc::MediaConstraintsInterface::kNoiseSuppression, |
| 70 webrtc::MediaConstraintsInterface::kValueTrue }, | 70 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 71 { webrtc::MediaConstraintsInterface::kHighpassFilter, | 71 { webrtc::MediaConstraintsInterface::kHighpassFilter, |
| 72 webrtc::MediaConstraintsInterface::kValueTrue }, | 72 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 // Merge |constraints| with |kDefaultAudioConstraints|. For any key which exists | 75 // Merge |constraints| with |kDefaultAudioConstraints|. For any key which exists |
| 76 // in both, the value from |constraints| is maintained, including its | 76 // in both, the value from |constraints| is maintained, including its |
| 77 // mandatory/optional status. New values from |kDefaultAudioConstraints| will | 77 // mandatory/optional status. New values from |kDefaultAudioConstraints| will |
| 78 // be added with mandatory status. | 78 // be added with mandatory status. |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 scoped_refptr<WebRtcAudioCapturer> capturer; | 434 scoped_refptr<WebRtcAudioCapturer> capturer; |
| 435 if (GetWebRtcAudioDevice()) | 435 if (GetWebRtcAudioDevice()) |
| 436 capturer = GetWebRtcAudioDevice()->GetDefaultCapturer(); | 436 capturer = GetWebRtcAudioDevice()->GetDefaultCapturer(); |
| 437 | 437 |
| 438 scoped_refptr<webrtc::AudioTrackInterface> audio_track( | 438 scoped_refptr<webrtc::AudioTrackInterface> audio_track( |
| 439 CreateLocalAudioTrack(track_id, | 439 CreateLocalAudioTrack(track_id, |
| 440 capturer, | 440 capturer, |
| 441 webaudio_source.get(), | 441 webaudio_source.get(), |
| 442 source_data->local_audio_source(), | 442 source_data->local_audio_source(), |
| 443 &track_constraints)); | 443 &track_constraints)); |
| 444 // Set the source provider to the webkit. |
| 445 WebKit::WebMediaStreamTrack writable_track = track; |
| 446 writable_track.setSourceProvider(static_cast<WebRtcLocalAudioTrack*>( |
| 447 audio_track.get())->audio_source_provider()); |
| 444 audio_track->set_enabled(track.isEnabled()); | 448 audio_track->set_enabled(track.isEnabled()); |
| 445 if (capturer.get()) { | |
| 446 WebKit::WebMediaStreamTrack writable_track = track; | |
| 447 writable_track.setSourceProvider(capturer->audio_source_provider()); | |
| 448 } | |
| 449 return native_stream->AddTrack(audio_track.get()); | 449 return native_stream->AddTrack(audio_track.get()); |
| 450 } else { | 450 } else { |
| 451 DCHECK(source.type() == WebKit::WebMediaStreamSource::TypeVideo); | 451 DCHECK(source.type() == WebKit::WebMediaStreamSource::TypeVideo); |
| 452 scoped_refptr<webrtc::VideoTrackInterface> video_track( | 452 scoped_refptr<webrtc::VideoTrackInterface> video_track( |
| 453 CreateLocalVideoTrack(track_id, source_data->video_source())); | 453 CreateLocalVideoTrack(track_id, source_data->video_source())); |
| 454 video_track->set_enabled(track.isEnabled()); | 454 video_track->set_enabled(track.isEnabled()); |
| 455 return native_stream->AddTrack(video_track.get()); | 455 return native_stream->AddTrack(video_track.get()); |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 | 458 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 const std::string& id, | 665 const std::string& id, |
| 666 const scoped_refptr<WebRtcAudioCapturer>& capturer, | 666 const scoped_refptr<WebRtcAudioCapturer>& capturer, |
| 667 WebAudioCapturerSource* webaudio_source, | 667 WebAudioCapturerSource* webaudio_source, |
| 668 webrtc::AudioSourceInterface* source, | 668 webrtc::AudioSourceInterface* source, |
| 669 const webrtc::MediaConstraintsInterface* constraints) { | 669 const webrtc::MediaConstraintsInterface* constraints) { |
| 670 // TODO(xians): Merge |source| to the capturer(). We can't do this today | 670 // TODO(xians): Merge |source| to the capturer(). We can't do this today |
| 671 // because only one capturer() is supported while one |source| is created | 671 // because only one capturer() is supported while one |source| is created |
| 672 // for each audio track. | 672 // for each audio track. |
| 673 scoped_refptr<WebRtcLocalAudioTrack> audio_track( | 673 scoped_refptr<WebRtcLocalAudioTrack> audio_track( |
| 674 WebRtcLocalAudioTrack::Create(id, capturer, webaudio_source, | 674 WebRtcLocalAudioTrack::Create(id, capturer, webaudio_source, |
| 675 source, constraints)); | 675 source, constraints, |
| 676 GetWebRtcAudioDevice())); |
| 676 | 677 |
| 677 // Add the WebRtcAudioDevice as the sink to the local audio track. | 678 // Add the WebRtcAudioDevice as the sink to the local audio track. |
| 678 audio_track->AddSink(GetWebRtcAudioDevice()); | 679 audio_track->AddSink(GetWebRtcAudioDevice()); |
| 679 // Start the audio track. This will hook the |audio_track| to the capturer | 680 // Start the audio track. This will hook the |audio_track| to the capturer |
| 680 // as the sink of the audio, and only start the source of the capturer if | 681 // as the sink of the audio, and only start the source of the capturer if |
| 681 // it is the first audio track connecting to the capturer. | 682 // it is the first audio track connecting to the capturer. |
| 682 audio_track->Start(); | 683 audio_track->Start(); |
| 683 return audio_track; | 684 return audio_track; |
| 684 } | 685 } |
| 685 | 686 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 } | 840 } |
| 840 | 841 |
| 841 // 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. |
| 842 if (is_new_capturer) | 843 if (is_new_capturer) |
| 843 GetWebRtcAudioDevice()->AddAudioCapturer(capturer); | 844 GetWebRtcAudioDevice()->AddAudioCapturer(capturer); |
| 844 | 845 |
| 845 return capturer; | 846 return capturer; |
| 846 } | 847 } |
| 847 | 848 |
| 848 } // namespace content | 849 } // namespace content |
| OLD | NEW |