Bug 1171311: P4. Don't compute start time for MSE. r=cpearce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 12 Jun 2015 09:26:58 +1000
changeset 279304 b5915eff97e52b822ea280769bd683888e572370
parent 279303 e2b05400738d30abc1496cf4b7711446c4ceafac
child 279305 34d1dedc56c42d4374f759f44eb380262a887d0e
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1171311
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1171311: P4. Don't compute start time for MSE. r=cpearce It is assumed per spec that it's 0. Extra: remove redundant virtual keywords.
dom/media/MediaDataDemuxer.h
dom/media/MediaFormatReader.cpp
dom/media/MediaFormatReader.h
dom/media/mediasource/MediaSourceDemuxer.h
--- a/dom/media/MediaDataDemuxer.h
+++ b/dom/media/MediaDataDemuxer.h
@@ -94,16 +94,21 @@ public:
   virtual void NotifyDataArrived(uint32_t aLength, int64_t aOffset) { }
 
   // Notifies the demuxer that the underlying resource has had data removed.
   // The demuxer can use this mechanism to inform all track demuxers to update
   // its TimeIntervals.
   // This will be called should the demuxer be used with MediaSource.
   virtual void NotifyDataRemoved() { }
 
+  // Indicate to MediaFormatReader if it should compute the start time
+  // of the demuxed data. If true (default) the first sample returned will be
+  // used as reference time base.
+  virtual bool ShouldComputeStartTime() const { return true; }
+
 protected:
   virtual ~MediaDataDemuxer()
   {
   }
 };
 
 class MediaTrackDemuxer
 {
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1464,9 +1464,18 @@ MediaFormatReader::NotifyDataRemoved()
   // Queue a task to notify our main demuxer.
   RefPtr<nsIRunnable> task =
     NS_NewRunnableMethodWithArgs<int32_t, uint64_t>(
       this, &MediaFormatReader::NotifyDemuxer,
       0, 0);
   TaskQueue()->Dispatch(task.forget());
 }
 
+int64_t
+MediaFormatReader::ComputeStartTime(const VideoData* aVideo, const AudioData* aAudio)
+{
+  if (mDemuxer->ShouldComputeStartTime()) {
+    return MediaDecoderReader::ComputeStartTime(aVideo, aAudio);
+  }
+  return 0;
+}
+
 } // namespace mozilla
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -30,77 +30,79 @@ class MediaFormatReader final : public M
 
 public:
   explicit MediaFormatReader(AbstractMediaDecoder* aDecoder,
                              MediaDataDemuxer* aDemuxer,
                              MediaTaskQueue* aBorrowedTaskQueue = nullptr);
 
   virtual ~MediaFormatReader();
 
-  virtual nsresult Init(MediaDecoderReader* aCloneDonor) override;
+  nsresult Init(MediaDecoderReader* aCloneDonor) override;
 
-  virtual size_t SizeOfVideoQueueInFrames() override;
-  virtual size_t SizeOfAudioQueueInFrames() override;
+  size_t SizeOfVideoQueueInFrames() override;
+  size_t SizeOfAudioQueueInFrames() override;
 
-  virtual nsRefPtr<VideoDataPromise>
+  nsRefPtr<VideoDataPromise>
   RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold) override;
 
-  virtual nsRefPtr<AudioDataPromise> RequestAudioData() override;
+  nsRefPtr<AudioDataPromise> RequestAudioData() override;
 
   bool HasVideo() override
   {
     return mInfo.HasVideo();
   }
 
   bool HasAudio() override
   {
     return mInfo.HasAudio();
   }
 
-  virtual nsRefPtr<MetadataPromise> AsyncReadMetadata() override;
+  nsRefPtr<MetadataPromise> AsyncReadMetadata() override;
 
-  virtual void ReadUpdatedMetadata(MediaInfo* aInfo) override;
+  void ReadUpdatedMetadata(MediaInfo* aInfo) override;
 
-  virtual nsRefPtr<SeekPromise>
+  nsRefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aUnused) override;
 
-  virtual bool IsMediaSeekable() override
+  bool IsMediaSeekable() override
   {
     return mSeekable;
   }
 
