Bug 1191170 - Move DecodedStreamData from the header to its source file. r=roc.
authorJW Wang <jwwang@mozilla.com>
Sun, 19 Jul 2015 21:25:08 +0800
changeset 287943 3ae3c45db961997a182616416097a8c49c6e9742
parent 287942 f1ac9a24ab82abd6ec440b29d01ac901f01a1ad3
child 287944 6f16a41f231879b3149db607362513889964604e
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1191170
milestone42.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 1191170 - Move DecodedStreamData from the header to its source file. r=roc.
dom/media/DecodedStream.cpp
dom/media/DecodedStream.h
--- a/dom/media/DecodedStream.cpp
+++ b/dom/media/DecodedStream.cpp
@@ -82,16 +82,62 @@ UpdateStreamBlocking(MediaStream* aStrea
     aStream->ChangeExplicitBlockerCount(delta);
   } else {
     nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<int32_t>(
       aStream, &MediaStream::ChangeExplicitBlockerCount, delta);
     AbstractThread::MainThread()->Dispatch(r.forget());
   }
 }
 
+/*
+ * All MediaStream-related data is protected by the decoder's monitor.
+ * We have at most one DecodedStreamDaata per MediaDecoder. Its stream
+ * is used as the input for each ProcessedMediaStream created by calls to
+ * captureStream(UntilEnded). Seeking creates a new source stream, as does
+ * replaying after the input as ended. In the latter case, the new source is
+ * not connected to streams created by captureStreamUntilEnded.
+ */
+class DecodedStreamData {
+public:
+  DecodedStreamData(SourceMediaStream* aStream, bool aPlaying);
+  ~DecodedStreamData();
+  bool IsFinished() const;
+  int64_t GetPosition() const;
+  void SetPlaying(bool aPlaying);
+
+  /* The following group of fields are protected by the decoder's monitor
+   * and can be read or written on any thread.
+   */
+  // Count of audio frames written to the stream
+  int64_t mAudioFramesWritten;
+  // 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.
+  int64_t mNextVideoTime; // microseconds
+  int64_t mNextAudioTime; // microseconds
+  // The last video image sent to the stream. Useful if we need to replicate
+  // the image.
+  nsRefPtr<layers::Image> mLastVideoImage;
+  gfx::IntSize mLastVideoImageDisplaySize;
+  // This is set to true when the stream is initialized (audio and
+  // video tracks added).
+  bool mStreamInitialized;
+  bool mHaveSentFinish;
+  bool mHaveSentFinishAudio;
+  bool mHaveSentFinishVideo;
+
+  // The decoder is responsible for calling Destroy() on this stream.
+  const nsRefPtr<SourceMediaStream> mStream;
+  nsRefPtr<DecodedStreamGraphListener> mListener;
+  bool mPlaying;
+  // True if we need to send a compensation video frame to ensure the
+  // StreamTime going forward.
+  bool mEOSVideoCompensation;
+};
+
 DecodedStreamData::DecodedStreamData(SourceMediaStream* aStream, bool aPlaying)
   : mAudioFramesWritten(0)
   , mNextVideoTime(-1)
   , mNextAudioTime(-1)
   , mStreamInitialized(false)
   , mHaveSentFinish(false)
   , mHaveSentFinishAudio(false)
   , mHaveSentFinishVideo(false)
