Chromium Code Reviews| 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/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 return false; | 401 return false; |
| 402 } | 402 } |
| 403 } | 403 } |
| 404 | 404 |
| 405 WebKit::WebMediaStreamSource::Type type = track.source().type(); | 405 WebKit::WebMediaStreamSource::Type type = track.source().type(); |
| 406 DCHECK(type == WebKit::WebMediaStreamSource::TypeAudio || | 406 DCHECK(type == WebKit::WebMediaStreamSource::TypeAudio || |
| 407 type == WebKit::WebMediaStreamSource::TypeVideo); | 407 type == WebKit::WebMediaStreamSource::TypeVideo); |
| 408 | 408 |
| 409 std::string track_id = UTF16ToUTF8(track.id()); | 409 std::string track_id = UTF16ToUTF8(track.id()); |
| 410 if (source.type() == WebKit::WebMediaStreamSource::TypeAudio) { | 410 if (source.type() == WebKit::WebMediaStreamSource::TypeAudio) { |
| 411 // TODO(henrika,xians): Refactor how an audio track is created to harmonize | 411 // TODO(henrika,xians): Refactor how an audio track is created to harmonize |
|
henrika (OOO until Aug 14)
2013/06/05 09:09:20
Is this TODO still vaild?
no longer working on chromium
2013/06/05 16:29:45
I think we can remove this TODO here since it does
| |
| 412 // with video tracks. | 412 // with video tracks. |
| 413 scoped_refptr<webrtc::AudioTrackInterface> audio_track( | 413 scoped_refptr<webrtc::AudioTrackInterface> audio_track( |
| 414 CreateLocalAudioTrack(track_id, source_data->local_audio_source())); | 414 CreateLocalAudioTrack(track_id, source_data->local_audio_source())); |
| 415 audio_track->set_enabled(track.isEnabled()); | 415 audio_track->set_enabled(track.isEnabled()); |
| 416 if (GetWebRtcAudioDevice()) { | 416 if (GetWebRtcAudioDevice() && GetWebRtcAudioDevice()->capturer().get()) |
|
henrika (OOO until Aug 14)
2013/06/05 09:09:20
It is now a bit unclear why this if-statement is n
no longer working on chromium
2013/06/05 16:29:45
Good catch, it is because we were using MockLocalA
| |
| 417 WebRtcAudioCapturer* capturer = GetWebRtcAudioDevice()->capturer().get(); | 417 static_cast<WebRtcLocalAudioTrack*>(audio_track.get())->Start(); |
|
henrika (OOO until Aug 14)
2013/06/05 09:09:20
Can you add some comments here to explain what act
no longer working on chromium
2013/06/05 16:29:45
Done.
| |
| 418 if (!capturer->is_recording()) | 418 |
| 419 capturer->Start(); | |
| 420 } | |
| 421 return native_stream->AddTrack(audio_track.get()); | 419 return native_stream->AddTrack(audio_track.get()); |
| 422 } else { | 420 } else { |
| 423 scoped_refptr<webrtc::VideoTrackInterface> video_track( | 421 scoped_refptr<webrtc::VideoTrackInterface> video_track( |
| 424 CreateLocalVideoTrack(track_id, source_data->video_source())); | 422 CreateLocalVideoTrack(track_id, source_data->video_source())); |
| 425 video_track->set_enabled(track.isEnabled()); | 423 video_track->set_enabled(track.isEnabled()); |
| 426 return native_stream->AddTrack(video_track.get()); | 424 return native_stream->AddTrack(video_track.get()); |
| 427 } | 425 } |
| 428 } | 426 } |
| 429 | 427 |
| 430 bool MediaStreamDependencyFactory::AddNativeVideoMediaTrack( | 428 bool MediaStreamDependencyFactory::AddNativeVideoMediaTrack( |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 WebRtcAudioDeviceImpl* | 681 WebRtcAudioDeviceImpl* |
| 684 MediaStreamDependencyFactory::GetWebRtcAudioDevice() { | 682 MediaStreamDependencyFactory::GetWebRtcAudioDevice() { |
| 685 return audio_device_.get(); | 683 return audio_device_.get(); |
| 686 } | 684 } |
| 687 | 685 |
| 688 void MediaStreamDependencyFactory::StopLocalAudioSource( | 686 void MediaStreamDependencyFactory::StopLocalAudioSource( |
| 689 const WebKit::WebMediaStream& description) { | 687 const WebKit::WebMediaStream& description) { |
| 690 MediaStreamExtraData* extra_data = static_cast<MediaStreamExtraData*>( | 688 MediaStreamExtraData* extra_data = static_cast<MediaStreamExtraData*>( |
| 691 description.extraData()); | 689 description.extraData()); |
| 692 if (extra_data && extra_data->is_local() && extra_data->stream().get() && | 690 if (extra_data && extra_data->is_local() && extra_data->stream().get() && |
| 693 !extra_data->stream()->GetAudioTracks().empty()) { | 691 !extra_data->stream()->GetAudioTracks().empty() && |
| 694 if (GetWebRtcAudioDevice()) { | 692 GetWebRtcAudioDevice() && |
|
henrika (OOO until Aug 14)
2013/06/05 09:09:20
Same comment as above. It is not clear why you mus
no longer working on chromium
2013/06/05 16:29:45
Removed.
| |
| 695 scoped_refptr<WebRtcAudioCapturer> capturer = | 693 GetWebRtcAudioDevice()->capturer().get()) { |
| 696 GetWebRtcAudioDevice()->capturer(); | 694 static_cast<WebRtcLocalAudioTrack*>( |
|
henrika (OOO until Aug 14)
2013/06/05 09:09:20
You call start when a track is added and stop when
no longer working on chromium
2013/06/05 16:29:45
StopLocalAudioSource is the wrong name, it should
| |
| 697 if (capturer.get()) | 695 extra_data->stream()->GetAudioTracks()[0].get())->Stop(); |
| 698 capturer->Stop(); | |
| 699 } | |
| 700 } | 696 } |
| 701 } | 697 } |
| 702 | 698 |
| 703 void MediaStreamDependencyFactory::InitializeWorkerThread( | 699 void MediaStreamDependencyFactory::InitializeWorkerThread( |
| 704 talk_base::Thread** thread, | 700 talk_base::Thread** thread, |
| 705 base::WaitableEvent* event) { | 701 base::WaitableEvent* event) { |
| 706 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 702 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
| 707 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); | 703 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); |
| 708 *thread = jingle_glue::JingleThreadWrapper::current(); | 704 *thread = jingle_glue::JingleThreadWrapper::current(); |
| 709 event->Signal(); | 705 event->Signal(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 797 // processed before returning. We wait for the above task to finish before | 793 // processed before returning. We wait for the above task to finish before |
| 798 // letting the the function continue to avoid any potential race issues. | 794 // letting the the function continue to avoid any potential race issues. |
| 799 chrome_worker_thread_.Stop(); | 795 chrome_worker_thread_.Stop(); |
| 800 } else { | 796 } else { |
| 801 NOTREACHED() << "Worker thread not running."; | 797 NOTREACHED() << "Worker thread not running."; |
| 802 } | 798 } |
| 803 } | 799 } |
| 804 } | 800 } |
| 805 | 801 |
| 806 } // namespace content | 802 } // namespace content |
| OLD | NEW |