mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1230184 - plumb setParameters down to JsepTrack. r=bwc, r=mrbkap
--HG-- extra : commitid : 4IT4rENtDxn extra : rebase_source : 72aef2d743c0afe6be8031226c11d9891b2a4ef7 extra : amend_source : 567f1abc770a0fcf04748b251ef43aaed9f0d99f
This commit is contained in:
parent
74f5fe3fc8
commit
5855c2732e
@ -1038,6 +1038,14 @@ RTCPeerConnection.prototype = {
|
||||
});
|
||||
},
|
||||
|
||||
_setParameters: function(sender, parameters) {
|
||||
this._impl.setParameters(sender.track, parameters);
|
||||
},
|
||||
|
||||
_getParameters: function(sender) {
|
||||
return this._impl.getParameters(sender.track);
|
||||
},
|
||||
|
||||
close: function() {
|
||||
if (this._closed) {
|
||||
return;
|
||||
@ -1494,6 +1502,14 @@ RTCRtpSender.prototype = {
|
||||
|
||||
replaceTrack: function(withTrack) {
|
||||
return this._pc._chain(() => this._pc._replaceTrack(this, withTrack));
|
||||
},
|
||||
|
||||
setParameters: function(parameters) {
|
||||
return this._pc._setParameters(this, parameters);
|
||||
},
|
||||
|
||||
getParameters: function() {
|
||||
return this._pc._getParameters(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -147,6 +147,7 @@ skip-if = toolkit == 'gonk' || buildapp == 'mulet' || (android_version == '18' &
|
||||
[test_peerConnection_setLocalAnswerInHaveLocalOffer.html]
|
||||
[test_peerConnection_setLocalAnswerInStable.html]
|
||||
[test_peerConnection_setLocalOfferInHaveRemoteOffer.html]
|
||||
[test_peerConnection_setParameters.html]
|
||||
[test_peerConnection_setRemoteAnswerInHaveRemoteOffer.html]
|
||||
[test_peerConnection_setRemoteAnswerInStable.html]
|
||||
[test_peerConnection_setRemoteOfferInHaveLocalOffer.html]
|
||||
|
@ -0,0 +1,83 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script type="application/javascript" src="pc.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript;version=1.8">
|
||||
createHTML({
|
||||
bug: "1230184",
|
||||
title: "Set parameters on sender",
|
||||
visible: true
|
||||
});
|
||||
|
||||
function parameterstest(wrapper) {
|
||||
var pc = wrapper._pc;
|
||||
ok(pc.getSenders().length > 0, "have senders");
|
||||
var sender = pc.getSenders()[0];
|
||||
|
||||
var testParameters = (params, errorName, errorMsg) => {
|
||||
var compareParameters = (a, b) => {
|
||||
var compareEncoding = (a, b) => {
|
||||
is(a.rid, b.rid || "", "same rid");
|
||||
is(a.maxBitrate, b.maxBitrate, "same maxBitrate");
|
||||
};
|
||||
is(a.encodings.length, (b.encodings || []).length, "same encodings");
|
||||
a.encodings.forEach((en, i) => compareEncoding(en, b.encodings[i]));
|
||||
};
|
||||
try {
|
||||
sender.setParameters(params);
|
||||
compareParameters(sender.getParameters(), params);
|
||||
is(null, errorName || null, "is success expected");
|
||||
} catch (e) {
|
||||
is(e.name, errorName, "correct error name");
|
||||
is(e.message, errorMsg, "correct error message");
|
||||
}
|
||||
};
|
||||
|
||||
testParameters({
|
||||
encodings: [
|
||||
{ rid: "foo", maxBitrate: 40000 },
|
||||
{ rid: "bar", maxBitrate: 10000 },
|
||||
]
|
||||
});
|
||||
testParameters({
|
||||
encodings: [
|
||||
{ maxBitrate: 10000 },
|
||||
]
|
||||
});
|
||||
testParameters({
|
||||
encodings: [
|
||||
{ maxBitrate: 40000 },
|
||||
{ rid: "bar", maxBitrate: 10000 },
|
||||
]
|
||||
}, "TypeError", "Missing rid");
|
||||
testParameters({
|
||||
encodings: [
|
||||
{ rid: "foo", maxBitrate: 40000 },
|
||||
{ rid: "bar", maxBitrate: 10000 },
|
||||
{ rid: "bar", maxBitrate: 20000 },
|
||||
]
|
||||
}, "TypeError", "Duplicate rid");
|
||||
testParameters({});
|
||||
}
|
||||
|
||||
runNetworkTest(function () {
|
||||
test = new PeerConnectionTest();
|
||||
test.setMediaConstraints([{video: true}], [{video: true}]);
|
||||
test.chain.removeAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW");
|
||||
|
||||
// Test sender parameters.
|
||||
test.chain.append([
|
||||
function PC_LOCAL_SET_PARAMETERS(test) {
|
||||
return parameterstest(test.pcLocal);
|
||||
}
|
||||
]);
|
||||
|
||||
test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -47,6 +47,11 @@ interface PeerConnectionImpl {
|
||||
[Throws]
|
||||
void replaceTrack(MediaStreamTrack thisTrack, MediaStreamTrack withTrack);
|
||||
[Throws]
|
||||
void setParameters(MediaStreamTrack track,
|
||||
optional RTCRtpParameters parameters);
|
||||
[Throws]
|
||||
RTCRtpParameters getParameters(MediaStreamTrack track);
|
||||
[Throws]
|
||||
void closeStreams();
|
||||
|
||||
sequence<MediaStream> getLocalStreams();
|
||||
|
@ -110,6 +110,15 @@ public:
|
||||
const std::string& oldTrackId,
|
||||
const std::string& newStreamId,
|
||||
const std::string& newTrackId) = 0;
|
||||
virtual nsresult SetParameters(
|
||||
const std::string& streamId,
|
||||
const std::string& trackId,
|
||||
const std::vector<JsepTrack::JsConstraints>& constraints) = 0;
|
||||
|
||||
virtual nsresult GetParameters(
|
||||
const std::string& streamId,
|
||||
const std::string& trackId,
|
||||
std::vector<JsepTrack::JsConstraints>* outConstraints) = 0;
|
||||
|
||||
virtual std::vector<RefPtr<JsepTrack>> GetLocalTracks() const = 0;
|
||||
|
||||
|
@ -264,6 +264,37 @@ JsepSessionImpl::ReplaceTrack(const std::string& oldStreamId,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
JsepSessionImpl::SetParameters(const std::string& streamId,
|
||||
const std::string& trackId,
|
||||
const std::vector<JsepTrack::JsConstraints>& constraints)
|
||||
{
|
||||
auto it = FindTrackByIds(mLocalTracks, streamId, trackId);
|
||||
|
||||
if (it == mLocalTracks.end()) {
|
||||
JSEP_SET_ERROR("Track " << streamId << "/" << trackId << " was never added.");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
it->mTrack->SetJsConstraints(constraints);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
JsepSessionImpl::GetParameters(const std::string& streamId,
|
||||
const std::string& trackId,
|
||||
std::vector<JsepTrack::JsConstraints>* outConstraints)
|
||||
{
|
||||
auto it = FindTrackByIds(mLocalTracks, streamId, trackId);
|
||||
|
||||
if (it == mLocalTracks.end()) {
|
||||
JSEP_SET_ERROR("Track " << streamId << "/" << trackId << " was never added.");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
it->mTrack->GetJsConstraints(outConstraints);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
std::vector<RefPtr<JsepTrack>>
|
||||
JsepSessionImpl::GetLocalTracks() const
|
||||
{
|
||||
|
@ -87,6 +87,16 @@ public:
|
||||
const std::string& newStreamId,
|
||||
const std::string& newTrackId) override;
|
||||
|
||||
virtual nsresult SetParameters(
|
||||
const std::string& streamId,
|
||||
const std::string& trackId,
|
||||
const std::vector<JsepTrack::JsConstraints>& constraints) override;
|
||||
|
||||
virtual nsresult GetParameters(
|
||||
const std::string& streamId,
|
||||
const std::string& trackId,
|
||||
std::vector<JsepTrack::JsConstraints>* outConstraints) override;
|
||||
|
||||
virtual std::vector<RefPtr<JsepTrack>> GetLocalTracks() const override;
|
||||
|
||||
virtual std::vector<RefPtr<JsepTrack>> GetRemoteTracks() const override;
|
||||
|
@ -185,6 +185,12 @@ public:
|
||||
mJsEncodeConstraints = constraintsList;
|
||||
}
|
||||
|
||||
void GetJsConstraints(std::vector<JsConstraints>* outConstraintsList) const
|
||||
{
|
||||
MOZ_ASSERT(outConstraintsList);
|
||||
*outConstraintsList = mJsEncodeConstraints;
|
||||
}
|
||||
|
||||
static void AddToMsection(const std::vector<JsConstraints>& constraintsList,
|
||||
sdp::Direction direction,
|
||||
SdpMediaSection* msection);
|
||||
|
@ -77,6 +77,7 @@
|
||||
#include "mozilla/PeerIdentity.h"
|
||||
#include "mozilla/dom/RTCCertificate.h"
|
||||
#include "mozilla/dom/RTCConfigurationBinding.h"
|
||||
#include "mozilla/dom/RTCRtpSenderBinding.h"
|
||||
#include "mozilla/dom/RTCStatsReportBinding.h"
|
||||
#include "mozilla/dom/RTCPeerConnectionBinding.h"
|
||||
#include "mozilla/dom/PeerConnectionImplBinding.h"
|
||||
@ -2319,6 +2320,61 @@ PeerConnectionImpl::ReplaceTrack(MediaStreamTrack& aThisTrack,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PeerConnectionImpl::SetParameters(MediaStreamTrack& aTrack,
|
||||
const RTCRtpParameters& aParameters) {
|
||||
PC_AUTO_ENTER_API_CALL(true);
|
||||
|
||||
std::string trackId = PeerConnectionImpl::GetTrackId(aTrack);
|
||||
std::string streamId = PeerConnectionImpl::GetStreamId(*aTrack.GetStream());
|
||||
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
std::vector<JsepTrack::JsConstraints> constraints;
|
||||
if (aParameters.mEncodings.WasPassed()) {
|
||||
for (auto& encoding : aParameters.mEncodings.Value()) {
|
||||
JsepTrack::JsConstraints constraint;
|
||||
if (encoding.mRid.WasPassed()) {
|
||||
constraint.rid = NS_ConvertUTF16toUTF8(encoding.mRid.Value()).get();
|
||||
}
|
||||
if (encoding.mMaxBitrate.WasPassed()) {
|
||||
constraint.constraints.maxBr = encoding.mMaxBitrate.Value();
|
||||
}
|
||||
constraints.push_back(constraint);
|
||||
}
|
||||
}
|
||||
nsresult rv = mJsepSession->SetParameters(streamId, trackId, constraints);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PeerConnectionImpl::GetParameters(MediaStreamTrack& aTrack,
|
||||
RTCRtpParameters& aOutParameters) {
|
||||
PC_AUTO_ENTER_API_CALL(true);
|
||||
|
||||
std::string trackId = PeerConnectionImpl::GetTrackId(aTrack);
|
||||
std::string streamId = PeerConnectionImpl::GetStreamId(*aTrack.GetStream());
|
||||
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
std::vector<JsepTrack::JsConstraints> constraints;
|
||||
nsresult rv = GetParameters(aTrack, &constraints);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
aOutParameters.mEncodings.Construct();
|
||||
for (auto& constraint : constraints) {
|
||||
RTCRtpEncodingParameters encoding;
|
||||
encoding.mRid.Construct(NS_ConvertASCIItoUTF16(constraint.rid.c_str()));
|
||||
encoding.mMaxBitrate.Construct(constraint.constraints.maxBr);
|
||||
aOutParameters.mEncodings.Value().AppendElement(Move(encoding), fallible);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PeerConnectionImpl::CalculateFingerprint(
|
||||
const std::string& algorithm,
|
||||
|
@ -81,6 +81,7 @@ class RTCCertificate;
|
||||
struct RTCConfiguration;
|
||||
struct RTCIceServer;
|
||||
struct RTCOfferOptions;
|
||||
struct RTCRtpParameters;
|
||||
#ifdef USE_FAKE_MEDIA_STREAMS
|
||||
typedef Fake_MediaStreamTrack MediaStreamTrack;
|
||||
#else
|
||||
@ -443,6 +444,30 @@ public:
|
||||
rv = ReplaceTrack(aThisTrack, aWithTrack);
|
||||
}
|
||||
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
NS_IMETHODIMP_TO_ERRORRESULT(SetParameters, ErrorResult &rv,
|
||||
mozilla::dom::MediaStreamTrack& aTrack,
|
||||
const mozilla::dom::RTCRtpParameters& aParameters)
|
||||
{
|
||||
rv = SetParameters(aTrack, aParameters);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_TO_ERRORRESULT(GetParameters, ErrorResult &rv,
|
||||
mozilla::dom::MediaStreamTrack& aTrack,
|
||||
mozilla::dom::RTCRtpParameters& aOutParameters)
|
||||
{
|
||||
rv = GetParameters(aTrack, aOutParameters);
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
SetParameters(dom::MediaStreamTrack& aTrack,
|
||||
const std::vector<JsepTrack::JsConstraints>& aConstraints);
|
||||
|
||||
nsresult
|
||||
GetParameters(dom::MediaStreamTrack& aTrack,
|
||||
std::vector<JsepTrack::JsConstraints>* aOutConstraints);
|
||||
|
||||
nsresult GetPeerIdentity(nsAString& peerIdentity)
|
||||
{
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
|
Loading…
Reference in New Issue
Block a user