Bug 1231975 - Part 1: Basic audio mochitests for NAT scenarios. r=drno

MozReview-Commit-ID: 1chfSrXeCL1

--HG--
extra : rebase_source : d5fa4d0138112d5932f4db43958b60f1606f0af2
extra : source : 81271ec54981bd4c7b0fa72889ba509e5c434ff4
This commit is contained in:
Byron Campen [:bwc] 2016-03-14 13:31:01 -05:00
parent 6fe30f7f6f
commit 18f4a13f02
10 changed files with 138 additions and 17 deletions

View File

@ -84,6 +84,12 @@ skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 1021776, too --ing
[test_peerConnection_addTrack.html]
[test_peerConnection_basicAudio.html]
skip-if = toolkit == 'gonk' # B2G emulator is too slow to handle a two-way audio call reliably
[test_peerConnection_basicAudioNATSrflx.html]
skip-if = toolkit == 'gonk' # B2G emulator is too slow to handle a two-way audio call reliably
[test_peerConnection_basicAudioNATRelay.html]
skip-if = toolkit == 'gonk' # B2G emulator is too slow to handle a two-way audio call reliably
[test_peerConnection_basicAudioNATRelayTCP.html]
skip-if = toolkit == 'gonk' # B2G emulator is too slow to handle a two-way audio call reliably
[test_peerConnection_basicAudioRequireEOC.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_peerConnection_basicAudioPcmaPcmuOnly.html]

View File

@ -65,10 +65,14 @@ function PeerConnectionTest(options) {
options.opus = "opus" in options ? options.opus : true;
if (iceServersArray.length) {
options.config_remote = options.config_remote || {}
options.config_local = options.config_local || {}
options.config_remote.iceServers = iceServersArray;
options.config_local.iceServers = iceServersArray;
if (!options.turn_disabled_local) {
options.config_local = options.config_local || {}
options.config_local.iceServers = iceServersArray;
}
if (!options.turn_disabled_remote) {
options.config_remote = options.config_remote || {}
options.config_remote.iceServers = iceServersArray;
}
}
else if (typeof turnServers !== "undefined") {
if ((!options.turn_disabled_local) && (turnServers.local)) {

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with port dependent NAT"
});
var test;
runNetworkTest(options => {
SpecialPowers.pushPrefEnv(
{
'set': [
['media.peerconnection.nat_simulator.filtering_type', 'PORT_DEPENDENT'],
['media.peerconnection.nat_simulator.mapping_type', 'PORT_DEPENDENT']
]
}, function (options) {
options = options || {};
options.expectedLocalCandidateType = "serverreflexive";
options.expectedRemoteCandidateType = "relayed";
// If both have TURN, it is a toss-up which one will end up using a
// relay.
options.turn_disabled_local = true;
test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
})
}, { useIceServer: true });
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,35 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with port dependent NAT that blocks UDP"
});
var test;
runNetworkTest(options => {
SpecialPowers.pushPrefEnv(
{
'set': [
['media.peerconnection.nat_simulator.filtering_type', 'PORT_DEPENDENT'],
['media.peerconnection.nat_simulator.mapping_type', 'PORT_DEPENDENT'],
['media.peerconnection.nat_simulator.block_udp', true]
]
}, function (options) {
options = options || {};
options.expectedLocalCandidateType = "relayed-tcp";
options.expectedRemoteCandidateType = "relayed-tcp";
test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
})
}, { useIceServer: true });
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,34 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1231975",
title: "Basic audio-only peer connection with endpoint independent NAT"
});
var test;
runNetworkTest(options => {
SpecialPowers.pushPrefEnv(
{
'set': [
['media.peerconnection.nat_simulator.filtering_type', 'ENDPOINT_INDEPENDENT'],
['media.peerconnection.nat_simulator.mapping_type', 'ENDPOINT_INDEPENDENT']
]
}, function (options) {
options = options || {};
options.expectedLocalCandidateType = "serverreflexive";
options.expectedRemoteCandidateType = "serverreflexive";
test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
})
}, { useIceServer: true });
</script>
</pre>
</body>
</html>

View File

@ -340,7 +340,7 @@ TCPSocketParent::RecvData(const SendableData& aData,
default:
MOZ_CRASH("unexpected SendableData type");
}
NS_ENSURE_FALSE(rv.Failed(), true);
NS_ENSURE_SUCCESS(rv.StealNSResult(), true);
return true;
}

View File

@ -710,7 +710,8 @@ int NrSocket::create(nr_transport_addr *addr) {
// Finally, register with the STS
rv = stservice->AttachSocket(fd_, this);
if (!NS_SUCCEEDED(rv)) {
r_log(LOG_GENERIC, LOG_CRIT, "Couldn't attach socket to STS");
r_log(LOG_GENERIC, LOG_CRIT, "Couldn't attach socket to STS, rv=%u",
static_cast<unsigned>(rv));
ABORT(R_INTERNAL);
}

View File

@ -576,8 +576,8 @@ NrIceCtx::Initialize(bool hide_non_default,
}
}
char* mapping_type = nullptr;
char* filtering_type = nullptr;
nsCString mapping_type;
nsCString filtering_type;
bool block_udp = false;
nsresult rv;
@ -590,22 +590,22 @@ NrIceCtx::Initialize(bool hide_non_default,
if (NS_SUCCEEDED(rv)) {
rv = pref_branch->GetCharPref(
"media.peerconnection.nat_simulator.mapping_type",
&mapping_type);
getter_Copies(mapping_type));
rv = pref_branch->GetCharPref(
"media.peerconnection.nat_simulator.filtering_type",
&filtering_type);
getter_Copies(filtering_type));
rv = pref_branch->GetBoolPref(
"media.peerconnection.nat_simulator.block_udp",
&block_udp);
}
}
if (mapping_type && filtering_type) {
MOZ_MTLOG(ML_DEBUG, "NAT filtering type: " << filtering_type);
MOZ_MTLOG(ML_DEBUG, "NAT mapping type: " << mapping_type);
if (!mapping_type.IsEmpty() && !filtering_type.IsEmpty()) {
MOZ_MTLOG(ML_DEBUG, "NAT filtering type: " << filtering_type.get());
MOZ_MTLOG(ML_DEBUG, "NAT mapping type: " << mapping_type.get());
TestNat* test_nat = new TestNat;
test_nat->filtering_type_ = TestNat::ToNatBehavior(filtering_type);
test_nat->mapping_type_ = TestNat::ToNatBehavior(mapping_type);
test_nat->filtering_type_ = TestNat::ToNatBehavior(filtering_type.get());
test_nat->mapping_type_ = TestNat::ToNatBehavior(mapping_type.get());
test_nat->block_udp_ = block_udp;
test_nat->enabled_ = true;
SetNat(test_nat);

View File

@ -252,8 +252,10 @@ int TestNrSocket::getaddr(nr_transport_addr *addrp) {
}
void TestNrSocket::close() {
// TODO: close port mappings too?
internal_socket_->close();
for (RefPtr<PortMapping>& port_mapping : port_mappings_) {
port_mapping->external_socket_->close();
}
}
int TestNrSocket::listen(int backlog) {

View File

@ -248,7 +248,9 @@ class TestNrSocket : public NrSocketBase {
nr_transport_addr remote_address_;
private:
~PortMapping(){}
~PortMapping() {
external_socket_->close();
}
// If external_socket_ returns E_WOULDBLOCK, we don't want to propagate
// that to the code using the TestNrSocket. We can also perhaps use this