2008-07-09 01:22:20 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2013-03-19 05:23:54 -07:00
|
|
|
#ifndef mozilla_dom_HTMLMediaElement_h
|
|
|
|
#define mozilla_dom_HTMLMediaElement_h
|
2010-04-01 20:03:07 -07:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
#include "nsIDOMHTMLMediaElement.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-11-08 21:52:53 -08:00
|
|
|
#include "MediaDecoderOwner.h"
|
2009-03-08 13:59:08 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2010-02-24 11:14:14 -08:00
|
|
|
#include "nsIObserver.h"
|
2012-03-10 08:13:51 -08:00
|
|
|
#include "mozilla/CORSMode.h"
|
2013-02-15 00:01:58 -08:00
|
|
|
#include "DOMMediaStream.h"
|
2012-11-15 19:25:26 -08:00
|
|
|
#include "AudioChannelCommon.h"
|
2012-11-21 19:10:41 -08:00
|
|
|
#include "DecoderTraits.h"
|
2013-10-21 14:23:33 -07:00
|
|
|
#include "nsIAudioChannelAgent.h"
|
2013-03-19 05:25:19 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-07-16 13:54:00 -07:00
|
|
|
#include "mozilla/dom/Promise.h"
|
2013-10-23 11:45:00 -07:00
|
|
|
#include "mozilla/dom/TextTrackManager.h"
|
2014-03-31 20:39:04 -07:00
|
|
|
#include "MediaDecoder.h"
|
2014-07-16 13:54:00 -07:00
|
|
|
#ifdef MOZ_EME
|
2014-06-06 13:52:15 -07:00
|
|
|
#include "mozilla/dom/MediaKeys.h"
|
2014-07-16 13:54:00 -07:00
|
|
|
#endif
|
2014-10-01 11:43:26 -07:00
|
|
|
#include "nsGkAtoms.h"
|
2014-06-06 13:52:15 -07:00
|
|
|
|
|
|
|
// Something on Linux #defines None, which is an entry in the
|
|
|
|
// MediaWaitingFor enum, so undef it here before including the binfing,
|
|
|
|
// so that the build doesn't fail...
|
|
|
|
#ifdef None
|
|
|
|
#undef None
|
|
|
|
#endif
|
|
|
|
|
2014-08-25 06:27:25 -07:00
|
|
|
// X.h on Linux #defines CurrentTime as 0L, so we have to #undef it here.
|
|
|
|
#ifdef CurrentTime
|
|
|
|
#undef CurrentTime
|
|
|
|
#endif
|
|
|
|
|
2014-06-06 13:52:15 -07:00
|
|
|
#include "mozilla/dom/HTMLMediaElementBinding.h"
|
2010-08-25 06:10:00 -07:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
// Define to output information on decoding and painting framerate
|
|
|
|
/* #define DEBUG_FRAME_RATE 1 */
|
|
|
|
|
2013-10-21 14:23:33 -07:00
|
|
|
class nsIChannel;
|
|
|
|
class nsIHttpChannel;
|
|
|
|
class nsILoadGroup;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
typedef uint16_t nsMediaNetworkState;
|
|
|
|
typedef uint16_t nsMediaReadyState;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2012-04-29 20:12:28 -07:00
|
|
|
namespace mozilla {
|
2013-10-21 14:23:33 -07:00
|
|
|
class ErrorResult;
|
2012-04-29 20:12:28 -07:00
|
|
|
class MediaResource;
|
2012-11-14 11:46:40 -08:00
|
|
|
class MediaDecoder;
|
2013-10-21 14:23:33 -07:00
|
|
|
class VideoFrameContainer;
|
|
|
|
namespace dom {
|
2014-06-06 13:52:15 -07:00
|
|
|
class MediaKeys;
|
2013-10-21 14:23:33 -07:00
|
|
|
class TextTrack;
|
|
|
|
class TimeRanges;
|
2014-01-07 04:16:07 -08:00
|
|
|
class WakeLock;
|
2014-05-23 02:34:14 -07:00
|
|
|
class MediaTrack;
|
2013-10-21 14:23:33 -07:00
|
|
|
}
|
2012-11-14 11:45:33 -08:00
|
|
|
}
|
2012-04-29 20:12:28 -07:00
|
|
|
|
2013-05-28 10:30:17 -07:00
|
|
|
class nsITimer;
|
2013-06-06 21:26:55 -07:00
|
|
|
class nsRange;
|
2013-09-19 06:54:39 -07:00
|
|
|
class nsIRunnable;
|
2013-05-28 10:30:17 -07:00
|
|
|
|
2013-03-19 05:23:54 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-04-08 08:29:07 -07:00
|
|
|
// Number of milliseconds between timeupdate events as defined by spec
|
|
|
|
#define TIMEUPDATE_MS 250
|
|
|
|
|
2013-03-19 05:25:19 -07:00
|
|
|
class MediaError;
|
2013-06-20 20:15:47 -07:00
|
|
|
class MediaSource;
|
2013-10-23 11:45:00 -07:00
|
|
|
class TextTrackList;
|
2014-05-23 02:34:14 -07:00
|
|
|
class AudioTrackList;
|
|
|
|
class VideoTrackList;
|
2013-03-19 05:25:19 -07:00
|
|
|
|
2013-03-19 05:23:54 -07:00
|
|
|
class HTMLMediaElement : public nsGenericHTMLElement,
|
2014-07-12 19:20:42 -07:00
|
|
|
public nsIDOMHTMLMediaElement,
|
2013-03-19 05:23:54 -07:00
|
|
|
public nsIObserver,
|
|
|
|
public MediaDecoderOwner,
|
|
|
|
public nsIAudioChannelAgentCallback
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-11-24 10:34:57 -08:00
|
|
|
typedef mozilla::TimeStamp TimeStamp;
|
2012-02-14 20:35:01 -08:00
|
|
|
typedef mozilla::layers::ImageContainer ImageContainer;
|
|
|
|
typedef mozilla::VideoFrameContainer VideoFrameContainer;
|
2012-04-29 20:12:28 -07:00
|
|
|
typedef mozilla::MediaStream MediaStream;
|
|
|
|
typedef mozilla::MediaResource MediaResource;
|
2012-11-14 11:45:31 -08:00
|
|
|
typedef mozilla::MediaDecoderOwner MediaDecoderOwner;
|
|
|
|
typedef mozilla::MetadataTags MetadataTags;
|
2010-11-24 10:34:57 -08:00
|
|
|
|
2013-03-19 05:23:54 -07:00
|
|
|
CORSMode GetCORSMode() {
|
2012-01-25 14:31:30 -08:00
|
|
|
return mCORSMode;
|
|
|
|
}
|
|
|
|
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2008-10-29 22:20:08 -07:00
|
|
|
/**
|
|
|
|
* This is used when the browser is constructing a video element to play
|
|
|
|
* a channel that we've already started loading. The src attribute and
|
2009-11-05 23:34:00 -08:00
|
|
|
* <source> children are ignored.
|
2008-10-29 22:20:08 -07:00
|
|
|
* @param aChannel the channel to use
|
|
|
|
* @param aListener returns a stream listener that should receive
|
|
|
|
* notifications for the stream
|
2009-11-05 23:34:00 -08:00
|
|
|
*/
|
2008-10-29 22:20:08 -07:00
|
|
|
nsresult LoadWithChannel(nsIChannel *aChannel, nsIStreamListener **aListener);
|
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
// nsIDOMHTMLMediaElement
|
|
|
|
NS_DECL_NSIDOMHTMLMEDIAELEMENT
|
|
|
|
|
2010-02-24 11:14:14 -08:00
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2012-12-06 07:25:18 -08:00
|
|
|
NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
|
|
|
|
|
2009-03-08 13:59:08 -07:00
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-03-19 05:23:54 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLMediaElement,
|
2009-03-08 13:59:08 -07:00
|
|
|
nsGenericHTMLElement)
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2013-03-19 05:25:19 -07:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2013-05-29 13:43:41 -07:00
|
|
|
nsAttrValue& aResult) MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
// SetAttr override. C++ is stupid, so have to override both
|
|
|
|
// overloaded methods.
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
2011-09-28 23:19:26 -07:00
|
|
|
const nsAString& aValue, bool aNotify)
|
2008-07-09 01:22:20 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
|
2008-07-09 01:22:20 -07:00
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
2008-07-09 01:22:20 -07:00
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE;
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aCompileEventHandlers) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNullParent = true) MOZ_OVERRIDE;
|
|
|
|
virtual void DoneCreatingElement() MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2013-02-11 20:56:03 -08:00
|
|
|
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable,
|
2013-05-29 13:43:41 -07:00
|
|
|
int32_t *aTabIndex) MOZ_OVERRIDE;
|
|
|
|
virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
|
2013-02-11 20:56:03 -08:00
|
|
|
|
2009-10-01 07:10:13 -07:00
|
|
|
/**
|
|
|
|
* Call this to reevaluate whether we should start/stop due to our owner
|
2012-12-04 11:46:07 -08:00
|
|
|
* document being active, inactive, visible or hidden.
|
2009-10-01 07:10:13 -07:00
|
|
|
*/
|
2013-05-10 05:42:39 -07:00
|
|
|
virtual void NotifyOwnerDocumentActivityChanged();
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when it has read the metadata containing video dimensions,
|
|
|
|
// etc.
|
2014-07-03 20:54:54 -07:00
|
|
|
virtual void MetadataLoaded(const MediaInfo* aInfo,
|
2014-11-06 00:17:05 -08:00
|
|
|
nsAutoPtr<const MetadataTags> aTags) MOZ_FINAL MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2014-09-24 00:25:00 -07:00
|
|
|
// Called by the decoder object, on the main thread,
|
|
|
|
// when it has read the first frame of the video or audio.
|
|
|
|
virtual void FirstFrameLoaded() MOZ_FINAL MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when the resource has a network error during loading.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void NetworkError() MOZ_FINAL MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2009-09-21 17:08:13 -07:00
|
|
|
// Called by the video decoder object, on the main thread, when the
|
|
|
|
// resource has a decode error during metadata loading or decoding.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void DecodeError() MOZ_FINAL MOZ_OVERRIDE;
|
2009-09-21 17:08:13 -07:00
|
|
|
|
2010-09-02 17:03:03 -07:00
|
|
|
// Called by the video decoder object, on the main thread, when the
|
|
|
|
// resource load has been cancelled.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void LoadAborted() MOZ_FINAL MOZ_OVERRIDE;
|
2010-09-02 17:03:03 -07:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when the video playback has ended.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void PlaybackEnded() MOZ_FINAL MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when the resource has started seeking.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void SeekStarted() MOZ_FINAL MOZ_OVERRIDE;
|
2008-10-19 00:39:21 -07:00
|
|
|
|
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when the resource has completed seeking.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void SeekCompleted() MOZ_FINAL MOZ_OVERRIDE;
|
2008-10-19 00:39:21 -07:00
|
|
|
|
2009-05-17 19:03:37 -07:00
|
|
|
// Called by the media stream, on the main thread, when the download
|
|
|
|
// has been suspended by the cache or because the element itself
|
|
|
|
// asked the decoder to suspend the download.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void DownloadSuspended() MOZ_FINAL MOZ_OVERRIDE;
|
2009-05-17 19:03:37 -07:00
|
|
|
|
|
|
|
// Called by the media stream, on the main thread, when the download
|
|
|
|
// has been resumed by the cache or because the element itself
|
|
|
|
// asked the decoder to resumed the download.
|
2012-05-30 19:30:23 -07:00
|
|
|
// If aForceNetworkLoading is True, ignore the fact that the download has
|
|
|
|
// previously finished. We are downloading the middle of the media after
|
|
|
|
// having downloaded the end, we need to notify the element a download in
|
|
|
|
// ongoing.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void DownloadResumed(bool aForceNetworkLoading = false) MOZ_FINAL MOZ_OVERRIDE;
|
2009-05-17 19:03:37 -07:00
|
|
|
|
2014-09-24 00:26:00 -07:00
|
|
|
// Called to indicate the download is progressing.
|
|
|
|
virtual void DownloadProgressed() MOZ_FINAL MOZ_OVERRIDE;
|
|
|
|
|
2012-05-27 15:40:06 -07:00
|
|
|
// Called by the media decoder to indicate whether the media cache has
|
|
|
|
// suspended the channel.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void NotifySuspendedByCache(bool aIsSuspended) MOZ_FINAL MOZ_OVERRIDE;
|
2012-05-27 15:40:06 -07:00
|
|
|
|
2010-03-01 15:41:49 -08:00
|
|
|
// Called by the media decoder and the video frame to get the
|
|
|
|
// ImageContainer containing the video data.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE;
|
2013-03-19 05:23:54 -07:00
|
|
|
layers::ImageContainer* GetImageContainer();
|
2010-03-01 15:41:49 -08:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
// Dispatch events
|
2011-06-23 19:17:59 -07:00
|
|
|
using nsGenericHTMLElement::DispatchEvent;
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual nsresult DispatchEvent(const nsAString& aName) MOZ_FINAL MOZ_OVERRIDE;
|
|
|
|
virtual nsresult DispatchAsyncEvent(const nsAString& aName) MOZ_FINAL MOZ_OVERRIDE;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2010-09-09 21:20:10 -07:00
|
|
|
// Dispatch events that were raised while in the bfcache
|
|
|
|
nsresult DispatchPendingMediaEvents();
|
|
|
|
|
2009-02-05 00:02:21 -08:00
|
|
|
// Called by the decoder when some data has been downloaded or
|
|
|
|
// buffering/seeking has ended. aNextFrameAvailable is true when
|
|
|
|
// the data for the next frame is available. This method will
|
|
|
|
// decide whether to set the ready state to HAVE_CURRENT_DATA,
|
|
|
|
// HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA.
|
2012-11-14 11:45:31 -08:00
|
|
|
virtual void UpdateReadyStateForData(MediaDecoderOwner::NextFrameStatus aNextFrame) MOZ_FINAL MOZ_OVERRIDE;
|
2009-02-05 00:02:21 -08:00
|
|
|
|
2009-10-01 07:10:13 -07:00
|
|
|
// Return true if we can activate autoplay assuming enough data has arrived.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool CanActivateAutoplay();
|
2009-10-01 07:10:13 -07:00
|
|
|
|
2013-03-20 04:11:48 -07:00
|
|
|
// Notify that state has changed that might cause an autoplay element to
|
|
|
|
// start playing.
|
2009-03-31 17:52:56 -07:00
|
|
|
// If the element is 'autoplay' and is ready to play back (not paused,
|
|
|
|
// autoplay pref enabled, etc), it should start playing back.
|
2013-03-20 04:11:48 -07:00
|
|
|
void CheckAutoplayDataReady();
|
2009-03-31 17:52:56 -07:00
|
|
|
|
2012-01-25 14:31:30 -08:00
|
|
|
// Check if the media element had crossorigin set when loading started
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ShouldCheckAllowOrigin();
|
2009-01-24 03:00:17 -08:00
|
|
|
|
2008-12-14 19:38:16 -08:00
|
|
|
// Is the media element potentially playing as defined by the HTML 5 specification.
|
|
|
|
// http://www.whatwg.org/specs/web-apps/current-work/#potentially-playing
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPotentiallyPlaying() const;
|
2008-10-19 00:39:21 -07:00
|
|
|
|
|
|
|
// Has playback ended as defined by the HTML 5 specification.
|
|
|
|
// http://www.whatwg.org/specs/web-apps/current-work/#ended
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPlaybackEnded() const;
|
2008-10-19 00:39:21 -07:00
|
|
|
|
2012-04-29 20:12:28 -07:00
|
|
|
// principal of the currently playing resource. Anything accessing the contents
|
|
|
|
// of this element must have a principal that subsumes this principal.
|
|
|
|
// Returns null if nothing is playing.
|
2009-03-31 17:52:56 -07:00
|
|
|
already_AddRefed<nsIPrincipal> GetCurrentPrincipal();
|
2008-09-06 16:47:28 -07:00
|
|
|
|
2012-04-29 20:12:42 -07:00
|
|
|
// called to notify that the principal of the decoder's media resource has changed.
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void NotifyDecoderPrincipalChanged() MOZ_FINAL MOZ_OVERRIDE;
|
2012-04-29 20:12:42 -07:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
// Update the visual size of the media. Called from the decoder on the
|
|
|
|
// main thread when/if the size changes.
|
|
|
|
void UpdateMediaSize(nsIntSize size);
|
|
|
|
|
2010-06-08 16:31:27 -07:00
|
|
|
// Returns the CanPlayStatus indicating if we can handle the
|
|
|
|
// full MIME type including the optional codecs parameter.
|
2013-03-19 05:23:54 -07:00
|
|
|
static CanPlayStatus GetCanPlay(const nsAString& aType);
|
2012-09-29 16:29:04 -07:00
|
|
|
|
2009-02-15 17:05:28 -08:00
|
|
|
/**
|
|
|
|
* Called when a child source element is added to this media element. This
|
2010-09-02 17:03:03 -07:00
|
|
|
* may queue a task to run the select resource algorithm if appropriate.
|
2009-02-15 17:05:28 -08:00
|
|
|
*/
|
|
|
|
void NotifyAddedSource();
|
|
|
|
|
2009-03-08 13:59:08 -07:00
|
|
|
/**
|
|
|
|
* Called when there's been an error fetching the resource. This decides
|
|
|
|
* whether it's appropriate to fire an error event.
|
|
|
|
*/
|
|
|
|
void NotifyLoadError();
|
|
|
|
|
2014-05-23 02:34:14 -07:00
|
|
|
void NotifyMediaTrackEnabled(MediaTrack* aTrack);
|
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
|
2009-02-15 17:05:28 -08:00
|
|
|
|
|
|
|
/**
|
2009-03-08 13:59:08 -07:00
|
|
|
* Returns the current load ID. Asynchronous events store the ID that was
|
|
|
|
* current when they were enqueued, and if it has changed when they come to
|
|
|
|
* fire, they consider themselves cancelled, and don't fire.
|
2009-02-15 17:05:28 -08:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetCurrentLoadID() { return mCurrentLoadID; }
|
2009-02-15 17:05:28 -08:00
|
|
|
|
2009-04-09 18:28:24 -07:00
|
|
|
/**
|
|
|
|
* Returns the load group for this media element's owner document.
|
|
|
|
* XXX XBL2 issue.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsILoadGroup> GetDocumentLoadGroup();
|
2009-02-19 18:49:00 -08:00
|
|
|
|
2009-11-05 23:34:00 -08:00
|
|
|
/**
|
2011-09-29 16:34:37 -07:00
|
|
|
* Returns true if the media has played or completed a seek.
|
2009-06-26 00:25:17 -07:00
|
|
|
* Used by video frame to determine whether to paint the poster.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetPlayedOrSeeked() const { return mHasPlayedOrSeeked; }
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2013-03-19 05:23:54 -07:00
|
|
|
nsresult CopyInnerTo(Element* aDest);
|
2010-07-28 21:58:07 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Accept header on the HTTP channel to the required
|
|
|
|
* video or audio MIME types.
|
|
|
|
*/
|
|
|
|
virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel) = 0;
|
|
|
|
|
2010-09-16 10:36:23 -07:00
|
|
|
/**
|
|
|
|
* Sets the required request headers on the HTTP channel for
|
|
|
|
* video or audio requests.
|
|
|
|
*/
|
|
|
|
void SetRequestHeaders(nsIHttpChannel* aChannel);
|
|
|
|
|
2013-06-27 18:05:03 -07:00
|
|
|
/**
|
|
|
|
* Asynchronously awaits a stable state, whereupon aRunnable runs on the main
|
|
|
|
* thread. This adds an event which run aRunnable to the appshell's list of
|
|
|
|
* sections synchronous the next time control returns to the event loop.
|
|
|
|
*/
|
|
|
|
void RunInStableState(nsIRunnable* aRunnable);
|
|
|
|
|
2010-11-24 10:34:57 -08:00
|
|
|
/**
|
2011-09-29 16:34:37 -07:00
|
|
|
* Fires a timeupdate event. If aPeriodic is true, the event will only
|
2010-11-24 10:34:57 -08:00
|
|
|
* be fired if we've not fired a timeupdate event (for any reason) in the
|
|
|
|
* last 250ms, as required by the spec when the current time is periodically
|
|
|
|
* increasing during playback.
|
|
|
|
*/
|
2012-11-08 21:52:53 -08:00
|
|
|
virtual void FireTimeUpdate(bool aPeriodic) MOZ_FINAL MOZ_OVERRIDE;
|
2010-11-24 10:34:57 -08:00
|
|
|
|
2013-03-19 05:25:19 -07:00
|
|
|
MediaStream* GetSrcMediaStream() const
|
2012-04-29 20:12:28 -07:00
|
|
|
{
|
2012-08-19 21:52:59 -07:00
|
|
|
NS_ASSERTION(mSrcStream, "Don't call this when not playing a stream");
|
|
|
|
return mSrcStream->GetStream();
|
2012-04-29 20:12:28 -07:00
|
|
|
}
|
|
|
|
|
2013-03-19 05:25:19 -07:00
|
|
|
// WebIDL
|
|
|
|
|
|
|
|
MediaError* GetError() const
|
|
|
|
{
|
|
|
|
return mError;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XPCOM GetSrc() is OK
|
|
|
|
void SetSrc(const nsAString& aSrc, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::src, aSrc, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
// XPCOM GetCurrentSrc() is OK
|
|
|
|
|
2014-09-05 19:42:33 -07:00
|
|
|
void GetCrossOrigin(nsAString& aResult)
|
2013-03-19 05:25:19 -07:00
|
|
|
{
|
2014-09-05 19:42:33 -07:00
|
|
|
// Null for both missing and invalid defaults is ok, since we
|
|
|
|
// always parse to an enum value, so we don't need an invalid
|
|
|
|
// default, and we _want_ the missing default to be null.
|
|
|
|
GetEnumAttr(nsGkAtoms::crossorigin, nullptr, aResult);
|
|
|
|
}
|
|
|
|
void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetOrRemoveNullableStringAttr(nsGkAtoms::crossorigin, aCrossOrigin, aError);
|
2013-03-19 05:25:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t NetworkState() const
|
|
|
|
{
|
|
|
|
return mNetworkState;
|
|
|
|
}
|
|
|
|
|
2013-11-19 19:08:10 -08:00
|
|
|
// Called by the media decoder object, on the main thread,
|
|
|
|
// when the connection between Rtsp server and client gets lost.
|
|
|
|
void ResetConnectionState() MOZ_FINAL MOZ_OVERRIDE;
|
|
|
|
|
2013-03-19 05:25:19 -07:00
|
|
|
// XPCOM GetPreload() is OK
|
|
|
|
void SetPreload(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::preload, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<TimeRanges> Buffered() const;
|
|
|
|
|
|
|
|
// XPCOM Load() is OK
|
|
|
|
|
|
|
|
// XPCOM CanPlayType() is OK
|
|
|
|
|
|
|
|
uint16_t ReadyState() const
|
|
|
|
{
|
|
|
|
return mReadyState;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Seeking() const;
|
|
|
|
|
|
|
|
double CurrentTime() const;
|
|
|
|
|
|
|
|
void SetCurrentTime(double aCurrentTime, ErrorResult& aRv);
|
|
|
|
|
2014-03-31 20:39:04 -07:00
|
|
|
void FastSeek(double aTime, ErrorResult& aRv);
|
|
|
|
|
2013-03-19 05:25:19 -07:00
|
|
|
double Duration() const;
|
|
|
|
|
|
|
|
bool Paused() const
|
|
|
|
{
|
|
|
|
return mPaused;
|
|
|
|
}
|
|
|
|
|
|
|
|
double DefaultPlaybackRate() const
|
|
|
|
{
|
|
|
|
return mDefaultPlaybackRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDefaultPlaybackRate(double aDefaultPlaybackRate, ErrorResult& aRv);
|
|
|
|
|
|
|
|
double PlaybackRate() const
|
|
|
|
{
|
|
|
|
return mPlaybackRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPlaybackRate(double aPlaybackRate, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<TimeRanges> Played();
|
|
|
|
|
|
|
|
already_AddRefed<TimeRanges> Seekable() const;
|
|
|
|
|
|
|
|
bool Ended();
|
|
|
|
|
|
|
|
bool Autoplay() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::autoplay);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetAutoplay(bool aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::autoplay, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Loop() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetLoop(bool aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::loop, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Play(ErrorResult& aRv);
|
|
|
|
|
|
|
|
void Pause(ErrorResult& aRv);
|
|
|
|
|
|
|
|
bool Controls() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::controls);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetControls(bool aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::controls, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
double Volume() const
|
|
|
|
{
|
|
|
|
return mVolume;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetVolume(double aVolume, ErrorResult& aRv);
|
|
|
|
|
|
|
|
bool Muted() const
|
|
|
|
{
|
2013-05-21 10:49:17 -07:00
|
|
|
return mMuted & MUTED_BY_CONTENT;
|
2013-03-19 05:25:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// XPCOM SetMuted() is OK
|
|
|
|
|
|
|
|
bool DefaultMuted() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::muted);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDefaultMuted(bool aMuted, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::muted, aMuted, aRv);
|
|
|
|
}
|
|
|
|
|
2014-06-06 09:33:50 -07:00
|
|
|
bool MozMediaStatisticsShowing() const
|
|
|
|
{
|
|
|
|
return mStatsShowing;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMozMediaStatisticsShowing(bool aShow)
|
|
|
|
{
|
|
|
|
mStatsShowing = aShow;
|
|
|
|
}
|
|
|
|
|
2014-06-14 14:01:55 -07:00
|
|
|
bool MozAllowCasting() const
|
|
|
|
{
|
|
|
|
return mAllowCasting;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMozAllowCasting(bool aShow)
|
|
|
|
{
|
|
|
|
mAllowCasting = aShow;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MozIsCasting() const
|
|
|
|
{
|
|
|
|
return mIsCasting;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMozIsCasting(bool aShow)
|
|
|
|
{
|
|
|
|
mIsCasting = aShow;
|
|
|
|
}
|
|
|
|
|
2013-03-19 05:25:19 -07:00
|
|
|
already_AddRefed<DOMMediaStream> GetMozSrcObject() const;
|
|
|
|
|
|
|
|
void SetMozSrcObject(DOMMediaStream& aValue);
|
2014-10-03 01:18:00 -07:00
|
|
|
void SetMozSrcObject(DOMMediaStream* aValue);
|
2013-03-19 05:25:19 -07:00
|
|
|
|
|
|
|
bool MozPreservesPitch() const
|
|
|
|
{
|
|
|
|
return mPreservesPitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XPCOM MozPreservesPitch() is OK
|
|
|
|
|
2014-07-16 13:54:00 -07:00
|
|
|
#ifdef MOZ_EME
|
2014-06-06 13:52:15 -07:00
|
|
|
MediaKeys* GetMediaKeys() const;
|
|
|
|
|
|
|
|
already_AddRefed<Promise> SetMediaKeys(MediaKeys* mediaKeys,
|
|
|
|
ErrorResult& aRv);
|
2014-09-24 00:25:00 -07:00
|
|
|
|
2014-06-06 13:52:15 -07:00
|
|
|
MediaWaitingFor WaitingFor() const;
|
|
|
|
|
2014-08-27 01:46:56 -07:00
|
|
|
mozilla::dom::EventHandlerNonNull* GetOnencrypted();
|
|
|
|
void SetOnencrypted(mozilla::dom::EventHandlerNonNull* listener);
|
2014-06-06 13:52:15 -07:00
|
|
|
|
2014-08-27 01:46:56 -07:00
|
|
|
void DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
|
|
|
|
const nsAString& aInitDataType);
|
2014-06-06 13:52:15 -07:00
|
|
|
|
|
|
|
|
|
|
|
bool IsEventAttributeName(nsIAtom* aName) MOZ_OVERRIDE;
|
2014-10-12 15:53:43 -07:00
|
|
|
|
|
|
|
// Returns the principal of the "top level" document; the origin displayed
|
|
|
|
// in the URL bar of the browser window.
|
|
|
|
already_AddRefed<nsIPrincipal> GetTopLevelPrincipal();
|
|
|
|
|
2014-10-27 17:21:12 -07:00
|
|
|
bool ContainsRestrictedContent();
|
2014-07-16 13:54:00 -07:00
|
|
|
#endif // MOZ_EME
|
2014-06-06 13:52:15 -07:00
|
|
|
|
2013-03-19 05:25:19 -07:00
|
|
|
bool MozAutoplayEnabled() const
|
|
|
|
{
|
|
|
|
return mAutoplayEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DOMMediaStream> MozCaptureStream(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMMediaStream> MozCaptureStreamUntilEnded(ErrorResult& aRv);
|
|
|
|
|
|
|
|
bool MozAudioCaptured() const
|
|
|
|
{
|
|
|
|
return mAudioCaptured;
|
|
|
|
}
|
|
|
|
|
2014-06-11 13:26:52 -07:00
|
|
|
void MozGetMetadata(JSContext* aCx, JS::MutableHandle<JSObject*> aResult,
|
|
|
|
ErrorResult& aRv);
|
2013-03-19 05:25:19 -07:00
|
|
|
|
|
|
|
double MozFragmentEnd();
|
|
|
|
|
2014-04-10 10:39:20 -07:00
|
|
|
AudioChannel MozAudioChannelType() const
|
|
|
|
{
|
|
|
|
return mAudioChannel;
|
|
|
|
}
|
|
|
|
|
2013-10-28 17:08:14 -07:00
|
|
|
void SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv);
|
2013-03-19 05:25:19 -07:00
|
|
|
|
2014-05-23 02:34:14 -07:00
|
|
|
AudioTrackList* AudioTracks();
|
|
|
|
|
|
|
|
VideoTrackList* VideoTracks();
|
|
|
|
|
2014-03-24 08:48:37 -07:00
|
|
|
TextTrackList* TextTracks();
|
2013-05-21 09:14:00 -07:00
|
|
|
|
|
|
|
already_AddRefed<TextTrack> AddTextTrack(TextTrackKind aKind,
|
|
|
|
const nsAString& aLabel,
|
|
|
|
const nsAString& aLanguage);
|
|
|
|
|
|
|
|
void AddTextTrack(TextTrack* aTextTrack) {
|
2014-03-24 08:48:37 -07:00
|
|
|
GetOrCreateTextTrackManager()->AddTextTrack(aTextTrack);
|
2013-05-21 09:14:00 -07:00
|
|
|
}
|
|
|
|
|
2013-10-24 21:14:36 -07:00
|
|
|
void RemoveTextTrack(TextTrack* aTextTrack, bool aPendingListOnly = false) {
|
2013-10-23 11:45:00 -07:00
|
|
|
if (mTextTrackManager) {
|
2013-10-24 21:14:36 -07:00
|
|
|
mTextTrackManager->RemoveTextTrack(aTextTrack, aPendingListOnly);
|
2013-06-24 08:35:58 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-06 10:03:50 -08:00
|
|
|
void AddCue(TextTrackCue& aCue) {
|
|
|
|
if (mTextTrackManager) {
|
|
|
|
mTextTrackManager->AddCue(aCue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-23 02:53:36 -07:00
|
|
|
/**
|
|
|
|
* A public wrapper for FinishDecoderSetup()
|
|
|
|
*/
|
|
|
|
nsresult FinishDecoderSetup(MediaDecoder* aDecoder, MediaResource* aStream) {
|
|
|
|
return FinishDecoderSetup(aDecoder, aStream, nullptr, nullptr);
|
|
|
|
}
|
|
|
|
|
2008-07-29 21:55:27 -07:00
|
|
|
protected:
|
2014-07-08 14:23:16 -07:00
|
|
|
virtual ~HTMLMediaElement();
|
|
|
|
|
2009-02-19 18:49:00 -08:00
|
|
|
class MediaLoadListener;
|
2012-04-29 20:12:28 -07:00
|
|
|
class StreamListener;
|
2008-12-15 19:32:03 -08:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void GetItemValueText(nsAString& text) MOZ_OVERRIDE;
|
|
|
|
virtual void SetItemValueText(const nsAString& text) MOZ_OVERRIDE;
|
2012-10-28 19:09:07 -07:00
|
|
|
|
2012-11-01 05:47:51 -07:00
|
|
|
class WakeLockBoolWrapper {
|
|
|
|
public:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit WakeLockBoolWrapper(bool val = false)
|
2013-05-02 09:45:35 -07:00
|
|
|
: mValue(val), mCanPlay(true), mOuter(nullptr) {}
|
|
|
|
|
2013-05-28 10:30:17 -07:00
|
|
|
~WakeLockBoolWrapper();
|
|
|
|
|
2013-05-02 09:44:49 -07:00
|
|
|
void SetOuter(HTMLMediaElement* outer) { mOuter = outer; }
|
2013-05-02 09:45:35 -07:00
|
|
|
void SetCanPlay(bool aCanPlay);
|
|
|
|
|
2013-05-02 09:44:49 -07:00
|
|
|
operator bool() const { return mValue; }
|
2013-05-02 09:45:35 -07:00
|
|
|
|
2012-11-01 05:47:51 -07:00
|
|
|
WakeLockBoolWrapper& operator=(bool val);
|
2013-05-02 09:45:35 -07:00
|
|
|
|
2012-11-01 05:47:51 -07:00
|
|
|
bool operator !() const { return !mValue; }
|
2013-05-02 09:45:35 -07:00
|
|
|
|
2013-05-28 10:30:17 -07:00
|
|
|
static void TimerCallback(nsITimer* aTimer, void* aClosure);
|
|
|
|
|
2012-11-01 05:47:51 -07:00
|
|
|
private:
|
2013-05-02 09:45:35 -07:00
|
|
|
void UpdateWakeLock();
|
|
|
|
|
2012-11-01 05:47:51 -07:00
|
|
|
bool mValue;
|
2013-05-02 09:45:35 -07:00
|
|
|
bool mCanPlay;
|
2013-05-02 09:44:49 -07:00
|
|
|
HTMLMediaElement* mOuter;
|
2013-05-28 10:30:17 -07:00
|
|
|
nsCOMPtr<nsITimer> mTimer;
|
2012-11-01 05:47:51 -07:00
|
|
|
};
|
|
|
|
|
2014-09-24 00:25:00 -07:00
|
|
|
/** Use this method to change the mReadyState member, so required
|
|
|
|
* events can be fired.
|
|
|
|
*/
|
|
|
|
void ChangeReadyState(nsMediaReadyState aState);
|
|
|
|
|
2014-09-24 00:26:00 -07:00
|
|
|
/**
|
|
|
|
* Use this method to change the mNetworkState member, so required
|
|
|
|
* actions will be taken during the transition.
|
|
|
|
*/
|
|
|
|
void ChangeNetworkState(nsMediaNetworkState aState);
|
|
|
|
|
2013-05-10 05:42:39 -07:00
|
|
|
/**
|
|
|
|
* These two methods are called by the WakeLockBoolWrapper when the wakelock
|
|
|
|
* has to be created or released.
|
|
|
|
*/
|
|
|
|
virtual void WakeLockCreate();
|
|
|
|
virtual void WakeLockRelease();
|
2014-01-07 04:16:07 -08:00
|
|
|
nsRefPtr<WakeLock> mWakeLock;
|
2013-05-10 05:42:39 -07:00
|
|
|
|
2011-12-21 15:33:39 -08:00
|
|
|
/**
|
|
|
|
* Logs a warning message to the web console to report various failures.
|
|
|
|
* aMsg is the localized message identifier, aParams is the parameters to
|
|
|
|
* be substituted into the localized message, and aParamCount is the number
|
|
|
|
* of parameters in aParams.
|
|
|
|
*/
|
|
|
|
void ReportLoadError(const char* aMsg,
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t** aParams = nullptr,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aParamCount = 0);
|
2011-12-21 15:33:39 -08:00
|
|
|
|
2009-06-26 00:25:17 -07:00
|
|
|
/**
|
|
|
|
* Changes mHasPlayedOrSeeked to aValue. If mHasPlayedOrSeeked changes
|
|
|
|
* we'll force a reflow so that the video frame gets reflowed to reflect
|
|
|
|
* the poster hiding or showing immediately.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetPlayedOrSeeked(bool aValue);
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2012-04-29 20:12:28 -07:00
|
|
|
/**
|
2012-09-24 20:25:43 -07:00
|
|
|
* Initialize the media element for playback of aStream
|
2012-04-29 20:12:28 -07:00
|
|
|
*/
|
2013-02-15 00:01:58 -08:00
|
|
|
void SetupSrcMediaStreamPlayback(DOMMediaStream* aStream);
|
2012-04-29 20:12:28 -07:00
|
|
|
/**
|
2012-08-19 21:52:59 -07:00
|
|
|
* Stop playback on mSrcStream.
|
2012-04-29 20:12:28 -07:00
|
|
|
*/
|
2012-08-19 21:52:59 -07:00
|
|
|
void EndSrcMediaStreamPlayback();
|
2012-04-29 20:12:28 -07:00
|
|
|
|
2012-04-29 20:12:42 -07:00
|
|
|
/**
|
|
|
|
* Returns an nsDOMMediaStream containing the played contents of this
|
|
|
|
* element. When aFinishWhenEnded is true, when this element ends playback
|
|
|
|
* we will finish the stream and not play any more into it.
|
|
|
|
* When aFinishWhenEnded is false, ending playback does not finish the stream.
|
|
|
|
* The stream will never finish.
|
|
|
|
*/
|
2013-02-15 00:01:58 -08:00
|
|
|
already_AddRefed<DOMMediaStream> CaptureStreamInternal(bool aFinishWhenEnded);
|
2012-04-29 20:12:42 -07:00
|
|
|
|
2009-09-14 19:30:44 -07:00
|
|
|
/**
|
|
|
|
* Initialize a decoder as a clone of an existing decoder in another
|
|
|
|
* element.
|
2011-11-24 18:06:22 -08:00
|
|
|
* mLoadingSrc must already be set.
|
2009-09-14 19:30:44 -07:00
|
|
|
*/
|
2012-11-14 11:46:40 -08:00
|
|
|
nsresult InitializeDecoderAsClone(MediaDecoder* aOriginal);
|
2009-09-14 19:30:44 -07:00
|
|
|
|
2008-10-29 22:20:08 -07:00
|
|
|
/**
|
|
|
|
* Initialize a decoder to load the given channel. The decoder's stream
|
|
|
|
* listener is returned via aListener.
|
2011-11-24 18:06:22 -08:00
|
|
|
* mLoadingSrc must already be set.
|
2008-10-29 22:20:08 -07:00
|
|
|
*/
|
|
|
|
nsresult InitializeDecoderForChannel(nsIChannel *aChannel,
|
|
|
|
nsIStreamListener **aListener);
|
2009-03-08 13:59:08 -07:00
|
|
|
|
2009-09-14 19:30:44 -07:00
|
|
|
/**
|
|
|
|
* Finish setting up the decoder after Load() has been called on it.
|
2011-11-24 18:06:22 -08:00
|
|
|
* Called by InitializeDecoderForChannel/InitializeDecoderAsClone.
|
2009-09-14 19:30:44 -07:00
|
|
|
*/
|
2012-11-14 11:46:40 -08:00
|
|
|
nsresult FinishDecoderSetup(MediaDecoder* aDecoder,
|
2012-04-29 20:12:28 -07:00
|
|
|
MediaResource* aStream,
|
|
|
|
nsIStreamListener **aListener,
|
2012-11-14 11:46:40 -08:00
|
|
|
MediaDecoder* aCloneDonor);
|
2009-09-14 19:30:44 -07:00
|
|
|
|
2011-11-24 18:06:22 -08:00
|
|
|
/**
|
|
|
|
* Call this after setting up mLoadingSrc and mDecoder.
|
|
|
|
*/
|
|
|
|
void AddMediaElementToURITable();
|
|
|
|
/**
|
|
|
|
* Call this before clearing mLoadingSrc.
|
|
|
|
*/
|
|
|
|
void RemoveMediaElementFromURITable();
|
|
|
|
/**
|
|
|
|
* Call this to find a media element with the same NodePrincipal and mLoadingSrc
|
|
|
|
* set to aURI, and with a decoder on which Load() has been called.
|
|
|
|
*/
|
2013-03-19 05:23:54 -07:00
|
|
|
HTMLMediaElement* LookupMediaElementURITable(nsIURI* aURI);
|
2011-11-24 18:06:22 -08:00
|
|
|
|
2012-04-29 20:13:09 -07:00
|
|
|
/**
|
|
|
|
* Shutdown and clear mDecoder and maintain associated invariants.
|
|
|
|
*/
|
|
|
|
void ShutdownDecoder();
|
2008-12-15 19:32:03 -08:00
|
|
|
/**
|
|
|
|
* Execute the initial steps of the load algorithm that ensure existing
|
2009-03-08 13:59:08 -07:00
|
|
|
* loads are aborted, the element is emptied, and a new load ID is
|
|
|
|
* created.
|
2008-12-15 19:32:03 -08:00
|
|
|
*/
|
2009-03-08 13:59:08 -07:00
|
|
|
void AbortExistingLoads();
|
2009-02-19 18:49:00 -08:00
|
|
|
|
2009-02-15 08:26:32 -08:00
|
|
|
/**
|
2009-09-21 17:08:13 -07:00
|
|
|
* Called when all potential resources are exhausted. Changes network
|
2009-03-08 13:59:08 -07:00
|
|
|
* state to NETWORK_NO_SOURCE, and sends error event with code
|
2009-09-21 17:08:13 -07:00
|
|
|
* MEDIA_ERR_SRC_NOT_SUPPORTED.
|
2009-02-15 08:26:32 -08:00
|
|
|
*/
|
2009-09-21 17:08:13 -07:00
|
|
|
void NoSupportedMediaSourceError();
|
2009-02-15 08:26:32 -08:00
|
|
|
|
2009-03-08 13:59:08 -07:00
|
|
|
/**
|
|
|
|
* Attempts to load resources from the <source> children. This is a
|
2010-09-02 17:03:03 -07:00
|
|
|
* substep of the resource selection algorithm. Do not call this directly,
|
2009-03-08 13:59:08 -07:00
|
|
|
* call QueueLoadFromSourceTask() instead.
|
|
|
|
*/
|
|
|
|
void LoadFromSourceChildren();
|
2009-02-19 18:49:00 -08:00
|
|
|
|
2009-03-08 13:59:08 -07:00
|
|
|
/**
|
2010-09-02 17:03:03 -07:00
|
|
|
* Asynchronously awaits a stable state, and then causes
|
|
|
|
* LoadFromSourceChildren() to be called on the main threads' event loop.
|
2009-03-08 13:59:08 -07:00
|
|
|
*/
|
|
|
|
void QueueLoadFromSourceTask();
|
2009-11-05 23:34:00 -08:00
|
|
|
|
2009-03-08 13:59:08 -07:00
|
|
|
/**
|
2010-09-02 17:03:03 -07:00
|
|
|
* Runs the media resource selection algorithm.
|
2009-03-08 13:59:08 -07:00
|
|
|
*/
|
|
|
|
void SelectResource();
|
2009-02-19 18:49:00 -08:00
|
|
|
|
2012-02-19 13:02:08 -08:00
|
|
|
/**
|
|
|
|
* A wrapper function that allows us to cleanly reset flags after a call
|
|
|
|
* to SelectResource()
|
|
|
|
*/
|
|
|
|
void SelectResourceWrapper();
|
|
|
|
|
2009-03-08 13:59:08 -07:00
|
|
|
/**
|
2010-09-02 17:03:03 -07:00
|
|
|
* Asynchronously awaits a stable state, and then causes SelectResource()
|
|
|
|
* to be run on the main thread's event loop.
|
2009-03-08 13:59:08 -07:00
|
|
|
*/
|
|
|
|
void QueueSelectResourceTask();
|
2009-02-19 18:49:00 -08:00
|
|
|
|
2012-12-27 07:21:30 -08:00
|
|
|
/**
|
|
|
|
* When loading a new source on an existing media element, make sure to reset
|
|
|
|
* everything that is accessible using the media element API.
|
|
|
|
*/
|
|
|
|
void ResetState();
|
|
|
|
|
2009-03-08 13:59:08 -07:00
|
|
|
/**
|
|
|
|
* The resource-fetch algorithm step of the load algorithm.
|
|
|
|
*/
|
2011-11-24 18:06:22 -08:00
|
|
|
nsresult LoadResource();
|
2009-03-08 13:59:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects the next <source> child from which to load a resource. Called
|
2010-09-02 17:03:03 -07:00
|
|
|
* during the resource selection algorithm. Stores the return value in
|
|
|
|
* mSourceLoadCandidate before returning.
|
2009-03-08 13:59:08 -07:00
|
|
|
*/
|
2010-09-02 17:03:03 -07:00
|
|
|
nsIContent* GetNextSource();
|
2009-02-19 18:49:00 -08:00
|
|
|
|
2009-03-08 14:01:03 -07:00
|
|
|
/**
|
|
|
|
* Changes mDelayingLoadEvent, and will call BlockOnLoad()/UnblockOnLoad()
|
|
|
|
* on the owning document, so it can delay the load event firing.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void ChangeDelayLoadStatus(bool aDelay);
|
2009-03-08 14:01:03 -07:00
|
|
|
|
2009-05-17 19:00:44 -07:00
|
|
|
/**
|
|
|
|
* If we suspended downloading after the first frame, unsuspend now.
|
|
|
|
*/
|
|
|
|
void StopSuspendingAfterFirstFrame();
|
|
|
|
|
2009-05-17 15:20:37 -07:00
|
|
|
/**
|
|
|
|
* Called when our channel is redirected to another channel.
|
|
|
|
* Updates our mChannel reference to aNewChannel.
|
|
|
|
*/
|
|
|
|
nsresult OnChannelRedirect(nsIChannel *aChannel,
|
|
|
|
nsIChannel *aNewChannel,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags);
|
2009-05-17 15:20:37 -07:00
|
|
|
|
2009-10-01 07:10:13 -07:00
|
|
|
/**
|
|
|
|
* Call this to reevaluate whether we should be holding a self-reference.
|
|
|
|
*/
|
|
|
|
void AddRemoveSelfReference();
|
|
|
|
|
|
|
|
/**
|
2010-02-24 11:14:14 -08:00
|
|
|
* Called asynchronously to release a self-reference to this element.
|
2009-10-01 07:10:13 -07:00
|
|
|
*/
|
2010-02-24 11:14:14 -08:00
|
|
|
void DoRemoveSelfReference();
|
2012-11-15 19:25:26 -08:00
|
|
|
|
2010-08-19 15:50:37 -07:00
|
|
|
/**
|
|
|
|
* Possible values of the 'preload' attribute.
|
|
|
|
*/
|
|
|
|
enum PreloadAttrValue {
|
|
|
|
PRELOAD_ATTR_EMPTY, // set to ""
|
|
|
|
PRELOAD_ATTR_NONE, // set to "none"
|
|
|
|
PRELOAD_ATTR_METADATA, // set to "metadata"
|
|
|
|
PRELOAD_ATTR_AUTO // set to "auto"
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-11-15 19:25:26 -08:00
|
|
|
* The preloading action to perform. These dictate how we react to the
|
2010-08-19 15:50:37 -07:00
|
|
|
* preload attribute. See mPreloadAction.
|
|
|
|
*/
|
|
|
|
enum PreloadAction {
|
|
|
|
PRELOAD_UNDEFINED = 0, // not determined - used only for initialization
|
|
|
|
PRELOAD_NONE = 1, // do not preload
|
|
|
|
PRELOAD_METADATA = 2, // preload only the metadata (and first frame)
|
|
|
|
PRELOAD_ENOUGH = 3 // preload enough data to allow uninterrupted
|
|
|
|
// playback
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2011-11-24 18:06:22 -08:00
|
|
|
* Suspends the load of mLoadingSrc, so that it can be resumed later
|
2010-08-19 15:50:37 -07:00
|
|
|
* by ResumeLoad(). This is called when we have a media with a 'preload'
|
|
|
|
* attribute value of 'none', during the resource selection algorithm.
|
|
|
|
*/
|
2011-11-24 18:06:22 -08:00
|
|
|
void SuspendLoad();
|
2010-08-19 15:50:37 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Resumes a previously suspended load (suspended by SuspendLoad(uri)).
|
|
|
|
* Will continue running the resource selection algorithm.
|
|
|
|
* Sets mPreloadAction to aAction.
|
|
|
|
*/
|
|
|
|
void ResumeLoad(PreloadAction aAction);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle a change to the preload attribute. Should be called whenever the
|
2012-11-15 19:25:26 -08:00
|
|
|
* value (or presence) of the preload attribute changes. The change in
|
2010-08-19 15:50:37 -07:00
|
|
|
* attribute value may cause a change in the mPreloadAction of this
|
|
|
|
* element. If there is a change then this method will initiate any
|
|
|
|
* behaviour that is necessary to implement the action.
|
|
|
|
*/
|
|
|
|
void UpdatePreloadAction();
|
2009-10-01 07:10:13 -07:00
|
|
|
|
2014-11-27 15:17:18 -08:00
|
|
|
/**
|
|
|
|
* Fire progress events if needed according to the time and byte constraints
|
|
|
|
* outlined in the specification. aHaveNewProgress is true if progress has
|
|
|
|
* just been detected. Otherwise the method is called as a result of the
|
|
|
|
* progress timer.
|
|
|
|
*/
|
|
|
|
void CheckProgress(bool aHaveNewProgress);
|
|
|
|
static void ProgressTimerCallback(nsITimer* aTimer, void* aClosure);
|
|
|
|
/**
|
|
|
|
* Start timer to update download progress.
|
|
|
|
*/
|
2014-11-27 20:07:15 -08:00
|
|
|
void StartProgressTimer();
|
2014-11-27 15:17:18 -08:00
|
|
|
/**
|
2014-11-27 20:07:15 -08:00
|
|
|
* Start sending progress and/or stalled events.
|
2014-11-27 15:17:18 -08:00
|
|
|
*/
|
2014-11-27 20:07:15 -08:00
|
|
|
void StartProgress();
|
|
|
|
/**
|
|
|
|
* Stop progress information timer and events.
|
|
|
|
*/
|
|
|
|
void StopProgress();
|
2014-11-27 15:17:18 -08:00
|
|
|
|
2010-09-02 17:03:03 -07:00
|
|
|
/**
|
|
|
|
* Dispatches an error event to a child source element.
|
|
|
|
*/
|
|
|
|
void DispatchAsyncSourceError(nsIContent* aSourceElement);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the media element for an error condition as per aErrorCode.
|
|
|
|
* aErrorCode must be one of nsIDOMHTMLMediaError codes.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void Error(uint16_t aErrorCode);
|
2010-09-02 17:03:03 -07:00
|
|
|
|
2011-08-24 16:42:23 -07:00
|
|
|
/**
|
|
|
|
* Returns the URL spec of the currentSrc.
|
|
|
|
**/
|
|
|
|
void GetCurrentSpec(nsCString& aString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process any media fragment entries in the URI
|
|
|
|
*/
|
|
|
|
void ProcessMediaFragmentURI();
|
|
|
|
|
2012-11-22 02:38:28 -08:00
|
|
|
/**
|
2013-05-21 10:49:17 -07:00
|
|
|
* Mute or unmute the audio and change the value that the |muted| map.
|
2012-11-22 02:38:28 -08:00
|
|
|
*/
|
2013-05-21 10:49:17 -07:00
|
|
|
void SetMutedInternal(uint32_t aMuted);
|
2013-05-26 22:13:05 -07:00
|
|
|
/**
|
|
|
|
* Update the volume of the output audio stream to match the element's
|
2013-09-02 02:45:44 -07:00
|
|
|
* current mMuted/mVolume/mAudioChannelFaded state.
|
2013-05-26 22:13:05 -07:00
|
|
|
*/
|
|
|
|
void SetVolumeInternal();
|
2012-11-22 02:38:28 -08:00
|
|
|
|
2012-12-11 17:58:07 -08:00
|
|
|
/**
|
|
|
|
* Suspend (if aPauseForInactiveDocument) or resume element playback and
|
|
|
|
* resource download. If aSuspendEvents is true, event delivery is
|
|
|
|
* suspended (and events queued) until the element is resumed.
|
|
|
|
*/
|
|
|
|
void SuspendOrResumeElement(bool aPauseElement, bool aSuspendEvents);
|
|
|
|
|
2013-03-19 05:23:54 -07:00
|
|
|
// Get the HTMLMediaElement object if the decoder is being used from an
|
2012-11-08 21:52:53 -08:00
|
|
|
// HTML media element, and null otherwise.
|
2013-03-19 05:23:54 -07:00
|
|
|
virtual HTMLMediaElement* GetMediaElement() MOZ_FINAL MOZ_OVERRIDE
|
2012-11-08 21:52:53 -08:00
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return true if decoding should be paused
|
|
|
|
virtual bool GetPaused() MOZ_FINAL MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
bool isPaused = false;
|
|
|
|
GetPaused(&isPaused);
|
|
|
|
return isPaused;
|
|
|
|
}
|
|
|
|
|
2012-12-04 11:46:07 -08:00
|
|
|
// Check the permissions for audiochannel.
|
|
|
|
bool CheckAudioChannelPermissions(const nsAString& aType);
|
|
|
|
|
2013-09-02 02:45:44 -07:00
|
|
|
// This method does the check for muting/fading/unmuting the audio channel.
|
|
|
|
nsresult UpdateChannelMuteState(mozilla::dom::AudioChannelState aCanPlay);
|
2012-12-04 11:46:07 -08:00
|
|
|
|
2014-03-31 20:39:04 -07:00
|
|
|
// Seeks to aTime seconds. aSeekType can be Exact to seek to exactly the
|
|
|
|
// seek target, or PrevSyncPoint if a quicker but less precise seek is
|
|
|
|
// desired, and we'll seek to the sync point (keyframe and/or start of the
|
|
|
|
// next block of audio samples) preceeding seek target.
|
|
|
|
void Seek(double aTime, SeekTarget::Type aSeekType, ErrorResult& aRv);
|
2014-09-24 00:25:00 -07:00
|
|
|
|
2012-12-04 11:46:07 -08:00
|
|
|
// Update the audio channel playing state
|
2014-04-02 14:53:39 -07:00
|
|
|
void UpdateAudioChannelPlayingState();
|
2012-12-04 11:46:07 -08:00
|
|
|
|
2013-10-24 21:14:36 -07:00
|
|
|
// Adds to the element's list of pending text tracks each text track
|
|
|
|
// in the element's list of text tracks whose text track mode is not disabled
|
|
|
|
// and whose text track readiness state is loading.
|
|
|
|
void PopulatePendingTextTrackList();
|
|
|
|
|
2014-03-24 08:48:37 -07:00
|
|
|
// Gets a reference to the MediaElement's TextTrackManager. If the
|
|
|
|
// MediaElement doesn't yet have one then it will create it.
|
|
|
|
TextTrackManager* GetOrCreateTextTrackManager();
|
|
|
|
|
2011-11-24 18:06:22 -08:00
|
|
|
// The current decoder. Load() has been called on this decoder.
|
2012-08-19 21:52:59 -07:00
|
|
|
// At most one of mDecoder and mSrcStream can be non-null.
|
2012-11-14 11:46:40 -08:00
|
|
|
nsRefPtr<MediaDecoder> mDecoder;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2012-02-14 20:35:01 -08:00
|
|
|
// A reference to the VideoFrameContainer which contains the current frame
|
2010-03-01 15:41:49 -08:00
|
|
|
// of video to display.
|
2012-02-14 20:35:01 -08:00
|
|
|
nsRefPtr<VideoFrameContainer> mVideoFrameContainer;
|
2010-03-01 15:41:49 -08:00
|
|
|
|
2012-04-29 20:12:28 -07:00
|
|
|
// Holds a reference to the DOM wrapper for the MediaStream that has been
|
|
|
|
// set in the src attribute.
|
2013-02-15 00:01:58 -08:00
|
|
|
nsRefPtr<DOMMediaStream> mSrcAttrStream;
|
2012-04-29 20:12:28 -07:00
|
|
|
|
|
|
|
// Holds a reference to the DOM wrapper for the MediaStream that we're
|
|
|
|
// actually playing.
|
2012-08-19 21:52:59 -07:00
|
|
|
// At most one of mDecoder and mSrcStream can be non-null.
|
2013-02-15 00:01:58 -08:00
|
|
|
nsRefPtr<DOMMediaStream> mSrcStream;
|
2012-04-29 20:12:28 -07:00
|
|
|
|
2012-04-29 20:12:42 -07:00
|
|
|
// Holds references to the DOM wrappers for the MediaStreams that we're
|
|
|
|
// writing to.
|
|
|
|
struct OutputMediaStream {
|
2013-02-15 00:01:58 -08:00
|
|
|
nsRefPtr<DOMMediaStream> mStream;
|
2012-04-29 20:12:42 -07:00
|
|
|
bool mFinishWhenEnded;
|
|
|
|
};
|
|
|
|
nsTArray<OutputMediaStream> mOutputStreams;
|
|
|
|
|
2012-08-26 16:33:56 -07:00
|
|
|
// Holds a reference to the MediaStreamListener attached to mSrcStream.
|
|
|
|
nsRefPtr<StreamListener> mSrcStreamListener;
|
2012-04-29 20:12:28 -07:00
|
|
|
|
2013-06-20 20:15:47 -07:00
|
|
|
// Holds a reference to the MediaSource supplying data for playback.
|
|
|
|
nsRefPtr<MediaSource> mMediaSource;
|
|
|
|
|
2009-04-09 18:28:24 -07:00
|
|
|
// Holds a reference to the first channel we open to the media resource.
|
|
|
|
// Once the decoder is created, control over the channel passes to the
|
|
|
|
// decoder, and we null out this reference. We must store this in case
|
|
|
|
// we need to cancel the channel before control of it passes to the decoder.
|
2008-12-15 19:32:03 -08:00
|
|
|
nsCOMPtr<nsIChannel> mChannel;
|
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
// Error attribute
|
2013-03-19 05:25:19 -07:00
|
|
|
nsRefPtr<MediaError> mError;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2009-03-08 13:59:08 -07:00
|
|
|
// The current media load ID. This is incremented every time we start a
|
|
|
|
// new load. Async events note the ID when they're first sent, and only fire
|
|
|
|
// if the ID is unchanged when they come to fire.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mCurrentLoadID;
|
2009-03-08 13:59:08 -07:00
|
|
|
|
|
|
|
// Points to the child source elements, used to iterate through the children
|
|
|
|
// when selecting a resource to load.
|
2013-06-06 21:26:55 -07:00
|
|
|
nsRefPtr<nsRange> mSourcePointer;
|
2009-02-15 17:05:28 -08:00
|
|
|
|
2009-03-08 14:01:03 -07:00
|
|
|
// Points to the document whose load we're blocking. This is the document
|
|
|
|
// we're bound to when loading starts.
|
|
|
|
nsCOMPtr<nsIDocument> mLoadBlockedDoc;
|
|
|
|
|
2010-09-09 21:20:10 -07:00
|
|
|
// Contains names of events that have been raised while in the bfcache.
|
|
|
|
// These events get re-dispatched when the bfcache is exited.
|
|
|
|
nsTArray<nsString> mPendingEvents;
|
|
|
|
|
2009-11-05 23:34:00 -08:00
|
|
|
// Media loading flags. See:
|
2008-07-09 01:22:20 -07:00
|
|
|
// http://www.whatwg.org/specs/web-apps/current-work/#video)
|
|
|
|
nsMediaNetworkState mNetworkState;
|
|
|
|
nsMediaReadyState mReadyState;
|
|
|
|
|
2009-03-08 13:59:08 -07:00
|
|
|
enum LoadAlgorithmState {
|
2010-09-02 17:03:03 -07:00
|
|
|
// No load algorithm instance is waiting for a source to be added to the
|
|
|
|
// media in order to continue loading.
|
2009-03-08 13:59:08 -07:00
|
|
|
NOT_WAITING,
|
2012-11-15 19:25:26 -08:00
|
|
|
// We've run the load algorithm, and we tried all source children of the
|
2010-09-02 17:03:03 -07:00
|
|
|
// media element, and failed to load any successfully. We're waiting for
|
|
|
|
// another source element to be added to the media element, and will try
|
|
|
|
// to load any such element when its added.
|
2009-11-05 23:34:00 -08:00
|
|
|
WAITING_FOR_SOURCE
|
2009-03-08 13:59:08 -07:00
|
|
|
};
|
2009-11-05 23:34:00 -08:00
|
|
|
|
2010-09-02 17:03:03 -07:00
|
|
|
// Denotes the waiting state of a load algorithm instance. When the load
|
|
|
|
// algorithm is waiting for a source element child to be added, this is set
|
|
|
|
// to WAITING_FOR_SOURCE, otherwise it's NOT_WAITING.
|
2009-03-08 13:59:08 -07:00
|
|
|
LoadAlgorithmState mLoadWaitStatus;
|
|
|
|
|
2009-02-25 02:59:00 -08:00
|
|
|
// Current audio volume
|
2011-01-16 19:03:00 -08:00
|
|
|
double mVolume;
|
2008-09-29 16:05:06 -07:00
|
|
|
|
2012-07-30 17:14:29 -07:00
|
|
|
// Helper function to iterate over a hash table
|
|
|
|
// and convert it to a JSObject.
|
|
|
|
static PLDHashOperator BuildObjectFromTags(nsCStringHashKey::KeyType aKey,
|
|
|
|
nsCString aValue,
|
|
|
|
void* aUserArg);
|
2012-11-28 14:08:53 -08:00
|
|
|
nsAutoPtr<const MetadataTags> mTags;
|
2012-07-30 17:14:29 -07:00
|
|
|
|
2011-11-24 18:06:22 -08:00
|
|
|
// URI of the resource we're attempting to load. This stores the value we
|
|
|
|
// return in the currentSrc attribute. Use GetCurrentSrc() to access the
|
|
|
|
// currentSrc attribute.
|
|
|
|
// This is always the original URL we're trying to load --- before
|
|
|
|
// redirects etc.
|
2010-09-02 17:03:03 -07:00
|
|
|
nsCOMPtr<nsIURI> mLoadingSrc;
|
2012-11-14 11:45:33 -08:00
|
|
|
|
2010-08-19 15:50:37 -07:00
|
|
|
// Stores the current preload action for this element. Initially set to
|
|
|
|
// PRELOAD_UNDEFINED, its value is changed by calling
|
|
|
|
// UpdatePreloadAction().
|
|
|
|
PreloadAction mPreloadAction;
|
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
// Size of the media. Updated by the decoder on the main thread if
|
2012-02-14 20:35:01 -08:00
|
|
|
// it changes. Defaults to a width and height of -1 if not set.
|
|
|
|
// We keep this separate from the intrinsic size stored in the
|
|
|
|
// VideoFrameContainer so that it doesn't change unexpectedly under us
|
|
|
|
// due to decoder activity.
|
2008-10-19 00:39:21 -07:00
|
|
|
nsIntSize mMediaSize;
|
|
|
|
|
2010-11-24 10:34:57 -08:00
|
|
|
// Time that the last timeupdate event was fired. Read/Write from the
|
|
|
|
// main thread only.
|
|
|
|
TimeStamp mTimeUpdateTime;
|
|
|
|
|
2014-11-27 15:17:18 -08:00
|
|
|
// Time that the last progress event was fired. Read/Write from the
|
|
|
|
// main thread only.
|
|
|
|
TimeStamp mProgressTime;
|
|
|
|
|
|
|
|
// Time that data was last read from the media resource. Used for
|
|
|
|
// computing if the download has stalled and to rate limit progress events
|
2014-11-27 20:07:15 -08:00
|
|
|
// when data is arriving slower than PROGRESS_MS.
|
|
|
|
// Read/Write from the main thread only.
|
2014-11-27 15:17:18 -08:00
|
|
|
TimeStamp mDataTime;
|
|
|
|
|
2010-11-24 10:34:57 -08:00
|
|
|
// Media 'currentTime' value when the last timeupdate event occurred.
|
|
|
|
// Read/Write from the main thread only.
|
2011-01-16 19:03:00 -08:00
|
|
|
double mLastCurrentTime;
|
2010-11-24 10:34:57 -08:00
|
|
|
|
2011-08-24 16:42:23 -07:00
|
|
|
// Logical start time of the media resource in seconds as obtained
|
|
|
|
// from any media fragments. A negative value indicates that no
|
|
|
|
// fragment time has been set. Read/Write from the main thread only.
|
|
|
|
double mFragmentStart;
|
|
|
|
|
|
|
|
// Logical end time of the media resource in seconds as obtained
|
|
|
|
// from any media fragments. A negative value indicates that no
|
|
|
|
// fragment time has been set. Read/Write from the main thread only.
|
|
|
|
double mFragmentEnd;
|
|
|
|
|
2012-11-22 02:38:28 -08:00
|
|
|
// The defaultPlaybackRate attribute gives the desired speed at which the
|
|
|
|
// media resource is to play, as a multiple of its intrinsic speed.
|
|
|
|
double mDefaultPlaybackRate;
|
|
|
|
|
|
|
|
// The playbackRate attribute gives the speed at which the media resource
|
|
|
|
// plays, as a multiple of its intrinsic speed. If it is not equal to the
|
|
|
|
// defaultPlaybackRate, then the implication is that the user is using a
|
|
|
|
// feature such as fast forward or slow motion playback.
|
|
|
|
double mPlaybackRate;
|
|
|
|
|
|
|
|
// True if pitch correction is applied when playbackRate is set to a
|
|
|
|
// non-intrinsic value.
|
|
|
|
bool mPreservesPitch;
|
|
|
|
|
2010-09-02 17:03:03 -07:00
|
|
|
// Reference to the source element last returned by GetNextSource().
|
|
|
|
// This is the child source element which we're trying to load from.
|
|
|
|
nsCOMPtr<nsIContent> mSourceLoadCandidate;
|
|
|
|
|
2012-04-30 17:29:24 -07:00
|
|
|
// Range of time played.
|
2013-04-22 16:45:00 -07:00
|
|
|
nsRefPtr<TimeRanges> mPlayed;
|
2012-04-30 17:29:24 -07:00
|
|
|
|
2014-11-27 15:17:18 -08:00
|
|
|
// Timer used for updating progress events
|
|
|
|
nsCOMPtr<nsITimer> mProgressTimer;
|
|
|
|
|
2014-07-16 13:54:00 -07:00
|
|
|
#ifdef MOZ_EME
|
2014-06-06 13:52:15 -07:00
|
|
|
// Encrypted Media Extension media keys.
|
|
|
|
nsRefPtr<MediaKeys> mMediaKeys;
|
2014-07-16 13:54:00 -07:00
|
|
|
#endif
|
2014-06-06 13:52:15 -07:00
|
|
|
|
2012-04-30 17:29:24 -07:00
|
|
|
// Stores the time at the start of the current 'played' range.
|
|
|
|
double mCurrentPlayRangeStart;
|
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
// If true then we have begun downloading the media content.
|
|
|
|
// Set to false when completed, or not yet started.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mBegun;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2014-09-24 00:25:00 -07:00
|
|
|
// True if loadeddata has been fired.
|
|
|
|
bool mLoadedDataFired;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
|
|
|
// Indicates whether current playback is a result of user action
|
|
|
|
// (ie. calling of the Play method), or automatic playback due to
|
2009-11-05 23:34:00 -08:00
|
|
|
// the 'autoplay' attribute being set. A true value indicates the
|
2008-07-09 01:22:20 -07:00
|
|
|
// latter case.
|
|
|
|
// The 'autoplay' HTML attribute indicates that the video should
|
|
|
|
// start playing when loaded. The 'autoplay' attribute of the object
|
|
|
|
// is a mirror of the HTML attribute. These are different from this
|
|
|
|
// 'mAutoplaying' flag, which indicates whether the current playback
|
|
|
|
// is a result of the autoplay attribute.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mAutoplaying;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2009-11-05 23:34:00 -08:00
|
|
|
// Indicates whether |autoplay| will actually autoplay based on the pref
|
2009-02-19 20:05:07 -08:00
|
|
|
// media.autoplay.enabled
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mAutoplayEnabled;
|
2009-02-19 20:05:07 -08:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
// Playback of the video is paused either due to calling the
|
|
|
|
// 'Pause' method, or playback not yet having started.
|
2012-11-01 05:47:51 -07:00
|
|
|
WakeLockBoolWrapper mPaused;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2013-05-21 10:49:17 -07:00
|
|
|
enum MutedReasons {
|
|
|
|
MUTED_BY_CONTENT = 0x01,
|
|
|
|
MUTED_BY_INVALID_PLAYBACK_RATE = 0x02,
|
2014-05-23 02:34:14 -07:00
|
|
|
MUTED_BY_AUDIO_CHANNEL = 0x04,
|
|
|
|
MUTED_BY_AUDIO_TRACK = 0x08
|
2013-05-21 10:49:17 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t mMuted;
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2014-06-06 09:33:50 -07:00
|
|
|
// True if the media statistics are currently being shown by the builtin
|
|
|
|
// video controls
|
|
|
|
bool mStatsShowing;
|
|
|
|
|
2014-06-14 14:01:55 -07:00
|
|
|
// The following two fields are here for the private storage of the builtin
|
|
|
|
// video controls, and control 'casting' of the video to external devices
|
|
|
|
// (TVs, projectors etc.)
|
|
|
|
// True if casting is currently allowed
|
|
|
|
bool mAllowCasting;
|
|
|
|
// True if currently casting this video
|
|
|
|
bool mIsCasting;
|
|
|
|
|
2012-04-29 20:12:42 -07:00
|
|
|
// True if the sound is being captured.
|
|
|
|
bool mAudioCaptured;
|
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
// If TRUE then the media element was actively playing before the currently
|
|
|
|
// in progress seeking. If FALSE then the media element is either not seeking
|
|
|
|
// or was not actively playing before the current seek. Used to decide whether
|
|
|
|
// to raise the 'waiting' event as per 4.7.1.8 in HTML 5 specification.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mPlayingBeforeSeek;
|
2008-10-28 11:48:39 -07:00
|
|
|
|
2014-08-28 01:07:00 -07:00
|
|
|
// if TRUE then the seek started while content was in active playing state
|
|
|
|
// if FALSE then the seek started while the content was not playing.
|
|
|
|
bool mPlayingThroughTheAudioChannelBeforeSeek;
|
|
|
|
|
2012-12-11 17:58:07 -08:00
|
|
|
// True iff this element is paused because the document is inactive or has
|
|
|
|
// been suspended by the audio channel service.
|
|
|
|
bool mPausedForInactiveDocumentOrChannel;
|
|
|
|
|
|
|
|
// True iff event delivery is suspended (mPausedForInactiveDocumentOrChannel must also be true).
|
|
|
|
bool mEventDeliveryPaused;
|
2009-11-05 23:34:00 -08:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if we've reported a "waiting" event since the last
|
2009-02-10 17:43:45 -08:00
|
|
|
// readyState change to HAVE_CURRENT_DATA.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mWaitingFired;
|
2009-02-15 17:05:28 -08:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if we're running the "load()" method.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsRunningLoadMethod;
|
2009-03-08 13:59:08 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if we're loading the resource from the child source elements.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsLoadingFromSourceChildren;
|
2009-03-08 14:01:03 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if we're delaying the "load" event. They are delayed until either
|
2009-03-08 14:01:03 -07:00
|
|
|
// an error occurs, or the first frame is loaded.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDelayingLoadEvent;
|
2009-03-08 14:01:03 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True when we've got a task queued to call SelectResource(),
|
2009-03-08 14:01:03 -07:00
|
|
|
// or while we're running SelectResource().
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsRunningSelectResource;
|
2009-05-17 19:00:44 -07:00
|
|
|
|
2012-02-19 13:02:08 -08:00
|
|
|
// True when we already have select resource call queued
|
|
|
|
bool mHaveQueuedSelectResource;
|
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if we suspended the decoder because we were paused,
|
2010-08-19 15:50:37 -07:00
|
|
|
// preloading metadata is enabled, autoplay was not enabled, and we loaded
|
|
|
|
// the first frame.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSuspendedAfterFirstFrame;
|
2009-05-17 19:00:44 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if we are allowed to suspend the decoder because we were paused,
|
2010-08-19 15:50:37 -07:00
|
|
|
// preloading metdata was enabled, autoplay was not enabled, and we loaded
|
|
|
|
// the first frame.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mAllowSuspendAfterFirstFrame;
|
2009-06-26 00:25:17 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if we've played or completed a seek. We use this to determine
|
2009-06-26 00:25:17 -07:00
|
|
|
// when the poster frame should be shown.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mHasPlayedOrSeeked;
|
2009-10-01 07:10:13 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if we've added a reference to ourselves to keep the element
|
2009-10-01 07:10:13 -07:00
|
|
|
// alive while no-one is referencing it but the element may still fire
|
|
|
|
// events of its own accord.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mHasSelfReference;
|
2009-12-10 20:02:13 -08:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if we've received a notification that the engine is shutting
|
2010-02-24 11:14:14 -08:00
|
|
|
// down.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mShuttingDown;
|
2010-02-24 11:14:14 -08:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if we've suspended a load in the resource selection algorithm
|
|
|
|
// due to loading a preload:none media. When true, the resource we'll
|
2010-08-19 15:50:37 -07:00
|
|
|
// load when the user initiates either playback or an explicit load is
|
|
|
|
// stored in mPreloadURI.
|
2012-05-27 15:40:06 -07:00
|
|
|
bool mSuspendedForPreloadNone;
|
2010-08-25 06:10:00 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if a same-origin check has been done for the media element and resource.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mMediaSecurityVerified;
|
2012-01-25 14:31:30 -08:00
|
|
|
|
|
|
|
// The CORS mode when loading the media element
|
2013-03-19 05:23:54 -07:00
|
|
|
CORSMode mCORSMode;
|
2012-04-28 08:01:10 -07:00
|
|
|
|
|
|
|
// True if the media has an audio track
|
|
|
|
bool mHasAudio;
|
2012-05-27 15:40:06 -07:00
|
|
|
|
2014-10-01 08:39:10 -07:00
|
|
|
// True if the media has a video track
|
|
|
|
bool mHasVideo;
|
|
|
|
|
2012-05-27 15:40:06 -07:00
|
|
|
// True if the media's channel's download has been suspended.
|
|
|
|
bool mDownloadSuspendedByCache;
|
2012-09-04 17:49:46 -07:00
|
|
|
|
2014-04-10 10:39:20 -07:00
|
|
|
// Audio Channel.
|
|
|
|
AudioChannel mAudioChannel;
|
2012-12-04 11:46:07 -08:00
|
|
|
|
2013-09-02 02:45:44 -07:00
|
|
|
// The audio channel has been faded.
|
|
|
|
bool mAudioChannelFaded;
|
|
|
|
|
2012-12-04 11:46:07 -08:00
|
|
|
// Is this media element playing?
|
|
|
|
bool mPlayingThroughTheAudioChannel;
|
2012-12-06 07:25:18 -08:00
|
|
|
|
2014-05-23 02:34:14 -07:00
|
|
|
// Disable the video playback by track selection. This flag might not be
|
|
|
|
// enough if we ever expand the ability of supporting multi-tracks video
|
|
|
|
// playback.
|
|
|
|
bool mDisableVideo;
|
|
|
|
|
2012-12-06 07:25:18 -08:00
|
|
|
// An agent used to join audio channel service.
|
|
|
|
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
|
2013-05-21 09:14:00 -07:00
|
|
|
|
2013-10-23 11:45:00 -07:00
|
|
|
nsRefPtr<TextTrackManager> mTextTrackManager;
|
2014-06-06 13:52:15 -07:00
|
|
|
|
2014-05-23 02:34:14 -07:00
|
|
|
nsRefPtr<AudioTrackList> mAudioTrackList;
|
|
|
|
|
|
|
|
nsRefPtr<VideoTrackList> mVideoTrackList;
|
|
|
|
|
2014-06-06 13:52:15 -07:00
|
|
|
MediaWaitingFor mWaitingFor;
|
2008-07-09 01:22:20 -07:00
|
|
|
};
|
2010-04-01 20:03:07 -07:00
|
|
|
|
2013-03-19 05:23:54 -07:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLMediaElement_h
|