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

Side by Side Diff: content/renderer/media/media_stream_audio_source.cc

Issue 1721273002: MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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 "third_party/WebKit/public/platform/WebMediaStreamSource.h"
8 9
9 namespace content { 10 namespace content {
10 11
11 MediaStreamAudioSource::MediaStreamAudioSource( 12 MediaStreamAudioSource::MediaStreamAudioSource(
12 int render_frame_id, 13 int render_frame_id,
13 const StreamDeviceInfo& device_info, 14 const StreamDeviceInfo& device_info,
14 const SourceStoppedCallback& stop_callback, 15 const SourceStoppedCallback& stop_callback,
15 PeerConnectionDependencyFactory* factory) 16 PeerConnectionDependencyFactory* factory)
16 : render_frame_id_(render_frame_id), factory_(factory) { 17 : render_frame_id_(render_frame_id), factory_(factory) {
17 SetDeviceInfo(device_info); 18 SetDeviceInfo(device_info);
18 SetStopCallback(stop_callback); 19 SetStopCallback(stop_callback);
19 } 20 }
20 21
21 MediaStreamAudioSource::MediaStreamAudioSource() 22 MediaStreamAudioSource::MediaStreamAudioSource()
22 : render_frame_id_(-1), factory_(NULL) { 23 : render_frame_id_(-1), factory_(NULL) {
23 } 24 }
24 25
25 MediaStreamAudioSource::~MediaStreamAudioSource() {} 26 MediaStreamAudioSource::~MediaStreamAudioSource() {}
26 27
28 // static
29 MediaStreamAudioSource* MediaStreamAudioSource::From(
30 const blink::WebMediaStreamSource& source) {
31 if (source.isNull() ||
32 source.type() != blink::WebMediaStreamSource::TypeAudio) {
33 return nullptr;
34 }
35 return static_cast<MediaStreamAudioSource*>(source.extraData());
36 }
37
27 void MediaStreamAudioSource::DoStopSource() { 38 void MediaStreamAudioSource::DoStopSource() {
28 if (audio_capturer_.get()) 39 if (audio_capturer_.get())
29 audio_capturer_->Stop(); 40 audio_capturer_->Stop();
30 } 41 }
31 42
32 void MediaStreamAudioSource::AddTrack( 43 void MediaStreamAudioSource::AddTrack(
33 const blink::WebMediaStreamTrack& track, 44 const blink::WebMediaStreamTrack& track,
34 const blink::WebMediaConstraints& constraints, 45 const blink::WebMediaConstraints& constraints,
35 const ConstraintsCallback& callback) { 46 const ConstraintsCallback& callback) {
36 // TODO(xians): Properly implement for audio sources. 47 // TODO(xians): Properly implement for audio sources.
37 if (!local_audio_source_.get()) { 48 if (!local_audio_source_.get()) {
38 if (!factory_->InitializeMediaStreamAudioSource(render_frame_id_, 49 if (!factory_->InitializeMediaStreamAudioSource(render_frame_id_,
39 constraints, this)) { 50 constraints, this)) {
40 // The source failed to start. 51 // The source failed to start.
41 // UserMediaClientImpl rely on the |stop_callback| to be triggered when 52 // UserMediaClientImpl rely on the |stop_callback| to be triggered when
42 // the last track is removed from the source. But in this case, the 53 // the last track is removed from the source. But in this case, the
43 // source is is not even started. So we need to fail both adding the 54 // source is is not even started. So we need to fail both adding the
44 // track and trigger |stop_callback|. 55 // track and trigger |stop_callback|.
45 callback.Run(this, MEDIA_DEVICE_TRACK_START_FAILURE, ""); 56 callback.Run(this, MEDIA_DEVICE_TRACK_START_FAILURE, "");
46 StopSource(); 57 StopSource();
47 return; 58 return;
48 } 59 }
49 } 60 }
50 61
51 factory_->CreateLocalAudioTrack(track); 62 factory_->CreateLocalAudioTrack(track);
52 callback.Run(this, MEDIA_DEVICE_OK, ""); 63 callback.Run(this, MEDIA_DEVICE_OK, "");
53 } 64 }
54 65
55 } // namespace content 66 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698