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_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 } | |
20 | 17 |
21 void MediaStreamSource::StopSource() { | 18 void MediaStreamSource::StopSource() { |
22 DCHECK(thread_checker_.CalledOnValidThread()); | |
23 DoStopSource(); | 19 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()); | |
47 if (!stop_callback_.is_null()) | 20 if (!stop_callback_.is_null()) |
48 base::ResetAndReturn(&stop_callback_).Run(owner()); | 21 base::ResetAndReturn(&stop_callback_).Run(owner()); |
49 if (!owner().isNull()) | 22 |
50 owner().setReadyState(blink::WebMediaStreamSource::ReadyStateEnded); | 23 owner().setReadyState(blink::WebMediaStreamSource::ReadyStateEnded); |
51 } | 24 } |
52 | 25 |
53 } // namespace content | 26 } // namespace content |
OLD | NEW |