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

Unified Diff: content/renderer/media/media_stream_dependency_factory.cc

Issue 15979027: start/stop the source of the capturer when 1st audiotrack/last audiotrack is added/removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Henrik's comments. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/renderer/media/mock_media_stream_dependency_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/media_stream_dependency_factory.cc
diff --git a/content/renderer/media/media_stream_dependency_factory.cc b/content/renderer/media/media_stream_dependency_factory.cc
index fc0cc0dc80b80c74b11d7050a857a626d1cec1e2..6e7caf89ffcafa4cafa8b5a4ad748cf209ad8082 100644
--- a/content/renderer/media/media_stream_dependency_factory.cc
+++ b/content/renderer/media/media_stream_dependency_factory.cc
@@ -408,16 +408,14 @@ bool MediaStreamDependencyFactory::AddNativeMediaStreamTrack(
std::string track_id = UTF16ToUTF8(track.id());
if (source.type() == WebKit::WebMediaStreamSource::TypeAudio) {
- // TODO(henrika,xians): Refactor how an audio track is created to harmonize
- // with video tracks.
scoped_refptr<webrtc::AudioTrackInterface> audio_track(
CreateLocalAudioTrack(track_id, source_data->local_audio_source()));
audio_track->set_enabled(track.isEnabled());
- if (GetWebRtcAudioDevice()) {
- WebRtcAudioCapturer* capturer = GetWebRtcAudioDevice()->capturer().get();
- if (!capturer->is_recording())
- capturer->Start();
- }
+ // Start the audio track. This will hook the |audio_track| to the capturer
+ // as the sink of the audio, and only start the source of the capturer if
+ // it is the first audio track connecting to the capturer.
+ static_cast<WebRtcLocalAudioTrack*>(audio_track.get())->Start();
+
return native_stream->AddTrack(audio_track.get());
} else {
scoped_refptr<webrtc::VideoTrackInterface> video_track(
@@ -691,12 +689,11 @@ void MediaStreamDependencyFactory::StopLocalAudioSource(
description.extraData());
if (extra_data && extra_data->is_local() && extra_data->stream().get() &&
!extra_data->stream()->GetAudioTracks().empty()) {
- if (GetWebRtcAudioDevice()) {
- scoped_refptr<WebRtcAudioCapturer> capturer =
- GetWebRtcAudioDevice()->capturer();
- if (capturer.get())
- capturer->Stop();
- }
+ // Stop the audio track. This will unhook the audio track from the capturer
+ // and will shutdown the source of the capturer if it is the last audio
+ // track connecting to the capturer.
+ static_cast<WebRtcLocalAudioTrack*>(
+ extra_data->stream()->GetAudioTracks()[0].get())->Stop();
}
}
« no previous file with comments | « no previous file | content/renderer/media/mock_media_stream_dependency_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698