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

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

Issue 170233009: Initial implementation of AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@blink-master
Patch Set: Address CR comments. Created 6 years, 9 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
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 class WebInbandTextTrack; 42 class WebInbandTextTrack;
43 class WebLayer; 43 class WebLayer;
44 } 44 }
45 45
46 namespace WebCore { 46 namespace WebCore {
47 47
48 #if ENABLE(WEB_AUDIO) 48 #if ENABLE(WEB_AUDIO)
49 class AudioSourceProvider; 49 class AudioSourceProvider;
50 class MediaElementAudioSourceNode; 50 class MediaElementAudioSourceNode;
51 #endif 51 #endif
52 class AudioTrackList;
52 class ContentType; 53 class ContentType;
53 class Event; 54 class Event;
54 class ExceptionState; 55 class ExceptionState;
55 class HTMLSourceElement; 56 class HTMLSourceElement;
56 class HTMLTrackElement; 57 class HTMLTrackElement;
57 class KURL; 58 class KURL;
58 class MediaController; 59 class MediaController;
59 class MediaControls; 60 class MediaControls;
60 class MediaError; 61 class MediaError;
61 class HTMLMediaSource; 62 class HTMLMediaSource;
62 class TextTrackList; 63 class TextTrackList;
63 class TimeRanges; 64 class TimeRanges;
64 class URLRegistry; 65 class URLRegistry;
66 class VideoTrackList;
65 67
66 typedef PODIntervalTree<double, TextTrackCue*> CueIntervalTree; 68 typedef PODIntervalTree<double, TextTrackCue*> CueIntervalTree;
67 typedef CueIntervalTree::IntervalType CueInterval; 69 typedef CueIntervalTree::IntervalType CueInterval;
68 typedef Vector<CueInterval> CueList; 70 typedef Vector<CueInterval> CueList;
69 71
70 // FIXME: The inheritance from MediaPlayerClient here should be private inherita nce. 72 // FIXME: The inheritance from MediaPlayerClient here should be private inherita nce.
71 // 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
72 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement. 74 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement.
73 75
74 class HTMLMediaElement : public Supplementable<HTMLMediaElement>, public HTMLEle ment, public MediaPlayerClient, public ActiveDOMObject, public MediaControllerIn terface 76 class HTMLMediaElement : public Supplementable<HTMLMediaElement>, public HTMLEle ment, public MediaPlayerClient, public ActiveDOMObject, public MediaControllerIn terface
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 virtual double volume() const OVERRIDE FINAL; 157 virtual double volume() const OVERRIDE FINAL;
156 virtual void setVolume(double, ExceptionState&) OVERRIDE FINAL; 158 virtual void setVolume(double, ExceptionState&) OVERRIDE FINAL;
157 virtual bool muted() const OVERRIDE FINAL; 159 virtual bool muted() const OVERRIDE FINAL;
158 virtual void setMuted(bool) OVERRIDE FINAL; 160 virtual void setMuted(bool) OVERRIDE FINAL;
159 161
160 virtual void beginScrubbing() OVERRIDE FINAL; 162 virtual void beginScrubbing() OVERRIDE FINAL;
161 virtual void endScrubbing() OVERRIDE FINAL; 163 virtual void endScrubbing() OVERRIDE FINAL;
162 164
163 virtual bool canPlay() const OVERRIDE FINAL; 165 virtual bool canPlay() const OVERRIDE FINAL;
164 166
167 AudioTrackList& audioTracks();
168 void audioTrackChanged(const String& audioTrackID);
169
170 VideoTrackList& videoTracks();
171 void selectedVideoTrackChanged(const String& selectedTrackID);
172
165 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, const AtomicStr ing& label, const AtomicString& language, ExceptionState&); 173 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, const AtomicStr ing& label, const AtomicString& language, ExceptionState&);
166 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, const AtomicStr ing& label, ExceptionState& exceptionState) { return addTextTrack(kind, label, e mptyAtom, exceptionState); } 174 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, const AtomicStr ing& label, ExceptionState& exceptionState) { return addTextTrack(kind, label, e mptyAtom, exceptionState); }
167 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, ExceptionState& exceptionState) { return addTextTrack(kind, emptyAtom, emptyAtom, exceptionStat e); } 175 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, ExceptionState& exceptionState) { return addTextTrack(kind, emptyAtom, emptyAtom, exceptionStat e); }
168 176
169 TextTrackList* textTracks(); 177 TextTrackList* textTracks();
170 CueList currentlyActiveCues() const { return m_currentlyActiveCues; } 178 CueList currentlyActiveCues() const { return m_currentlyActiveCues; }
171 179
172 void addTextTrack(TextTrack*); 180 void addTextTrack(TextTrack*);
173 void removeTextTrack(TextTrack*); 181 void removeTextTrack(TextTrack*);
174 void closeCaptionTracksChanged(); 182 void closeCaptionTracksChanged();
175 void notifyMediaPlayerOfTextTrackChanges(); 183 void notifyMediaPlayerOfTextTrackChanges();
176 184
177 // Implements the "forget the media element's media-resource-specific tracks " algorithm in the HTML5 spec. 185 // Implements the "forget the media element's media-resource-specific tracks " algorithm in the HTML5 spec.
178 void forgetResourceSpecificTracks(); 186 void forgetResourceSpecificTracks();
179 187
180 void didAddTrackElement(HTMLTrackElement*); 188 void didAddTrackElement(HTMLTrackElement*);
181 void didRemoveTrackElement(HTMLTrackElement*); 189 void didRemoveTrackElement(HTMLTrackElement*);
182 190
191 void addVideoTrack(const String& id, blink::WebMediaPlayerClient::VideoTrack Kind, const AtomicString& label, const AtomicString& language, bool selected);
192 void removeVideoTrack(const String& id);
193 void addAudioTrack(const String& id, blink::WebMediaPlayerClient::AudioTrack Kind, const AtomicString& label, const AtomicString& language, bool enabled);
194 void removeAudioTrack(const String& id);
195
183 virtual void mediaPlayerDidAddTextTrack(blink::WebInbandTextTrack*) OVERRIDE FINAL; 196 virtual void mediaPlayerDidAddTextTrack(blink::WebInbandTextTrack*) OVERRIDE FINAL;
184 virtual void mediaPlayerDidRemoveTextTrack(blink::WebInbandTextTrack*) OVERR IDE FINAL; 197 virtual void mediaPlayerDidRemoveTextTrack(blink::WebInbandTextTrack*) OVERR IDE FINAL;
185 // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not d epend on it. 198 // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not d epend on it.
186 virtual KURL mediaPlayerPosterURL() OVERRIDE { return KURL(); } 199 virtual KURL mediaPlayerPosterURL() OVERRIDE { return KURL(); }
187 200
188 struct TrackGroup { 201 struct TrackGroup {
189 enum GroupKind { CaptionsAndSubtitles, Description, Chapter, Metadata, O ther }; 202 enum GroupKind { CaptionsAndSubtitles, Description, Chapter, Metadata, O ther };
190 203
191 TrackGroup(GroupKind kind) 204 TrackGroup(GroupKind kind)
192 : visibleTrack(nullptr) 205 : visibleTrack(nullptr)
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 420
408 void changeNetworkStateFromLoadingToIdle(); 421 void changeNetworkStateFromLoadingToIdle();
409 422
410 const AtomicString& mediaGroup() const; 423 const AtomicString& mediaGroup() const;
411 void setMediaGroup(const AtomicString&); 424 void setMediaGroup(const AtomicString&);
412 void updateMediaController(); 425 void updateMediaController();
413 bool isBlocked() const; 426 bool isBlocked() const;
414 bool isBlockedOnMediaController() const; 427 bool isBlockedOnMediaController() const;
415 bool isAutoplaying() const { return m_autoplaying; } 428 bool isAutoplaying() const { return m_autoplaying; }
416 429
430 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects
431 // advertise they have audio and/or video, but don't explicity signal them v ia
432 // mediaPlayerDidAddAudioTrack() and mediaPlayerDidAddVideoTrack().
433 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info.
434 void createPlaceholderTracksIfNecessary();
435
436 // Sets the selected/enabled tracks if they aren't set before we initially
437 // transition to HAVE_METADATA.
438 void selectInitialTracksIfNecessary();
439
440 void audioTracksTimerFired(Timer<HTMLMediaElement>*);
441
417 Timer<HTMLMediaElement> m_loadTimer; 442 Timer<HTMLMediaElement> m_loadTimer;
418 Timer<HTMLMediaElement> m_progressEventTimer; 443 Timer<HTMLMediaElement> m_progressEventTimer;
419 Timer<HTMLMediaElement> m_playbackProgressTimer; 444 Timer<HTMLMediaElement> m_playbackProgressTimer;
445 Timer<HTMLMediaElement> m_audioTracksTimer;
420 RefPtr<TimeRanges> m_playedTimeRanges; 446 RefPtr<TimeRanges> m_playedTimeRanges;
421 OwnPtr<GenericEventQueue> m_asyncEventQueue; 447 OwnPtr<GenericEventQueue> m_asyncEventQueue;
422 448
423 double m_playbackRate; 449 double m_playbackRate;
424 double m_defaultPlaybackRate; 450 double m_defaultPlaybackRate;
425 NetworkState m_networkState; 451 NetworkState m_networkState;
426 ReadyState m_readyState; 452 ReadyState m_readyState;
427 ReadyState m_readyStateMaximum; 453 ReadyState m_readyStateMaximum;
428 KURL m_currentSrc; 454 KURL m_currentSrc;
429 455
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 bool m_closedCaptionsVisible : 1; 517 bool m_closedCaptionsVisible : 1;
492 518
493 bool m_completelyLoaded : 1; 519 bool m_completelyLoaded : 1;
494 bool m_havePreparedToPlay : 1; 520 bool m_havePreparedToPlay : 1;
495 521
496 bool m_tracksAreReady : 1; 522 bool m_tracksAreReady : 1;
497 bool m_haveVisibleTextTrack : 1; 523 bool m_haveVisibleTextTrack : 1;
498 bool m_processingPreferenceChange : 1; 524 bool m_processingPreferenceChange : 1;
499 double m_lastTextTrackUpdateTime; 525 double m_lastTextTrackUpdateTime;
500 526
527 RefPtr<AudioTrackList> m_audioTracks;
528 RefPtr<VideoTrackList> m_videoTracks;
501 RefPtr<TextTrackList> m_textTracks; 529 RefPtr<TextTrackList> m_textTracks;
502 Vector<RefPtr<TextTrack> > m_textTracksWhenResourceSelectionBegan; 530 Vector<RefPtr<TextTrack> > m_textTracksWhenResourceSelectionBegan;
503 531
504 CueIntervalTree m_cueTree; 532 CueIntervalTree m_cueTree;
505 533
506 CueList m_currentlyActiveCues; 534 CueList m_currentlyActiveCues;
507 int m_ignoreTrackDisplayUpdate; 535 int m_ignoreTrackDisplayUpdate;
508 536
509 #if ENABLE(WEB_AUDIO) 537 #if ENABLE(WEB_AUDIO)
510 // This is a weak reference, since m_audioSourceNode holds a reference to us . 538 // 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
548 inline bool isHTMLMediaElement(const Node* node) 576 inline bool isHTMLMediaElement(const Node* node)
549 { 577 {
550 return node && isHTMLMediaElement(*node); 578 return node && isHTMLMediaElement(*node);
551 } 579 }
552 580
553 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); 581 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement);
554 582
555 } //namespace 583 } //namespace
556 584
557 #endif 585 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698