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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 , public PlatformTextTrackMenuClient | 89 , public PlatformTextTrackMenuClient |
90 #endif | 90 #endif |
91 { | 91 { |
92 public: | 92 public: |
93 MediaPlayer* player() const { return m_player.get(); } | 93 MediaPlayer* player() const { return m_player.get(); } |
94 | 94 |
95 virtual bool isVideo() const = 0; | 95 virtual bool isVideo() const = 0; |
96 virtual bool hasVideo() const { return false; } | 96 virtual bool hasVideo() const { return false; } |
97 virtual bool hasAudio() const; | 97 virtual bool hasAudio() const; |
98 | 98 |
99 void rewind(float timeDelta); | 99 void rewind(double timeDelta); |
100 void returnToRealtime(); | 100 void returnToRealtime(); |
101 | 101 |
102 // Eventually overloaded in HTMLVideoElement | 102 // Eventually overloaded in HTMLVideoElement |
103 virtual bool supportsFullscreen() const { return false; }; | 103 virtual bool supportsFullscreen() const { return false; }; |
104 | 104 |
105 virtual bool supportsSave() const; | 105 virtual bool supportsSave() const; |
106 virtual bool supportsScanning() const; | 106 virtual bool supportsScanning() const; |
107 | 107 |
108 PlatformMedia platformMedia() const; | 108 PlatformMedia platformMedia() const; |
109 #if USE(ACCELERATED_COMPOSITING) | 109 #if USE(ACCELERATED_COMPOSITING) |
(...skipping 27 matching lines...) Expand all Loading... |
137 | 137 |
138 PassRefPtr<TimeRanges> buffered() const; | 138 PassRefPtr<TimeRanges> buffered() const; |
139 void load(); | 139 void load(); |
140 String canPlayType(const String& mimeType, const String& keySystem = String(
), const KURL& = KURL()) const; | 140 String canPlayType(const String& mimeType, const String& keySystem = String(
), const KURL& = KURL()) const; |
141 | 141 |
142 // ready state | 142 // ready state |
143 ReadyState readyState() const; | 143 ReadyState readyState() const; |
144 bool seeking() const; | 144 bool seeking() const; |
145 | 145 |
146 // playback state | 146 // playback state |
147 float currentTime() const; | 147 double currentTime() const; |
148 void setCurrentTime(float, ExceptionCode&); | 148 void setCurrentTime(double, ExceptionCode&); |
149 double initialTime() const; | 149 double initialTime() const; |
150 float startTime() const; | 150 double startTime() const; |
151 float duration() const; | 151 double duration() const; |
152 bool paused() const; | 152 bool paused() const; |
153 float defaultPlaybackRate() const; | 153 double defaultPlaybackRate() const; |
154 void setDefaultPlaybackRate(float); | 154 void setDefaultPlaybackRate(double); |
155 float playbackRate() const; | 155 double playbackRate() const; |
156 void setPlaybackRate(float); | 156 void setPlaybackRate(double); |
157 void updatePlaybackRate(); | 157 void updatePlaybackRate(); |
158 bool webkitPreservesPitch() const; | 158 bool webkitPreservesPitch() const; |
159 void setWebkitPreservesPitch(bool); | 159 void setWebkitPreservesPitch(bool); |
160 PassRefPtr<TimeRanges> played(); | 160 PassRefPtr<TimeRanges> played(); |
161 PassRefPtr<TimeRanges> seekable() const; | 161 PassRefPtr<TimeRanges> seekable() const; |
162 bool ended() const; | 162 bool ended() const; |
163 bool autoplay() const; | 163 bool autoplay() const; |
164 void setAutoplay(bool b); | 164 void setAutoplay(bool b); |
165 bool loop() const; | 165 bool loop() const; |
166 void setLoop(bool b); | 166 void setLoop(bool b); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 #endif | 199 #endif |
200 | 200 |
201 #if ENABLE(ENCRYPTED_MEDIA_V2) | 201 #if ENABLE(ENCRYPTED_MEDIA_V2) |
202 MediaKeys* mediaKeys() const { return m_mediaKeys.get(); } | 202 MediaKeys* mediaKeys() const { return m_mediaKeys.get(); } |
203 void setMediaKeys(MediaKeys*); | 203 void setMediaKeys(MediaKeys*); |
204 #endif | 204 #endif |
205 | 205 |
206 // controls | 206 // controls |
207 bool controls() const; | 207 bool controls() const; |
208 void setControls(bool); | 208 void setControls(bool); |
209 float volume() const; | 209 double volume() const; |
210 void setVolume(float, ExceptionCode&); | 210 void setVolume(double, ExceptionCode&); |
211 bool muted() const; | 211 bool muted() const; |
212 void setMuted(bool); | 212 void setMuted(bool); |
213 | 213 |
214 void togglePlayState(); | 214 void togglePlayState(); |
215 void beginScrubbing(); | 215 void beginScrubbing(); |
216 void endScrubbing(); | 216 void endScrubbing(); |
217 | 217 |
218 bool canPlay() const; | 218 bool canPlay() const; |
219 | 219 |
220 float percentLoaded() const; | 220 double percentLoaded() const; |
221 | 221 |
222 #if ENABLE(VIDEO_TRACK) | 222 #if ENABLE(VIDEO_TRACK) |
223 PassRefPtr<TextTrack> addTextTrack(const String& kind, const String& label,
const String& language, ExceptionCode&); | 223 PassRefPtr<TextTrack> addTextTrack(const String& kind, const String& label,
const String& language, ExceptionCode&); |
224 PassRefPtr<TextTrack> addTextTrack(const String& kind, const String& label,
ExceptionCode& ec) { return addTextTrack(kind, label, emptyString(), ec); } | 224 PassRefPtr<TextTrack> addTextTrack(const String& kind, const String& label,
ExceptionCode& ec) { return addTextTrack(kind, label, emptyString(), ec); } |
225 PassRefPtr<TextTrack> addTextTrack(const String& kind, ExceptionCode& ec) {
return addTextTrack(kind, emptyString(), emptyString(), ec); } | 225 PassRefPtr<TextTrack> addTextTrack(const String& kind, ExceptionCode& ec) {
return addTextTrack(kind, emptyString(), emptyString(), ec); } |
226 | 226 |
227 TextTrackList* textTracks(); | 227 TextTrackList* textTracks(); |
228 CueList currentlyActiveCues() const { return m_currentlyActiveCues; } | 228 CueList currentlyActiveCues() const { return m_currentlyActiveCues; } |
229 | 229 |
230 void addTrack(TextTrack*); | 230 void addTrack(TextTrack*); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 virtual GraphicsDeviceAdapter* mediaPlayerGraphicsDeviceAdapter(const MediaP
layer*) const OVERRIDE; | 489 virtual GraphicsDeviceAdapter* mediaPlayerGraphicsDeviceAdapter(const MediaP
layer*) const OVERRIDE; |
490 #endif | 490 #endif |
491 | 491 |
492 void loadTimerFired(Timer<HTMLMediaElement>*); | 492 void loadTimerFired(Timer<HTMLMediaElement>*); |
493 void progressEventTimerFired(Timer<HTMLMediaElement>*); | 493 void progressEventTimerFired(Timer<HTMLMediaElement>*); |
494 void playbackProgressTimerFired(Timer<HTMLMediaElement>*); | 494 void playbackProgressTimerFired(Timer<HTMLMediaElement>*); |
495 void startPlaybackProgressTimer(); | 495 void startPlaybackProgressTimer(); |
496 void startProgressEventTimer(); | 496 void startProgressEventTimer(); |
497 void stopPeriodicTimers(); | 497 void stopPeriodicTimers(); |
498 | 498 |
499 void seek(float time, ExceptionCode&); | 499 void seek(double time, ExceptionCode&); |
500 void finishSeek(); | 500 void finishSeek(); |
501 void checkIfSeekNeeded(); | 501 void checkIfSeekNeeded(); |
502 void addPlayedRange(float start, float end); | 502 void addPlayedRange(double start, double end); |
503 | 503 |
504 void scheduleTimeupdateEvent(bool periodicEvent); | 504 void scheduleTimeupdateEvent(bool periodicEvent); |
505 void scheduleEvent(const AtomicString& eventName); | 505 void scheduleEvent(const AtomicString& eventName); |
506 | 506 |
507 // loading | 507 // loading |
508 void selectMediaResource(); | 508 void selectMediaResource(); |
509 void loadResource(const KURL&, ContentType&, const String& keySystem); | 509 void loadResource(const KURL&, ContentType&, const String& keySystem); |
510 void scheduleNextSourceChild(); | 510 void scheduleNextSourceChild(); |
511 void loadNextSourceChild(); | 511 void loadNextSourceChild(); |
512 void userCancelledLoad(); | 512 void userCancelledLoad(); |
513 void clearMediaPlayer(int flags); | 513 void clearMediaPlayer(int flags); |
514 bool havePotentialSourceChild(); | 514 bool havePotentialSourceChild(); |
515 void noneSupported(); | 515 void noneSupported(); |
516 void mediaEngineError(PassRefPtr<MediaError> err); | 516 void mediaEngineError(PassRefPtr<MediaError> err); |
517 void cancelPendingEventsAndCallbacks(); | 517 void cancelPendingEventsAndCallbacks(); |
518 void waitForSourceChange(); | 518 void waitForSourceChange(); |
519 void prepareToPlay(); | 519 void prepareToPlay(); |
520 | 520 |
521 KURL selectNextSourceChild(ContentType*, String* keySystem, InvalidURLAction
); | 521 KURL selectNextSourceChild(ContentType*, String* keySystem, InvalidURLAction
); |
522 | 522 |
523 void mediaLoadingFailed(MediaPlayer::NetworkState); | 523 void mediaLoadingFailed(MediaPlayer::NetworkState); |
524 | 524 |
525 #if ENABLE(VIDEO_TRACK) | 525 #if ENABLE(VIDEO_TRACK) |
526 void updateActiveTextTrackCues(float); | 526 void updateActiveTextTrackCues(double); |
527 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; | 527 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; |
528 | 528 |
529 void markCaptionAndSubtitleTracksAsUnconfigured(); | 529 void markCaptionAndSubtitleTracksAsUnconfigured(); |
530 virtual void captionPreferencesChanged() OVERRIDE; | 530 virtual void captionPreferencesChanged() OVERRIDE; |
531 #endif | 531 #endif |
532 | 532 |
533 // These "internal" functions do not check user gesture restrictions. | 533 // These "internal" functions do not check user gesture restrictions. |
534 void loadInternal(); | 534 void loadInternal(); |
535 void playInternal(); | 535 void playInternal(); |
536 void pauseInternal(); | 536 void pauseInternal(); |
537 | 537 |
538 void prepareForLoad(); | 538 void prepareForLoad(); |
539 void allowVideoRendering(); | 539 void allowVideoRendering(); |
540 | 540 |
541 bool processingMediaPlayerCallback() const { return m_processingMediaPlayerC
allback > 0; } | 541 bool processingMediaPlayerCallback() const { return m_processingMediaPlayerC
allback > 0; } |
542 void beginProcessingMediaPlayerCallback() { ++m_processingMediaPlayerCallbac
k; } | 542 void beginProcessingMediaPlayerCallback() { ++m_processingMediaPlayerCallbac
k; } |
543 void endProcessingMediaPlayerCallback() { ASSERT(m_processingMediaPlayerCall
back); --m_processingMediaPlayerCallback; } | 543 void endProcessingMediaPlayerCallback() { ASSERT(m_processingMediaPlayerCall
back); --m_processingMediaPlayerCallback; } |
544 | 544 |
545 void updateVolume(); | 545 void updateVolume(); |
546 void updatePlayState(); | 546 void updatePlayState(); |
547 bool potentiallyPlaying() const; | 547 bool potentiallyPlaying() const; |
548 bool endedPlayback() const; | 548 bool endedPlayback() const; |
549 bool stoppedDueToErrors() const; | 549 bool stoppedDueToErrors() const; |
550 bool pausedForUserInteraction() const; | 550 bool pausedForUserInteraction() const; |
551 bool couldPlayIfEnoughData() const; | 551 bool couldPlayIfEnoughData() const; |
552 | 552 |
553 float minTimeSeekable() const; | 553 double minTimeSeekable() const; |
554 float maxTimeSeekable() const; | 554 double maxTimeSeekable() const; |
555 | 555 |
556 // Pauses playback without changing any states or generating events | 556 // Pauses playback without changing any states or generating events |
557 void setPausedInternal(bool); | 557 void setPausedInternal(bool); |
558 | 558 |
559 void setPlaybackRateInternal(float); | 559 void setPlaybackRateInternal(double); |
560 | 560 |
561 virtual void mediaCanStart(); | 561 virtual void mediaCanStart(); |
562 | 562 |
563 void setShouldDelayLoadEvent(bool); | 563 void setShouldDelayLoadEvent(bool); |
564 void invalidateCachedTime(); | 564 void invalidateCachedTime(); |
565 void refreshCachedTime() const; | 565 void refreshCachedTime() const; |
566 | 566 |
567 bool hasMediaControls() const; | 567 bool hasMediaControls() const; |
568 bool createMediaControls(); | 568 bool createMediaControls(); |
569 void configureMediaControls(); | 569 void configureMediaControls(); |
(...skipping 23 matching lines...) Expand all Loading... |
593 void updateDisableSleep(); | 593 void updateDisableSleep(); |
594 bool shouldDisableSleep() const; | 594 bool shouldDisableSleep() const; |
595 #endif | 595 #endif |
596 | 596 |
597 Timer<HTMLMediaElement> m_loadTimer; | 597 Timer<HTMLMediaElement> m_loadTimer; |
598 Timer<HTMLMediaElement> m_progressEventTimer; | 598 Timer<HTMLMediaElement> m_progressEventTimer; |
599 Timer<HTMLMediaElement> m_playbackProgressTimer; | 599 Timer<HTMLMediaElement> m_playbackProgressTimer; |
600 RefPtr<TimeRanges> m_playedTimeRanges; | 600 RefPtr<TimeRanges> m_playedTimeRanges; |
601 OwnPtr<GenericEventQueue> m_asyncEventQueue; | 601 OwnPtr<GenericEventQueue> m_asyncEventQueue; |
602 | 602 |
603 float m_playbackRate; | 603 double m_playbackRate; |
604 float m_defaultPlaybackRate; | 604 double m_defaultPlaybackRate; |
605 bool m_webkitPreservesPitch; | 605 bool m_webkitPreservesPitch; |
606 NetworkState m_networkState; | 606 NetworkState m_networkState; |
607 ReadyState m_readyState; | 607 ReadyState m_readyState; |
608 ReadyState m_readyStateMaximum; | 608 ReadyState m_readyStateMaximum; |
609 KURL m_currentSrc; | 609 KURL m_currentSrc; |
610 | 610 |
611 RefPtr<MediaError> m_error; | 611 RefPtr<MediaError> m_error; |
612 | 612 |
613 float m_volume; | 613 double m_volume; |
614 float m_lastSeekTime; | 614 double m_lastSeekTime; |
615 | 615 |
616 unsigned m_previousProgress; | 616 unsigned m_previousProgress; |
617 double m_previousProgressTime; | 617 double m_previousProgressTime; |
618 | 618 |
619 // The last time a timeupdate event was sent (wall clock). | 619 // The last time a timeupdate event was sent (wall clock). |
620 double m_lastTimeUpdateEventWallTime; | 620 double m_lastTimeUpdateEventWallTime; |
621 | 621 |
622 // The last time a timeupdate event was sent in movie time. | 622 // The last time a timeupdate event was sent in movie time. |
623 float m_lastTimeUpdateEventMovieTime; | 623 double m_lastTimeUpdateEventMovieTime; |
624 | 624 |
625 // Loading state. | 625 // Loading state. |
626 enum LoadState { WaitingForSource, LoadingFromSrcAttr, LoadingFromSourceElem
ent }; | 626 enum LoadState { WaitingForSource, LoadingFromSrcAttr, LoadingFromSourceElem
ent }; |
627 LoadState m_loadState; | 627 LoadState m_loadState; |
628 RefPtr<HTMLSourceElement> m_currentSourceNode; | 628 RefPtr<HTMLSourceElement> m_currentSourceNode; |
629 RefPtr<Node> m_nextChildNodeToConsider; | 629 RefPtr<Node> m_nextChildNodeToConsider; |
630 | 630 |
631 OwnPtr<MediaPlayer> m_player; | 631 OwnPtr<MediaPlayer> m_player; |
632 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) | 632 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) |
633 RefPtr<Widget> m_proxyWidget; | 633 RefPtr<Widget> m_proxyWidget; |
634 #endif | 634 #endif |
635 | 635 |
636 BehaviorRestrictions m_restrictions; | 636 BehaviorRestrictions m_restrictions; |
637 | 637 |
638 MediaPlayer::Preload m_preload; | 638 MediaPlayer::Preload m_preload; |
639 | 639 |
640 DisplayMode m_displayMode; | 640 DisplayMode m_displayMode; |
641 | 641 |
642 // Counter incremented while processing a callback from the media player, so
we can avoid | 642 // Counter incremented while processing a callback from the media player, so
we can avoid |
643 // calling the media engine recursively. | 643 // calling the media engine recursively. |
644 int m_processingMediaPlayerCallback; | 644 int m_processingMediaPlayerCallback; |
645 | 645 |
646 #if ENABLE(MEDIA_SOURCE) | 646 #if ENABLE(MEDIA_SOURCE) |
647 RefPtr<MediaSource> m_mediaSource; | 647 RefPtr<MediaSource> m_mediaSource; |
648 #endif | 648 #endif |
649 | 649 |
650 mutable float m_cachedTime; | 650 mutable double m_cachedTime; |
651 mutable double m_cachedTimeWallClockUpdateTime; | 651 mutable double m_cachedTimeWallClockUpdateTime; |
652 mutable double m_minimumWallClockTimeToCacheMediaTime; | 652 mutable double m_minimumWallClockTimeToCacheMediaTime; |
653 | 653 |
654 double m_fragmentStartTime; | 654 double m_fragmentStartTime; |
655 double m_fragmentEndTime; | 655 double m_fragmentEndTime; |
656 | 656 |
657 typedef unsigned PendingActionFlags; | 657 typedef unsigned PendingActionFlags; |
658 PendingActionFlags m_pendingActionFlags; | 658 PendingActionFlags m_pendingActionFlags; |
659 | 659 |
660 bool m_playing : 1; | 660 bool m_playing : 1; |
(...skipping 28 matching lines...) Expand all Loading... |
689 bool m_dispatchingCanPlayEvent : 1; | 689 bool m_dispatchingCanPlayEvent : 1; |
690 bool m_loadInitiatedByUserGesture : 1; | 690 bool m_loadInitiatedByUserGesture : 1; |
691 bool m_completelyLoaded : 1; | 691 bool m_completelyLoaded : 1; |
692 bool m_havePreparedToPlay : 1; | 692 bool m_havePreparedToPlay : 1; |
693 bool m_parsingInProgress : 1; | 693 bool m_parsingInProgress : 1; |
694 | 694 |
695 #if ENABLE(VIDEO_TRACK) | 695 #if ENABLE(VIDEO_TRACK) |
696 bool m_tracksAreReady : 1; | 696 bool m_tracksAreReady : 1; |
697 bool m_haveVisibleTextTrack : 1; | 697 bool m_haveVisibleTextTrack : 1; |
698 bool m_processingPreferenceChange : 1; | 698 bool m_processingPreferenceChange : 1; |
699 float m_lastTextTrackUpdateTime; | 699 double m_lastTextTrackUpdateTime; |
700 | 700 |
701 RefPtr<TextTrackList> m_textTracks; | 701 RefPtr<TextTrackList> m_textTracks; |
702 Vector<RefPtr<TextTrack> > m_textTracksWhenResourceSelectionBegan; | 702 Vector<RefPtr<TextTrack> > m_textTracksWhenResourceSelectionBegan; |
703 | 703 |
704 CueIntervalTree m_cueTree; | 704 CueIntervalTree m_cueTree; |
705 | 705 |
706 CueList m_currentlyActiveCues; | 706 CueList m_currentlyActiveCues; |
707 int m_ignoreTrackDisplayUpdate; | 707 int m_ignoreTrackDisplayUpdate; |
708 #endif | 708 #endif |
709 | 709 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 inline HTMLMediaElement* toMediaElement(Node* node) | 762 inline HTMLMediaElement* toMediaElement(Node* node) |
763 { | 763 { |
764 ASSERT_WITH_SECURITY_IMPLICATION(!node || isMediaElement(node)); | 764 ASSERT_WITH_SECURITY_IMPLICATION(!node || isMediaElement(node)); |
765 return static_cast<HTMLMediaElement*>(node); | 765 return static_cast<HTMLMediaElement*>(node); |
766 } | 766 } |
767 | 767 |
768 } //namespace | 768 } //namespace |
769 | 769 |
770 #endif | 770 #endif |
771 #endif | 771 #endif |
OLD | NEW |