Backed out changeset 263cc3ad83c2 (bug 1201363)

This commit is contained in:
Sebastian Hengst 2016-08-03 19:33:25 +02:00
Родитель 1fe0a1cfb8
Коммит 70a5dca1bd
5 изменённых файлов: 44 добавлений и 73 удалений

Просмотреть файл

@ -60,18 +60,18 @@ CameraPreviewMediaStream::RemoveAudioOutput(void* aKey)
}
void
CameraPreviewMediaStream::AddVideoOutput(MediaStreamVideoSink* aSink, TrackID aID)
CameraPreviewMediaStream::AddVideoOutput(MediaStreamVideoSink* aSink)
{
MutexAutoLock lock(mMutex);
RefPtr<MediaStreamVideoSink> sink = aSink;
AddVideoOutputImpl(sink.forget(), aID);
AddVideoOutputImpl(sink.forget());
}
void
CameraPreviewMediaStream::RemoveVideoOutput(MediaStreamVideoSink* aSink, TrackID aID)
CameraPreviewMediaStream::RemoveVideoOutput(MediaStreamVideoSink* aSink)
{
MutexAutoLock lock(mMutex);
RemoveVideoOutputImpl(aSink, aID);
RemoveVideoOutputImpl(aSink);
}
void
@ -126,8 +126,8 @@ CameraPreviewMediaStream::Invalidate()
{
MutexAutoLock lock(mMutex);
--mInvalidatePending;
for (const TrackBound<MediaStreamVideoSink>& sink : mVideoOutputs) {
VideoFrameContainer* output = sink.mListener->AsVideoFrameContainer();
for (MediaStreamVideoSink* sink : mVideoOutputs) {
VideoFrameContainer* output = sink->AsVideoFrameContainer();
if (!output) {
continue;
}
@ -168,8 +168,8 @@ CameraPreviewMediaStream::SetCurrentFrame(const gfx::IntSize& aIntrinsicSize, Im
mDiscardedFrames = 0;
TimeStamp now = TimeStamp::Now();
for (const TrackBound<MediaStreamVideoSink>& sink : mVideoOutputs) {
VideoFrameContainer* output = sink.mListener->AsVideoFrameContainer();
for (MediaStreamVideoSink* sink : mVideoOutputs) {
VideoFrameContainer* output = sink->AsVideoFrameContainer();
if (!output) {
continue;
}
@ -187,8 +187,8 @@ CameraPreviewMediaStream::ClearCurrentFrame()
{
MutexAutoLock lock(mMutex);
for (const TrackBound<MediaStreamVideoSink>& sink : mVideoOutputs) {
VideoFrameContainer* output = sink.mListener->AsVideoFrameContainer();
for (MediaStreamVideoSink* sink : mVideoOutputs) {
VideoFrameContainer* output = sink->AsVideoFrameContainer();
if (!output) {
continue;
}

Просмотреть файл

@ -43,16 +43,16 @@ class CameraPreviewMediaStream : public ProcessedMediaStream
public:
CameraPreviewMediaStream();
void AddAudioOutput(void* aKey) override;
void SetAudioOutputVolume(void* aKey, float aVolume) override;
void RemoveAudioOutput(void* aKey) override;
void AddVideoOutput(MediaStreamVideoSink* aSink, TrackID aID) override;
void RemoveVideoOutput(MediaStreamVideoSink* aSink, TrackID aID) override;
void Suspend() override {}
void Resume() override {}
void AddListener(MediaStreamListener* aListener) override;
void RemoveListener(MediaStreamListener* aListener) override;
void Destroy() override;
virtual void AddAudioOutput(void* aKey) override;
virtual void SetAudioOutputVolume(void* aKey, float aVolume) override;
virtual void RemoveAudioOutput(void* aKey) override;
virtual void AddVideoOutput(MediaStreamVideoSink* aSink) override;
virtual void RemoveVideoOutput(MediaStreamVideoSink* aSink) override;
virtual void Suspend() override {}
virtual void Resume() override {}
virtual void AddListener(MediaStreamListener* aListener) override;
virtual void RemoveListener(MediaStreamListener* aListener) override;
virtual void Destroy() override;
void OnPreviewStateChange(bool aActive);
void Invalidate();

Просмотреть файл

@ -1025,10 +1025,10 @@ MediaStreamGraphImpl::PlayVideo(MediaStream* aStream)
// "Call MediaStreamVideoSink::setCurrentFrames in SourceMediaStream::AppendToTrack."
// of this bug.
// This is a temp workaround to pass the build and test.
if (!aStream->mVideoOutputs[0].mListener->AsVideoFrameContainer()) {
if (!aStream->mVideoOutputs[0]->AsVideoFrameContainer()) {
return;
}
blackImage = aStream->mVideoOutputs[0].mListener->AsVideoFrameContainer()->
blackImage = aStream->mVideoOutputs[0]->AsVideoFrameContainer()->
GetImageContainer()->CreatePlanarYCbCrImage();
if (blackImage) {
// Sets the image to a single black pixel, which will be scaled to
@ -1053,8 +1053,8 @@ MediaStreamGraphImpl::PlayVideo(MediaStream* aStream)
AutoTArray<ImageContainer::NonOwningImage,4> images;
bool haveMultipleImages = false;
for (const TrackBound<MediaStreamVideoSink>& sink : aStream->mVideoOutputs) {
VideoFrameContainer* output = sink.mListener->AsVideoFrameContainer();
for (MediaStreamVideoSink* sink : aStream->mVideoOutputs) {
VideoFrameContainer* output = sink->AsVideoFrameContainer();
if (!output) {
continue;
}
@ -2271,76 +2271,55 @@ MediaStream::RemoveAudioOutput(void* aKey)
}
void
MediaStream::AddVideoOutputImpl(already_AddRefed<MediaStreamVideoSink> aSink,
TrackID aID)
MediaStream::AddVideoOutputImpl(already_AddRefed<MediaStreamVideoSink> aSink)
{
RefPtr<MediaStreamVideoSink> sink = aSink;
STREAM_LOG(LogLevel::Info, ("MediaStream %p Adding MediaStreamVideoSink %p as output",
this, sink.get()));
MOZ_ASSERT(aID != TRACK_NONE);
for (auto entry : mVideoOutputs) {
if (entry.mListener == sink &&
(entry.mTrackID == TRACK_ANY || entry.mTrackID == aID)) {
return;
}
}
TrackBound<MediaStreamVideoSink>* l = mVideoOutputs.AppendElement();
l->mListener = sink;
l->mTrackID = aID;
*mVideoOutputs.AppendElement() = sink.forget();
}
void
MediaStream::RemoveVideoOutputImpl(MediaStreamVideoSink* aSink,
TrackID aID)
MediaStream::RemoveVideoOutputImpl(MediaStreamVideoSink* aSink)
{
STREAM_LOG(LogLevel::Info, ("MediaStream %p Removing MediaStreamVideoSink %p as output",
this, aSink));
MOZ_ASSERT(aID != TRACK_NONE);
// Ensure that any frames currently queued for playback by the compositor
// are removed.
aSink->ClearFrames();
for (size_t i = 0; i < mVideoOutputs.Length(); ++i) {
if (mVideoOutputs[i].mListener == aSink &&
(mVideoOutputs[i].mTrackID == TRACK_ANY ||
mVideoOutputs[i].mTrackID == aID)) {
mVideoOutputs.RemoveElementAt(i);
}
}
mVideoOutputs.RemoveElement(aSink);
}
void
MediaStream::AddVideoOutput(MediaStreamVideoSink* aSink, TrackID aID)
MediaStream::AddVideoOutput(MediaStreamVideoSink* aSink)
{
class Message : public ControlMessage {
public:
Message(MediaStream* aStream, MediaStreamVideoSink* aSink, TrackID aID) :
ControlMessage(aStream), mSink(aSink), mID(aID) {}
Message(MediaStream* aStream, MediaStreamVideoSink* aSink) :
ControlMessage(aStream), mSink(aSink) {}
void Run() override
{
mStream->AddVideoOutputImpl(mSink.forget(), mID);
mStream->AddVideoOutputImpl(mSink.forget());
}
RefPtr<MediaStreamVideoSink> mSink;
TrackID mID;
};
GraphImpl()->AppendMessage(MakeUnique<Message>(this, aSink, aID));
GraphImpl()->AppendMessage(MakeUnique<Message>(this, aSink));
}
void
MediaStream::RemoveVideoOutput(MediaStreamVideoSink* aSink, TrackID aID)
MediaStream::RemoveVideoOutput(MediaStreamVideoSink* aSink)
{
class Message : public ControlMessage {
public:
Message(MediaStream* aStream, MediaStreamVideoSink* aSink, TrackID aID) :
ControlMessage(aStream), mSink(aSink), mID(aID) {}
Message(MediaStream* aStream, MediaStreamVideoSink* aSink) :
ControlMessage(aStream), mSink(aSink) {}
void Run() override
{
mStream->RemoveVideoOutputImpl(mSink, mID);
mStream->RemoveVideoOutputImpl(mSink);
}
RefPtr<MediaStreamVideoSink> mSink;
TrackID mID;
};
GraphImpl()->AppendMessage(MakeUnique<Message>(this, aSink, aID));
GraphImpl()->AppendMessage(MakeUnique<Message>(this, aSink));
}
void

Просмотреть файл

@ -17,6 +17,7 @@
#include "nsIRunnable.h"
#include "VideoSegment.h"
#include "StreamTracks.h"
#include "MediaStreamVideoSink.h"
#include "MainThreadUtils.h"
#include "StreamTracks.h"
#include "nsAutoPtr.h"
@ -166,10 +167,8 @@ class MediaInputPort;
class MediaStreamGraphImpl;
class MediaStreamListener;
class MediaStreamTrackListener;
class MediaStreamVideoSink;
class ProcessedMediaStream;
class SourceMediaStream;
class TrackUnionStream;
enum MediaStreamGraphEvent : uint32_t;
enum TrackEventCommand : uint32_t;
@ -295,10 +294,8 @@ public:
// Since a stream can be played multiple ways, we need to be able to
// play to multiple MediaStreamVideoSinks.
// Only the first enabled video track is played.
virtual void AddVideoOutput(MediaStreamVideoSink* aSink,
TrackID aID = TRACK_ANY);
virtual void RemoveVideoOutput(MediaStreamVideoSink* aSink,
TrackID aID = TRACK_ANY);
virtual void AddVideoOutput(MediaStreamVideoSink* aSink);
virtual void RemoveVideoOutput(MediaStreamVideoSink* aSink);
// Explicitly suspend. Useful for example if a media element is pausing
// and we need to stop its stream emitting its buffered data. As soon as the
// Suspend message reaches the graph, the stream stops processing. It
@ -407,7 +404,6 @@ public:
virtual SourceMediaStream* AsSourceStream() { return nullptr; }
virtual ProcessedMediaStream* AsProcessedStream() { return nullptr; }
virtual AudioNodeStream* AsAudioNodeStream() { return nullptr; }
virtual TrackUnionStream* AsTrackUnionStream() { return nullptr; }
// These Impl methods perform the core functionality of the control methods
// above, on the media graph thread.
@ -428,9 +424,8 @@ public:
return !mAudioOutputs.IsEmpty();
}
void RemoveAudioOutputImpl(void* aKey);
void AddVideoOutputImpl(already_AddRefed<MediaStreamVideoSink> aSink,
TrackID aID);
void RemoveVideoOutputImpl(MediaStreamVideoSink* aSink, TrackID aID);
void AddVideoOutputImpl(already_AddRefed<MediaStreamVideoSink> aSink);
void RemoveVideoOutputImpl(MediaStreamVideoSink* aSink);
void AddListenerImpl(already_AddRefed<MediaStreamListener> aListener);
void RemoveListenerImpl(MediaStreamListener* aListener);
void RemoveAllListenersImpl();
@ -589,7 +584,7 @@ protected:
float mVolume;
};
nsTArray<AudioOutput> mAudioOutputs;
nsTArray<TrackBound<MediaStreamVideoSink>> mVideoOutputs;
nsTArray<RefPtr<MediaStreamVideoSink>> mVideoOutputs;
// We record the last played video frame to avoid playing the frame again
// with a different frame id.
VideoFrame mLastPlayedVideoFrame;

Просмотреть файл

@ -19,9 +19,6 @@ class TrackUnionStream : public ProcessedMediaStream {
public:
explicit TrackUnionStream();
virtual TrackUnionStream* AsTrackUnionStream() override { return this; }
friend class DOMMediaStream;
void RemoveInput(MediaInputPort* aPort) override;
void ProcessInput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags) override;