| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef MediaController_h | |
| 27 #define MediaController_h | |
| 28 | |
| 29 #include "core/events/EventTarget.h" | |
| 30 #include "core/html/HTMLMediaElement.h" | |
| 31 #include "wtf/LinkedHashSet.h" | |
| 32 #include "wtf/PassRefPtr.h" | |
| 33 #include "wtf/RefCounted.h" | |
| 34 | |
| 35 namespace blink { | |
| 36 | |
| 37 class Clock; | |
| 38 class ExceptionState; | |
| 39 class ExecutionContext; | |
| 40 class GenericEventQueue; | |
| 41 | |
| 42 class MediaController final : public RefCountedGarbageCollectedEventTargetWithIn
lineData<MediaController> { | |
| 43 DEFINE_WRAPPERTYPEINFO(); | |
| 44 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(MediaController); | |
| 45 public: | |
| 46 static MediaController* create(ExecutionContext*); | |
| 47 ~MediaController() override; | |
| 48 | |
| 49 void addMediaElement(HTMLMediaElement*); | |
| 50 void removeMediaElement(HTMLMediaElement*); | |
| 51 | |
| 52 TimeRanges* buffered() const; | |
| 53 TimeRanges* seekable() const; | |
| 54 TimeRanges* played(); | |
| 55 | |
| 56 double duration() const; | |
| 57 double currentTime() const; | |
| 58 void setCurrentTime(double); | |
| 59 | |
| 60 bool paused() const { return m_paused; } | |
| 61 void play(); | |
| 62 void pause(); | |
| 63 void unpause(); | |
| 64 | |
| 65 double defaultPlaybackRate() const { return m_defaultPlaybackRate; } | |
| 66 void setDefaultPlaybackRate(double); | |
| 67 | |
| 68 double playbackRate() const; | |
| 69 void setPlaybackRate(double); | |
| 70 | |
| 71 double volume() const { return m_volume; } | |
| 72 void setVolume(double, ExceptionState&); | |
| 73 | |
| 74 bool muted() const { return m_muted; } | |
| 75 void setMuted(bool); | |
| 76 | |
| 77 typedef HTMLMediaElement::ReadyState ReadyState; | |
| 78 ReadyState readyState() const { return m_readyState; } | |
| 79 | |
| 80 enum PlaybackState { WAITING, PLAYING, ENDED }; | |
| 81 const AtomicString& playbackState() const; | |
| 82 | |
| 83 bool isRestrained() const; | |
| 84 bool isBlocked() const; | |
| 85 | |
| 86 #if !ENABLE(OILPAN) | |
| 87 void clearExecutionContext() { m_executionContext = nullptr; } | |
| 88 #endif | |
| 89 | |
| 90 DECLARE_VIRTUAL_TRACE(); | |
| 91 | |
| 92 private: | |
| 93 MediaController(ExecutionContext*); | |
| 94 void reportControllerState(); | |
| 95 void updateReadyState(); | |
| 96 void updatePlaybackState(); | |
| 97 void updateMediaElements(); | |
| 98 void bringElementUpToSpeed(HTMLMediaElement*); | |
| 99 void scheduleEvent(const AtomicString& eventName); | |
| 100 void clearPositionTimerFired(Timer<MediaController>*); | |
| 101 bool hasEnded() const; | |
| 102 void scheduleTimeupdateEvent(); | |
| 103 void timeupdateTimerFired(Timer<MediaController>*); | |
| 104 void startTimeupdateTimer(); | |
| 105 | |
| 106 // EventTarget | |
| 107 const AtomicString& interfaceName() const override; | |
| 108 ExecutionContext* executionContext() const override { return m_executionCont
ext; } | |
| 109 | |
| 110 friend class HTMLMediaElement; | |
| 111 friend class MediaControllerEventListener; | |
| 112 // FIXME: A MediaController should ideally keep an otherwise | |
| 113 // unreferenced slaved media element alive. When Oilpan is | |
| 114 // enabled by default, consider making the hash set references | |
| 115 // strong to accomplish that. crbug.com/383072 | |
| 116 typedef WillBeHeapLinkedHashSet<RawPtrWillBeWeakMember<HTMLMediaElement>> Me
diaElementSequence; | |
| 117 MediaElementSequence m_mediaElements; | |
| 118 bool m_paused; | |
| 119 double m_defaultPlaybackRate; | |
| 120 double m_volume; | |
| 121 mutable double m_position; | |
| 122 bool m_muted; | |
| 123 ReadyState m_readyState; | |
| 124 PlaybackState m_playbackState; | |
| 125 OwnPtrWillBeMember<GenericEventQueue> m_pendingEventsQueue; | |
| 126 mutable Timer<MediaController> m_clearPositionTimer; | |
| 127 OwnPtr<Clock> m_clock; | |
| 128 RawPtrWillBeWeakMember<ExecutionContext> m_executionContext; | |
| 129 Timer<MediaController> m_timeupdateTimer; | |
| 130 double m_previousTimeupdateTime; | |
| 131 }; | |
| 132 | |
| 133 } // namespace blink | |
| 134 | |
| 135 #endif // MediaController_h | |
| OLD | NEW |