Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes

nsHTMLMediaElement Class Reference

#include <nsHTMLMediaElement.h>

Inheritance diagram for nsHTMLMediaElement:
Collaboration diagram for nsHTMLMediaElement:

List of all members.

Classes

class  cycleCollection

Public Types

enum  NextFrameStatus { NEXT_FRAME_AVAILABLE, NEXT_FRAME_UNAVAILABLE_BUFFERING, NEXT_FRAME_UNAVAILABLE }

Public Member Functions

 nsHTMLMediaElement (nsINodeInfo *aNodeInfo, PRBool aFromParser=0)
virtual ~nsHTMLMediaElement ()
nsresult LoadWithChannel (nsIChannel *aChannel, nsIStreamListener **aListener)
 This is used when the browser is constructing a video element to play a channel that we've already started loading.
virtual PRBool ParseAttribute (PRInt32 aNamespaceID, nsIAtom *aAttribute, const nsAString &aValue, nsAttrValue &aResult)
nsresult SetAttr (PRInt32 aNameSpaceID, nsIAtom *aName, const nsAString &aValue, PRBool aNotify)
virtual nsresult SetAttr (PRInt32 aNameSpaceID, nsIAtom *aName, nsIAtom *aPrefix, const nsAString &aValue, PRBool aNotify)
virtual nsresult UnsetAttr (PRInt32 aNameSpaceID, nsIAtom *aAttr, PRBool aNotify)
virtual nsresult BindToTree (nsIDocument *aDocument, nsIContent *aParent, nsIContent *aBindingParent, PRBool aCompileEventHandlers)
virtual void UnbindFromTree (PRBool aDeep=1, PRBool aNullParent=1)
virtual PRBool IsDoneAddingChildren ()
virtual nsresult DoneAddingChildren (PRBool aHaveNotified)
void NotifyOwnerDocumentActivityChanged ()
 Call this to reevaluate whether we should start/stop due to our owner document being active or inactive.
void MetadataLoaded ()
void FirstFrameLoaded (PRBool aResourceFullyLoaded)
void ResourceLoaded ()
void NetworkError ()
void DecodeError ()
void PlaybackEnded ()
void SeekStarted ()
void SeekCompleted ()
void DownloadSuspended ()
void DownloadResumed ()
void DownloadStalled ()
void Paint (gfxContext *aContext, gfxPattern::GraphicsFilter aFilter, const gfxRect &aRect)
nsresult DispatchSimpleEvent (const nsAString &aName)
nsresult DispatchProgressEvent (const nsAString &aName)
nsresult DispatchAsyncSimpleEvent (const nsAString &aName)
nsresult DispatchAsyncProgressEvent (const nsAString &aName)
void UpdateReadyStateForData (NextFrameStatus aNextFrame)
void ChangeReadyState (nsMediaReadyState aState)
PRBool CanActivateAutoplay ()
void NotifyAutoplayDataReady ()
PRBool ShouldCheckAllowOrigin ()
PRBool IsPotentiallyPlaying () const
PRBool IsPlaybackEnded () const
already_AddRefed< nsIPrincipalGetCurrentPrincipal ()
void UpdateMediaSize (nsIntSize size)
void NotifyAddedSource ()
 Called when a child source element is added to this media element.
void NotifyLoadError ()
 Called when there's been an error fetching the resource.
virtual PRBool IsNodeOfType (PRUint32 aFlags) const
PRUint32 GetCurrentLoadID ()
 Returns the current load ID.
already_AddRefed< nsILoadGroupGetDocumentLoadGroup ()
 Returns the load group for this media element's owner document.
PRBool GetPlayedOrSeeked () const
 Returns PR_TRUE if the media has played or completed a seek.
nsresult CopyInnerTo (nsGenericElement *aDest) const

Static Public Member Functions

static PRBool CanHandleMediaType (const char *aMIMEType, const char ***aSupportedCodecs)
static PRBool ShouldHandleMediaType (const char *aMIMEType)
static void InitMediaTypes ()
 Initialize data for available media types.
static void ShutdownMediaTypes ()
 Shutdown data for available media types.

Static Public Attributes

static cycleCollection _cycleCollectorGlobal

Protected Types

enum  LoadAlgorithmState { NOT_WAITING, WAITING_FOR_SRC_OR_SOURCE, WAITING_FOR_SOURCE }

Protected Member Functions

void SetPlayedOrSeeked (PRBool aValue)
 Changes mHasPlayedOrSeeked to aValue.
already_AddRefed< nsMediaDecoderCreateDecoder (const nsACString &aMIMEType)
 Create a decoder for the given aMIMEType.