@@ -186,17 +232,20 @@ OutputStreamData::Init(DecodedStream* aD
 
 DecodedStream::DecodedStream(MediaQueue<MediaData>& aAudioQueue,
                              MediaQueue<MediaData>& aVideoQueue)
   : mMonitor("DecodedStream::mMonitor")
   , mPlaying(false)
   , mAudioQueue(aAudioQueue)
   , mVideoQueue(aVideoQueue)
 {
-  //
+}
+
+DecodedStream::~DecodedStream()
+{
 }
 
 void
 DecodedStream::StartPlayback(int64_t aStartTime, const MediaInfo& aInfo)
 {
   ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
   if (mStartTime.isNothing()) {
     mStartTime.emplace(aStartTime);
--- a/dom/media/DecodedStream.h
+++ b/dom/media/DecodedStream.h
@@ -2,92 +2,44 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #ifndef DecodedStream_h_
 #define DecodedStream_h_
 
-#include "mozilla/nsRefPtr.h"
 #include "nsTArray.h"
 #include "MediaInfo.h"
 
+#include "mozilla/CheckedInt.h"
+#include "mozilla/Maybe.h"
+#include "mozilla/nsRefPtr.h"
+#include "mozilla/ReentrantMonitor.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/gfx/Point.h"
-#include "mozilla/CheckedInt.h"
-#include "mozilla/ReentrantMonitor.h"
-#include "mozilla/Maybe.h"
 
 namespace mozilla {
 
+class DecodedStream;
+class DecodedStreamData;
 class MediaData;
-class AudioSegment;
+class MediaInputPort;
 class MediaStream;
-class MediaInputPort;
-class SourceMediaStream;
+class MediaStreamGraph;
+class OutputStreamListener;
 class ProcessedMediaStream;
-class DecodedStream;
-class DecodedStreamGraphListener;
-class OutputStreamListener;
 class ReentrantMonitor;
-class MediaStreamGraph;
 
 template <class T> class MediaQueue;
 
 namespace layers {
 class Image;
 } // namespace layers
 
-/*
- * All MediaStream-related data is protected by the decoder's monitor.
- * We have at most one DecodedStreamDaata per MediaDecoder. Its stream
- * is used as the input for each ProcessedMediaStream created by calls to
- * captureStream(UntilEnded). Seeking creates a new source stream, as does
- * replaying after the input as ended. In the latter case, the new source is
- * not connected to streams created by captureStreamUntilEnded.
- */
-class DecodedStreamData {
-public:
-  DecodedStreamData(SourceMediaStream* aStream, bool aPlaying);
-  ~DecodedStreamData();
-  bool IsFinished() const;
-  int64_t GetPosition() const;
-  void SetPlaying(bool aPlaying);
-
-  /* The following group of fields are protected by the decoder's monitor
-   * and can be read or written on any thread.
-   */
-  // Count of audio frames written to the stream
-  int64_t mAudioFramesWritten;
-  // 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.
-  int64_t mNextVideoTime; // microseconds
-  int64_t mNextAudioTime; // microseconds
-  // The last video image sent to the stream. Useful if we need to replicate
-  // the image.
-  nsRefPtr<layers::Image> mLastVideoImage;
-  gfx::IntSize mLastVideoImageDisplaySize;
-  // This is set to true when the stream is initialized (audio and
-  // video tracks added).
-  bool mStreamInitialized;
-  bool mHaveSentFinish;
-  bool mHaveSentFinishAudio;
-  bool mHaveSentFinishVideo;
-
-  // The decoder is responsible for calling Destroy() on this stream.
-  const nsRefPtr<SourceMediaStream> mStream;
-  nsRefPtr<DecodedStreamGraphListener> mListener;
-  bool mPlaying;
-  // True if we need to send a compensation video frame to ensure the
-  // StreamTime going forward.
-  bool mEOSVideoCompensation;
-};
-
 class OutputStreamData {
 public:
   ~OutputStreamData();
   void Init(DecodedStream* aDecodedStream, ProcessedMediaStream* aStream);
   nsRefPtr<ProcessedMediaStream> mStream;
   // mPort connects DecodedStreamData::mStream to our mStream.
   nsRefPtr<MediaInputPort> mPort;
   nsRefPtr<OutputStreamListener> mListener;
@@ -114,17 +66,17 @@ public:
   int64_t GetPosition() const;
   bool IsFinished() const;
   bool HasConsumers() const;
 
   // Return true if stream is finished.
   bool SendData(double aVolume, bool aIsSameOrigin);
 
 protected:
-  virtual ~DecodedStream() {}
+  virtual ~DecodedStream();
 
 private:
   ReentrantMonitor& GetReentrantMonitor() const;
   void RecreateData(MediaStreamGraph* aGraph);
   void Connect(OutputStreamData* aStream);
   nsTArray<OutputStreamData>& OutputStreams();
   void InitTracks();
   void AdvanceTracks();