Bug 1319992: P2. Update MediaDecoderReader documentation. r?jwwang draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 30 Nov 2016 01:23:38 +1100
changeset 450146 be093af60ee57ad5c06bb09d3cc0e6e8de7ceb7e
parent 450145 c90473540c936a17e75e02a8b0c9cb7090f400d3
child 450147 6c7d3e6271c5d40116f02b971b0a9fa1b88b4348
push id38763
push userbmo:jyavenard@mozilla.com
push dateFri, 16 Dec 2016 02:12:02 +0000
reviewersjwwang
bugs1319992
milestone53.0a1
Bug 1319992: P2. Update MediaDecoderReader documentation. r?jwwang Remove all no longer relevant information. MozReview-Commit-ID: 89HB0Pk1XoI
dom/media/MediaDecoderReader.h
--- 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;