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()); | 17 DCHECK(thread_checker_.CalledOnValidThread()); |
18 DCHECK(stop_callback_.is_null()); | 18 DCHECK(stop_callback_.is_null()); |
19 } | 19 } |
20 | 20 |
21 void MediaStreamSource::StopSource() { | 21 void MediaStreamSource::StopSource() { |
22 DCHECK(thread_checker_.CalledOnValidThread()); | 22 DCHECK(thread_checker_.CalledOnValidThread()); |
23 DoStopSource(); | 23 DoStopSource(); |
24 if (!stop_callback_.is_null()) | 24 if (!stop_callback_.is_null()) |
25 base::ResetAndReturn(&stop_callback_).Run(Owner()); | 25 base::ResetAndReturn(&stop_callback_).Run(Owner()); |
26 Owner().SetReadyState(blink::WebMediaStreamSource::kReadyStateEnded); | 26 Owner().SetReadyState(blink::WebMediaStreamSource::kReadyStateEnded); |
27 } | 27 } |
28 | 28 |
| 29 void MediaStreamSource::SetSourceMuted(bool is_muted) { |
| 30 DCHECK(thread_checker_.CalledOnValidThread()); |
| 31 // Although this change is valid only if the ready state isn't already Ended, |
| 32 // there's code further along (like in blink::MediaStreamTrack) which filters |
| 33 // that out alredy. |
| 34 Owner().SetReadyState(is_muted |
| 35 ? blink::WebMediaStreamSource::kReadyStateMuted |
| 36 : blink::WebMediaStreamSource::kReadyStateLive); |
| 37 } |
| 38 |
29 void MediaStreamSource::SetDeviceInfo(const StreamDeviceInfo& device_info) { | 39 void MediaStreamSource::SetDeviceInfo(const StreamDeviceInfo& device_info) { |
30 DCHECK(thread_checker_.CalledOnValidThread()); | 40 DCHECK(thread_checker_.CalledOnValidThread()); |
31 device_info_ = device_info; | 41 device_info_ = device_info; |
32 } | 42 } |
33 | 43 |
34 void MediaStreamSource::SetStopCallback( | 44 void MediaStreamSource::SetStopCallback( |
35 const SourceStoppedCallback& stop_callback) { | 45 const SourceStoppedCallback& stop_callback) { |
36 DCHECK(thread_checker_.CalledOnValidThread()); | 46 DCHECK(thread_checker_.CalledOnValidThread()); |
37 DCHECK(stop_callback_.is_null()); | 47 DCHECK(stop_callback_.is_null()); |
38 stop_callback_ = stop_callback; | 48 stop_callback_ = stop_callback; |
39 } | 49 } |
40 | 50 |
41 void MediaStreamSource::ResetSourceStoppedCallback() { | 51 void MediaStreamSource::ResetSourceStoppedCallback() { |
42 DCHECK(thread_checker_.CalledOnValidThread()); | 52 DCHECK(thread_checker_.CalledOnValidThread()); |
43 DCHECK(!stop_callback_.is_null()); | 53 DCHECK(!stop_callback_.is_null()); |
44 stop_callback_.Reset(); | 54 stop_callback_.Reset(); |
45 } | 55 } |
46 | 56 |
47 } // namespace content | 57 } // namespace content |
OLD | NEW |