mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1201363 - MediaStreamVideoSink for MediaPipelineTransmit case. r=jesup
Replace |MediaPipelineTransmit::PipelineListener::NotifyQueuedTrackChanges| with |MediaPipelineTransmit::PipelineVideoSink::SetCurrentFrames|. We only need to deal with the video case since audio will be routed to |NotifyQueuedAudioData|. MozReview-Commit-ID: EVpMVgJynGT --HG-- extra : transplant_source : %0By%B5%91Fr%5B%BA%F7%D4%EE%FBs7%0C%F2%84%EC%5C5
This commit is contained in:
parent
e759836a63
commit
749ec15b11
@ -25,7 +25,9 @@
|
||||
#include "DOMMediaStream.h"
|
||||
#include "MediaStreamTrack.h"
|
||||
#include "MediaStreamListener.h"
|
||||
#include "MediaStreamVideoSink.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "VideoStreamTrack.h"
|
||||
#ifdef WEBRTC_GONK
|
||||
#include "GrallocImages.h"
|
||||
#include "mozilla/layers/GrallocTextureClient.h"
|
||||
@ -1261,6 +1263,34 @@ protected:
|
||||
};
|
||||
#endif
|
||||
|
||||
class MediaPipelineTransmit::PipelineVideoSink :
|
||||
public MediaStreamVideoSink
|
||||
{
|
||||
public:
|
||||
explicit PipelineVideoSink(const RefPtr<MediaSessionConduit>& conduit,
|
||||
MediaPipelineTransmit::PipelineListener* listener)
|
||||
: conduit_(conduit)
|
||||
, pipelineListener_(listener)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void SetCurrentFrames(const VideoSegment& aSegment) override;
|
||||
virtual void ClearFrames() override {}
|
||||
|
||||
private:
|
||||
~PipelineVideoSink() {
|
||||
// release conduit on mainthread. Must use forget()!
|
||||
nsresult rv = NS_DispatchToMainThread(new
|
||||
ConduitDeleteEvent(conduit_.forget()));
|
||||
MOZ_ASSERT(!NS_FAILED(rv),"Could not dispatch conduit shutdown to main");
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
}
|
||||
RefPtr<MediaSessionConduit> conduit_;
|
||||
MediaPipelineTransmit::PipelineListener* pipelineListener_;
|
||||
};
|
||||
|
||||
MediaPipelineTransmit::MediaPipelineTransmit(
|
||||
const std::string& pc,
|
||||
nsCOMPtr<nsIEventTarget> main_thread,
|
||||
@ -1275,6 +1305,7 @@ MediaPipelineTransmit::MediaPipelineTransmit(
|
||||
MediaPipeline(pc, TRANSMIT, main_thread, sts_thread, track_id, level,
|
||||
conduit, rtp_transport, rtcp_transport, filter),
|
||||
listener_(new PipelineListener(conduit)),
|
||||
video_sink_(new PipelineVideoSink(conduit, listener_)),
|
||||
domtrack_(domtrack)
|
||||
{
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
@ -1328,6 +1359,10 @@ void MediaPipelineTransmit::AttachToTrack(const std::string& track_id) {
|
||||
domtrack_->AddDirectListener(listener_);
|
||||
domtrack_->AddListener(listener_);
|
||||
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
domtrack_->AddDirectListener(video_sink_);
|
||||
#endif
|
||||
|
||||
#ifndef MOZILLA_INTERNAL_API
|
||||
// this enables the unit tests that can't fiddle with principals and the like
|
||||
listener_->SetEnabled(true);
|
||||
@ -1376,6 +1411,7 @@ MediaPipelineTransmit::DetachMedia()
|
||||
if (domtrack_) {
|
||||
domtrack_->RemoveDirectListener(listener_);
|
||||
domtrack_->RemoveListener(listener_);
|
||||
domtrack_->RemoveDirectListener(video_sink_);
|
||||
domtrack_ = nullptr;
|
||||
}
|
||||
// Let the listener be destroyed with the pipeline (or later).
|
||||
@ -1646,17 +1682,6 @@ NewData(MediaStreamGraph* graph,
|
||||
rate, *iter);
|
||||
iter.Next();
|
||||
}
|
||||
} else if (media.GetType() == MediaSegment::VIDEO) {
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
VideoSegment* video = const_cast<VideoSegment *>(
|
||||
static_cast<const VideoSegment *>(&media));
|
||||
|
||||
VideoSegment::ChunkIterator iter(*video);
|
||||
while(!iter.IsEnded()) {
|
||||
converter_->QueueVideoChunk(*iter, !enabled_);
|
||||
iter.Next();
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// Ignore
|
||||
}
|
||||
@ -1730,6 +1755,32 @@ void MediaPipelineTransmit::PipelineListener::ProcessAudioChunk(
|
||||
}
|
||||
}
|
||||
|
||||
void MediaPipelineTransmit::PipelineVideoSink::
|
||||
SetCurrentFrames(const VideoSegment& aSegment)
|
||||
{
|
||||
MOZ_ASSERT(pipelineListener_);
|
||||
|
||||
if (!pipelineListener_->active_) {
|
||||
MOZ_MTLOG(ML_DEBUG, "Discarding packets because transport not ready");
|
||||
return;
|
||||
}
|
||||
|
||||
if (conduit_->type() != MediaSessionConduit::VIDEO) {
|
||||
// Ignore data of wrong kind in case we have a muxed stream
|
||||
return;
|
||||
}
|
||||
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
VideoSegment* video = const_cast<VideoSegment *>(&aSegment);
|
||||
|
||||
VideoSegment::ChunkIterator iter(*video);
|
||||
while(!iter.IsEnded()) {
|
||||
pipelineListener_->converter_->QueueVideoChunk(*iter, !pipelineListener_->enabled_);
|
||||
iter.Next();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
class TrackAddedCallback {
|
||||
public:
|
||||
virtual void TrackAdded(TrackTicks current_ticks) = 0;
|
||||
|
@ -343,6 +343,7 @@ public:
|
||||
// Separate classes to allow ref counting
|
||||
class PipelineListener;
|
||||
class VideoFrameFeeder;
|
||||
class PipelineVideoSink;
|
||||
|
||||
protected:
|
||||
~MediaPipelineTransmit();
|
||||
@ -353,6 +354,7 @@ public:
|
||||
RefPtr<VideoFrameFeeder> feeder_;
|
||||
RefPtr<VideoFrameConverter> converter_;
|
||||
#endif
|
||||
RefPtr<PipelineVideoSink> video_sink_;
|
||||
dom::MediaStreamTrack* domtrack_;
|
||||
};
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "AudioSegment.h"
|
||||
#include "MediaSegment.h"
|
||||
#include "StreamTracks.h"
|
||||
#include "VideoSegment.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
@ -147,6 +148,27 @@ public:
|
||||
virtual void NotifyDirectListenerUninstalled() = 0;
|
||||
};
|
||||
|
||||
class Fake_MediaStreamVideoSink : public Fake_DirectMediaStreamTrackListener{
|
||||
public:
|
||||
Fake_MediaStreamVideoSink() {}
|
||||
|
||||
void NotifyQueuedChanges(mozilla::MediaStreamGraph* aGraph,
|
||||
mozilla::StreamTime aTrackOffset,
|
||||
const mozilla::MediaSegment& aQueuedMedia) override {}
|
||||
|
||||
void NotifyRealtimeTrackData(mozilla::MediaStreamGraph* aGraph,
|
||||
mozilla::StreamTime aTrackOffset,
|
||||
const mozilla::MediaSegment& aMedia) override {}
|
||||
void NotifyDirectListenerInstalled(InstallationResult aResult) override {}
|
||||
void NotifyDirectListenerUninstalled() override {}
|
||||
|
||||
virtual void SetCurrentFrames(const mozilla::VideoSegment& aSegment) {};
|
||||
virtual void ClearFrames() {};
|
||||
|
||||
protected:
|
||||
virtual ~Fake_MediaStreamVideoSink() {}
|
||||
};
|
||||
|
||||
// Note: only one listener supported
|
||||
class Fake_MediaStream {
|
||||
protected:
|
||||
@ -619,6 +641,7 @@ typedef Fake_MediaStreamTrackListener MediaStreamTrackListener;
|
||||
typedef Fake_DirectMediaStreamTrackListener DirectMediaStreamTrackListener;
|
||||
typedef Fake_DOMMediaStream DOMMediaStream;
|
||||
typedef Fake_DOMMediaStream DOMLocalMediaStream;
|
||||
typedef Fake_MediaStreamVideoSink MediaStreamVideoSink;
|
||||
|
||||
namespace dom {
|
||||
typedef Fake_MediaStreamTrack MediaStreamTrack;
|
||||
|
Loading…
Reference in New Issue
Block a user