OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 class VideoTrackList; | 66 class VideoTrackList; |
67 | 67 |
68 // FIXME: The inheritance from MediaPlayerClient here should be private inherita
nce. | 68 // FIXME: The inheritance from MediaPlayerClient here should be private inherita
nce. |
69 // But it can't be until the Chromium WebMediaPlayerClientImpl class is fixed so
it | 69 // But it can't be until the Chromium WebMediaPlayerClientImpl class is fixed so
it |
70 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement. | 70 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement. |
71 | 71 |
72 class CORE_EXPORT HTMLMediaElement : public HTMLElement, public WillBeHeapSupple
mentable<HTMLMediaElement>, public MediaPlayerClient, public ActiveDOMObject { | 72 class CORE_EXPORT HTMLMediaElement : public HTMLElement, public WillBeHeapSupple
mentable<HTMLMediaElement>, public MediaPlayerClient, public ActiveDOMObject { |
73 DEFINE_WRAPPERTYPEINFO(); | 73 DEFINE_WRAPPERTYPEINFO(); |
74 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLMediaElement); | 74 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLMediaElement); |
75 public: | 75 public: |
76 static blink::WebMimeRegistry::SupportsType supportsType(const ContentType&,
const String& keySystem = String()); | 76 static WebMimeRegistry::SupportsType supportsType(const ContentType&, const
String& keySystem = String()); |
77 | 77 |
78 static void setMediaStreamRegistry(URLRegistry*); | 78 static void setMediaStreamRegistry(URLRegistry*); |
79 static bool isMediaStreamURL(const String& url); | 79 static bool isMediaStreamURL(const String& url); |
80 | 80 |
81 DECLARE_VIRTUAL_TRACE(); | 81 DECLARE_VIRTUAL_TRACE(); |
82 #if ENABLE(WEB_AUDIO) | 82 #if ENABLE(WEB_AUDIO) |
83 void clearWeakMembers(Visitor*); | 83 void clearWeakMembers(Visitor*); |
84 #endif | 84 #endif |
85 blink::WebMediaPlayer* webMediaPlayer() const { return m_player ? m_player->
webMediaPlayer() : 0; } | 85 WebMediaPlayer* webMediaPlayer() const { return m_player ? m_player->webMedi
aPlayer() : 0; } |
86 | 86 |
87 virtual bool hasVideo() const { return false; } | 87 virtual bool hasVideo() const { return false; } |
88 bool hasAudio() const; | 88 bool hasAudio() const; |
89 | 89 |
90 bool supportsSave() const; | 90 bool supportsSave() const; |
91 | 91 |
92 blink::WebLayer* platformLayer() const; | 92 WebLayer* platformLayer() const; |
93 | 93 |
94 enum DelayedActionType { | 94 enum DelayedActionType { |
95 LoadMediaResource = 1 << 0, | 95 LoadMediaResource = 1 << 0, |
96 LoadTextTrackResource = 1 << 1, | 96 LoadTextTrackResource = 1 << 1, |
97 TextTrackChangesNotification = 1 << 2 | 97 TextTrackChangesNotification = 1 << 2 |
98 }; | 98 }; |
99 void scheduleDelayedAction(DelayedActionType); | 99 void scheduleDelayedAction(DelayedActionType); |
100 | 100 |
101 bool hasRemoteRoutes() const { return m_remoteRoutesAvailable; } | 101 bool hasRemoteRoutes() const { return m_remoteRoutesAvailable; } |
102 bool isPlayingRemotely() const { return m_playingRemotely; } | 102 bool isPlayingRemotely() const { return m_playingRemotely; } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 // play/pause toggling that uses the media controller if present. togglePlay
StateWillPlay() is | 163 // play/pause toggling that uses the media controller if present. togglePlay
StateWillPlay() is |
164 // true if togglePlayState() will call play() or unpause() on the media elem
ent or controller. | 164 // true if togglePlayState() will call play() or unpause() on the media elem
ent or controller. |
165 bool togglePlayStateWillPlay() const; | 165 bool togglePlayStateWillPlay() const; |
166 void togglePlayState(); | 166 void togglePlayState(); |
167 | 167 |
168 AudioTrackList& audioTracks(); | 168 AudioTrackList& audioTracks(); |
169 void audioTrackChanged(); | 169 void audioTrackChanged(); |
170 | 170 |
171 VideoTrackList& videoTracks(); | 171 VideoTrackList& videoTracks(); |
172 void selectedVideoTrackChanged(blink::WebMediaPlayer::TrackId*); | 172 void selectedVideoTrackChanged(WebMediaPlayer::TrackId*); |
173 | 173 |
174 PassRefPtrWillBeRawPtr<TextTrack> addTextTrack(const AtomicString& kind, con
st AtomicString& label, const AtomicString& language, ExceptionState&); | 174 PassRefPtrWillBeRawPtr<TextTrack> addTextTrack(const AtomicString& kind, con
st AtomicString& label, const AtomicString& language, ExceptionState&); |
175 | 175 |
176 TextTrackList* textTracks(); | 176 TextTrackList* textTracks(); |
177 CueTimeline& cueTimeline(); | 177 CueTimeline& cueTimeline(); |
178 | 178 |
179 void addTextTrack(TextTrack*); | 179 void addTextTrack(TextTrack*); |
180 void removeTextTrack(TextTrack*); | 180 void removeTextTrack(TextTrack*); |
181 void textTracksChanged(); | 181 void textTracksChanged(); |
182 void notifyMediaPlayerOfTextTrackChanges(); | 182 void notifyMediaPlayerOfTextTrackChanges(); |
183 | 183 |
184 // Implements the "forget the media element's media-resource-specific tracks
" algorithm in the HTML5 spec. | 184 // Implements the "forget the media element's media-resource-specific tracks
" algorithm in the HTML5 spec. |
185 void forgetResourceSpecificTracks(); | 185 void forgetResourceSpecificTracks(); |
186 | 186 |
187 void didAddTrackElement(HTMLTrackElement*); | 187 void didAddTrackElement(HTMLTrackElement*); |
188 void didRemoveTrackElement(HTMLTrackElement*); | 188 void didRemoveTrackElement(HTMLTrackElement*); |
189 | 189 |
190 blink::WebMediaPlayer::TrackId addAudioTrack(const String& id, blink::WebMed
iaPlayerClient::AudioTrackKind, const AtomicString& label, const AtomicString& l
anguage, bool enabled); | 190 WebMediaPlayer::TrackId addAudioTrack(const String& id, WebMediaPlayerClient
::AudioTrackKind, const AtomicString& label, const AtomicString& language, bool
enabled); |
191 void removeAudioTrack(blink::WebMediaPlayer::TrackId); | 191 void removeAudioTrack(WebMediaPlayer::TrackId); |
192 blink::WebMediaPlayer::TrackId addVideoTrack(const String& id, blink::WebMed
iaPlayerClient::VideoTrackKind, const AtomicString& label, const AtomicString& l
anguage, bool selected); | 192 WebMediaPlayer::TrackId addVideoTrack(const String& id, WebMediaPlayerClient
::VideoTrackKind, const AtomicString& label, const AtomicString& language, bool
selected); |
193 void removeVideoTrack(blink::WebMediaPlayer::TrackId); | 193 void removeVideoTrack(WebMediaPlayer::TrackId); |
194 | 194 |
195 virtual void mediaPlayerDidAddTextTrack(blink::WebInbandTextTrack*) override
final; | 195 virtual void mediaPlayerDidAddTextTrack(WebInbandTextTrack*) override final; |
196 virtual void mediaPlayerDidRemoveTextTrack(blink::WebInbandTextTrack*) overr
ide final; | 196 virtual void mediaPlayerDidRemoveTextTrack(WebInbandTextTrack*) override fin
al; |
197 // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not d
epend on it. | 197 // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not d
epend on it. |
198 virtual KURL mediaPlayerPosterURL() override { return KURL(); } | 198 virtual KURL mediaPlayerPosterURL() override { return KURL(); } |
199 | 199 |
200 void honorUserPreferencesForAutomaticTextTrackSelection(); | 200 void honorUserPreferencesForAutomaticTextTrackSelection(); |
201 | 201 |
202 bool textTracksAreReady() const; | 202 bool textTracksAreReady() const; |
203 enum VisibilityChangeAssumption { | 203 enum VisibilityChangeAssumption { |
204 AssumeNoVisibleChange, | 204 AssumeNoVisibleChange, |
205 AssumeVisibleChange | 205 AssumeVisibleChange |
206 }; | 206 }; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 virtual void willStopBeingFullscreenElement() override final; | 319 virtual void willStopBeingFullscreenElement() override final; |
320 virtual bool isInteractiveContent() const override final; | 320 virtual bool isInteractiveContent() const override final; |
321 virtual void defaultEventHandler(Event*) override final; | 321 virtual void defaultEventHandler(Event*) override final; |
322 | 322 |
323 // ActiveDOMObject functions. | 323 // ActiveDOMObject functions. |
324 virtual void stop() override final; | 324 virtual void stop() override final; |
325 | 325 |
326 virtual void updateDisplayState() { } | 326 virtual void updateDisplayState() { } |
327 | 327 |
328 void setReadyState(ReadyState); | 328 void setReadyState(ReadyState); |
329 void setNetworkState(blink::WebMediaPlayer::NetworkState); | 329 void setNetworkState(WebMediaPlayer::NetworkState); |
330 | 330 |
331 virtual void mediaPlayerNetworkStateChanged() override final; | 331 virtual void mediaPlayerNetworkStateChanged() override final; |
332 virtual void mediaPlayerReadyStateChanged() override final; | 332 virtual void mediaPlayerReadyStateChanged() override final; |
333 virtual void mediaPlayerTimeChanged() override final; | 333 virtual void mediaPlayerTimeChanged() override final; |
334 virtual void mediaPlayerDurationChanged() override final; | 334 virtual void mediaPlayerDurationChanged() override final; |
335 virtual void mediaPlayerPlaybackStateChanged() override final; | 335 virtual void mediaPlayerPlaybackStateChanged() override final; |
336 virtual void mediaPlayerRequestFullscreen() override final; | 336 virtual void mediaPlayerRequestFullscreen() override final; |
337 virtual void mediaPlayerRequestSeek(double) override final; | 337 virtual void mediaPlayerRequestSeek(double) override final; |
338 virtual void mediaPlayerRepaint() override final; | 338 virtual void mediaPlayerRepaint() override final; |
339 virtual void mediaPlayerSizeChanged() override final; | 339 virtual void mediaPlayerSizeChanged() override final; |
340 virtual void mediaPlayerSetWebLayer(blink::WebLayer*) override final; | 340 virtual void mediaPlayerSetWebLayer(WebLayer*) override final; |
341 virtual void mediaPlayerMediaSourceOpened(blink::WebMediaSource*) override f
inal; | 341 virtual void mediaPlayerMediaSourceOpened(WebMediaSource*) override final; |
342 | 342 |
343 void loadTimerFired(Timer<HTMLMediaElement>*); | 343 void loadTimerFired(Timer<HTMLMediaElement>*); |
344 void progressEventTimerFired(Timer<HTMLMediaElement>*); | 344 void progressEventTimerFired(Timer<HTMLMediaElement>*); |
345 void playbackProgressTimerFired(Timer<HTMLMediaElement>*); | 345 void playbackProgressTimerFired(Timer<HTMLMediaElement>*); |
346 void startPlaybackProgressTimer(); | 346 void startPlaybackProgressTimer(); |
347 void startProgressEventTimer(); | 347 void startProgressEventTimer(); |
348 void stopPeriodicTimers(); | 348 void stopPeriodicTimers(); |
349 | 349 |
350 void seek(double time); | 350 void seek(double time); |
351 void finishSeek(); | 351 void finishSeek(); |
352 void checkIfSeekNeeded(); | 352 void checkIfSeekNeeded(); |
353 void addPlayedRange(double start, double end); | 353 void addPlayedRange(double start, double end); |
354 | 354 |
355 void scheduleEvent(const AtomicString& eventName); // FIXME: Rename to sched
uleNamedEvent for clarity. | 355 void scheduleEvent(const AtomicString& eventName); // FIXME: Rename to sched
uleNamedEvent for clarity. |
356 | 356 |
357 // loading | 357 // loading |
358 void prepareForLoad(); | 358 void prepareForLoad(); |
359 void loadInternal(); | 359 void loadInternal(); |
360 void selectMediaResource(); | 360 void selectMediaResource(); |
361 void loadResource(const KURL&, ContentType&, const String& keySystem); | 361 void loadResource(const KURL&, ContentType&, const String& keySystem); |
362 void startPlayerLoad(); | 362 void startPlayerLoad(); |
363 void setPlayerPreload(); | 363 void setPlayerPreload(); |
364 blink::WebMediaPlayer::LoadType loadType() const; | 364 WebMediaPlayer::LoadType loadType() const; |
365 void scheduleNextSourceChild(); | 365 void scheduleNextSourceChild(); |
366 void loadNextSourceChild(); | 366 void loadNextSourceChild(); |
367 void userCancelledLoad(); | 367 void userCancelledLoad(); |
368 void clearMediaPlayer(int flags); | 368 void clearMediaPlayer(int flags); |
369 void clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 369 void clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
370 bool havePotentialSourceChild(); | 370 bool havePotentialSourceChild(); |
371 void noneSupported(); | 371 void noneSupported(); |
372 void mediaEngineError(PassRefPtrWillBeRawPtr<MediaError>); | 372 void mediaEngineError(PassRefPtrWillBeRawPtr<MediaError>); |
373 void cancelPendingEventsAndCallbacks(); | 373 void cancelPendingEventsAndCallbacks(); |
374 void waitForSourceChange(); | 374 void waitForSourceChange(); |
375 void prepareToPlay(); | 375 void prepareToPlay(); |
376 | 376 |
377 KURL selectNextSourceChild(ContentType*, String* keySystem, InvalidURLAction
); | 377 KURL selectNextSourceChild(ContentType*, String* keySystem, InvalidURLAction
); |
378 | 378 |
379 void mediaLoadingFailed(blink::WebMediaPlayer::NetworkState); | 379 void mediaLoadingFailed(WebMediaPlayer::NetworkState); |
380 | 380 |
381 // deferred loading (preload=none) | 381 // deferred loading (preload=none) |
382 bool loadIsDeferred() const; | 382 bool loadIsDeferred() const; |
383 void deferLoad(); | 383 void deferLoad(); |
384 void cancelDeferredLoad(); | 384 void cancelDeferredLoad(); |
385 void startDeferredLoad(); | 385 void startDeferredLoad(); |
386 void executeDeferredLoad(); | 386 void executeDeferredLoad(); |
387 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); | 387 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); |
388 | 388 |
389 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; | 389 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 422 |
423 void changeNetworkStateFromLoadingToIdle(); | 423 void changeNetworkStateFromLoadingToIdle(); |
424 | 424 |
425 const AtomicString& mediaGroup() const; | 425 const AtomicString& mediaGroup() const; |
426 void setMediaGroup(const AtomicString&); | 426 void setMediaGroup(const AtomicString&); |
427 void updateMediaController(); | 427 void updateMediaController(); |
428 bool isBlocked() const; | 428 bool isBlocked() const; |
429 bool isBlockedOnMediaController() const; | 429 bool isBlockedOnMediaController() const; |
430 bool isAutoplaying() const { return m_autoplaying; } | 430 bool isAutoplaying() const { return m_autoplaying; } |
431 | 431 |
432 blink::WebMediaPlayer::CORSMode corsMode() const; | 432 WebMediaPlayer::CORSMode corsMode() const; |
433 | 433 |
434 // Returns the "direction of playback" value as specified in the HTML5 spec. | 434 // Returns the "direction of playback" value as specified in the HTML5 spec. |
435 enum DirectionOfPlayback { Backward, Forward }; | 435 enum DirectionOfPlayback { Backward, Forward }; |
436 DirectionOfPlayback directionOfPlayback() const; | 436 DirectionOfPlayback directionOfPlayback() const; |
437 | 437 |
438 // Returns the "effective playback rate" value as specified in the HTML5 spe
c. | 438 // Returns the "effective playback rate" value as specified in the HTML5 spe
c. |
439 double effectivePlaybackRate() const; | 439 double effectivePlaybackRate() const; |
440 | 440 |
441 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP
layer objects | 441 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP
layer objects |
442 // advertise they have audio and/or video, but don't explicitly signal them
via | 442 // advertise they have audio and/or video, but don't explicitly signal them
via |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 // The load is the deferred, and waiting for a triggering event. | 499 // The load is the deferred, and waiting for a triggering event. |
500 WaitingForTrigger, | 500 WaitingForTrigger, |
501 // The load is deferred, and waiting for the task to set the | 501 // The load is deferred, and waiting for the task to set the |
502 // delaying-the-load-event flag, after which the load will be executed. | 502 // delaying-the-load-event flag, after which the load will be executed. |
503 ExecuteOnStopDelayingLoadEventTask | 503 ExecuteOnStopDelayingLoadEventTask |
504 }; | 504 }; |
505 DeferredLoadState m_deferredLoadState; | 505 DeferredLoadState m_deferredLoadState; |
506 Timer<HTMLMediaElement> m_deferredLoadTimer; | 506 Timer<HTMLMediaElement> m_deferredLoadTimer; |
507 | 507 |
508 OwnPtr<MediaPlayer> m_player; | 508 OwnPtr<MediaPlayer> m_player; |
509 blink::WebLayer* m_webLayer; | 509 WebLayer* m_webLayer; |
510 | 510 |
511 MediaPlayer::Preload m_preload; | 511 MediaPlayer::Preload m_preload; |
512 | 512 |
513 DisplayMode m_displayMode; | 513 DisplayMode m_displayMode; |
514 | 514 |
515 RefPtrWillBeMember<HTMLMediaSource> m_mediaSource; | 515 RefPtrWillBeMember<HTMLMediaSource> m_mediaSource; |
516 | 516 |
517 // Cached time value. Only valid when ready state is HAVE_METADATA or | 517 // Cached time value. Only valid when ready state is HAVE_METADATA or |
518 // higher, otherwise the current time is assumed to be zero. | 518 // higher, otherwise the current time is assumed to be zero. |
519 mutable double m_cachedTime; | 519 mutable double m_cachedTime; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 inline bool isHTMLMediaElement(const HTMLElement& element) | 583 inline bool isHTMLMediaElement(const HTMLElement& element) |
584 { | 584 { |
585 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 585 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
586 } | 586 } |
587 | 587 |
588 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 588 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
589 | 589 |
590 } // namespace blink | 590 } // namespace blink |
591 | 591 |
592 #endif // HTMLMediaElement_h | 592 #endif // HTMLMediaElement_h |
OLD | NEW |