nsresult InitializeDecoderAsClone (nsMediaDecoder *aOriginal)
 Initialize a decoder as a clone of an existing decoder in another element.
nsresult InitializeDecoderForChannel (nsIChannel *aChannel, nsIStreamListener **aListener)
 Initialize a decoder to load the given channel.
nsresult FinishDecoderSetup (nsMediaDecoder *aDecoder)
 Finish setting up the decoder after Load() has been called on it.
void AbortExistingLoads ()
 Execute the initial steps of the load algorithm that ensure existing loads are aborted, the element is emptied, and a new load ID is created.
nsresult NewURIFromString (const nsAutoString &aURISpec, nsIURI **aURI)
 Create a URI for the given aURISpec string.
void NoSupportedMediaSourceError ()
 Called when all potential resources are exhausted.
void LoadFromSourceChildren ()
 Attempts to load resources from the <source> children.
void QueueLoadFromSourceTask ()
 Sends an async event to call LoadFromSourceChildren().
void SelectResource ()
 Media selection algorithm.
void QueueSelectResourceTask ()
 Sends an async event to call SelectResource().
nsresult LoadResource (nsIURI *aURI)
 The resource-fetch algorithm step of the load algorithm.
already_AddRefed< nsIURIGetNextSource ()
 Selects the next <source> child from which to load a resource.
void ChangeDelayLoadStatus (PRBool aDelay)
 Changes mDelayingLoadEvent, and will call BlockOnLoad()/UnblockOnLoad() on the owning document, so it can delay the load event firing.
void StopSuspendingAfterFirstFrame ()
 If we suspended downloading after the first frame, unsuspend now.
nsresult OnChannelRedirect (nsIChannel *aChannel, nsIChannel *aNewChannel, PRUint32 aFlags)
 Called when our channel is redirected to another channel.
void AddRemoveSelfReference ()
 Call this to reevaluate whether we should be holding a self-reference.
void DoRelease ()
 Alias for Release(), but using stdcall calling convention so on platforms where Release has a strange calling convention (Windows) we can still get a method pointer to this method.

Protected Attributes

nsRefPtr< nsMediaDecodermDecoder
nsCOMPtr< nsIChannelmChannel
nsCOMPtr< nsIDOMHTMLMediaErrormError
PRUint32 mCurrentLoadID
nsCOMPtr< nsIDOMRangemSourcePointer
nsCOMPtr< nsIDocument > mLoadBlockedDoc
nsMediaNetworkState mNetworkState
nsMediaReadyState mReadyState
LoadAlgorithmState mLoadWaitStatus
float mVolume
nsIntSize mMediaSize
PRPackedBool mBegun
PRPackedBool mLoadedFirstFrame
PRPackedBool mAutoplaying
PRPackedBool mAutoplayEnabled
PRPackedBool mPaused
PRPackedBool mMuted
PRPackedBool mIsDoneAddingChildren
PRPackedBool mPlayingBeforeSeek
PRPackedBool mPausedForInactiveDocument
PRPackedBool mWaitingFired
PRPackedBool mIsBindingToTree
PRPackedBool mIsRunningLoadMethod
PRPackedBool mIsLoadingFromSrcAttribute
PRPackedBool mDelayingLoadEvent
PRPackedBool mIsRunningSelectResource
PRPackedBool mSuspendedAfterFirstFrame
PRPackedBool mAllowSuspendAfterFirstFrame
PRPackedBool mHasPlayedOrSeeked
PRPackedBool mHasSelfReference
nsRefPtr< gfxASurfacemPrintSurface

Member Enumeration Documentation

Enumerator:
NOT_WAITING 
WAITING_FOR_SRC_OR_SOURCE 
WAITING_FOR_SOURCE 
Enumerator:
NEXT_FRAME_AVAILABLE 
NEXT_FRAME_UNAVAILABLE_BUFFERING 
NEXT_FRAME_UNAVAILABLE 

Constructor & Destructor Documentation

nsHTMLMediaElement::nsHTMLMediaElement ( nsINodeInfo *  aNodeInfo,
PRBool  aFromParser = 0 
)
virtual nsHTMLMediaElement::~nsHTMLMediaElement (  )  [virtual]

Member Function Documentation

void nsHTMLMediaElement::AbortExistingLoads (  )  [protected]

Execute the initial steps of the load algorithm that ensure existing loads are aborted, the element is emptied, and a new load ID is created.

void nsHTMLMediaElement::AddRemoveSelfReference (  )  [protected]

