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

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

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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_source.h" 5 #include "content/renderer/media/media_stream_source.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 const char MediaStreamSource::kSourceId[] = "sourceId"; 11 const char MediaStreamSource::kSourceId[] = "sourceId";
12 12
13 MediaStreamSource::MediaStreamSource() { 13 MediaStreamSource::MediaStreamSource() {
14 } 14 }
15 15
16 MediaStreamSource::~MediaStreamSource() {} 16 MediaStreamSource::~MediaStreamSource() {
17 DCHECK(thread_checker_.CalledOnValidThread());
18 RunStopCallbackAndEndStream();
19 }
17 20
18 void MediaStreamSource::StopSource() { 21 void MediaStreamSource::StopSource() {
22 DCHECK(thread_checker_.CalledOnValidThread());
19 DoStopSource(); 23 DoStopSource();
24 RunStopCallbackAndEndStream();
25 }
26
27 void MediaStreamSource::SetDeviceInfo(const StreamDeviceInfo& device_info) {
28 DCHECK(thread_checker_.CalledOnValidThread());
29 device_info_ = device_info;
30 }
31
32 void MediaStreamSource::SetStopCallback(
33 const SourceStoppedCallback& stop_callback) {
34 DCHECK(thread_checker_.CalledOnValidThread());
35 DCHECK(stop_callback_.is_null());
36 stop_callback_ = stop_callback;
37 }
38
39 void MediaStreamSource::ResetSourceStoppedCallback() {
40 DCHECK(thread_checker_.CalledOnValidThread());
41 DCHECK(!stop_callback_.is_null());
42 stop_callback_.Reset();
43 }
44
45 void MediaStreamSource::RunStopCallbackAndEndStream() {
46 DCHECK(thread_checker_.CalledOnValidThread());
20 if (!stop_callback_.is_null()) 47 if (!stop_callback_.is_null())
21 base::ResetAndReturn(&stop_callback_).Run(owner()); 48 base::ResetAndReturn(&stop_callback_).Run(owner());
22 49 if (!owner().isNull())
23 owner().setReadyState(blink::WebMediaStreamSource::ReadyStateEnded); 50 owner().setReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
24 } 51 }
25 52
26 } // namespace content 53 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_source.h ('k') | content/renderer/media/mock_audio_device_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698