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

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: Rebase 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 virtual double volume() const OVERRIDE FINAL; 158 virtual double volume() const OVERRIDE FINAL;
157 virtual void setVolume(double, ExceptionState&) OVERRIDE FINAL; 159 virtual void setVolume(double, ExceptionState&) OVERRIDE FINAL;
158 virtual bool muted() const OVERRIDE FINAL; 160 virtual bool muted() const OVERRIDE FINAL;
159 virtual void setMuted(bool) OVERRIDE FINAL; 161 virtual void setMuted(bool) OVERRIDE FINAL;
160 162
161 virtual void beginScrubbing() OVERRIDE FINAL; 163 virtual void beginScrubbing() OVERRIDE FINAL;
162 virtual void endScrubbing() OVERRIDE FINAL; 164 virtual void endScrubbing() OVERRIDE FINAL;
163 165
164 virtual bool canPlay() const OVERRIDE FINAL; 166 virtual bool canPlay() const OVERRIDE FINAL;
165 167
168 AudioTrackList& audioTracks();
169 void audioTrackChanged(const AtomicString& audioTrackID, bool enabled);
170
171 VideoTrackList& videoTracks();
172 void selectedVideoTrackChanged(const AtomicString& selectedTrackID);
173
166 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, const AtomicStr ing& label, const AtomicString& language, ExceptionState&); 174 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, const AtomicStr ing& label, const AtomicString& language, ExceptionState&);
167 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, const AtomicStr ing& label, ExceptionState& exceptionState) { return addTextTrack(kind, label, e mptyAtom, exceptionState); } 175 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, const AtomicStr ing& label, ExceptionState& exceptionState) { return addTextTrack(kind, label, e mptyAtom, exceptionState); }
168 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, ExceptionState& exceptionState) { return addTextTrack(kind, emptyAtom, emptyAtom, exceptionStat e); } 176 PassRefPtr<TextTrack> addTextTrack(const AtomicString& kind, ExceptionState& exceptionState) { return addTextTrack(kind, emptyAtom, emptyAtom, exceptionStat e); }
169 177
170 TextTrackList* textTracks(); 178 TextTrackList* textTracks();
171 CueList currentlyActiveCues() const { return m_currentlyActiveCues; } 179 CueList currentlyActiveCues() const { return m_currentlyActiveCues; }
172 180
173 void addTextTrack(TextTrack*); 181 void addTextTrack(TextTrack*);
174 void removeTextTrack(TextTrack*); 182 void removeTextTrack(TextTrack*);
175 void closeCaptionTracksChanged(); 183 void closeCaptionTracksChanged();
176 void notifyMediaPlayerOfTextTrackChanges(); 184 void notifyMediaPlayerOfTextTrackChanges();
177 185
178 // Implements the "forget the media element's media-resource-specific tracks " algorithm in the HTML5 spec. 186 // Implements the "forget the media element's media-resource-specific tracks " algorithm in the HTML5 spec.
179 void forgetResourceSpecificTracks(); 187 void forgetResourceSpecificTracks();
180 188
181 void didAddTrackElement(HTMLTrackElement*); 189 void didAddTrackElement(HTMLTrackElement*);
182 void didRemoveTrackElement(HTMLTrackElement*); 190 void didRemoveTrackElement(HTMLTrackElement*);
183 191
192 void addVideoTrack(const AtomicString& id, blink::WebMediaPlayerClient::Vide oTrackKind, const AtomicString& label, const AtomicString& language, bool select ed);
193 void removeVideoTrack(const AtomicString& id);
194 void addAudioTrack(const AtomicString& id, blink::WebMediaPlayerClient::Audi oTrackKind, const AtomicString& label, const AtomicString& language, bool enable d);
195 void removeAudioTrack(const AtomicString& id);
196
184 virtual void mediaPlayerDidAddTextTrack(blink::WebInbandTextTrack*) OVERRIDE FINAL; 197 virtual void mediaPlayerDidAddTextTrack(blink::WebInbandTextTrack*) OVERRIDE FINAL;
185 virtual void mediaPlayerDidRemoveTextTrack(blink::WebInbandTextTrack*) OVERR IDE FINAL; 198 virtual void mediaPlayerDidRemoveTextTrack(blink::WebInbandTextTrack*) OVERR IDE FINAL;
186 // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not d epend on it. 199 // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not d epend on it.
187 virtual KURL mediaPlayerPosterURL() OVERRIDE { return KURL(); } 200 virtual KURL mediaPlayerPosterURL() OVERRIDE { return KURL(); }
188 201
189 struct TrackGroup { 202 struct TrackGroup {
190 enum GroupKind { CaptionsAndSubtitles, Description, Chapter, Metadata, O ther }; 203 enum GroupKind { CaptionsAndSubtitles, Description, Chapter, Metadata, O ther };
191 204
192 TrackGroup(GroupKind kind) 205 TrackGroup(GroupKind kind)
193 : visibleTrack(nullptr) 206 : visibleTrack(nullptr)
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 423
411 void changeNetworkStateFromLoadingToIdle(); 424 void changeNetworkStateFromLoadingToIdle();
412 425
413 const AtomicString& mediaGroup() const; 426 const AtomicString& mediaGroup() const;
414 void setMediaGroup(const AtomicString&); 427 void setMediaGroup(const AtomicString&);
415 void updateMediaController(); 428 void updateMediaController();
416 bool isBlocked() const; 429 bool isBlocked() const;
417 bool isBlockedOnMediaController() const; 430 bool isBlockedOnMediaController() const;
418 bool isAutoplaying() const { return m_autoplaying; } 431 bool isAutoplaying() const { return m_autoplaying; }
419 432
433 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects
434 // advertise they have audio and/or video, but don't explicity signal them v ia
435 // mediaPlayerDidAddAudioTrack() and mediaPlayerDidAddVideoTrack().
436 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info.
437 void createPlaceholderTracksIfNecessary();
438
439 // Sets the selected/enabled tracks if they aren't set before we initially
440 // transition to HAVE_METADATA.
441 void selectInitialTracksIfNecessary();
442
420 Timer<HTMLMediaElement> m_loadTimer; 443 Timer<HTMLMediaElement> m_loadTimer;
421 Timer<HTMLMediaElement> m_progressEventTimer; 444 Timer<HTMLMediaElement> m_progressEventTimer;
422 Timer<HTMLMediaElement> m_playbackProgressTimer; 445 Timer<HTMLMediaElement> m_playbackProgressTimer;
423 RefPtr<TimeRanges> m_playedTimeRanges; 446 RefPtr<TimeRanges> m_playedTimeRanges;
424 OwnPtr<GenericEventQueue> m_asyncEventQueue; 447 OwnPtr<GenericEventQueue> m_asyncEventQueue;
425 448
426 double m_playbackRate; 449 double m_playbackRate;
427 double m_defaultPlaybackRate; 450 double m_defaultPlaybackRate;
428 NetworkState m_networkState; 451 NetworkState m_networkState;
429 ReadyState m_readyState; 452 ReadyState m_readyState;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 bool m_closedCaptionsVisible : 1; 517 bool m_closedCaptionsVisible : 1;
495 518
496 bool m_completelyLoaded : 1; 519 bool m_completelyLoaded : 1;
497 bool m_havePreparedToPlay : 1; 520 bool m_havePreparedToPlay : 1;
498 521
499 bool m_tracksAreReady : 1; 522 bool m_tracksAreReady : 1;
500 bool m_haveVisibleTextTrack : 1; 523 bool m_haveVisibleTextTrack : 1;
501 bool m_processingPreferenceChange : 1; 524 bool m_processingPreferenceChange : 1;
502 double m_lastTextTrackUpdateTime; 525 double m_lastTextTrackUpdateTime;
503 526
527 RefPtr<AudioTrackList> m_audioTracks;
528 RefPtr<VideoTrackList> m_videoTracks;
504 RefPtr<TextTrackList> m_textTracks; 529 RefPtr<TextTrackList> m_textTracks;
505 Vector<RefPtr<TextTrack> > m_textTracksWhenResourceSelectionBegan; 530 Vector<RefPtr<TextTrack> > m_textTracksWhenResourceSelectionBegan;
506 531
507 CueIntervalTree m_cueTree; 532 CueIntervalTree m_cueTree;
508 533
509 CueList m_currentlyActiveCues; 534 CueList m_currentlyActiveCues;
510 int m_ignoreTrackDisplayUpdate; 535 int m_ignoreTrackDisplayUpdate;
511 536
512 #if ENABLE(WEB_AUDIO) 537 #if ENABLE(WEB_AUDIO)
513 // 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 inline bool isHTMLMediaElement(const Node& node) 571 inline bool isHTMLMediaElement(const Node& node)
547 { 572 {
548 return node.isElementNode() && toElement(node).isMediaElement(); 573 return node.isElementNode() && toElement(node).isMediaElement();
549 } 574 }
550 575
551 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); 576 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement);
552 577
553 } //namespace 578 } //namespace
554 579
555 #endif 580 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698