Bug 1233650. Part 3 - move creation of OutputStreamManager from DecodedStream to MDSM. r=roc.
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -10,20 +10,21 @@
#include "mmsystem.h"
#endif
#include <algorithm>
#include <stdint.h>
#include "gfx2DGlue.h"
+#include "mediasink/AudioSinkWrapper.h"
#include "mediasink/DecodedAudioDataSink.h"
-#include "mediasink/AudioSinkWrapper.h"
+#include "mediasink/DecodedStream.h"
+#include "mediasink/OutputStreamManager.h"
#include "mediasink/VideoSink.h"
-#include "mediasink/DecodedStream.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Logging.h"
#include "mozilla/mozalloc.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Preferences.h"
#include "mozilla/SharedThreadPool.h"
#include "mozilla/TaskQueue.h"
@@ -234,17 +235,19 @@ MediaDecoderStateMachine::MediaDecoderSt
mDropVideoUntilNextDiscontinuity(false),
mDecodeToSeekTarget(false),
mCurrentTimeBeforeSeek(0),
mCorruptFrames(60),
mDecodingFirstFrame(true),
mSentLoadedMetadataEvent(false),
mSentFirstFrameLoadedEvent(false, "MediaDecoderStateMachine::mSentFirstFrameLoadedEvent"),
mSentPlaybackEndedEvent(false),
- mStreamSink(new DecodedStream(mTaskQueue, mAudioQueue, mVideoQueue)),
+ mOutputStreamManager(new OutputStreamManager()),
+ mStreamSink(new DecodedStream(
+ mTaskQueue, mAudioQueue, mVideoQueue, mOutputStreamManager)),
mResource(aDecoder->GetResource()),
mAudioOffloading(false),
mBuffered(mTaskQueue, TimeIntervals(),
"MediaDecoderStateMachine::mBuffered (Mirror)"),
mEstimatedDuration(mTaskQueue, NullableTimeUnit(),
"MediaDecoderStateMachine::mEstimatedDuration (Mirror)"),
mExplicitDuration(mTaskQueue, Maybe<double>(),
"MediaDecoderStateMachine::mExplicitDuration (Mirror)"),
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -100,16 +100,17 @@ hardware (via AudioStream).
namespace mozilla {
namespace media {
class MediaSink;
}
class AudioSegment;
class DecodedStream;
+class OutputStreamManager;
class TaskQueue;
extern LazyLogModule gMediaDecoderLog;
extern LazyLogModule gMediaSampleLog;
enum class MediaEventType : int8_t {
PlaybackStarted,
PlaybackStopped,
@@ -1181,16 +1182,19 @@ private:
// FirstFrameLoadedEvent was already sent, then we can skip
// SetStartTime because the mStartTime already set before. Also we don't need
// to decode any audio/video since the MediaDecoder will trigger a seek
// operation soon.
Watchable<bool> mSentFirstFrameLoadedEvent;
bool mSentPlaybackEndedEvent;
+ // Data about MediaStreams that are being fed by the decoder.
+ const RefPtr<OutputStreamManager> mOutputStreamManager;
+
// The SourceMediaStream we are using to feed the mOutputStreams. This stream
// is never exposed outside the decoder.
// Only written on the main thread while holding the monitor. Therefore it
// can be read on any thread while holding the monitor, or on the main thread
// without holding the monitor.
RefPtr<DecodedStream> mStreamSink;
// Media data resource from the decoder.
--- a/dom/media/mediasink/DecodedStream.cpp
+++ b/dom/media/mediasink/DecodedStream.cpp
@@ -182,19 +182,20 @@ DecodedStreamData::SetPlaying(bool aPlay
if (mPlaying != aPlaying) {
mPlaying = aPlaying;
UpdateStreamSuspended(mStream, !mPlaying);
}
}
DecodedStream::DecodedStream(AbstractThread* aOwnerThread,
MediaQueue<MediaData>& aAudioQueue,
- MediaQueue<MediaData>& aVideoQueue)
+ MediaQueue<MediaData>& aVideoQueue,
+ OutputStreamManager* aOutputStreamManager)
: mOwnerThread(aOwnerThread)
- , mOutputStreamManager(new OutputStreamManager())
+ , mOutputStreamManager(aOutputStreamManager)
, mPlaying(false)
, mSameOrigin(false)
, mAudioQueue(aAudioQueue)
, mVideoQueue(aVideoQueue)
{
}
DecodedStream::~DecodedStream()
--- a/dom/media/mediasink/DecodedStream.h
+++ b/dom/media/mediasink/DecodedStream.h
@@ -29,17 +29,18 @@ class TimeStamp;
template <class T> class MediaQueue;
class DecodedStream : public media::MediaSink {
using media::MediaSink::PlaybackParams;
public:
DecodedStream(AbstractThread* aOwnerThread,
MediaQueue<MediaData>& aAudioQueue,
- MediaQueue<MediaData>& aVideoQueue);
+ MediaQueue<MediaData>& aVideoQueue,
+ OutputStreamManager* aOutputStreamManager);
// MediaSink functions.
const PlaybackParams& GetPlaybackParams() const override;
void SetPlaybackParams(const PlaybackParams& aParams) override;
RefPtr<GenericPromise> OnEnded(TrackType aType) override;
int64_t GetEndTime(TrackType aType) const override;
int64_t GetPosition(TimeStamp* aTimeStamp = nullptr) const override;