Bug 1124139 - Don't use mPlaybackStream for CameraPreview. r=jesup

From db346795ad1a0ae33e7496df893288eb1fbf7699 Mon Sep 17 00:00:00 2001
---
 dom/camera/CameraPreviewMediaStream.h |  1 +
 dom/html/HTMLMediaElement.cpp         | 29 +++++++++++++++++------------
 dom/html/HTMLMediaElement.h           |  6 +++++-
 dom/media/MediaStreamGraph.h          |  2 ++
 4 files changed, 25 insertions(+), 13 deletions(-)
This commit is contained in:
Andreas Pehrson 2015-01-22 09:27:24 +01:00
parent 28d1e567e6
commit ddb72d387a
4 changed files with 25 additions and 13 deletions

View File

@ -42,6 +42,7 @@ class CameraPreviewMediaStream : public MediaStream
public:
explicit CameraPreviewMediaStream(DOMMediaStream* aWrapper);
virtual CameraPreviewMediaStream* AsCameraPreviewStream() MOZ_OVERRIDE { return this; };
virtual void AddAudioOutput(void* aKey) MOZ_OVERRIDE;
virtual void SetAudioOutputVolume(void* aKey, float aVolume) MOZ_OVERRIDE;
virtual void RemoveAudioOutput(void* aKey) MOZ_OVERRIDE;

View File

@ -2893,19 +2893,22 @@ void HTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream)
return;
}
// Now that we have access to |mSrcStream| we can pipe it to our shadow
// version |mPlaybackStream|. If two media elements are playing the
// same realtime DOMMediaStream, this allows them to pause playback
// independently of each other.
mPlaybackStream = DOMMediaStream::CreateTrackUnionStream(window);
mPlaybackStreamInputPort = mPlaybackStream->GetStream()->AsProcessedStream()->
AllocateInputPort(mSrcStream->GetStream(), MediaInputPort::FLAG_BLOCK_OUTPUT);
// XXX Remove this if with CameraPreviewMediaStream per bug 1124630.
if (!mSrcStream->GetStream()->AsCameraPreviewStream()) {
// Now that we have access to |mSrcStream| we can pipe it to our shadow
// version |mPlaybackStream|. If two media elements are playing the
// same realtime DOMMediaStream, this allows them to pause playback
// independently of each other.
mPlaybackStream = DOMMediaStream::CreateTrackUnionStream(window);
mPlaybackStreamInputPort = mPlaybackStream->GetStream()->AsProcessedStream()->
AllocateInputPort(mSrcStream->GetStream(), MediaInputPort::FLAG_BLOCK_OUTPUT);
nsRefPtr<nsIPrincipal> principal = GetCurrentPrincipal();
mPlaybackStream->CombineWithPrincipal(principal);
nsRefPtr<nsIPrincipal> principal = GetCurrentPrincipal();
mPlaybackStream->CombineWithPrincipal(principal);
// Let |mSrcStream| decide when the stream has finished.
GetSrcMediaStream()->AsProcessedStream()->SetAutofinish(true);
// Let |mSrcStream| decide when the stream has finished.
GetSrcMediaStream()->AsProcessedStream()->SetAutofinish(true);
}
nsRefPtr<MediaStream> stream = mSrcStream->GetStream();
if (stream) {
@ -2953,7 +2956,9 @@ void HTMLMediaElement::EndSrcMediaStreamPlayback()
}
mSrcStream->DisconnectTrackListListeners(AudioTracks(), VideoTracks());
mPlaybackStreamInputPort->Destroy();
if (mPlaybackStreamInputPort) {
mPlaybackStreamInputPort->Destroy();
}
// Kill its reference to this element
mSrcStreamListener->Forget();

View File

@ -340,7 +340,11 @@ public:
MediaStream* GetSrcMediaStream() const
{
NS_ASSERTION(mPlaybackStream, "Don't call this when not playing a stream");
NS_ASSERTION(mSrcStream, "Don't call this when not playing a stream");
if (!mPlaybackStream) {
// XXX Remove this check with CameraPreviewMediaStream per bug 1124630.
return mSrcStream->GetStream();
}
return mPlaybackStream->GetStream();
}

View File

@ -240,6 +240,7 @@ class AudioNodeEngine;
class AudioNodeExternalInputStream;
class AudioNodeStream;
struct AudioChunk;
class CameraPreviewMediaStream;
/**
* A stream of synchronized audio and video data. All (not blocked) streams
@ -418,6 +419,7 @@ public:
virtual SourceMediaStream* AsSourceStream() { return nullptr; }
virtual ProcessedMediaStream* AsProcessedStream() { return nullptr; }
virtual AudioNodeStream* AsAudioNodeStream() { return nullptr; }
virtual CameraPreviewMediaStream* AsCameraPreviewStream() { return nullptr; }
// media graph thread only
void Init();