Bug 1319992: P2. Update MediaDecoderReader documentation. r=jwwang
Remove all no longer relevant information.
MozReview-Commit-ID: 89HB0Pk1XoI
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -49,17 +49,17 @@ public:
private:
virtual ~MetadataHolder() {}
};
// Encapsulates the decoding and reading of media data. Reading can either
// synchronous and done on the calling "decode" thread, or asynchronous and
// performed on a background thread, with the result being returned by
-// callback. Never hold the decoder monitor when calling into this class.
+// callback.
// Unless otherwise specified, methods and fields of this class can only
// be accessed on the decode task queue.
class MediaDecoderReader {
friend class ReRequestVideoWithSkipTask;
friend class ReRequestAudioTask;
static const bool IsExclusive = true;
@@ -109,37 +109,29 @@ public:
// Cancels all pending Request*Data() request callbacks, rejects any
// outstanding seek promises, and flushes the decode pipeline. The
// decoder must not call any of the callbacks for outstanding
// Request*Data() calls after this is called. Calls to Request*Data()
// made after this should be processed as usual.
//
// Normally this call preceedes a Seek() call, or shutdown.
//
- // The first samples of every stream produced after a ResetDecode() call
- // *must* be marked as "discontinuities". If it's not, seeking work won't
- // properly!
- //
// aParam is a set of TrackInfo::TrackType enums specifying which
// queues need to be reset, defaulting to both audio and video tracks.
virtual nsresult ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
TrackInfo::kVideoTrack));
// Requests one audio sample from the reader.
//
// The decode should be performed asynchronously, and the promise should
- // be resolved when it is complete. Don't hold the decoder
- // monitor while calling this, as the implementation may try to wait
- // on something that needs the monitor and deadlock.
+ // be resolved when it is complete.
virtual RefPtr<MediaDataPromise> RequestAudioData();
// Requests one video sample from the reader.
//
- // Don't hold the decoder monitor while calling this, as the implementation
- // may try to wait on something that needs the monitor and deadlock.
// If aSkipToKeyframe is true, the decode should skip ahead to the
// the next keyframe at or after aTimeThreshold microseconds.
virtual RefPtr<MediaDataPromise>
RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold);
// By default, the state machine polls the reader once per second when it's
// in buffering mode. Some readers support a promise-based mechanism by which
// they notify the state machine when the data arrives.
@@ -189,16 +181,18 @@ public:
// Returns the number of bytes of memory allocated by structures/frames in
// the audio queue.
size_t SizeOfAudioQueueInBytes() const;
virtual size_t SizeOfVideoQueueInFrames();
virtual size_t SizeOfAudioQueueInFrames();
+ // Called once new data has been cached by the MediaResource.
+ // mBuffered should be recalculated and updated accordingly.
virtual void NotifyDataArrived()
{
MOZ_ASSERT(OnTaskQueue());
NS_ENSURE_TRUE_VOID(!mShutdown);
UpdateBuffered();
}
virtual MediaQueue<AudioData>& AudioQueue() { return mAudioQueue; }
@@ -340,32 +334,23 @@ private:
// (unless they're not keyframes and aKeyframeSkip is true), but will
// not be added to the queue. This function blocks until the decode
// is complete.
virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold)
{
return false;
}
- // Populates aBuffered with the time ranges which are buffered. This may only
- // be called on the decode task queue, and should only be used internally by
- // UpdateBuffered - mBuffered (or mirrors of it) should be used for everything
- // else.
+ // GetBuffered estimates the time ranges buffered by interpolating the cached
+ // byte ranges with the duration of the media. Reader subclasses should
+ // override this method if they can quickly calculate the buffered ranges more
+ // accurately.
//
- // This base implementation in MediaDecoderReader estimates the time ranges
- // buffered by interpolating the cached byte ranges with the duration
- // of the media. Reader subclasses should override this method if they
- // can quickly calculate the buffered ranges more accurately.
- //
- // The primary advantage of this implementation in the reader base class
- // is that it's a fast approximation, which does not perform any I/O.
- //
- // The OggReader relies on this base implementation not performing I/O,
- // since in FirefoxOS we can't do I/O on the main thread, where this is
- // called.
+ // The primary advantage of this implementation in the reader base class is
+ // that it's a fast approximation, which does not perform any I/O.
media::TimeIntervals GetBuffered();
// Promises used only for the base-class (sync->async adapter) implementation
// of Request{Audio,Video}Data.
MozPromiseHolder<MediaDataPromise> mBaseAudioPromise;
MozPromiseHolder<MediaDataPromise> mBaseVideoPromise;
MediaEventListener mDataArrivedListener;