2008-07-29 23:50:14 -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/. */
|
2008-07-29 23:50:14 -07:00
|
|
|
/*
|
2011-07-11 20:39:39 -07:00
|
|
|
Each video element based on nsBuiltinDecoder has a state machine to manage
|
|
|
|
its play state and keep the current frame up to date. All state machines
|
|
|
|
share time in a single shared thread. Each decoder also has one thread
|
|
|
|
dedicated to decoding audio and video data. This thread is shutdown when
|
|
|
|
playback is paused. Each decoder also has a thread to push decoded audio
|
|
|
|
to the hardware. This thread is not created until playback starts, but
|
|
|
|
currently is not destroyed when paused, only when playback ends.
|
|
|
|
|
|
|
|
The decoder owns the resources for downloading the media file, and the
|
|
|
|
high level state. It holds an owning reference to the state machine
|
|
|
|
(a subclass of nsDecoderStateMachine; nsBuiltinDecoderStateMachine) that
|
|
|
|
owns all the resources related to decoding data, and manages the low level
|
|
|
|
decoding operations and A/V sync.
|
|
|
|
|
|
|
|
Each state machine runs on the shared state machine thread. Every time some
|
|
|
|
action is required for a state machine, it is scheduled to run on the shared
|
|
|
|
the state machine thread. The state machine runs one "cycle" on the state
|
|
|
|
machine thread, and then returns. If necessary, it will schedule itself to
|
|
|
|
run again in future. While running this cycle, it must not block the
|
|
|
|
thread, as other state machines' events may need to run. State shared
|
|
|
|
between a state machine's threads is synchronised via the monitor owned
|
|
|
|
by its nsBuiltinDecoder object.
|
2008-10-19 00:39:21 -07:00
|
|
|
|
|
|
|
The Main thread controls the decode state machine by setting the value
|
2010-04-27 01:53:44 -07:00
|
|
|
of a mPlayState variable and notifying on the monitor based on the
|
|
|
|
high level player actions required (Seek, Pause, Play, etc).
|
2008-10-19 00:39:21 -07:00
|
|
|
|
|
|
|
The player states are the states requested by the client through the
|
|
|
|
DOM API. They represent the desired state of the player, while the
|
|
|
|
decoder's state represents the actual state of the decoder.
|
|
|
|
|
|
|
|
The high level state of the player is maintained via a PlayState value.
|
|
|
|
It can have the following states:
|
|
|
|
|
|
|
|
START
|
|
|
|
The decoder has been initialized but has no resource loaded.
|
|
|
|
PAUSED
|
|
|
|
A request via the API has been received to pause playback.
|
|
|
|
LOADING
|
|
|
|
A request via the API has been received to load a resource.
|
|
|
|
PLAYING
|
|
|
|
A request via the API has been received to start playback.
|
|
|
|
SEEKING
|
|
|
|
A request via the API has been received to start seeking.
|
|
|
|
COMPLETED
|
|
|
|
Playback has completed.
|
|
|
|
SHUTDOWN
|
|
|
|
The decoder is about to be destroyed.
|
|
|
|
|
|
|
|
State transition occurs when the Media Element calls the Play, Seek,
|
2010-04-27 01:53:44 -07:00
|
|
|
etc methods on the nsBuiltinDecoder object. When the transition
|
|
|
|
occurs nsBuiltinDecoder then calls the methods on the decoder state
|
2011-07-11 20:39:39 -07:00
|
|
|
machine object to cause it to behave as required by the play state.
|
|
|
|
State transitions will likely schedule the state machine to run to
|
|
|
|
affect the change.
|
2008-10-19 00:39:21 -07:00
|
|
|
|
2010-05-05 19:31:02 -07:00
|
|
|
An implementation of the nsDecoderStateMachine class is the event
|
2011-07-11 20:39:39 -07:00
|
|
|
that gets dispatched to the state machine thread. Each time the event is run,
|
|
|
|
the state machine must cycle the state machine once, and then return.
|
|
|
|
|
|
|
|
The state machine has the following states:
|
2010-05-05 19:31:02 -07:00
|
|
|
|
|
|
|
DECODING_METADATA
|
|
|
|
The media headers are being loaded, and things like framerate, etc are
|
|
|
|
being determined, and the first frame of audio/video data is being decoded.
|
|
|
|
DECODING
|
2011-07-11 20:39:39 -07:00
|
|
|
The decode has started. If the PlayState is PLAYING, the decode thread
|
|
|
|
should be alive and decoding video and audio frame, the audio thread
|
|
|
|
should be playing audio, and the state machine should run periodically
|
|
|
|
to update the video frames being displayed.
|
2010-05-05 19:31:02 -07:00
|
|
|
SEEKING
|
2011-07-11 20:39:39 -07:00
|
|
|
A seek operation is in progress. The decode thread should be seeking.
|
2010-05-05 19:31:02 -07:00
|
|
|
BUFFERING
|
2011-07-11 20:39:39 -07:00
|
|
|
Decoding is paused while data is buffered for smooth playback. If playback
|
|
|
|
is paused (PlayState transitions to PAUSED) we'll destory the decode thread.
|
2010-05-05 19:31:02 -07:00
|
|
|
COMPLETED
|
2011-07-11 20:39:39 -07:00
|
|
|
The resource has completed decoding, but possibly not finished playback.
|
|
|
|
The decode thread will be destroyed. Once playback finished, the audio
|
|
|
|
thread will also be destroyed.
|
2010-05-05 19:31:02 -07:00
|
|
|
SHUTDOWN
|
2011-07-11 20:39:39 -07:00
|
|
|
The decoder object and its state machine are about to be destroyed.
|
|
|
|
Once the last state machine has been destroyed, the shared state machine
|
|
|
|
thread will also be destroyed. It will be recreated later if needed.
|
2010-05-05 19:31:02 -07:00
|
|
|
|
|
|
|
The following result in state transitions.
|
|
|
|
|
|
|
|
Shutdown()
|
|
|
|
Clean up any resources the nsDecoderStateMachine owns.
|
2011-03-23 15:28:57 -07:00
|
|
|
Play()
|
|
|
|
Start decoding and playback of media data.
|
2010-05-05 19:31:02 -07:00
|
|
|
Buffer
|
|
|
|
This is not user initiated. It occurs when the
|
|
|
|
available data in the stream drops below a certain point.
|
|
|
|
Complete
|
|
|
|
This is not user initiated. It occurs when the
|
|
|
|
stream is completely decoded.
|
2011-01-16 19:03:00 -08:00
|
|
|
Seek(double)
|
2010-05-05 19:31:02 -07:00
|
|
|
Seek to the time position given in the resource.
|
|
|
|
|
|
|
|
A state transition diagram:
|
|
|
|
|
|
|
|
DECODING_METADATA
|
|
|
|
| |
|
|
|
|
v | Shutdown()
|
|
|
|
| |
|
|
|
|
v -->-------------------->--------------------------|
|
|
|
|
|---------------->----->------------------------| v
|
|
|
|
DECODING | | | | |
|
|
|
|
^ v Seek(t) | | | |
|
2011-03-23 15:28:57 -07:00
|
|
|
| Play() | v | | |
|
2010-05-05 19:31:02 -07:00
|
|
|
^-----------<----SEEKING | v Complete v v
|
|
|
|
| | | | | |
|
|
|
|
| | | COMPLETED SHUTDOWN-<-|
|
|
|
|
^ ^ | |Shutdown() |
|
|
|
|
| | | >-------->-----^
|
2011-03-23 15:28:57 -07:00
|
|
|
| Play() |Seek(t) |Buffer() |
|
2010-05-05 19:31:02 -07:00
|
|
|
-----------<--------<-------BUFFERING |
|
|
|
|
| ^
|
|
|
|
v Shutdown() |
|
|
|
|
| |
|
|
|
|
------------>-----|
|
|
|
|
|
|
|
|
The following represents the states that the nsBuiltinDecoder object
|
|
|
|
can be in, and the valid states the nsDecoderStateMachine can be in at that
|
|
|
|
time:
|
|
|
|
|
|
|
|
player LOADING decoder DECODING_METADATA
|
|
|
|
player PLAYING decoder DECODING, BUFFERING, SEEKING, COMPLETED
|
|
|
|
player PAUSED decoder DECODING, BUFFERING, SEEKING, COMPLETED
|
|
|
|
player SEEKING decoder SEEKING
|
|
|
|
player COMPLETED decoder SHUTDOWN
|
|
|
|
player SHUTDOWN decoder SHUTDOWN
|
|
|
|
|
2010-04-27 01:53:44 -07:00
|
|
|
The general sequence of events is:
|
2008-10-19 00:39:21 -07:00
|
|
|
|
|
|
|
1) The video element calls Load on nsMediaDecoder. This creates the
|
2011-07-11 20:39:39 -07:00
|
|
|
state machine and starts the channel for downloading the
|
|
|
|
file. It instantiates and schedules the nsDecoderStateMachine. The
|
2010-04-27 01:53:44 -07:00
|
|
|
high level LOADING state is entered, which results in the decode
|
2011-07-11 20:39:39 -07:00
|
|
|
thread being created and starting to decode metadata. These are
|
|
|
|
the headers that give the video size, framerate, etc. Load() returns
|
|
|
|
immediately to the calling video element.
|
|
|
|
|
|
|
|
2) When the metadata has been loaded by the decode thread, the state machine
|
|
|
|
will call a method on the video element object to inform it that this
|
|
|
|
step is done, so it can do the things required by the video specification
|
|
|
|
at this stage. The decode thread then continues to decode the first frame
|
2010-04-27 01:53:44 -07:00
|
|
|
of data.
|
|
|
|
|
2011-07-11 20:39:39 -07:00
|
|
|
3) When the first frame of data has been successfully decoded the state
|
|
|
|
machine calls a method on the video element object to inform it that
|
|
|
|
this step has been done, once again so it can do the required things
|
|
|
|
by the video specification at this stage.
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
This results in the high level state changing to PLAYING or PAUSED
|
|
|
|
depending on any user action that may have occurred.
|
|
|
|
|
2011-07-11 20:39:39 -07:00
|
|
|
While the play state is PLAYING, the decode thread will decode
|
|
|
|
data, and the audio thread will push audio data to the hardware to
|
|
|
|
be played. The state machine will run periodically on the shared
|
|
|
|
state machine thread to ensure video frames are played at the
|
|
|
|
correct time; i.e. the state machine manages A/V sync.
|
|
|
|
|
|
|
|
The Shutdown method on nsBuiltinDecoder closes the download channel, and
|
|
|
|
signals to the state machine that it should shutdown. The state machine
|
|
|
|
shuts down asynchronously, and will release the owning reference to the
|
|
|
|
state machine once its threads are shutdown.
|
2010-04-27 01:53:44 -07:00
|
|
|
|
2011-07-11 20:39:39 -07:00
|
|
|
The owning object of a nsBuiltinDecoder object *MUST* call Shutdown when
|
|
|
|
destroying the nsBuiltinDecoder object.
|
2010-04-27 01:53:44 -07:00
|
|
|
|
2008-07-29 23:50:14 -07:00
|
|
|
*/
|
2010-04-27 01:53:44 -07:00
|
|
|
#if !defined(nsBuiltinDecoder_h_)
|
|
|
|
#define nsBuiltinDecoder_h_
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2009-09-29 14:32:44 -07:00
|
|
|
#include "nsMediaDecoder.h"
|
|
|
|
|
2008-07-29 23:50:14 -07:00
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIThread.h"
|
|
|
|
#include "nsIChannel.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsSize.h"
|
|
|
|
#include "prlog.h"
|
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxRect.h"
|
2012-02-14 20:35:01 -08:00
|
|
|
#include "MediaResource.h"
|
2010-04-01 20:03:07 -07:00
|
|
|
#include "nsMediaDecoder.h"
|
2010-04-27 01:53:44 -07:00
|
|
|
#include "nsHTMLMediaElement.h"
|
2011-04-29 12:21:57 -07:00
|
|
|
#include "mozilla/ReentrantMonitor.h"
|
2012-07-18 09:31:40 -07:00
|
|
|
#include "ImageLayers.h"
|
2008-07-29 23:50:14 -07:00
|
|
|
class nsAudioStream;
|
|
|
|
|
2012-07-18 09:31:40 -07:00
|
|
|
typedef mozilla::layers::Image Image;
|
|
|
|
typedef mozilla::layers::ImageContainer ImageContainer;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static inline bool IsCurrentThread(nsIThread* aThread) {
|
2010-04-27 01:53:44 -07:00
|
|
|
return NS_GetCurrentThread() == aThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Decoder backends must implement this class to perform the codec
|
|
|
|
// specific parts of decoding the video/audio format.
|
|
|
|
class nsDecoderStateMachine : public nsRunnable
|
2008-07-29 23:50:14 -07:00
|
|
|
{
|
2010-04-27 01:53:44 -07:00
|
|
|
public:
|
2010-05-05 19:31:02 -07:00
|
|
|
// Enumeration for the valid decoding states
|
|
|
|
enum State {
|
|
|
|
DECODER_STATE_DECODING_METADATA,
|
|
|
|
DECODER_STATE_DECODING,
|
|
|
|
DECODER_STATE_SEEKING,
|
|
|
|
DECODER_STATE_BUFFERING,
|
|
|
|
DECODER_STATE_COMPLETED,
|
|
|
|
DECODER_STATE_SHUTDOWN
|
|
|
|
};
|
|
|
|
|
2010-04-27 01:53:44 -07:00
|
|
|
// Initializes the state machine, returns NS_OK on success, or
|
|
|
|
// NS_ERROR_FAILURE on failure.
|
2010-09-20 17:49:50 -07:00
|
|
|
virtual nsresult Init(nsDecoderStateMachine* aCloneDonor) = 0;
|
2010-04-27 01:53:44 -07:00
|
|
|
|
2010-05-05 19:31:02 -07:00
|
|
|
// Return the current decode state. The decoder monitor must be
|
|
|
|
// obtained before calling this.
|
|
|
|
virtual State GetState() = 0;
|
|
|
|
|
2010-04-27 01:53:44 -07:00
|
|
|
// Set the audio volume. The decoder monitor must be obtained before
|
|
|
|
// calling this.
|
2011-01-16 19:03:00 -08:00
|
|
|
virtual void SetVolume(double aVolume) = 0;
|
2012-04-29 20:12:42 -07:00
|
|
|
virtual void SetAudioCaptured(bool aCapture) = 0;
|
2010-04-27 01:53:44 -07:00
|
|
|
|
|
|
|
virtual void Shutdown() = 0;
|
|
|
|
|
|
|
|
// Called from the main thread to get the duration. The decoder monitor
|
2011-04-13 15:12:23 -07:00
|
|
|
// must be obtained before calling this. It is in units of microseconds.
|
2010-04-27 01:53:44 -07:00
|
|
|
virtual PRInt64 GetDuration() = 0;
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2010-04-27 01:53:44 -07:00
|
|
|
// Called from the main thread to set the duration of the media resource
|
2010-06-08 16:31:27 -07:00
|
|
|
// if it is able to be obtained via HTTP headers. Called from the
|
|
|
|
// state machine thread to set the duration if it is obtained from the
|
|
|
|
// media metadata. The decoder monitor must be obtained before calling this.
|
2011-04-13 15:12:23 -07:00
|
|
|
// aDuration is in microseconds.
|
2010-04-27 01:53:44 -07:00
|
|
|
virtual void SetDuration(PRInt64 aDuration) = 0;
|
|
|
|
|
2011-05-08 14:10:28 -07:00
|
|
|
// Called while decoding metadata to set the end time of the media
|
|
|
|
// resource. The decoder monitor must be obtained before calling this.
|
|
|
|
// aEndTime is in microseconds.
|
|
|
|
virtual void SetEndTime(PRInt64 aEndTime) = 0;
|
|
|
|
|
2011-08-24 16:42:23 -07:00
|
|
|
// Set the media fragment end time. aEndTime is in microseconds.
|
|
|
|
virtual void SetFragmentEndTime(PRInt64 aEndTime) = 0;
|
|
|
|
|
2010-04-27 01:53:44 -07:00
|
|
|
// Functions used by assertions to ensure we're calling things
|
|
|
|
// on the appropriate threads.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool OnDecodeThread() const = 0;
|
2010-04-27 01:53:44 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// Returns true if the current thread is the state machine thread.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool OnStateMachineThread() const = 0;
|
2011-07-11 20:39:34 -07:00
|
|
|
|
2010-04-27 01:53:44 -07:00
|
|
|
virtual nsHTMLMediaElement::NextFrameStatus GetNextFrameStatus() = 0;
|
|
|
|
|
|
|
|
// Cause state transitions. These methods obtain the decoder monitor
|
|
|
|
// to synchronise the change of state, and to notify other threads
|
|
|
|
// that the state has changed.
|
2011-03-23 15:28:57 -07:00
|
|
|
virtual void Play() = 0;
|
2010-04-27 01:53:44 -07:00
|
|
|
|
|
|
|
// Seeks to aTime in seconds
|
2011-01-16 19:03:00 -08:00
|
|
|
virtual void Seek(double aTime) = 0;
|
2010-04-27 01:53:44 -07:00
|
|
|
|
|
|
|
// Returns the current playback position in seconds.
|
|
|
|
// Called from the main thread to get the current frame time. The decoder
|
|
|
|
// monitor must be obtained before calling this.
|
2011-03-23 15:28:57 -07:00
|
|
|
virtual double GetCurrentTime() const = 0;
|
2010-04-27 01:53:44 -07:00
|
|
|
|
|
|
|
// Clear the flag indicating that a playback position change event
|
|
|
|
// is currently queued. This is called from the main thread and must
|
|
|
|
// be called with the decode monitor held.
|
|
|
|
virtual void ClearPositionChangeFlag() = 0;
|
|
|
|
|
|
|
|
// Called from the main thread to set whether the media resource can
|
2011-05-08 14:10:28 -07:00
|
|
|
// seek into unbuffered ranges. The decoder monitor must be obtained
|
|
|
|
// before calling this.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void SetSeekable(bool aSeekable) = 0;
|
2010-05-05 19:31:02 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// Returns true if the media resource can seek into unbuffered ranges,
|
2011-05-08 14:10:28 -07:00
|
|
|
// as set by SetSeekable(). The decoder monitor must be obtained before
|
|
|
|
// calling this.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsSeekable() = 0;
|
2011-05-08 14:10:28 -07:00
|
|
|
|
2010-05-05 19:31:02 -07:00
|
|
|
// Update the playback position. This can result in a timeupdate event
|
|
|
|
// and an invalidate of the frame being dispatched asynchronously if
|
|
|
|
// there is no such event currently queued.
|
|
|
|
// Only called on the decoder thread. Must be called with
|
|
|
|
// the decode monitor held.
|
|
|
|
virtual void UpdatePlaybackPosition(PRInt64 aTime) = 0;
|
2010-07-22 15:48:32 -07:00
|
|
|
|
2010-08-25 01:43:00 -07:00
|
|
|
virtual nsresult GetBuffered(nsTimeRanges* aBuffered) = 0;
|
2010-09-13 01:45:50 -07:00
|
|
|
|
2012-05-18 10:35:43 -07:00
|
|
|
// Return true if the media is seekable using only buffered ranges.
|
|
|
|
virtual bool IsSeekableInBufferedRanges() = 0;
|
|
|
|
|
2011-07-21 20:17:23 -07:00
|
|
|
virtual PRInt64 VideoQueueMemoryInUse() = 0;
|
|
|
|
virtual PRInt64 AudioQueueMemoryInUse() = 0;
|
|
|
|
|
2012-01-31 14:05:51 -08:00
|
|
|
virtual void NotifyDataArrived(const char* aBuffer, PRUint32 aLength, PRInt64 aOffset) = 0;
|
2010-09-13 01:45:50 -07:00
|
|
|
|
2010-07-22 15:48:32 -07:00
|
|
|
// Causes the state machine to switch to buffering state, and to
|
|
|
|
// immediately stop playback and buffer downloaded data. Must be called
|
|
|
|
// with the decode monitor held. Called on the state machine thread and
|
|
|
|
// the main thread.
|
|
|
|
virtual void StartBuffering() = 0;
|
2011-04-11 14:15:45 -07:00
|
|
|
|
|
|
|
// Sets the current size of the framebuffer used in MozAudioAvailable events.
|
|
|
|
// Called on the state machine thread and the main thread.
|
|
|
|
virtual void SetFrameBufferLength(PRUint32 aLength) = 0;
|
2011-11-21 16:34:21 -08:00
|
|
|
|
|
|
|
// Called when a "MozAudioAvailable" event listener is added to the media
|
|
|
|
// element. Called on the main thread.
|
|
|
|
virtual void NotifyAudioAvailableListener() = 0;
|
2010-04-27 01:53:44 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsBuiltinDecoder : public nsMediaDecoder
|
|
|
|
{
|
2012-02-14 20:35:01 -08:00
|
|
|
public:
|
|
|
|
typedef mozilla::MediaChannelStatistics MediaChannelStatistics;
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2012-02-14 20:35:01 -08:00
|
|
|
NS_DECL_ISUPPORTS
|
2008-07-29 23:50:14 -07:00
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
// Enumeration for the valid play states (see mPlayState)
|
|
|
|
enum PlayState {
|
|
|
|
PLAY_STATE_START,
|
|
|
|
PLAY_STATE_LOADING,
|
|
|
|
PLAY_STATE_PAUSED,
|
|
|
|
PLAY_STATE_PLAYING,
|
|
|
|
PLAY_STATE_SEEKING,
|
|
|
|
PLAY_STATE_ENDED,
|
|
|
|
PLAY_STATE_SHUTDOWN
|
|
|
|
};
|
|
|
|
|
2010-04-27 01:53:44 -07:00
|
|
|
nsBuiltinDecoder();
|
|
|
|
~nsBuiltinDecoder();
|
2009-09-14 19:30:44 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool Init(nsHTMLMediaElement* aElement);
|
2008-10-19 00:39:21 -07:00
|
|
|
|
|
|
|
// This method must be called by the owning object before that
|
|
|
|
// object disposes of this decoder object.
|
2008-10-29 22:20:08 -07:00
|
|
|
virtual void Shutdown();
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2011-01-16 19:03:00 -08:00
|
|
|
virtual double GetCurrentTime();
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2012-02-14 20:35:01 -08:00
|
|
|
virtual nsresult Load(MediaResource* aResource,
|
2010-09-20 17:49:50 -07:00
|
|
|
nsIStreamListener** aListener,
|
|
|
|
nsMediaDecoder* aCloneDonor);
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2010-04-27 01:53:44 -07:00
|
|
|
virtual nsDecoderStateMachine* CreateStateMachine() = 0;
|
|
|
|
|
2008-07-29 23:50:14 -07:00
|
|
|
// Start playback of a video. 'Load' must have previously been
|
|
|
|
// called.
|
2008-10-29 22:20:08 -07:00
|
|
|
virtual nsresult Play();
|
2008-07-29 23:50:14 -07:00
|
|
|
|
|
|
|
// Seek to the time position in (seconds) from the start of the video.
|
2011-01-16 19:03:00 -08:00
|
|
|
virtual nsresult Seek(double aTime);
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-10-29 22:20:08 -07:00
|
|
|
virtual nsresult PlaybackRateChanged();
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-10-29 22:20:08 -07:00
|
|
|
virtual void Pause();
|
2011-01-16 19:03:00 -08:00
|
|
|
virtual void SetVolume(double aVolume);
|
2012-04-29 20:12:42 -07:00
|
|
|
virtual void SetAudioCaptured(bool aCaptured);
|
|
|
|
|
|
|
|
virtual void AddOutputStream(SourceMediaStream* aStream, bool aFinishWhenEnded);
|
|
|
|
// Protected by mReentrantMonitor. All decoder output is copied to these streams.
|
|
|
|
struct OutputMediaStream {
|
|
|
|
void Init(PRInt64 aInitialTime, SourceMediaStream* aStream, bool aFinishWhenEnded)
|
|
|
|
{
|
|
|
|
mLastAudioPacketTime = -1;
|
|
|
|
mLastAudioPacketEndTime = -1;
|
|
|
|
mAudioFramesWrittenBaseTime = aInitialTime;
|
|
|
|
mAudioFramesWritten = 0;
|
|
|
|
mNextVideoTime = aInitialTime;
|
|
|
|
mStream = aStream;
|
|
|
|
mStreamInitialized = false;
|
|
|
|
mFinishWhenEnded = aFinishWhenEnded;
|
|
|
|
mHaveSentFinish = false;
|
|
|
|
mHaveSentFinishAudio = false;
|
|
|
|
mHaveSentFinishVideo = false;
|
|
|
|
}
|
|
|
|
PRInt64 mLastAudioPacketTime; // microseconds
|
|
|
|
PRInt64 mLastAudioPacketEndTime; // microseconds
|
|
|
|
// Count of audio frames written to the stream
|
|
|
|
PRInt64 mAudioFramesWritten;
|
|
|
|
// Timestamp of the first audio packet whose frames we wrote.
|
|
|
|
PRInt64 mAudioFramesWrittenBaseTime; // microseconds
|
|
|
|
// mNextVideoTime is the end timestamp for the last packet sent to the stream.
|
|
|
|
// Therefore video packets starting at or after this time need to be copied
|
|
|
|
// to the output stream.
|
|
|
|
PRInt64 mNextVideoTime; // microseconds
|
|
|
|
// The last video image sent to the stream. Useful if we need to replicate
|
|
|
|
// the image.
|
|
|
|
nsRefPtr<Image> mLastVideoImage;
|
|
|
|
nsRefPtr<SourceMediaStream> mStream;
|
|
|
|
gfxIntSize mLastVideoImageDisplaySize;
|
|
|
|
// This is set to true when the stream is initialized (audio and
|
|
|
|
// video tracks added).
|
|
|
|
bool mStreamInitialized;
|
|
|
|
bool mFinishWhenEnded;
|
|
|
|
bool mHaveSentFinish;
|
|
|
|
bool mHaveSentFinishAudio;
|
|
|
|
bool mHaveSentFinishVideo;
|
|
|
|
};
|
|
|
|
nsTArray<OutputMediaStream>& OutputStreams()
|
|
|
|
{
|
|
|
|
GetReentrantMonitor().AssertCurrentThreadIn();
|
|
|
|
return mOutputStreams;
|
|
|
|
}
|
|
|
|
|
2011-01-16 19:03:00 -08:00
|
|
|
virtual double GetDuration();
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void SetInfinite(bool aInfinite);
|
|
|
|
virtual bool IsInfinite();
|
2011-08-01 11:11:20 -07:00
|
|
|
|
2012-02-14 20:35:01 -08:00
|
|
|
virtual MediaResource* GetResource() { return mResource; }
|
2009-03-31 17:52:56 -07:00
|
|
|
virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal();
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2009-03-31 17:52:56 -07:00
|
|
|
virtual void NotifySuspendedStatusChanged();
|
|
|
|
virtual void NotifyBytesDownloaded();
|
2009-02-05 00:02:21 -08:00
|
|
|
virtual void NotifyDownloadEnded(nsresult aStatus);
|
2012-04-29 20:12:42 -07:00
|
|
|
virtual void NotifyPrincipalChanged();
|
2010-04-01 20:03:07 -07:00
|
|
|
// Called by the decode thread to keep track of the number of bytes read
|
|
|
|
// from the resource.
|
2009-03-31 17:52:56 -07:00
|
|
|
void NotifyBytesConsumed(PRInt64 aBytes);
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
// Called when the video file has completed downloading.
|
|
|
|
// Call on the main thread only.
|
|
|
|
void ResourceLoaded();
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-11-06 12:53:20 -08:00
|
|
|
// Called if the media file encounters a network error.
|
|
|
|
// Call on the main thread only.
|
2008-11-18 00:19:32 -08:00
|
|
|
virtual void NetworkError();
|
2008-11-06 12:53:20 -08:00
|
|
|
|
2012-05-14 22:57:17 -07:00
|
|
|
// Return true if we are currently seeking in the media resource.
|
|
|
|
// Call on the main thread only.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsSeeking() const;
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// Return true if the decoder has reached the end of playback.
|
2008-12-14 10:02:54 -08:00
|
|
|
// Call on the main thread only.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsEnded() const;
|
2008-12-14 10:02:54 -08:00
|
|
|
|
2011-04-13 15:12:23 -07:00
|
|
|
// Set the duration of the media resource in units of seconds.
|
2009-02-07 02:10:34 -08:00
|
|
|
// This is called via a channel listener if it can pick up the duration
|
|
|
|
// from a content header. Must be called from the main thread only.
|
2011-04-13 15:12:23 -07:00
|
|
|
virtual void SetDuration(double aDuration);
|
2009-02-07 02:10:34 -08:00
|
|
|
|
2008-11-09 17:38:02 -08:00
|
|
|
// Set a flag indicating whether seeking is supported
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void SetSeekable(bool aSeekable);
|
2008-11-09 17:38:02 -08:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// Return true if seeking is supported.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsSeekable();
|
2011-08-09 03:10:48 -07:00
|
|
|
|
|
|
|
virtual nsresult GetSeekable(nsTimeRanges* aSeekable);
|
2008-11-09 17:38:02 -08:00
|
|
|
|
2011-08-24 16:42:23 -07:00
|
|
|
// Set the end time of the media resource. When playback reaches
|
|
|
|
// this point the media pauses. aTime is in seconds.
|
|
|
|
virtual void SetEndTime(double aTime);
|
|
|
|
|
2009-02-05 00:02:21 -08:00
|
|
|
virtual Statistics GetStatistics();
|
|
|
|
|
2009-01-21 15:54:40 -08:00
|
|
|
// Suspend any media downloads that are in progress. Called by the
|
|
|
|
// media element when it is sent to the bfcache. Call on the main
|
|
|
|
// thread only.
|
|
|
|
virtual void Suspend();
|
|
|
|
|
|
|
|
// Resume any media downloads that have been suspended. Called by the
|
|
|
|
// media element when it is restored from the bfcache. Call on the
|
|
|
|
// main thread only.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void Resume(bool aForceBuffering);
|
2009-01-21 15:54:40 -08:00
|
|
|
|
2012-02-14 20:35:01 -08:00
|
|
|
// Tells our MediaResource to put all loads in the background.
|
2009-04-09 18:28:24 -07:00
|
|
|
virtual void MoveLoadsToBackground();
|
|
|
|
|
2010-10-06 15:58:36 -07:00
|
|
|
void AudioAvailable(float* aFrameBuffer, PRUint32 aFrameBufferLength, float aTime);
|
2010-08-25 06:10:00 -07:00
|
|
|
|
2010-04-01 20:03:07 -07:00
|
|
|
// Called by the state machine to notify the decoder that the duration
|
|
|
|
// has changed.
|
|
|
|
void DurationChanged();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool OnStateMachineThread() const;
|
2010-04-27 01:53:44 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool OnDecodeThread() const {
|
2010-04-27 01:53:44 -07:00
|
|
|
return mDecoderStateMachine->OnDecodeThread();
|
|
|
|
}
|
2008-10-19 00:39:21 -07:00
|
|
|
|
|
|
|
// Returns the monitor for other threads to synchronise access to
|
2008-11-18 00:19:32 -08:00
|
|
|
// state.
|
2011-04-29 12:21:57 -07:00
|
|
|
ReentrantMonitor& GetReentrantMonitor() {
|
|
|
|
return mReentrantMonitor;
|
2008-10-19 00:39:21 -07:00
|
|
|
}
|
|
|
|
|
2010-08-05 00:40:35 -07:00
|
|
|
// Constructs the time ranges representing what segments of the media
|
|
|
|
// are buffered and playable.
|
2010-08-25 01:43:00 -07:00
|
|
|
virtual nsresult GetBuffered(nsTimeRanges* aBuffered) {
|
2011-03-23 22:04:16 -07:00
|
|
|
if (mDecoderStateMachine) {
|
|
|
|
return mDecoderStateMachine->GetBuffered(aBuffered);
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
2010-08-05 00:40:35 -07:00
|
|
|
}
|
|
|
|
|
2011-07-21 20:17:23 -07:00
|
|
|
virtual PRInt64 VideoQueueMemoryInUse() {
|
|
|
|
if (mDecoderStateMachine) {
|
|
|
|
return mDecoderStateMachine->VideoQueueMemoryInUse();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual PRInt64 AudioQueueMemoryInUse() {
|
|
|
|
if (mDecoderStateMachine) {
|
|
|
|
return mDecoderStateMachine->AudioQueueMemoryInUse();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-31 14:05:51 -08:00
|
|
|
virtual void NotifyDataArrived(const char* aBuffer, PRUint32 aLength, PRInt64 aOffset) {
|
2011-11-08 18:42:26 -08:00
|
|
|
if (mDecoderStateMachine) {
|
|
|
|
mDecoderStateMachine->NotifyDataArrived(aBuffer, aLength, aOffset);
|
|
|
|
}
|
2010-09-13 01:45:50 -07:00
|
|
|
}
|
|
|
|
|
2011-04-11 14:15:45 -07:00
|
|
|
// Sets the length of the framebuffer used in MozAudioAvailable events.
|
|
|
|
// The new size must be between 512 and 16384.
|
|
|
|
virtual nsresult RequestFrameBufferLength(PRUint32 aLength);
|
|
|
|
|
2008-11-18 00:19:32 -08:00
|
|
|
// Return the current state. Can be called on any thread. If called from
|
|
|
|
// a non-main thread, the decoder monitor must be held.
|
2010-04-01 20:03:07 -07:00
|
|
|
PlayState GetState() {
|
2008-10-19 00:39:21 -07:00
|
|
|
return mPlayState;
|
|
|
|
}
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2009-01-15 12:26:51 -08:00
|
|
|
// Stop updating the bytes downloaded for progress notifications. Called
|
|
|
|
// when seeking to prevent wild changes to the progress notification.
|
|
|
|
// Must be called with the decoder monitor held.
|
|
|
|
void StopProgressUpdates();
|
|
|
|
|
|
|
|
// Allow updating the bytes downloaded for progress notifications. Must
|
|
|
|
// be called with the decoder monitor held.
|
|
|
|
void StartProgressUpdates();
|
|
|
|
|
2009-03-31 17:52:56 -07:00
|
|
|
// Something has changed that could affect the computed playback rate,
|
|
|
|
// so recompute it. The monitor must be held.
|
|
|
|
void UpdatePlaybackRate();
|
|
|
|
|
|
|
|
// The actual playback rate computation. The monitor must be held.
|
2011-09-28 23:19:26 -07:00
|
|
|
double ComputePlaybackRate(bool* aReliable);
|
2009-03-31 17:52:56 -07:00
|
|
|
|
2010-05-05 19:31:02 -07:00
|
|
|
// Make the decoder state machine update the playback position. Called by
|
|
|
|
// the reader on the decoder thread (Assertions for this checked by
|
|
|
|
// mDecoderStateMachine). This must be called with the decode monitor
|
|
|
|
// held.
|
|
|
|
void UpdatePlaybackPosition(PRInt64 aTime)
|
|
|
|
{
|
|
|
|
mDecoderStateMachine->UpdatePlaybackPosition(aTime);
|
|
|
|
}
|
|
|
|
|
2008-07-29 23:50:14 -07:00
|
|
|
/******
|
|
|
|
* The following methods must only be called on the main
|
|
|
|
* thread.
|
|
|
|
******/
|
|
|
|
|
2008-11-18 00:19:32 -08:00
|
|
|
// Change to a new play state. This updates the mState variable and
|
|
|
|
// notifies any thread blocking on this object's monitor of the
|
|
|
|
// change. Call on the main thread only.
|
|
|
|
void ChangeState(PlayState aState);
|
|
|
|
|
2010-05-05 19:31:02 -07:00
|
|
|
// Called when the metadata from the media file has been read.
|
2008-07-29 23:50:14 -07:00
|
|
|
// Call on the main thread only.
|
2010-08-25 06:10:00 -07:00
|
|
|
void MetadataLoaded(PRUint32 aChannels,
|
2012-04-28 08:01:10 -07:00
|
|
|
PRUint32 aRate,
|
|
|
|
bool aHasAudio);
|
2008-07-29 23:50:14 -07:00
|
|
|
|
|
|
|
// Called when the first frame has been loaded.
|
|
|
|
// Call on the main thread only.
|
|
|
|
void FirstFrameLoaded();
|
|
|
|
|
|
|
|
// Called when the video has completed playing.
|
|
|
|
// Call on the main thread only.
|
2008-10-19 00:39:21 -07:00
|
|
|
void PlaybackEnded();
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
// Seeking has stopped. Inform the element on the main
|
|
|
|
// thread.
|
|
|
|
void SeekingStopped();
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2009-05-31 03:02:17 -07:00
|
|
|
// Seeking has stopped at the end of the resource. Inform the element on the main
|
|
|
|
// thread.
|
|
|
|
void SeekingStoppedAtEnd();
|
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
// Seeking has started. Inform the element on the main
|
|
|
|
// thread.
|
|
|
|
void SeekingStarted();
|
|
|
|
|
2008-10-23 01:02:18 -07:00
|
|
|
// Called when the backend has changed the current playback
|
|
|
|
// position. It dispatches a timeupdate event and invalidates the frame.
|
|
|
|
// This must be called on the main thread only.
|
|
|
|
void PlaybackPositionChanged();
|
|
|
|
|
2010-03-14 16:46:38 -07:00
|
|
|
// Calls mElement->UpdateReadyStateForData, telling it which state we have
|
|
|
|
// entered. Main thread only.
|
|
|
|
void NextFrameUnavailableBuffering();
|
|
|
|
void NextFrameAvailable();
|
|
|
|
void NextFrameUnavailable();
|
|
|
|
|
2009-02-10 17:43:45 -08:00
|
|
|
// Calls mElement->UpdateReadyStateForData, telling it whether we have
|
|
|
|
// data for the next frame and if we're buffering. Main thread only.
|
|
|
|
void UpdateReadyStateForData();
|
|
|
|
|
2009-03-31 17:52:56 -07:00
|
|
|
// Find the end of the cached data starting at the current decoder
|
|
|
|
// position.
|
|
|
|
PRInt64 GetDownloadPosition();
|
|
|
|
|
2010-04-27 01:53:45 -07:00
|
|
|
// Updates the approximate byte offset which playback has reached. This is
|
|
|
|
// used to calculate the readyState transitions.
|
|
|
|
void UpdatePlaybackOffset(PRInt64 aOffset);
|
2010-05-05 19:31:02 -07:00
|
|
|
|
|
|
|
// Provide access to the state machine object
|
|
|
|
nsDecoderStateMachine* GetStateMachine() { return mDecoderStateMachine; }
|
|
|
|
|
|
|
|
// Return the current decode state. The decoder monitor must be
|
|
|
|
// obtained before calling this.
|
|
|
|
nsDecoderStateMachine::State GetDecodeState() { return mDecoderStateMachine->GetState(); }
|
|
|
|
|
2011-09-21 00:01:00 -07:00
|
|
|
// Drop reference to state machine. Only called during shutdown dance.
|
|
|
|
void ReleaseStateMachine() { mDecoderStateMachine = nsnull; }
|
|
|
|
|
2011-11-21 16:34:21 -08:00
|
|
|
// Called when a "MozAudioAvailable" event listener is added to the media
|
|
|
|
// element. Called on the main thread.
|
|
|
|
virtual void NotifyAudioAvailableListener();
|
|
|
|
|
2009-09-21 17:08:13 -07:00
|
|
|
// Notifies the element that decoding has failed.
|
|
|
|
void DecodeError();
|
|
|
|
|
2011-07-11 20:39:34 -07:00
|
|
|
// Schedules the state machine to run one cycle on the shared state
|
|
|
|
// machine thread. Main thread only.
|
|
|
|
nsresult ScheduleStateMachineThread();
|
2011-07-11 20:39:32 -07:00
|
|
|
|
2008-07-29 23:50:14 -07:00
|
|
|
/******
|
2009-02-05 00:02:21 -08:00
|
|
|
* The following members should be accessed with the decoder lock held.
|
2008-07-29 23:50:14 -07:00
|
|
|
******/
|
2009-02-05 00:02:21 -08:00
|
|
|
|
|
|
|
// Current decoding position in the stream. This is where the decoder
|
2009-03-31 17:52:56 -07:00
|
|
|
// is up to consuming the stream. This is not adjusted during decoder
|
|
|
|
// seek operations, but it's updated at the end when we start playing
|
|
|
|
// back again.
|
2009-02-05 00:02:21 -08:00
|
|
|
PRInt64 mDecoderPosition;
|
|
|
|
// Current playback position in the stream. This is (approximately)
|
2009-03-31 17:52:56 -07:00
|
|
|
// where we're up to playing back the stream. This is not adjusted
|
|
|
|
// during decoder seek operations, but it's updated at the end when we
|
|
|
|
// start playing back again.
|
2009-02-05 00:02:21 -08:00
|
|
|
PRInt64 mPlaybackPosition;
|
|
|
|
// Data needed to estimate playback data rate. The timeline used for
|
|
|
|
// this estimate is "decode time" (where the "current time" is the
|
|
|
|
// time of the last decoded video frame).
|
2012-02-14 20:35:01 -08:00
|
|
|
MediaChannelStatistics mPlaybackStatistics;
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-10-23 01:02:18 -07:00
|
|
|
// The current playback position of the media resource in units of
|
|
|
|
// seconds. This is updated approximately at the framerate of the
|
|
|
|
// video (if it is a video) or the callback period of the audio.
|
|
|
|
// It is read and written from the main thread only.
|
2011-01-16 19:03:00 -08:00
|
|
|
double mCurrentTime;
|
2008-10-23 01:02:18 -07:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
// Volume that playback should start at. 0.0 = muted. 1.0 = full
|
2010-04-01 20:03:07 -07:00
|
|
|
// volume. Readable/Writeable from the main thread.
|
2011-01-16 19:03:00 -08:00
|
|
|
double mInitialVolume;
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
// Position to seek to when the seek notification is received by the
|
2010-04-01 20:03:07 -07:00
|
|
|
// decode thread. Written by the main thread and read via the
|
2011-04-29 12:21:57 -07:00
|
|
|
// decode thread. Synchronised using mReentrantMonitor. If the
|
2008-10-19 00:39:21 -07:00
|
|
|
// value is negative then no seek has been requested. When a seek is
|
|
|
|
// started this is reset to negative.
|
2011-01-16 19:03:00 -08:00
|
|
|
double mRequestedSeekTime;
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2008-11-09 17:38:02 -08:00
|
|
|
// Duration of the media resource. Set to -1 if unknown.
|
2010-05-05 19:31:02 -07:00
|
|
|
// Set when the metadata is loaded. Accessed on the main thread
|
2008-11-09 17:38:02 -08:00
|
|
|
// only.
|
|
|
|
PRInt64 mDuration;
|
|
|
|
|
2012-04-29 20:12:42 -07:00
|
|
|
// True when playback should start with audio captured (not playing).
|
|
|
|
bool mInitialAudioCaptured;
|
|
|
|
|
2008-11-09 17:38:02 -08:00
|
|
|
// True if the media resource is seekable (server supports byte range
|
|
|
|
// requests).
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSeekable;
|
2008-11-09 17:38:02 -08:00
|
|
|
|
2008-07-29 23:50:14 -07:00
|
|
|
/******
|
|
|
|
* The following member variables can be accessed from any thread.
|
|
|
|
******/
|
|
|
|
|
2010-04-01 20:03:07 -07:00
|
|
|
// The state machine object for handling the decoding. It is safe to
|
|
|
|
// call methods of this object from other threads. Its internal data
|
|
|
|
// is synchronised on a monitor. The lifetime of this object is
|
|
|
|
// after mPlayState is LOADING and before mPlayState is SHUTDOWN. It
|
|
|
|
// is safe to access it during this period.
|
2010-04-27 01:53:44 -07:00
|
|
|
nsCOMPtr<nsDecoderStateMachine> mDecoderStateMachine;
|
2010-04-01 20:03:07 -07:00
|
|
|
|
2012-02-14 20:35:01 -08:00
|
|
|
// Media data resource.
|
|
|
|
nsAutoPtr<MediaResource> mResource;
|
2008-07-29 23:50:14 -07:00
|
|
|
|
2011-04-29 12:21:57 -07:00
|
|
|
// ReentrantMonitor for detecting when the video play state changes. A call
|
2008-10-19 00:39:21 -07:00
|
|
|
// to Wait on this monitor will block the thread until the next
|
|
|
|
// state change.
|
2011-04-29 12:21:57 -07:00
|
|
|
ReentrantMonitor mReentrantMonitor;
|
2008-10-19 00:39:21 -07:00
|
|
|
|
2012-04-29 20:12:42 -07:00
|
|
|
// Data about MediaStreams that are being fed by this decoder.
|
|
|
|
nsTArray<OutputMediaStream> mOutputStreams;
|
|
|
|
|
2012-05-14 22:57:17 -07:00
|
|
|
// Set to one of the valid play states.
|
|
|
|
// This can only be changed on the main thread while holding the decoder
|
|
|
|
// monitor. Thus, it can be safely read while holding the decoder monitor
|
|
|
|
// OR on the main thread.
|
|
|
|
// Any change to the state on the main thread must call NotifyAll on the
|
|
|
|
// monitor so the decode thread can wake up.
|
2008-10-19 00:39:21 -07:00
|
|
|
PlayState mPlayState;
|
|
|
|
|
2012-05-14 22:57:17 -07:00
|
|
|
// The state to change to after a seek or load operation.
|
|
|
|
// This can only be changed on the main thread while holding the decoder
|
|
|
|
// monitor. Thus, it can be safely read while holding the decoder monitor
|
|
|
|
// OR on the main thread.
|
2008-11-18 00:19:32 -08:00
|
|
|
// Any change to the state must call NotifyAll on the monitor.
|
2012-05-14 22:57:23 -07:00
|
|
|
// This can only be PLAY_STATE_PAUSED or PLAY_STATE_PLAYING.
|
|
|
|
PlayState mNextState;
|
2009-01-15 12:26:51 -08:00
|
|
|
|
2009-02-05 00:02:21 -08:00
|
|
|
// True when we have fully loaded the resource and reported that
|
|
|
|
// to the element (i.e. reached NETWORK_LOADED state).
|
|
|
|
// Accessed on the main thread only.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mResourceLoaded;
|
2009-01-15 12:26:51 -08:00
|
|
|
|
|
|
|
// True when seeking or otherwise moving the play position around in
|
|
|
|
// such a manner that progress event data is inaccurate. This is set
|
2009-02-05 00:02:21 -08:00
|
|
|
// during seek and duration operations to prevent the progress indicator
|
2009-01-15 12:26:51 -08:00
|
|
|
// from jumping around. Read/Write from any thread. Must have decode monitor
|
|
|
|
// locked before accessing.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIgnoreProgressData;
|
2011-08-01 11:11:20 -07:00
|
|
|
|
2011-09-29 16:34:37 -07:00
|
|
|
// True if the stream is infinite (e.g. a webradio).
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInfiniteStream;
|
2008-07-29 23:50:14 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|