Skip to content

Commit

Permalink
Bug 1616875: Move some receiver-related testing functions from RTCPee…
Browse files Browse the repository at this point in the history
…rConnection to RTCRtpReceiver. r=ng,smaug

Differential Revision: https://phabricator.services.mozilla.com/D64262

--HG--
extra : moz-landing-system : lando
  • Loading branch information
docfaraday committed Mar 19, 2020
1 parent 88d7392 commit 72efb61
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 192 deletions.
27 changes: 0 additions & 27 deletions dom/media/PeerConnection.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1547,33 +1547,6 @@ class RTCPeerConnection {
.map(transceiver => transceiver.receiver);
}

// test-only: insert a contributing source entry for a track
mozInsertAudioLevelForContributingSource(
receiver,
source,
timestamp,
rtpTimestamp,
hasLevel,
level
) {
this._impl.insertAudioLevelForContributingSource(
receiver.track,
source,
timestamp,
rtpTimestamp,
hasLevel,
level
);
}

mozAddRIDExtension(receiver, extensionId) {
this._impl.addRIDExtension(receiver.track, extensionId);
}

mozAddRIDFilter(receiver, rid) {
this._impl.addRIDFilter(receiver.track, rid);
}

mozSetPacketCallback(callback) {
this._onPacket = callback;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
// Audio level as expected to be returned
const expectedAudioLevel0 = 10 ** (-audioLevel0 / 20);

SpWrap(test.pcRemote).mozInsertAudioLevelForContributingSource(
remoteReceiver,
SpecialPowers.wrap(remoteReceiver).mozInsertAudioLevelForContributingSource(
csrc0,
timestamp0,
rtpTimestamp0,
Expand All @@ -59,8 +58,7 @@
const hasAudioLevel1 = false;
const audioLevel1 = 0;

SpWrap(test.pcRemote).mozInsertAudioLevelForContributingSource(
remoteReceiver,
SpecialPowers.wrap(remoteReceiver).mozInsertAudioLevelForContributingSource(
csrc1,
timestamp1,
rtpTimestamp1,
Expand All @@ -73,8 +71,7 @@
const hasAudioLevel2 = true;
const audioLevel2 = 127;

SpWrap(test.pcRemote).mozInsertAudioLevelForContributingSource(
remoteReceiver,
SpecialPowers.wrap(remoteReceiver).mozInsertAudioLevelForContributingSource(
csrc2,
timestamp2,
rtpTimestamp2,
Expand Down Expand Up @@ -126,8 +123,7 @@
// Larger offsets are further back in time
const testOffsets = [3, 7, 5, 6, 1, 4];
for (const offset of testOffsets) {
SpWrap(test.pcLocal).mozInsertAudioLevelForContributingSource(
localReceiver,
SpecialPowers.wrap(localReceiver).mozInsertAudioLevelForContributingSource(
offset, // Using offset for SSRC for convenience
timestamp3 - offset,
rtpTimestamp3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
is(receivers.length, 1, "We have exactly one RTP receiver");
const receiver = receivers[0];

SpecialPowers.wrap(pc._pc).mozAddRIDExtension(receiver, extensionId);
SpecialPowers.wrap(receiver).mozAddRIDExtension(extensionId);
}

function selectRecvRID(pc, rid) {
const receivers = pc._pc.getReceivers();
is(receivers.length, 1, "We have exactly one RTP receiver");
const receiver = receivers[0];

SpecialPowers.wrap(pc._pc).mozAddRIDFilter(receiver, rid);
SpecialPowers.wrap(receiver).mozAddRIDFilter(rid);
}

runNetworkTest(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
is(receivers.length, 1, "We have exactly one RTP receiver");
const receiver = receivers[0];

SpecialPowers.wrap(pc._pc).mozAddRIDExtension(receiver, extensionId);
SpecialPowers.wrap(receiver).mozAddRIDExtension(extensionId);
}

function selectRecvRID(pc, rid) {
const receivers = pc._pc.getReceivers();
is(receivers.length, 1, "We have exactly one RTP receiver");
const receiver = receivers[0];

SpecialPowers.wrap(pc._pc).mozAddRIDFilter(receiver, rid);
SpecialPowers.wrap(receiver).mozAddRIDFilter(rid);
}

async function changeSourceResolution(test, emitter, width, height) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
is(receivers.length, 1, "We have exactly one RTP receiver");
const receiver = receivers[0];

SpecialPowers.wrap(pc._pc).mozAddRIDExtension(receiver, extensionId);
SpecialPowers.wrap(receiver).mozAddRIDExtension(extensionId);
}

function selectRecvRID(pc, rid) {
const receivers = pc._pc.getReceivers();
is(receivers.length, 1, "We have exactly one RTP receiver");
const receiver = receivers[0];

SpecialPowers.wrap(pc._pc).mozAddRIDFilter(receiver, rid);
SpecialPowers.wrap(receiver).mozAddRIDFilter(rid);
}

runNetworkTest(() =>
Expand Down
14 changes: 0 additions & 14 deletions dom/webidl/PeerConnectionImpl.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,6 @@ interface PeerConnectionImpl {
[Throws]
void closeStreams();

[Throws]
void addRIDExtension(MediaStreamTrack recvTrack, unsigned short extensionId);
[Throws]
void addRIDFilter(MediaStreamTrack recvTrack, DOMString rid);

// Inserts CSRC data for the RtpSourceObserver for testing
[Throws]
void insertAudioLevelForContributingSource(MediaStreamTrack recvTrack,
unsigned long source,
DOMHighResTimeStamp timestamp,
unsigned long rtpTimestamp,
boolean hasLevel,
byte level);

[Throws]
void enablePacketDump(unsigned long level,
mozPacketDumpType type,
Expand Down
12 changes: 0 additions & 12 deletions dom/webidl/RTCPeerConnection.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,6 @@ interface RTCPeerConnection : EventTarget {
sequence<RTCRtpReceiver> getReceivers();
sequence<RTCRtpTransceiver> getTransceivers();

// test-only: for testing getContributingSources
[ChromeOnly]
void mozInsertAudioLevelForContributingSource(RTCRtpReceiver receiver,
unsigned long source,
DOMHighResTimeStamp timestamp,
unsigned long rtpTimestamp,
boolean hasLevel,
byte level);
[ChromeOnly]
void mozAddRIDExtension(RTCRtpReceiver receiver, unsigned short extensionId);
[ChromeOnly]
void mozAddRIDFilter(RTCRtpReceiver receiver, DOMString rid);
[ChromeOnly]
void mozSetPacketCallback(mozPacketCallback callback);
[ChromeOnly]
Expand Down
12 changes: 12 additions & 0 deletions dom/webidl/RTCRtpReceiver.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@ interface RTCRtpReceiver {
sequence<RTCRtpContributingSource> getContributingSources();
[Pref="media.peerconnection.rtpsourcesapi.enabled"]
sequence<RTCRtpSynchronizationSource> getSynchronizationSources();

[ChromeOnly]
void mozAddRIDExtension(unsigned short extensionId);
[ChromeOnly]
void mozAddRIDFilter(DOMString rid);
// test-only: for testing getContributingSources
[ChromeOnly]
void mozInsertAudioLevelForContributingSource(unsigned long source,
DOMHighResTimeStamp timestamp,
unsigned long rtpTimestamp,
boolean hasLevel,
byte level);
};
29 changes: 0 additions & 29 deletions media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,35 +1693,6 @@ void PeerConnectionImpl::DumpPacket_m(size_t level, dom::mozPacketDumpType type,
mPCObserver->OnPacket(level, type, sending, arrayBuffer, jrv);
}

// test-only: adds fake CSRCs and audio data
nsresult PeerConnectionImpl::InsertAudioLevelForContributingSource(
const dom::MediaStreamTrack& aRecvTrack, const unsigned long aSource,
const DOMHighResTimeStamp aTimestamp, const unsigned long aRtpTimestamp,
const bool aHasLevel, const uint8_t aLevel) {
PC_AUTO_ENTER_API_CALL(true);
std::vector<RefPtr<TransceiverImpl>>& transceivers =
mMedia->GetTransceivers();
for (RefPtr<TransceiverImpl>& transceiver : transceivers) {
if (transceiver->HasReceiveTrack(&aRecvTrack)) {
transceiver->InsertAudioLevelForContributingSource(
aSource, aTimestamp, aRtpTimestamp, aHasLevel, aLevel);
break;
}
}

return NS_OK;
}

nsresult PeerConnectionImpl::AddRIDExtension(MediaStreamTrack& aRecvTrack,
unsigned short aExtensionId) {
return mMedia->AddRIDExtension(aRecvTrack, aExtensionId);
}

nsresult PeerConnectionImpl::AddRIDFilter(MediaStreamTrack& aRecvTrack,
const nsAString& aRid) {
return mMedia->AddRIDFilter(aRecvTrack, aRid);
}

nsresult PeerConnectionImpl::EnablePacketDump(unsigned long level,
dom::mozPacketDumpType type,
bool sending) {
Expand Down
26 changes: 0 additions & 26 deletions media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,32 +306,6 @@ class PeerConnectionImpl final
rv = ReplaceTrackNoRenegotiation(aTransceiver, aWithTrack);
}

// test-only: called from contributing sources mochitests.
NS_IMETHODIMP_TO_ERRORRESULT(InsertAudioLevelForContributingSource,
ErrorResult& rv,
const dom::MediaStreamTrack& aRecvTrack,
const unsigned long aSource,
const DOMHighResTimeStamp aTimestamp,
const unsigned long aRtpTimestamp,
const bool aHasLevel, const uint8_t aLevel) {
rv = InsertAudioLevelForContributingSource(
aRecvTrack, aSource, aTimestamp, aRtpTimestamp, aHasLevel, aLevel);
}

// test-only: called from simulcast mochitests.
NS_IMETHODIMP_TO_ERRORRESULT(AddRIDExtension, ErrorResult& rv,
dom::MediaStreamTrack& aRecvTrack,
unsigned short aExtensionId) {
rv = AddRIDExtension(aRecvTrack, aExtensionId);
}

// test-only: called from simulcast mochitests.
NS_IMETHODIMP_TO_ERRORRESULT(AddRIDFilter, ErrorResult& rv,
dom::MediaStreamTrack& aRecvTrack,
const nsAString& aRid) {
rv = AddRIDFilter(aRecvTrack, aRid);
}

// test-only
NS_IMETHODIMP_TO_ERRORRESULT(EnablePacketDump, ErrorResult& rv,
unsigned long level, dom::mozPacketDumpType type,
Expand Down
27 changes: 0 additions & 27 deletions media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,33 +740,6 @@ std::string PeerConnectionMedia::GetTransportIdMatchingSendTrack(
return std::string();
}

nsresult PeerConnectionMedia::AddRIDExtension(MediaStreamTrack& aRecvTrack,
unsigned short aExtensionId) {
DebugOnly<bool> trackFound = false;
for (RefPtr<TransceiverImpl>& transceiver : mTransceivers) {
if (transceiver->HasReceiveTrack(&aRecvTrack)) {
transceiver->AddRIDExtension(aExtensionId);
trackFound = true;
}
}
MOZ_ASSERT(trackFound);
return NS_OK;
}

nsresult PeerConnectionMedia::AddRIDFilter(MediaStreamTrack& aRecvTrack,
const nsAString& aRid) {
DebugOnly<bool> trackFound = false;
for (RefPtr<TransceiverImpl>& transceiver : mTransceivers) {
MOZ_ASSERT(transceiver->HasReceiveTrack(&aRecvTrack));
if (transceiver->HasReceiveTrack(&aRecvTrack)) {
transceiver->AddRIDFilter(aRid);
trackFound = true;
}
}
MOZ_ASSERT(trackFound);
return NS_OK;
}

void PeerConnectionMedia::IceGatheringStateChange_s(
dom::RTCIceGatheringState aState) {
ASSERT_ON_THREAD(mSTSThread);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
const dom::MediaStreamTrack* aTrack,
nsTArray<RefPtr<MediaPipelineTransmit>>* aPipelines);

nsresult AddRIDExtension(dom::MediaStreamTrack& aRecvTrack,
unsigned short aExtensionId);

nsresult AddRIDFilter(dom::MediaStreamTrack& aRecvTrack,
const nsAString& aRid);
std::string GetTransportIdMatchingSendTrack(
const dom::MediaStreamTrack& aTrack) const;

Expand Down
25 changes: 25 additions & 0 deletions media/webrtc/signaling/src/peerconnection/RTCRtpReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,31 @@ void RTCRtpReceiver::UpdateStreams(StreamAssociationChanges* aChanges) {
}
}

void RTCRtpReceiver::MozAddRIDExtension(unsigned short aExtensionId) {
if (mPipeline) {
mPipeline->AddRIDExtension_m(aExtensionId);
}
}

void RTCRtpReceiver::MozAddRIDFilter(const nsAString& aRid) {
if (mPipeline) {
mPipeline->AddRIDFilter_m(NS_ConvertUTF16toUTF8(aRid).get());
}
}

// test-only: adds fake CSRCs and audio data
void RTCRtpReceiver::MozInsertAudioLevelForContributingSource(
const uint32_t aSource, const DOMHighResTimeStamp aTimestamp,
const uint32_t aRtpTimestamp, const bool aHasLevel, const uint8_t aLevel) {
if (!mPipeline || mPipeline->IsVideo() || !mPipeline->Conduit()) {
return;
}
WebrtcAudioConduit* audio_conduit =
static_cast<WebrtcAudioConduit*>(mPipeline->Conduit());
audio_conduit->InsertAudioLevelForContributingSource(
aSource, aTimestamp, aRtpTimestamp, aHasLevel, aLevel);
}

void RTCRtpReceiver::OnRtcpBye() { SetReceiveTrackMuted(true); }

void RTCRtpReceiver::OnRtcpTimeout() { SetReceiveTrackMuted(true); }
Expand Down
7 changes: 7 additions & 0 deletions media/webrtc/signaling/src/peerconnection/RTCRtpReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ class RTCRtpReceiver : public nsISupports,
nsTArray<dom::RTCRtpContributingSource>& aSources);
void GetSynchronizationSources(
nsTArray<dom::RTCRtpSynchronizationSource>& aSources);
// test-only: called from simulcast mochitests.
void MozAddRIDExtension(unsigned short aExtensionId);
void MozAddRIDFilter(const nsAString& aRid);
// test-only: insert fake CSRCs and audio levels for testing
void MozInsertAudioLevelForContributingSource(
const uint32_t aSource, const DOMHighResTimeStamp aTimestamp,
const uint32_t aRtpTimestamp, const bool aHasLevel, const uint8_t aLevel);

nsPIDOMWindowInner* GetParentObject() const;
nsTArray<RefPtr<RTCStatsPromise>> GetStatsInternal();
Expand Down
28 changes: 0 additions & 28 deletions media/webrtc/signaling/src/peerconnection/TransceiverImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,22 +507,6 @@ RefPtr<MediaPipelineReceive> TransceiverImpl::GetReceivePipeline() {
return mReceivePipeline;
}

void TransceiverImpl::AddRIDExtension(unsigned short aExtensionId) {
if (mJsepTransceiver->IsStopped()) {
return;
}

mReceivePipeline->AddRIDExtension_m(aExtensionId);
}

void TransceiverImpl::AddRIDFilter(const nsAString& aRid) {
if (mJsepTransceiver->IsStopped()) {
return;
}

mReceivePipeline->AddRIDFilter_m(NS_ConvertUTF16toUTF8(aRid).get());
}

static nsresult JsepCodecDescToAudioCodecConfig(
const JsepCodecDescription& aCodec, UniquePtr<AudioCodecConfig>* aConfig) {
MOZ_ASSERT(aCodec.mType == SdpMediaSection::kAudio);
Expand Down Expand Up @@ -823,16 +807,4 @@ bool TransceiverImpl::IsVideo() const {
return mJsepTransceiver->GetMediaType() == SdpMediaSection::MediaType::kVideo;
}

void TransceiverImpl::InsertAudioLevelForContributingSource(
const uint32_t aSource, const int64_t aTimestamp,
const uint32_t aRtpTimestamp, const bool aHasLevel, const uint8_t aLevel) {
if (!IsValid() || IsVideo()) {
return;
}
WebrtcAudioConduit* audio_conduit =
static_cast<WebrtcAudioConduit*>(mConduit.get());
audio_conduit->InsertAudioLevelForContributingSource(
aSource, aTimestamp, aRtpTimestamp, aHasLevel, aLevel);
}

} // namespace mozilla
Loading

0 comments on commit 72efb61

Please sign in to comment.