mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1230184 - add input parameter validation to setParameters. r=bwc
--HG-- extra : rebase_source : 184f1d2870e97d06706ea2e50520de39320b73b8
This commit is contained in:
parent
5855c2732e
commit
38ee4c5f0c
@ -1039,6 +1039,21 @@ RTCPeerConnection.prototype = {
|
||||
},
|
||||
|
||||
_setParameters: function(sender, parameters) {
|
||||
|
||||
// validate parameters input
|
||||
var encodings = parameters.encodings || [];
|
||||
|
||||
encodings.reduce((uniqueRids, encoding) => {
|
||||
if (!encoding.rid && encodings.length > 1) {
|
||||
throw new this._win.DOMException("Missing rid", "TypeError");
|
||||
}
|
||||
if (uniqueRids[encoding.rid]) {
|
||||
throw new this._win.DOMException("Duplicate rid", "TypeError");
|
||||
}
|
||||
uniqueRids[encoding.rid] = true;
|
||||
return uniqueRids;
|
||||
}, {});
|
||||
|
||||
this._impl.setParameters(sender.track, parameters);
|
||||
},
|
||||
|
||||
|
@ -2320,15 +2320,12 @@ PeerConnectionImpl::ReplaceTrack(MediaStreamTrack& aThisTrack,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
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()) {
|
||||
@ -2342,27 +2339,31 @@ PeerConnectionImpl::SetParameters(MediaStreamTrack& aTrack,
|
||||
constraints.push_back(constraint);
|
||||
}
|
||||
}
|
||||
nsresult rv = mJsepSession->SetParameters(streamId, trackId, constraints);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return SetParameters(aTrack, constraints);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
|
||||
nsresult
|
||||
PeerConnectionImpl::SetParameters(
|
||||
MediaStreamTrack& aTrack,
|
||||
const std::vector<JsepTrack::JsConstraints>& aConstraints)
|
||||
{
|
||||
std::string trackId = PeerConnectionImpl::GetTrackId(aTrack);
|
||||
std::string streamId = PeerConnectionImpl::GetStreamId(*aTrack.GetStream());
|
||||
|
||||
return mJsepSession->SetParameters(streamId, trackId, aConstraints);
|
||||
}
|
||||
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
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;
|
||||
return rv;
|
||||
}
|
||||
aOutParameters.mEncodings.Construct();
|
||||
for (auto& constraint : constraints) {
|
||||
@ -2371,9 +2372,20 @@ PeerConnectionImpl::GetParameters(MediaStreamTrack& aTrack,
|
||||
encoding.mMaxBitrate.Construct(constraint.constraints.maxBr);
|
||||
aOutParameters.mEncodings.Value().AppendElement(Move(encoding), fallible);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
PeerConnectionImpl::GetParameters(
|
||||
MediaStreamTrack& aTrack,
|
||||
std::vector<JsepTrack::JsConstraints>* aOutConstraints)
|
||||
{
|
||||
std::string trackId = PeerConnectionImpl::GetTrackId(aTrack);
|
||||
std::string streamId = PeerConnectionImpl::GetStreamId(*aTrack.GetStream());
|
||||
|
||||
return mJsepSession->GetParameters(streamId, trackId, aOutConstraints);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PeerConnectionImpl::CalculateFingerprint(
|
||||
|
@ -446,15 +446,15 @@ public:
|
||||
|
||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
||||
NS_IMETHODIMP_TO_ERRORRESULT(SetParameters, ErrorResult &rv,
|
||||
mozilla::dom::MediaStreamTrack& aTrack,
|
||||
const mozilla::dom::RTCRtpParameters& aParameters)
|
||||
dom::MediaStreamTrack& aTrack,
|
||||
const dom::RTCRtpParameters& aParameters)
|
||||
{
|
||||
rv = SetParameters(aTrack, aParameters);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_TO_ERRORRESULT(GetParameters, ErrorResult &rv,
|
||||
mozilla::dom::MediaStreamTrack& aTrack,
|
||||
mozilla::dom::RTCRtpParameters& aOutParameters)
|
||||
dom::MediaStreamTrack& aTrack,
|
||||
dom::RTCRtpParameters& aOutParameters)
|
||||
{
|
||||
rv = GetParameters(aTrack, aOutParameters);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user