OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
6 #include "modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" | 6 #include "modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
11 #include "modules/audio_output_devices/SetSinkIdCallbacks.h" | 11 #include "modules/audio_output_devices/SetSinkIdCallbacks.h" |
12 #include "platform/Logging.h" | 12 #include "platform/Logging.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 HTMLMediaElementAudioOutputDevice::HTMLMediaElementAudioOutputDevice() | 16 HTMLMediaElementAudioOutputDevice::HTMLMediaElementAudioOutputDevice() |
17 : m_sinkId("") | 17 : m_sinkId("") |
18 { | 18 { |
19 } | 19 } |
20 | 20 |
21 String HTMLMediaElementAudioOutputDevice::sinkId(HTMLMediaElement& element) | 21 String HTMLMediaElementAudioOutputDevice::sinkId(HTMLMediaElement& element) |
22 { | 22 { |
23 WTF_LOG(Media, __FUNCTION__); | |
24 HTMLMediaElementAudioOutputDevice& aodElement = HTMLMediaElementAudioOutputD
evice::from(element); | 23 HTMLMediaElementAudioOutputDevice& aodElement = HTMLMediaElementAudioOutputD
evice::from(element); |
25 return aodElement.m_sinkId; | 24 return aodElement.m_sinkId; |
26 } | 25 } |
27 | 26 |
28 void HTMLMediaElementAudioOutputDevice::setSinkId(const String& sinkId) | 27 void HTMLMediaElementAudioOutputDevice::setSinkId(const String& sinkId) |
29 { | 28 { |
30 m_sinkId = sinkId; | 29 m_sinkId = sinkId; |
31 } | 30 } |
32 | 31 |
33 ScriptPromise HTMLMediaElementAudioOutputDevice::setSinkId(ScriptState* scriptSt
ate, HTMLMediaElement& element, const String& sinkId) | 32 ScriptPromise HTMLMediaElementAudioOutputDevice::setSinkId(ScriptState* scriptSt
ate, HTMLMediaElement& element, const String& sinkId) |
34 { | 33 { |
35 WTF_LOG(Media, __FUNCTION__); | |
36 WebMediaPlayer* webMediaPlayer = element.webMediaPlayer(); | 34 WebMediaPlayer* webMediaPlayer = element.webMediaPlayer(); |
37 if (!webMediaPlayer) | 35 if (!webMediaPlayer) |
38 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "No media player available")); | 36 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "No media player available")); |
39 | 37 |
40 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 38 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
41 HTMLMediaElementAudioOutputDevice& aodElement = HTMLMediaElementAudioOutputD
evice::from(element); | 39 HTMLMediaElementAudioOutputDevice& aodElement = HTMLMediaElementAudioOutputD
evice::from(element); |
42 if (sinkId == aodElement.m_sinkId) | 40 if (sinkId == aodElement.m_sinkId) |
43 resolver->resolve(); | 41 resolver->resolve(); |
44 else | 42 else |
45 webMediaPlayer->setSinkId(sinkId, new SetSinkIdCallbacks(resolver, eleme
nt, sinkId)); | 43 webMediaPlayer->setSinkId(sinkId, new SetSinkIdCallbacks(resolver, eleme
nt, sinkId)); |
(...skipping 15 matching lines...) Expand all Loading... |
61 } | 59 } |
62 return *supplement; | 60 return *supplement; |
63 } | 61 } |
64 | 62 |
65 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice) | 63 DEFINE_TRACE(HTMLMediaElementAudioOutputDevice) |
66 { | 64 { |
67 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); | 65 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); |
68 } | 66 } |
69 | 67 |
70 } // namespace blink | 68 } // namespace blink |
OLD | NEW |