Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / HTMLMediaElement.h
1 /*
2  * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 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 HTMLMediaElement_h
27 #define HTMLMediaElement_h
28
29 #include "core/dom/ActiveDOMObject.h"
30 #include "core/events/GenericEventQueue.h"
31 #include "core/html/HTMLElement.h"
32 #include "core/html/MediaControllerInterface.h"
33 #include "core/html/track/TextTrack.h"
34 #include "core/html/track/TextTrackCue.h"
35 #include "core/html/track/vtt/VTTCue.h"
36 #include "platform/PODIntervalTree.h"
37 #include "platform/graphics/media/MediaPlayer.h"
38 #include "public/platform/WebMimeRegistry.h"
39
40 namespace blink {
41 class WebContentDecryptionModule;
42 class WebInbandTextTrack;
43 class WebLayer;
44 }
45
46 namespace WebCore {
47
48 #if ENABLE(WEB_AUDIO)
49 class AudioSourceProvider;
50 class MediaElementAudioSourceNode;
51 #endif
52 class ContentType;
53 class Event;
54 class ExceptionState;
55 class HTMLSourceElement;
56 class HTMLTrackElement;
57 class KURL;
58 class MediaController;
59 class MediaControls;
60 class MediaError;
61 class MediaKeys;
62 class HTMLMediaSource;
63 class TextTrackList;
64 class TimeRanges;
65 class URLRegistry;
66
67 typedef PODIntervalTree<double, TextTrackCue*> CueIntervalTree;
68 typedef CueIntervalTree::IntervalType CueInterval;
69 typedef Vector<CueInterval> CueList;
70
71 // FIXME: The inheritance from MediaPlayerClient here should be private inheritance.
72 // But it can't be until the Chromium WebMediaPlayerClientImpl class is fixed so it
73 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement.
74
75 class HTMLMediaElement : public HTMLElement, public MediaPlayerClient, public ActiveDOMObject, public MediaControllerInterface
76     , private TextTrackClient
77 {
78 public:
79     static blink::WebMimeRegistry::SupportsType supportsType(const ContentType&, const String& keySystem = String());
80
81     static void setMediaStreamRegistry(URLRegistry*);
82     static bool isMediaStreamURL(const String& url);
83
84     MediaPlayer* player() const { return m_player.get(); }
85
86     virtual bool isVideo() const = 0;
87     virtual bool hasVideo() const OVERRIDE { return false; }
88     virtual bool hasAudio() const OVERRIDE FINAL;
89
90     bool supportsSave() const;
91
92     blink::WebLayer* platformLayer() const;
93
94     enum DelayedActionType {
95         LoadMediaResource = 1 << 0,
96         LoadTextTrackResource = 1 << 1,
97         TextTrackChangesNotification = 1 << 2
98     };
99     void scheduleDelayedAction(DelayedActionType);
100
101     bool isActive() const { return m_active; }
102
103     // error state
104     PassRefPtr<MediaError> error() const;
105
106     // network state
107     void setSrc(const AtomicString&);
108     const KURL& currentSrc() const { return m_currentSrc; }
109
110     enum NetworkState { NETWORK_EMPTY, NETWORK_IDLE, NETWORK_LOADING, NETWORK_NO_SOURCE };
111     NetworkState networkState() const;
112
113     String preload() const;
114     void setPreload(const AtomicString&);
115
116     PassRefPtr<TimeRanges> buffered() const;
117     void load();
118     String canPlayType(const String& mimeType, const String& keySystem = String()) const;
119
120     // ready state
121     enum ReadyState { HAVE_NOTHING, HAVE_METADATA, HAVE_CURRENT_DATA, HAVE_FUTURE_DATA, HAVE_ENOUGH_DATA };
122     ReadyState readyState() const;
123     bool seeking() const;
124
125     // playback state
126     virtual double currentTime() const OVERRIDE FINAL;
127     virtual void setCurrentTime(double, ExceptionState&) OVERRIDE FINAL;
128     virtual double duration() const OVERRIDE FINAL;
129     virtual bool paused() const OVERRIDE FINAL;
130     double defaultPlaybackRate() const;
131     void setDefaultPlaybackRate(double);
132     double playbackRate() const;
133     void setPlaybackRate(double);
134     void updatePlaybackRate();
135     PassRefPtr<TimeRanges> played();
136     PassRefPtr<TimeRanges> seekable() const;
137     bool ended() const;
138     bool autoplay() const;
139     bool loop() const;
140     void setLoop(bool b);
141     virtual void play() OVERRIDE FINAL;
142     virtual void pause() OVERRIDE FINAL;
143
144     // statistics
145     unsigned webkitAudioDecodedByteCount() const;
146     unsigned webkitVideoDecodedByteCount() const;
147
148     // media source extensions
149     void closeMediaSource();
150     void durationChanged(double duration);
151
152     // encrypted media extensions (v0.1b)
153     void webkitGenerateKeyRequest(const String& keySystem, PassRefPtr<Uint8Array> initData, ExceptionState&);
154     void webkitGenerateKeyRequest(const String& keySystem, ExceptionState&);
155     void webkitAddKey(const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionState&);
156     void webkitAddKey(const String& keySystem, PassRefPtr<Uint8Array> key, ExceptionState&);
157     void webkitCancelKeyRequest(const String& keySystem, const String& sessionId, ExceptionState&);
158
159     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeyadded);
160     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeyerror);
161     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeymessage);
162     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitneedkey);
163
164     // encrypted media extensions (WD)
165     MediaKeys* mediaKeys() const { return m_mediaKeys.get(); }
166     void setMediaKeys(MediaKeys*, ExceptionState&);
167     DEFINE_ATTRIBUTE_EVENT_LISTENER(needkey);
168
169     // controls
170     bool controls() const;
171     void setControls(bool);
172     virtual double volume() const OVERRIDE FINAL;
173     virtual void setVolume(double, ExceptionState&) OVERRIDE FINAL;
174     virtual bool muted() const OVERRIDE FINAL;
175     virtual void setMuted(bool) OVERRIDE FINAL;
176
177     virtual void beginScrubbing() OVERRIDE FINAL;
178     virtual void endScrubbing() OVERRIDE FINAL;
179
180     virtual bool canPlay() const OVERRIDE FINAL;
181
182     PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, const AtomicString& label, const AtomicString& language, ExceptionState&);
183     PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, const AtomicString& label, ExceptionState& exceptionState) { return addTextTrack(kind, label, emptyAtom, exceptionState); }
184     PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, ExceptionState& exceptionState) { return addTextTrack(kind, emptyAtom, emptyAtom, exceptionState); }
185
186     TextTrackList* textTracks();
187     CueList currentlyActiveCues() const { return m_currentlyActiveCues; }
188
189     void addTrack(TextTrack*);
190     void removeTrack(TextTrack*);
191     void removeAllInbandTracks();
192     void closeCaptionTracksChanged();
193     void notifyMediaPlayerOfTextTrackChanges();
194
195     void didAddTrack(HTMLTrackElement*);
196     void didRemoveTrack(HTMLTrackElement*);
197
198     virtual void mediaPlayerDidAddTrack(blink::WebInbandTextTrack*) OVERRIDE FINAL;
199     virtual void mediaPlayerDidRemoveTrack(blink::WebInbandTextTrack*) OVERRIDE FINAL;
200     // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not depend on it.
201     virtual KURL mediaPlayerPosterURL() OVERRIDE { return KURL(); }
202
203     struct TrackGroup {
204         enum GroupKind { CaptionsAndSubtitles, Description, Chapter, Metadata, Other };
205
206         TrackGroup(GroupKind kind)
207             : visibleTrack(0)
208             , defaultTrack(0)
209             , kind(kind)
210             , hasSrcLang(false)
211         {
212         }
213
214         Vector<RefPtr<TextTrack> > tracks;
215         RefPtr<TextTrack> visibleTrack;
216         RefPtr<TextTrack> defaultTrack;
217         GroupKind kind;
218         bool hasSrcLang;
219     };
220
221     void configureTextTrackGroupForLanguage(const TrackGroup&) const;
222     void configureTextTracks();
223     void configureTextTrackGroup(const TrackGroup&);
224
225     bool textTracksAreReady() const;
226     enum VisibilityChangeAssumption {
227         AssumeNoVisibleChange,
228         AssumeVisibleChange
229     };
230     void configureTextTrackDisplay(VisibilityChangeAssumption);
231     void updateTextTrackDisplay();
232     void textTrackReadyStateChanged(TextTrack*);
233
234     // TextTrackClient
235     virtual void textTrackKindChanged(TextTrack*) OVERRIDE FINAL;
236     virtual void textTrackModeChanged(TextTrack*) OVERRIDE FINAL;
237     virtual void textTrackAddCues(TextTrack*, const TextTrackCueList*) OVERRIDE FINAL;
238     virtual void textTrackRemoveCues(TextTrack*, const TextTrackCueList*) OVERRIDE FINAL;
239     virtual void textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue>) OVERRIDE FINAL;
240     virtual void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>) OVERRIDE FINAL;
241
242     // EventTarget function.
243     // Both Node (via HTMLElement) and ActiveDOMObject define this method, which
244     // causes an ambiguity error at compile time. This class's constructor
245     // ensures that both implementations return document, so return the result
246     // of one of them here.
247     virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return HTMLElement::executionContext(); }
248
249     bool hasSingleSecurityOrigin() const { return !m_player || m_player->hasSingleSecurityOrigin(); }
250
251     bool isFullscreen() const;
252     virtual void enterFullscreen() OVERRIDE FINAL;
253     void exitFullscreen();
254
255     virtual bool hasClosedCaptions() const OVERRIDE FINAL;
256     virtual bool closedCaptionsVisible() const OVERRIDE FINAL;
257     virtual void setClosedCaptionsVisible(bool) OVERRIDE FINAL;
258
259     MediaControls* mediaControls() const;
260
261     void sourceWasRemoved(HTMLSourceElement*);
262     void sourceWasAdded(HTMLSourceElement*);
263
264     bool isPlaying() const { return m_playing; }
265
266     // ActiveDOMObject functions.
267     virtual bool hasPendingActivity() const OVERRIDE FINAL;
268     virtual void contextDestroyed() OVERRIDE FINAL;
269
270 #if ENABLE(WEB_AUDIO)
271     MediaElementAudioSourceNode* audioSourceNode() { return m_audioSourceNode; }
272     void setAudioSourceNode(MediaElementAudioSourceNode*);
273
274     AudioSourceProvider* audioSourceProvider();
275 #endif
276
277     enum InvalidURLAction { DoNothing, Complain };
278     bool isSafeToLoadURL(const KURL&, InvalidURLAction);
279
280     MediaController* controller() const;
281     void setController(PassRefPtr<MediaController>); // Resets the MediaGroup and sets the MediaController.
282
283 protected:
284     HTMLMediaElement(const QualifiedName&, Document&);
285     virtual ~HTMLMediaElement();
286
287     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
288     virtual void finishParsingChildren() OVERRIDE FINAL;
289     virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
290     virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
291
292     virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE;
293
294     enum DisplayMode { Unknown, Poster, PosterWaitingForVideo, Video };
295     DisplayMode displayMode() const { return m_displayMode; }
296     virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; }
297
298     virtual bool isMediaElement() const OVERRIDE FINAL { return true; }
299
300     void setControllerInternal(PassRefPtr<MediaController>);
301
302     // Restrictions to change default behaviors.
303     enum BehaviorRestrictionFlags {
304         NoRestrictions = 0,
305         RequireUserGestureForPlayRestriction = 1 << 0,
306         RequireUserGestureForFullscreenRestriction = 1 << 1,
307     };
308     typedef unsigned BehaviorRestrictions;
309
310     bool userGestureRequiredForPlay() const { return m_restrictions & RequireUserGestureForPlayRestriction; }
311     bool userGestureRequiredForFullscreen() const { return m_restrictions & RequireUserGestureForFullscreenRestriction; }
312
313     void addBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions |= restriction; }
314     void removeBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions &= ~restriction; }
315
316     bool ignoreTrackDisplayUpdateRequests() const { return m_ignoreTrackDisplayUpdate > 0; }
317     void beginIgnoringTrackDisplayUpdateRequests();
318     void endIgnoringTrackDisplayUpdateRequests();
319
320 private:
321     void createMediaPlayer();
322
323     virtual bool alwaysCreateUserAgentShadowRoot() const OVERRIDE FINAL { return true; }
324     virtual bool areAuthorShadowsAllowed() const OVERRIDE FINAL { return false; }
325
326     virtual bool hasCustomFocusLogic() const OVERRIDE FINAL;
327     virtual bool supportsFocus() const OVERRIDE FINAL;
328     virtual bool isMouseFocusable() const OVERRIDE FINAL;
329     virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE;
330     virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
331     virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE FINAL;
332     virtual void removedFrom(ContainerNode*) OVERRIDE FINAL;
333     virtual void didRecalcStyle(StyleRecalcChange) OVERRIDE FINAL;
334
335     virtual void didBecomeFullscreenElement() OVERRIDE FINAL;
336     virtual void willStopBeingFullscreenElement() OVERRIDE FINAL;
337     virtual bool isInteractiveContent() const OVERRIDE FINAL;
338
339     // ActiveDOMObject functions.
340     virtual void stop() OVERRIDE FINAL;
341
342     virtual void updateDisplayState() { }
343
344     void setReadyState(MediaPlayer::ReadyState);
345     void setNetworkState(MediaPlayer::NetworkState);
346
347     virtual void mediaPlayerNetworkStateChanged() OVERRIDE FINAL;
348     virtual void mediaPlayerReadyStateChanged() OVERRIDE FINAL;
349     virtual void mediaPlayerTimeChanged() OVERRIDE FINAL;
350     virtual void mediaPlayerDurationChanged() OVERRIDE FINAL;
351     virtual void mediaPlayerPlaybackStateChanged() OVERRIDE FINAL;
352     virtual void mediaPlayerRequestFullscreen() OVERRIDE FINAL;
353     virtual void mediaPlayerRequestSeek(double) OVERRIDE FINAL;
354     virtual void mediaPlayerRepaint() OVERRIDE FINAL;
355     virtual void mediaPlayerSizeChanged() OVERRIDE FINAL;
356
357     virtual void mediaPlayerKeyAdded(const String& keySystem, const String& sessionId) OVERRIDE FINAL;
358     virtual void mediaPlayerKeyError(const String& keySystem, const String& sessionId, MediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode) OVERRIDE FINAL;
359     virtual void mediaPlayerKeyMessage(const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength, const KURL& defaultURL) OVERRIDE FINAL;
360     virtual bool mediaPlayerKeyNeeded(const String& contentType, const unsigned char* initData, unsigned initDataLength) OVERRIDE FINAL;
361
362     virtual CORSMode mediaPlayerCORSMode() const OVERRIDE FINAL;
363
364     virtual void mediaPlayerSetWebLayer(blink::WebLayer*) OVERRIDE FINAL;
365     virtual void mediaPlayerSetOpaque(bool) OVERRIDE FINAL;
366     virtual void mediaPlayerMediaSourceOpened(blink::WebMediaSource*) OVERRIDE FINAL;
367
368     void loadTimerFired(Timer<HTMLMediaElement>*);
369     void progressEventTimerFired(Timer<HTMLMediaElement>*);
370     void playbackProgressTimerFired(Timer<HTMLMediaElement>*);
371     void startPlaybackProgressTimer();
372     void startProgressEventTimer();
373     void stopPeriodicTimers();
374
375     void seek(double time, ExceptionState&);
376     void finishSeek();
377     void checkIfSeekNeeded();
378     void addPlayedRange(double start, double end);
379
380     void scheduleTimeupdateEvent(bool periodicEvent);
381     void scheduleEvent(const AtomicString& eventName);
382
383     // loading
384     void prepareForLoad();
385     void loadInternal();
386     void selectMediaResource();
387     void loadResource(const KURL&, ContentType&, const String& keySystem);
388     void scheduleNextSourceChild();
389     void loadNextSourceChild();
390     void userCancelledLoad();
391     void clearMediaPlayer(int flags);
392     void clearMediaPlayerAndAudioSourceProviderClient();
393     bool havePotentialSourceChild();
394     void noneSupported();
395     void mediaEngineError(PassRefPtr<MediaError> err);
396     void cancelPendingEventsAndCallbacks();
397     void waitForSourceChange();
398     void prepareToPlay();
399
400     KURL selectNextSourceChild(ContentType*, String* keySystem, InvalidURLAction);
401
402     void mediaLoadingFailed(MediaPlayer::NetworkState);
403
404     void updateActiveTextTrackCues(double);
405     HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const;
406
407     void markCaptionAndSubtitleTracksAsUnconfigured();
408
409     // This does not check user gesture restrictions.
410     void playInternal();
411
412     void allowVideoRendering();
413
414     void updateVolume();
415     void updatePlayState();
416     bool potentiallyPlaying() const;
417     bool endedPlayback() const;
418     bool stoppedDueToErrors() const;
419     bool pausedForUserInteraction() const;
420     bool couldPlayIfEnoughData() const;
421
422     // Pauses playback without changing any states or generating events
423     void setPausedInternal(bool);
424
425     void setPlaybackRateInternal(double);
426
427     void setShouldDelayLoadEvent(bool);
428     void invalidateCachedTime();
429     void refreshCachedTime() const;
430
431     bool hasMediaControls() const;
432     bool createMediaControls();
433     void configureMediaControls();
434
435     void prepareMediaFragmentURI();
436     void applyMediaFragmentURI();
437
438     virtual void* preDispatchEventHandler(Event*) OVERRIDE FINAL;
439
440     void changeNetworkStateFromLoadingToIdle();
441
442     void removeBehaviorsRestrictionsAfterFirstUserGesture();
443
444     const AtomicString& mediaGroup() const;
445     void setMediaGroup(const AtomicString&);
446     void updateMediaController();
447     bool isBlocked() const;
448     bool isBlockedOnMediaController() const;
449     bool isAutoplaying() const { return m_autoplaying; }
450
451     // Currently we have both EME v0.1b and EME WD implemented in media element.
452     // But we do not want to support both at the same time. The one used first
453     // will be supported. Use |m_emeMode| to track this selection.
454     // FIXME: Remove EmeMode once EME v0.1b support is removed. See crbug.com/249976.
455     enum EmeMode { EmeModeNotSelected, EmeModePrefixed, EmeModeUnprefixed };
456
457     // check (and set if necessary) the encrypted media extensions (EME) mode
458     // (v0.1b or WD). Returns whether the mode is allowed and successfully set.
459     bool setEmeMode(EmeMode, ExceptionState&);
460
461     blink::WebContentDecryptionModule* contentDecryptionModule();
462     void setMediaKeysInternal(MediaKeys*);
463
464     Timer<HTMLMediaElement> m_loadTimer;
465     Timer<HTMLMediaElement> m_progressEventTimer;
466     Timer<HTMLMediaElement> m_playbackProgressTimer;
467     RefPtr<TimeRanges> m_playedTimeRanges;
468     OwnPtr<GenericEventQueue> m_asyncEventQueue;
469
470     double m_playbackRate;
471     double m_defaultPlaybackRate;
472     NetworkState m_networkState;
473     ReadyState m_readyState;
474     ReadyState m_readyStateMaximum;
475     KURL m_currentSrc;
476
477     RefPtr<MediaError> m_error;
478
479     double m_volume;
480     double m_lastSeekTime;
481
482     double m_previousProgressTime;
483
484     // Cached duration to suppress duplicate events if duration unchanged.
485     double m_duration;
486
487     // The last time a timeupdate event was sent (wall clock).
488     double m_lastTimeUpdateEventWallTime;
489
490     // The last time a timeupdate event was sent in movie time.
491     double m_lastTimeUpdateEventMovieTime;
492
493     // Loading state.
494     enum LoadState { WaitingForSource, LoadingFromSrcAttr, LoadingFromSourceElement };
495     LoadState m_loadState;
496     RefPtr<HTMLSourceElement> m_currentSourceNode;
497     RefPtr<Node> m_nextChildNodeToConsider;
498
499     OwnPtr<MediaPlayer> m_player;
500     blink::WebLayer* m_webLayer;
501     bool m_opaque;
502
503     BehaviorRestrictions m_restrictions;
504
505     MediaPlayer::Preload m_preload;
506
507     DisplayMode m_displayMode;
508
509     RefPtr<HTMLMediaSource> m_mediaSource;
510
511     mutable double m_cachedTime;
512     mutable double m_cachedTimeWallClockUpdateTime;
513     mutable double m_minimumWallClockTimeToCacheMediaTime;
514
515     double m_fragmentStartTime;
516     double m_fragmentEndTime;
517
518     typedef unsigned PendingActionFlags;
519     PendingActionFlags m_pendingActionFlags;
520
521     // FIXME: MediaElement has way too many state bits.
522     bool m_playing : 1;
523     bool m_shouldDelayLoadEvent : 1;
524     bool m_haveFiredLoadedData : 1;
525     bool m_active : 1;
526     bool m_autoplaying : 1;
527     bool m_muted : 1;
528     bool m_paused : 1;
529     bool m_seeking : 1;
530
531     // data has not been loaded since sending a "stalled" event
532     bool m_sentStalledEvent : 1;
533
534     // time has not changed since sending an "ended" event
535     bool m_sentEndEvent : 1;
536
537     bool m_pausedInternal : 1;
538
539     bool m_closedCaptionsVisible : 1;
540
541     bool m_completelyLoaded : 1;
542     bool m_havePreparedToPlay : 1;
543
544     bool m_tracksAreReady : 1;
545     bool m_haveVisibleTextTrack : 1;
546     bool m_processingPreferenceChange : 1;
547     double m_lastTextTrackUpdateTime;
548
549     RefPtr<TextTrackList> m_textTracks;
550     Vector<RefPtr<TextTrack> > m_textTracksWhenResourceSelectionBegan;
551
552     CueIntervalTree m_cueTree;
553
554     CueList m_currentlyActiveCues;
555     int m_ignoreTrackDisplayUpdate;
556
557 #if ENABLE(WEB_AUDIO)
558     // This is a weak reference, since m_audioSourceNode holds a reference to us.
559     // The value is set just after the MediaElementAudioSourceNode is created.
560     // The value is cleared in MediaElementAudioSourceNode::~MediaElementAudioSourceNode().
561     MediaElementAudioSourceNode* m_audioSourceNode;
562 #endif
563
564     friend class MediaController;
565     RefPtr<MediaController> m_mediaController;
566
567     friend class TrackDisplayUpdateScope;
568
569     EmeMode m_emeMode;
570
571     RefPtrWillBePersistent<MediaKeys> m_mediaKeys;
572
573     static URLRegistry* s_mediaStreamRegistry;
574 };
575
576 #ifndef NDEBUG
577 // Template specializations required by PodIntervalTree in debug mode.
578 template <>
579 struct ValueToString<double> {
580     static String string(const double value)
581     {
582         return String::number(value);
583     }
584 };
585
586 template <>
587 struct ValueToString<TextTrackCue*> {
588     static String string(TextTrackCue* const& cue)
589     {
590         return cue->toString();
591     }
592 };
593 #endif
594
595 inline bool isHTMLMediaElement(const Node& node)
596 {
597     return node.isElementNode() && toElement(node).isMediaElement();
598 }
599
600 DEFINE_NODE_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement);
601
602 } //namespace
603
604 #endif