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 #include "content/renderer/render_frame_impl.h" | 7 #include "content/renderer/render_frame_impl.h" |
8 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
(...skipping 30 matching lines...) Expand all Loading... |
41 void MediaStreamAudioSource::DoStopSource() { | 41 void MediaStreamAudioSource::DoStopSource() { |
42 if (audio_capturer_.get()) | 42 if (audio_capturer_.get()) |
43 audio_capturer_->Stop(); | 43 audio_capturer_->Stop(); |
44 } | 44 } |
45 | 45 |
46 void MediaStreamAudioSource::AddTrack( | 46 void MediaStreamAudioSource::AddTrack( |
47 const blink::WebMediaStreamTrack& track, | 47 const blink::WebMediaStreamTrack& track, |
48 const blink::WebMediaConstraints& constraints, | 48 const blink::WebMediaConstraints& constraints, |
49 const ConstraintsCallback& callback) { | 49 const ConstraintsCallback& callback) { |
50 // TODO(xians): Properly implement for audio sources. | 50 // TODO(xians): Properly implement for audio sources. |
51 if (!local_audio_source_) { | 51 if (!local_audio_source_.get()) { |
52 if (!factory_->InitializeMediaStreamAudioSource(render_view_id_, | 52 if (!factory_->InitializeMediaStreamAudioSource(render_view_id_, |
53 constraints, | 53 constraints, |
54 this)) { | 54 this)) { |
55 // The source failed to start. | 55 // The source failed to start. |
56 // MediaStreamImpl rely on the |stop_callback| to be triggered when the | 56 // MediaStreamImpl rely on the |stop_callback| to be triggered when the |
57 // last track is removed from the source. But in this case, the source is | 57 // last track is removed from the source. But in this case, the source is |
58 // is not even started. So we need to fail both adding the track and | 58 // is not even started. So we need to fail both adding the track and |
59 // trigger |stop_callback|. | 59 // trigger |stop_callback|. |
60 callback.Run(this, MEDIA_DEVICE_TRACK_START_FAILURE, ""); | 60 callback.Run(this, MEDIA_DEVICE_TRACK_START_FAILURE, ""); |
61 StopSource(); | 61 StopSource(); |
62 return; | 62 return; |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 factory_->CreateLocalAudioTrack(track); | 66 factory_->CreateLocalAudioTrack(track); |
67 callback.Run(this, MEDIA_DEVICE_OK, ""); | 67 callback.Run(this, MEDIA_DEVICE_OK, ""); |
68 } | 68 } |
69 | 69 |
70 } // namespace content | 70 } // namespace content |
OLD | NEW |