Call this to reevaluate whether we should be holding a self-reference.

virtual nsresult nsHTMLMediaElement::BindToTree ( nsIDocument *  aDocument,
nsIContent *  aParent,
nsIContent *  aBindingParent,
PRBool  aCompileEventHandlers 
) [virtual]
PRBool nsHTMLMediaElement::CanActivateAutoplay (  ) 
static PRBool nsHTMLMediaElement::CanHandleMediaType ( const char *  aMIMEType,
const char ***  aSupportedCodecs 
) [static]
void nsHTMLMediaElement::ChangeDelayLoadStatus ( PRBool  aDelay  )  [protected]

Changes mDelayingLoadEvent, and will call BlockOnLoad()/UnblockOnLoad() on the owning document, so it can delay the load event firing.

void nsHTMLMediaElement::ChangeReadyState ( nsMediaReadyState  aState  ) 
nsresult nsHTMLMediaElement::CopyInnerTo ( nsGenericElement *  aDest  )  const
already_AddRefed<nsMediaDecoder> nsHTMLMediaElement::CreateDecoder ( const nsACString aMIMEType  )  [protected]

Create a decoder for the given aMIMEType.

Returns null if we were unable to create the decoder.

void nsHTMLMediaElement::DecodeError (  ) 
nsresult nsHTMLMediaElement::DispatchAsyncProgressEvent ( const nsAString aName  ) 
nsresult nsHTMLMediaElement::DispatchAsyncSimpleEvent ( const nsAString aName  ) 
nsresult nsHTMLMediaElement::DispatchProgressEvent ( const nsAString aName  ) 
nsresult nsHTMLMediaElement::DispatchSimpleEvent ( const nsAString aName  ) 
virtual nsresult nsHTMLMediaElement::DoneAddingChildren ( PRBool  aHaveNotified  )  [virtual]
void nsHTMLMediaElement::DoRelease (  )  [inline, protected]

Alias for Release(), but using stdcall calling convention so on platforms where Release has a strange calling convention (Windows) we can still get a method pointer to this method.

void nsHTMLMediaElement::DownloadResumed (  ) 
void nsHTMLMediaElement::DownloadStalled (  ) 
void nsHTMLMediaElement::DownloadSuspended (  ) 
nsresult nsHTMLMediaElement::FinishDecoderSetup ( nsMediaDecoder aDecoder  )  [protected]

Finish setting up the decoder after Load() has been called on it.

void nsHTMLMediaElement::FirstFrameLoaded ( PRBool  aResourceFullyLoaded  ) 
PRUint32 nsHTMLMediaElement::GetCurrentLoadID (  )  [inline]

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.

already_AddRefed<nsIPrincipal> nsHTMLMediaElement::GetCurrentPrincipal (  ) 
already_AddRefed<nsILoadGroup> nsHTMLMediaElement::GetDocumentLoadGroup (  ) 

Returns the load group for this media element's owner document.

XXX XBL2 issue.

already_AddRefed<nsIURI> nsHTMLMediaElement::GetNextSource (  )  [protected]

Selects the next <source> child from which to load a resource.

Called during the media selection algorithm.

PRBool nsHTMLMediaElement::GetPlayedOrSeeked (  )  const [inline]

Returns PR_TRUE if the media has played or completed a seek.

Used by video frame to determine whether to paint the poster.

nsresult nsHTMLMediaElement::InitializeDecoderAsClone ( nsMediaDecoder aOriginal  )  [protected]

Initialize a decoder as a clone of an existing decoder in another element.

nsresult nsHTMLMediaElement::InitializeDecoderForChannel ( nsIChannel aChannel,
nsIStreamListener **  aListener 
) [protected]

Initialize a decoder to load the given channel.

The decoder's stream listener is returned via aListener.

static void nsHTMLMediaElement::InitMediaTypes (  )  [static]

Initialize data for available media types.

virtual PRBool nsHTMLMediaElement::IsDoneAddingChildren (  )  [virtual]
virtual PRBool nsHTMLMediaElement::IsNodeOfType ( PRUint32  aFlags  )  const [virtual]
PRBool nsHTMLMediaElement::IsPlaybackEnded (  )  const
PRBool nsHTMLMediaElement::IsPotentiallyPlaying (  )  const
void nsHTMLMediaElement::LoadFromSourceChildren (  )  [protected]

Attempts to load resources from the <source> children.

This is a substep of the media selection algorith. Do not call this directly, call QueueLoadFromSourceTask() instead.

nsresult nsHTMLMediaElement::LoadResource ( nsIURI aURI  )  [protected]

