Skip to content

Commit

Permalink
Bug 1328142 - enable switching between simulcast receive streams r=jesup
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Kerr [:pkerr] committed Jan 6, 2017
1 parent e1e039b commit c63cea9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 38 deletions.
18 changes: 4 additions & 14 deletions dom/media/tests/mochitest/test_peerConnection_simulcastOffer.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
ok(vremote, "Should have remote video element for pcRemote");
ok(vlocal.videoWidth > 0, "source width is positive");
ok(vlocal.videoHeight > 0, "source height is positive");
is(vremote.videoWidth, vlocal.videoWidth, "sink is same width as source");
is(vremote.videoHeight, vlocal.videoHeight, "sink is same height as source");
is(vremote.videoWidth, vlocal.videoWidth / 2, "sink is 1/2 width of source");
is(vremote.videoHeight, vlocal.videoHeight / 2, "sink is 1/2 height of source");
},
function PC_REMOTE_SET_RTP_SECOND_RID(test) {
// Now, cause pcRemote to filter out everything but the second SSRC.
Expand Down Expand Up @@ -116,18 +116,8 @@
ok(vremote, "Should have remote video element for pcRemote");
ok(vlocal.videoWidth > 0, "source width is positive");
ok(vlocal.videoHeight > 0, "source height is positive");
is(vremote.videoWidth, vlocal.videoWidth / 2, "sink is 1/2 width of source");
is(vremote.videoHeight, vlocal.videoHeight / 2, "sink is 1/2 height of source");
},
function PC_REMOTE_SET_RTP_NONEXISTENT_RID(test) {
// Now, cause pcRemote to filter out everything, just to make sure
// selectRecvSsrc is working.
selectRecvSsrc(test.pcRemote, 2);
},
function PC_REMOTE_ENSURE_NO_FRAMES() {
var vremote = test.pcRemote.remoteMediaElements[0];
ok(vremote, "Should have remote video element for pcRemote");
return helper.verifyNoFrames(vremote);
is(vremote.videoWidth, vlocal.videoWidth, "sink is same width as source");
is(vremote.videoHeight, vlocal.videoHeight, "sink is same height as source");
},
]);

Expand Down
4 changes: 4 additions & 0 deletions media/webrtc/signaling/src/media-conduit/AudioConduit.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ class WebrtcAudioConduit: public AudioSessionConduit
*/
bool SetLocalSSRCs(const std::vector<unsigned int>& aSSRCs) override;
std::vector<unsigned int> GetLocalSSRCs() const override;
bool SetRemoteSSRC(unsigned int ssrc) override
{
return false;
}
bool GetRemoteSSRC(unsigned int* ssrc) override;
bool SetLocalCNAME(const char* cname) override;
bool GetVideoEncoderStats(double* framerateMean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class MediaSessionConduit
virtual std::vector<unsigned int> GetLocalSSRCs() const = 0;

virtual bool GetRemoteSSRC(unsigned int* ssrc) = 0;
virtual bool SetRemoteSSRC(unsigned int ssrc) = 0;
virtual bool SetLocalCNAME(const char* cname) = 0;

/**
Expand Down
23 changes: 14 additions & 9 deletions media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ WebrtcVideoConduit::CreateRecvStream()
std::unique_ptr<webrtc::VideoDecoder> decoder;
webrtc::VideoDecoder::DecoderType decoder_type;

mRecvStreamConfig.decoders.clear();
for (auto& config : mRecvCodecList) {
decoder_type = PayloadNameToDecoderType(config->mName);
if (decoder_type == webrtc::VideoDecoder::DecoderType::kUnsupportedCodec) {
Expand Down Expand Up @@ -692,6 +693,12 @@ WebrtcVideoConduit::SetRemoteSSRC(unsigned int ssrc)
}

DeleteRecvStream();
MediaConduitErrorCode rval = CreateRecvStream();
if (rval != kMediaConduitNoError) {
CSFLogError(logTag, "%s Start Receive Error %d ", __FUNCTION__, rval);
return false;
}

return (StartReceiving() == kMediaConduitNoError);
}

Expand Down Expand Up @@ -1148,10 +1155,15 @@ WebrtcVideoConduit::ConfigureRecvMediaCodecs(
// XXX Copy over those that are the same and don't rebuild them
mRecvCodecList.SwapElements(recv_codecs);
recv_codecs.Clear();
mRecvStreamConfig.decoders.clear();
mRecvStreamConfig.rtp.rtx.clear();
// Rebuilds mRecvStream from mRecvStreamConfig
DeleteRecvStream();
MediaConduitErrorCode rval = CreateRecvStream();
if (rval != kMediaConduitNoError) {
CSFLogError(logTag, "%s Start Receive Error %d ", __FUNCTION__, rval);
return rval;
}

return StartReceiving();
}
return kMediaConduitNoError;
Expand Down Expand Up @@ -1812,14 +1824,7 @@ WebrtcVideoConduit::StartReceiving()
{
// Start Receive on the video engine
MutexAutoLock lock(mCodecMutex);

if (!mRecvStream) {
MediaConduitErrorCode rval = CreateRecvStream();
if (rval != kMediaConduitNoError) {
CSFLogError(logTag, "%s Start Receive Error %d ", __FUNCTION__, rval);
return rval;
}
}
MOZ_ASSERT(mRecvStream);

mRecvStream->Start();
mEngineReceiving = true;
Expand Down
27 changes: 13 additions & 14 deletions media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,25 +750,24 @@ MediaPipeline::UpdateTransport_s(int level,
void
MediaPipeline::SelectSsrc_m(size_t ssrc_index)
{
RUN_ON_THREAD(sts_thread_,
WrapRunnable(
this,
&MediaPipeline::SelectSsrc_s,
ssrc_index),
NS_DISPATCH_NORMAL);
if (ssrc_index < ssrcs_received_.size()) {
uint32_t ssrc = ssrcs_received_[ssrc_index];
RUN_ON_THREAD(sts_thread_,
WrapRunnable(
this,
&MediaPipeline::SelectSsrc_s,
ssrc),
NS_DISPATCH_NORMAL);

conduit_->SetRemoteSSRC(ssrc);
}
}

void
MediaPipeline::SelectSsrc_s(size_t ssrc_index)
MediaPipeline::SelectSsrc_s(uint32_t ssrc)
{
filter_ = new MediaPipelineFilter;
if (ssrc_index < ssrcs_received_.size()) {
filter_->AddRemoteSSRC(ssrcs_received_[ssrc_index]);
} else {
MOZ_MTLOG(ML_WARNING, "SelectSsrc called with " << ssrc_index << " but we "
<< "have only seen " << ssrcs_received_.size()
<< " ssrcs");
}
filter_->AddRemoteSSRC(ssrc);
}

void MediaPipeline::StateChange(TransportFlow *flow, TransportLayer::State state) {
Expand Down
2 changes: 1 addition & 1 deletion media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class MediaPipeline : public sigslot::has_slots<> {
// Used only for testing; installs a MediaPipelineFilter that filters
// everything but the nth ssrc
void SelectSsrc_m(size_t ssrc_index);
void SelectSsrc_s(size_t ssrc_index);
void SelectSsrc_s(uint32_t ssrc);

virtual Direction direction() const { return direction_; }
virtual const std::string& trackid() const { return track_id_; }
Expand Down

0 comments on commit c63cea9

Please sign in to comment.