-  virtual int64_t GetEvictionOffset(double aTime) override;
-  virtual void NotifyDataArrived(const char* aBuffer,
+  int64_t GetEvictionOffset(double aTime) override;
+  void NotifyDataArrived(const char* aBuffer,
                                  uint32_t aLength,
                                  int64_t aOffset) override;
-  virtual void NotifyDataRemoved() override;
+  void NotifyDataRemoved() override;
 
-  virtual media::TimeIntervals GetBuffered() override;
+  media::TimeIntervals GetBuffered() override;
 
   // For Media Resource Management
-  virtual void SetIdle() override;
-  virtual bool IsDormantNeeded() override;
-  virtual void ReleaseMediaResources() override;
-  virtual void SetSharedDecoderManager(SharedDecoderManager* aManager)
+  void SetIdle() override;
+  bool IsDormantNeeded() override;
+  void ReleaseMediaResources() override;
+  void SetSharedDecoderManager(SharedDecoderManager* aManager)
     override;
 
-  virtual nsresult ResetDecode() override;
+  nsresult ResetDecode() override;
+
+  nsRefPtr<ShutdownPromise> Shutdown() override;
 
-  virtual nsRefPtr<ShutdownPromise> Shutdown() override;
+  bool IsAsync() const override { return true; }
 
-  virtual bool IsAsync() const override { return true; }
+  bool VideoIsHardwareAccelerated() const override;
 
-  virtual bool VideoIsHardwareAccelerated() const override;
-
-  virtual void DisableHardwareAcceleration() override;
+  void DisableHardwareAcceleration() override;
 
-  virtual bool IsWaitForDataSupported() override { return true; }
-  virtual nsRefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType) override;
+  bool IsWaitForDataSupported() override { return true; }
+  nsRefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType) override;
 
-  virtual bool IsWaitingOnCDMResource() override;
+  bool IsWaitingOnCDMResource() override;
+
+  int64_t ComputeStartTime(const VideoData* aVideo, const AudioData* aAudio) override;
 
 private:
   bool InitDemuxer();
   // Notify the demuxer that new data has been received.
   // The next queued task calling GetBuffered() is guaranteed to have up to date
   // buffered ranges.
   void NotifyDemuxer(uint32_t aLength, int64_t aOffset);
   void ReturnOutput(MediaData* aData, TrackType aTrack);
@@ -149,32 +151,32 @@ private:
 
   class DecoderCallback : public MediaDataDecoderCallback {
   public:
     DecoderCallback(MediaFormatReader* aReader, TrackType aType)
       : mReader(aReader)
       , mType(aType)
     {
     }
-    virtual void Output(MediaData* aSample) override {
+    void Output(MediaData* aSample) override {
       mReader->Output(mType, aSample);
     }
-    virtual void InputExhausted() override {
+    void InputExhausted() override {
       mReader->InputExhausted(mType);
     }
-    virtual void Error() override {
+    void Error() override {
       mReader->Error(mType);
     }
-    virtual void DrainComplete() override {
+    void DrainComplete() override {
       mReader->DrainComplete(mType);
     }
-    virtual void ReleaseMediaResources() override {
+    void ReleaseMediaResources() override {
       mReader->ReleaseMediaResources();
     }
-    virtual bool OnReaderTaskQueue() override {
+    bool OnReaderTaskQueue() override {
       return mReader->OnTaskQueue();
     }
 
   private:
     MediaFormatReader* mReader;
     TrackType mType;
   };
 
--- a/dom/media/mediasource/MediaSourceDemuxer.h
+++ b/dom/media/mediasource/MediaSourceDemuxer.h
@@ -42,16 +42,18 @@ public:
 
   already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(TrackInfo::TrackType aType,
                                                               uint32_t aTrackNumber) override;
 
   bool IsSeekable() const override;
 
   UniquePtr<EncryptionInfo> GetCrypto() override;
 
+  bool ShouldComputeStartTime() const override { return false; }
+
   /* interface for TrackBuffersManager */
   void AttachSourceBuffer(TrackBuffersManager* aSourceBuffer);
   void DetachSourceBuffer(TrackBuffersManager* aSourceBuffer);
   MediaTaskQueue* GetTaskQueue() { return mTaskQueue; }
   void NotifyTimeRangesChanged();
 
 private:
   ~MediaSourceDemuxer();