The resource-fetch algorithm step of the load algorithm.

nsresult nsHTMLMediaElement::LoadWithChannel ( nsIChannel aChannel,
nsIStreamListener **  aListener 
)

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 <source> children are ignored.

Parameters:
aChannel the channel to use
aListener returns a stream listener that should receive notifications for the stream
void nsHTMLMediaElement::MetadataLoaded (  ) 
void nsHTMLMediaElement::NetworkError (  ) 
nsresult nsHTMLMediaElement::NewURIFromString ( const nsAutoString aURISpec,
nsIURI **  aURI 
) [protected]

Create a URI for the given aURISpec string.

void nsHTMLMediaElement::NoSupportedMediaSourceError (  )  [protected]

Called when all potential resources are exhausted.

Changes network state to NETWORK_NO_SOURCE, and sends error event with code MEDIA_ERR_SRC_NOT_SUPPORTED.

void nsHTMLMediaElement::NotifyAddedSource (  ) 

Called when a child source element is added to this media element.

This may queue a load() task if appropriate.

void nsHTMLMediaElement::NotifyAutoplayDataReady (  ) 
void nsHTMLMediaElement::NotifyLoadError (  ) 

Called when there's been an error fetching the resource.

This decides whether it's appropriate to fire an error event.

void nsHTMLMediaElement::NotifyOwnerDocumentActivityChanged (  ) 

Call this to reevaluate whether we should start/stop due to our owner document being active or inactive.

nsresult nsHTMLMediaElement::OnChannelRedirect ( nsIChannel aChannel,
nsIChannel aNewChannel,
PRUint32  aFlags 
) [protected]

Called when our channel is redirected to another channel.

Updates our mChannel reference to aNewChannel.

void nsHTMLMediaElement::Paint ( gfxContext aContext,
gfxPattern::GraphicsFilter  aFilter,
const gfxRect aRect 
)
virtual PRBool nsHTMLMediaElement::ParseAttribute ( PRInt32  aNamespaceID,
nsIAtom aAttribute,
const nsAString aValue,
nsAttrValue &  aResult 
) [virtual]

Reimplemented in nsHTMLVideoElement.

void nsHTMLMediaElement::PlaybackEnded (  ) 
void nsHTMLMediaElement::QueueLoadFromSourceTask (  )  [protected]

Sends an async event to call LoadFromSourceChildren().

void nsHTMLMediaElement::QueueSelectResourceTask (  )  [protected]

Sends an async event to call SelectResource().

void nsHTMLMediaElement::ResourceLoaded (  ) 
void nsHTMLMediaElement::SeekCompleted (  ) 
void nsHTMLMediaElement::SeekStarted (  ) 
void nsHTMLMediaElement::SelectResource (  )  [protected]

Media selection algorithm.

nsresult nsHTMLMediaElement::SetAttr ( PRInt32  aNameSpaceID,
nsIAtom aName,
const nsAString aValue,
PRBool  aNotify 
) [inline]
virtual nsresult nsHTMLMediaElement::SetAttr ( PRInt32  aNameSpaceID,
nsIAtom aName,
nsIAtom aPrefix,
const nsAString aValue,
PRBool  aNotify 
) [virtual]
void nsHTMLMediaElement::SetPlayedOrSeeked ( PRBool  aValue  )  [protected]

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.

PRBool nsHTMLMediaElement::ShouldCheckAllowOrigin (  ) 
static PRBool nsHTMLMediaElement::ShouldHandleMediaType ( const char *  aMIMEType  )  [static]
static void nsHTMLMediaElement::ShutdownMediaTypes (  )  [static]

Shutdown data for available media types.

void nsHTMLMediaElement::StopSuspendingAfterFirstFrame (  )  [protected]

If we suspended downloading after the first frame, unsuspend now.

virtual void nsHTMLMediaElement::UnbindFromTree ( PRBool  aDeep = 1,
PRBool  aNullParent = 1 
) [virtual]
virtual nsresult nsHTMLMediaElement::UnsetAttr ( PRInt32  aNameSpaceID,
nsIAtom aAttr,
PRBool  aNotify 
) [virtual]
void nsHTMLMediaElement::UpdateMediaSize ( nsIntSize  size  ) 
void nsHTMLMediaElement::UpdateReadyStateForData ( NextFrameStatus  aNextFrame  ) 

Member Data Documentation

PRUint32 nsHTMLMediaElement::mCurrentLoadID [protected]
float nsHTMLMediaElement::mVolume [protected]

The documentation for this class was generated from the following file: