| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_audio_source.h" | 5 #include "content/renderer/media/media_stream_audio_source.h" |
| 6 | 6 |
| 7 namespace content { | 7 namespace content { |
| 8 | 8 |
| 9 MediaStreamAudioSource::MediaStreamAudioSource( | 9 MediaStreamAudioSource::MediaStreamAudioSource( |
| 10 int render_view_id, | 10 int render_view_id, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 void MediaStreamAudioSource::DoStopSource() { | 27 void MediaStreamAudioSource::DoStopSource() { |
| 28 if (audio_capturer_.get()) | 28 if (audio_capturer_.get()) |
| 29 audio_capturer_->Stop(); | 29 audio_capturer_->Stop(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void MediaStreamAudioSource::AddTrack( | 32 void MediaStreamAudioSource::AddTrack( |
| 33 const blink::WebMediaStreamTrack& track, | 33 const blink::WebMediaStreamTrack& track, |
| 34 const blink::WebMediaConstraints& constraints, | 34 const blink::WebMediaConstraints& constraints, |
| 35 const ConstraintsCallback& callback) { | 35 const ConstraintsCallback& callback) { |
| 36 // TODO(xians): Properly implement for audio sources. | 36 // TODO(xians): Properly implement for audio sources. |
| 37 if (!factory_) | 37 if (!local_audio_source_) { |
| 38 callback.Run(this, false); | 38 if (!factory_->InitializeMediaStreamAudioSource(render_view_id_, |
| 39 constraints, |
| 40 this)) { |
| 41 // The source failed to start. |
| 42 // MediaStreamImpl rely on the |stop_callback| to be triggered when the |
| 43 // last track is removed from the source. But in this case, the source is |
| 44 // is not even started. So we need to fail both adding the track and |
| 45 // trigger |stop_callback|. |
| 46 callback.Run(this, false); |
| 47 StopSource(); |
| 48 return; |
| 49 } |
| 50 } |
| 39 | 51 |
| 40 bool result = true; | 52 factory_->CreateLocalAudioTrack(track); |
| 41 if (!local_audio_source_) { | 53 callback.Run(this, true); |
| 42 result = factory_->InitializeMediaStreamAudioSource(render_view_id_, | |
| 43 constraints, | |
| 44 this); | |
| 45 } | |
| 46 if (result) | |
| 47 factory_->CreateLocalAudioTrack(track); | |
| 48 callback.Run(this, result); | |
| 49 } | 54 } |
| 50 | 55 |
| 51 } // namespace content | 56 } // namespace content |
| OLD | NEW |