Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: Source/core/html/HTMLMediaElement.h

Issue 284513003: Implement AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: nits Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/events/EventTargetFactory.in ('k') | Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 #define HTMLMediaElement_h 27 #define HTMLMediaElement_h
28 28
29 #include "core/dom/ActiveDOMObject.h" 29 #include "core/dom/ActiveDOMObject.h"
30 #include "core/events/GenericEventQueue.h" 30 #include "core/events/GenericEventQueue.h"
31 #include "core/html/HTMLElement.h" 31 #include "core/html/HTMLElement.h"
32 #include "core/html/track/TextTrack.h" 32 #include "core/html/track/TextTrack.h"
33 #include "core/html/track/TextTrackCue.h" 33 #include "core/html/track/TextTrackCue.h"
34 #include "core/html/track/vtt/VTTCue.h" 34 #include "core/html/track/vtt/VTTCue.h"
35 #include "platform/PODIntervalTree.h" 35 #include "platform/PODIntervalTree.h"
36 #include "platform/graphics/media/MediaPlayer.h" 36 #include "platform/graphics/media/MediaPlayer.h"
37 #include "public/platform/WebMediaPlayerClient.h"
37 #include "public/platform/WebMimeRegistry.h" 38 #include "public/platform/WebMimeRegistry.h"
38 39
39 namespace blink { 40 namespace blink {
40 class WebContentDecryptionModule; 41 class WebContentDecryptionModule;
41 class WebInbandTextTrack; 42 class WebInbandTextTrack;
42 class WebLayer; 43 class WebLayer;
43 } 44 }
44 45
45 namespace WebCore { 46 namespace WebCore {
46 47
47 #if ENABLE(WEB_AUDIO) 48 #if ENABLE(WEB_AUDIO)
48 class AudioSourceProvider; 49 class AudioSourceProvider;
49 class AudioSourceProviderClient; 50 class AudioSourceProviderClient;
50 #endif 51 #endif
52 class AudioTrackList;
51 class ContentType; 53 class ContentType;
52 class Event; 54 class Event;
53 class ExceptionState; 55 class ExceptionState;
54 class HTMLSourceElement; 56 class HTMLSourceElement;
55 class HTMLTrackElement; 57 class HTMLTrackElement;
56 class KURL; 58 class KURL;
57 class MediaController; 59 class MediaController;
58 class MediaControls; 60 class MediaControls;
59 class MediaError; 61 class MediaError;
60 class HTMLMediaSource; 62 class HTMLMediaSource;
61 class TextTrackList; 63 class TextTrackList;
62 class TimeRanges; 64 class TimeRanges;
63 class URLRegistry; 65 class URLRegistry;
66 class VideoTrackList;
64 67
65 typedef PODIntervalTree<double, TextTrackCue*> CueIntervalTree; 68 typedef PODIntervalTree<double, TextTrackCue*> CueIntervalTree;
66 typedef CueIntervalTree::IntervalType CueInterval; 69 typedef CueIntervalTree::IntervalType CueInterval;
67 typedef Vector<CueInterval> CueList; 70 typedef Vector<CueInterval> CueList;
68 71
69 // FIXME: The inheritance from MediaPlayerClient here should be private inherita nce. 72 // FIXME: The inheritance from MediaPlayerClient here should be private inherita nce.
70 // But it can't be until the Chromium WebMediaPlayerClientImpl class is fixed so it 73 // But it can't be until the Chromium WebMediaPlayerClientImpl class is fixed so it
71 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement. 74 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement.
72 75
73 class HTMLMediaElement : public HTMLElement, public WillBeHeapSupplementable<HTM LMediaElement>, public MediaPlayerClient, public ActiveDOMObject 76 class HTMLMediaElement : public HTMLElement, public WillBeHeapSupplementable<HTM LMediaElement>, public MediaPlayerClient, public ActiveDOMObject
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 double volume() const; 163 double volume() const;
161 void setVolume(double, ExceptionState&); 164 void setVolume(double, ExceptionState&);
162 bool muted() const; 165 bool muted() const;
163 void setMuted(bool); 166 void setMuted(bool);
164 167
165 // play/pause toggling that uses the media controller if present. togglePlay StateWillPlay() is 168 // play/pause toggling that uses the media controller if present. togglePlay StateWillPlay() is
166 // true if togglePlayState() will call play() or unpause() on the media elem ent or controller. 169 // true if togglePlayState() will call play() or unpause() on the media elem ent or controller.
167 bool togglePlayStateWillPlay() const; 170 bool togglePlayStateWillPlay() const;
168 void togglePlayState(); 171 void togglePlayState();
169 172
173 AudioTrackList& audioTracks();
174 void audioTrackChanged();
175
176 VideoTrackList& videoTracks();
177 void selectedVideoTrackChanged(blink::WebMediaPlayer::TrackId*);
178
170 PassRefPtrWillBeRawPtr<TextTrack> addTextTrack(const AtomicString& kind, con st AtomicString& label, const AtomicString& language, ExceptionState&); 179 PassRefPtrWillBeRawPtr<TextTrack> addTextTrack(const AtomicString& kind, con st AtomicString& label, const AtomicString& language, ExceptionState&);
171 PassRefPtrWillBeRawPtr<TextTrack> addTextTrack(const AtomicString& kind, con st AtomicString& label, ExceptionState& exceptionState) { return addTextTrack(ki nd, label, emptyAtom, exceptionState); } 180 PassRefPtrWillBeRawPtr<TextTrack> addTextTrack(const AtomicString& kind, con st AtomicString& label, ExceptionState& exceptionState) { return addTextTrack(ki nd, label, emptyAtom, exceptionState); }
172 PassRefPtrWillBeRawPtr<TextTrack> addTextTrack(const AtomicString& kind, Exc eptionState& exceptionState) { return addTextTrack(kind, emptyAtom, emptyAtom, e xceptionState); } 181 PassRefPtrWillBeRawPtr<TextTrack> addTextTrack(const AtomicString& kind, Exc eptionState& exceptionState) { return addTextTrack(kind, emptyAtom, emptyAtom, e xceptionState); }
173 182
174 TextTrackList* textTracks(); 183 TextTrackList* textTracks();
175 CueList currentlyActiveCues() const { return m_currentlyActiveCues; } 184 CueList currentlyActiveCues() const { return m_currentlyActiveCues; }
176 185
177 void addTextTrack(TextTrack*); 186 void addTextTrack(TextTrack*);
178 void removeTextTrack(TextTrack*); 187 void removeTextTrack(TextTrack*);
179 void closeCaptionTracksChanged(); 188 void closeCaptionTracksChanged();
180 void notifyMediaPlayerOfTextTrackChanges(); 189 void notifyMediaPlayerOfTextTrackChanges();
181 190
182 // Implements the "forget the media element's media-resource-specific tracks " algorithm in the HTML5 spec. 191 // Implements the "forget the media element's media-resource-specific tracks " algorithm in the HTML5 spec.
183 void forgetResourceSpecificTracks(); 192 void forgetResourceSpecificTracks();
184 193
185 void didAddTrackElement(HTMLTrackElement*); 194 void didAddTrackElement(HTMLTrackElement*);
186 void didRemoveTrackElement(HTMLTrackElement*); 195 void didRemoveTrackElement(HTMLTrackElement*);
187 196
197 blink::WebMediaPlayer::TrackId addAudioTrack(const String& id, blink::WebMed iaPlayerClient::AudioTrackKind, const AtomicString& label, const AtomicString& l anguage, bool enabled);
198 void removeAudioTrack(blink::WebMediaPlayer::TrackId);
199 blink::WebMediaPlayer::TrackId addVideoTrack(const String& id, blink::WebMed iaPlayerClient::VideoTrackKind, const AtomicString& label, const AtomicString& l anguage, bool selected);
200 void removeVideoTrack(blink::WebMediaPlayer::TrackId);
201
188 virtual void mediaPlayerDidAddTextTrack(blink::WebInbandTextTrack*) OVERRIDE FINAL; 202 virtual void mediaPlayerDidAddTextTrack(blink::WebInbandTextTrack*) OVERRIDE FINAL;
189 virtual void mediaPlayerDidRemoveTextTrack(blink::WebInbandTextTrack*) OVERR IDE FINAL; 203 virtual void mediaPlayerDidRemoveTextTrack(blink::WebInbandTextTrack*) OVERR IDE FINAL;
190 // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not d epend on it. 204 // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not d epend on it.
191 virtual KURL mediaPlayerPosterURL() OVERRIDE { return KURL(); } 205 virtual KURL mediaPlayerPosterURL() OVERRIDE { return KURL(); }
192 206
193 class TrackGroup { 207 class TrackGroup {
194 STACK_ALLOCATED(); 208 STACK_ALLOCATED();
195 public: 209 public:
196 enum GroupKind { CaptionsAndSubtitles, Description, Chapter, Metadata, O ther }; 210 enum GroupKind { CaptionsAndSubtitles, Description, Chapter, Metadata, O ther };
197 211
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 433
420 const AtomicString& mediaGroup() const; 434 const AtomicString& mediaGroup() const;
421 void setMediaGroup(const AtomicString&); 435 void setMediaGroup(const AtomicString&);
422 void updateMediaController(); 436 void updateMediaController();
423 bool isBlocked() const; 437 bool isBlocked() const;
424 bool isBlockedOnMediaController() const; 438 bool isBlockedOnMediaController() const;
425 bool isAutoplaying() const { return m_autoplaying; } 439 bool isAutoplaying() const { return m_autoplaying; }
426 440
427 blink::WebMediaPlayer::CORSMode corsMode() const; 441 blink::WebMediaPlayer::CORSMode corsMode() const;
428 442
443 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects
444 // advertise they have audio and/or video, but don't explicitly signal them via
445 // addAudioTrack() and addVideoTrack().
446 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info.
447 void createPlaceholderTracksIfNecessary();
448
449 // Sets the selected/enabled tracks if they aren't set before we initially
450 // transition to HAVE_METADATA.
451 void selectInitialTracksIfNecessary();
452
453 void audioTracksTimerFired(Timer<HTMLMediaElement>*);
454
429 Timer<HTMLMediaElement> m_loadTimer; 455 Timer<HTMLMediaElement> m_loadTimer;
430 Timer<HTMLMediaElement> m_progressEventTimer; 456 Timer<HTMLMediaElement> m_progressEventTimer;
431 Timer<HTMLMediaElement> m_playbackProgressTimer; 457 Timer<HTMLMediaElement> m_playbackProgressTimer;
458 Timer<HTMLMediaElement> m_audioTracksTimer;
432 RefPtr<TimeRanges> m_playedTimeRanges; 459 RefPtr<TimeRanges> m_playedTimeRanges;
433 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; 460 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue;
434 461
435 double m_playbackRate; 462 double m_playbackRate;
436 double m_defaultPlaybackRate; 463 double m_defaultPlaybackRate;
437 NetworkState m_networkState; 464 NetworkState m_networkState;
438 ReadyState m_readyState; 465 ReadyState m_readyState;
439 ReadyState m_readyStateMaximum; 466 ReadyState m_readyStateMaximum;
440 KURL m_currentSrc; 467 KURL m_currentSrc;
441 468
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 bool m_delayingLoadForPreloadNone : 1; 533 bool m_delayingLoadForPreloadNone : 1;
507 534
508 bool m_tracksAreReady : 1; 535 bool m_tracksAreReady : 1;
509 bool m_haveVisibleTextTrack : 1; 536 bool m_haveVisibleTextTrack : 1;
510 bool m_processingPreferenceChange : 1; 537 bool m_processingPreferenceChange : 1;
511 #if ENABLE(OILPAN) 538 #if ENABLE(OILPAN)
512 bool m_isFinalizing : 1; 539 bool m_isFinalizing : 1;
513 #endif 540 #endif
514 double m_lastTextTrackUpdateTime; 541 double m_lastTextTrackUpdateTime;
515 542
543 RefPtrWillBeMember<AudioTrackList> m_audioTracks;
544 RefPtrWillBeMember<VideoTrackList> m_videoTracks;
516 RefPtrWillBeMember<TextTrackList> m_textTracks; 545 RefPtrWillBeMember<TextTrackList> m_textTracks;
517 WillBeHeapVector<RefPtrWillBeMember<TextTrack> > m_textTracksWhenResourceSel ectionBegan; 546 WillBeHeapVector<RefPtrWillBeMember<TextTrack> > m_textTracksWhenResourceSel ectionBegan;
518 547
519 CueIntervalTree m_cueTree; 548 CueIntervalTree m_cueTree;
520 549
521 CueList m_currentlyActiveCues; 550 CueList m_currentlyActiveCues;
522 int m_ignoreTrackDisplayUpdate; 551 int m_ignoreTrackDisplayUpdate;
523 552
524 #if ENABLE(WEB_AUDIO) 553 #if ENABLE(WEB_AUDIO)
525 // This is a weak reference, since m_audioSourceNode holds a reference to us . 554 // This is a weak reference, since m_audioSourceNode holds a reference to us .
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 inline bool isHTMLMediaElement(const HTMLElement& element) 592 inline bool isHTMLMediaElement(const HTMLElement& element)
564 { 593 {
565 return isHTMLAudioElement(element) || isHTMLVideoElement(element); 594 return isHTMLAudioElement(element) || isHTMLVideoElement(element);
566 } 595 }
567 596
568 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); 597 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement);
569 598
570 } //namespace 599 } //namespace
571 600
572 #endif 601 #endif
OLDNEW
« no previous file with comments | « Source/core/events/EventTargetFactory.in ('k') | Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698