Skip to content

Commit

Permalink
Backed out 3 changesets (bug 1641600) for failures at test_peerConnec…
Browse files Browse the repository at this point in the history
…tion_constructedStream.html. CLOSED TREE

Backed out changeset 41a85b7d3e5e (bug 1641600)
Backed out changeset 249782af96bb (bug 1641600)
Backed out changeset 86c2932e66d3 (bug 1641600)
  • Loading branch information
Butkovits Atila committed Jun 4, 2020
1 parent af5e269 commit 8257764
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 113 deletions.
6 changes: 0 additions & 6 deletions media/webrtc/signaling/src/jsep/JsepSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,10 @@ class JsepSession {
}
}

// See Bug 1642419, this can be removed when all sites are working with RTX.
void SetRtxIsAllowed(bool aRtxIsAllowed) { mRtxIsAllowed = aRtxIsAllowed; }

protected:
const std::string mName;
JsepSignalingState mState;
uint32_t mNegotiations;

// See Bug 1642419, this can be removed when all sites are working with RTX.
bool mRtxIsAllowed = true;
};

} // namespace mozilla
Expand Down
4 changes: 1 addition & 3 deletions media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ std::vector<SdpExtmapAttributeList::Extmap> JsepSessionImpl::GetRtpExtensions(
AddVideoRtpExtension(webrtc::RtpExtension::kRtpStreamIdUri,
SdpDirectionAttribute::kSendonly);

if (mRtxIsAllowed &&
Preferences::GetBool("media.peerconnection.video.use_rtx", false)) {
if (Preferences::GetBool("media.peerconnection.video.use_rtx", false)) {
AddVideoRtpExtension(webrtc::RtpExtension::kRepairedRtpStreamIdUri,
SdpDirectionAttribute::kSendonly);
}
Expand Down Expand Up @@ -1950,7 +1949,6 @@ void JsepSessionImpl::SetupDefaultCodecs() {
new JsepAudioCodecDescription("101", "telephone-event", 8000, 1));

bool useRtx =
mRtxIsAllowed &&
Preferences::GetBool("media.peerconnection.video.use_rtx", false);
// Supported video codecs.
// Note: order here implies priority for building offers!
Expand Down
1 change: 0 additions & 1 deletion media/webrtc/signaling/src/jsep/JsepTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ std::vector<UniquePtr<JsepCodecDescription>> JsepTrack::NegotiateCodecs(
JsepVideoCodecDescription* cloneVideoCodec =
static_cast<JsepVideoCodecDescription*>(clone.get());
bool useRtx =
mRtxIsAllowed &&
Preferences::GetBool("media.peerconnection.video.use_rtx", false);
videoCodec->mRtxEnabled = useRtx && cloneVideoCodec->mRtxEnabled;
videoCodec->mRtxPayloadType = cloneVideoCodec->mRtxPayloadType;
Expand Down
9 changes: 1 addition & 8 deletions media/webrtc/signaling/src/jsep/JsepTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ class JsepTrack {

virtual std::vector<uint32_t> GetRtxSsrcs() const {
std::vector<uint32_t> result;
if (mRtxIsAllowed &&
Preferences::GetBool("media.peerconnection.video.use_rtx", false)) {
if (Preferences::GetBool("media.peerconnection.video.use_rtx", false)) {
std::for_each(
mSsrcToRtxSsrc.begin(), mSsrcToRtxSsrc.end(),
[&result](const auto& pair) { result.push_back(pair.second); });
Expand Down Expand Up @@ -279,9 +278,6 @@ class JsepTrack {
sdp::Direction direction, SsrcGenerator& ssrcGenerator,
bool requireRtxSsrcs, SdpMediaSection* msection);

// See Bug 1642419, this can be removed when all sites are working with RTX.
void SetRtxIsAllowed(bool aRtxIsAllowed) { mRtxIsAllowed = aRtxIsAllowed; }

private:
std::vector<UniquePtr<JsepCodecDescription>> GetCodecClones() const;
static void EnsureNoDuplicatePayloadTypes(
Expand Down Expand Up @@ -329,9 +325,6 @@ class JsepTrack {
std::map<uint32_t, uint32_t> mSsrcToRtxSsrc;
bool mActive;
bool mRemoteSetSendBit;

// See Bug 1642419, this can be removed when all sites are working with RTX.
bool mRtxIsAllowed = true;
};

} // namespace mozilla
Expand Down
6 changes: 0 additions & 6 deletions media/webrtc/signaling/src/jsep/JsepTransceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,6 @@ class JsepTransceiver {
return false;
}

// See Bug 1642419, this can be removed when all sites are working with RTX.
void SetRtxIsAllowed(bool aRtxIsAllowed) {
mSendTrack.SetRtxIsAllowed(aRtxIsAllowed);
mRecvTrack.SetRtxIsAllowed(aRtxIsAllowed);
}

// This is the direction JS wants. It might not actually happen.
SdpDirectionAttribute::Direction mJsDirection;

Expand Down
75 changes: 0 additions & 75 deletions media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "pk11pub.h"

#include "nsNetCID.h"
#include "nsIIDNService.h"
#include "nsILoadContext.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
Expand Down Expand Up @@ -322,10 +321,6 @@ PeerConnectionImpl::PeerConnectionImpl(const GlobalObject* aGlobal)
}
mWindow->AddPeerConnection();
mActiveOnWindow = true;

mRtxIsAllowed =
!HostnameInPref("media.peerconnection.video.use_rtx.blocklist",
mWindow->GetDocumentURI());
}
CSFLogInfo(LOGTAG, "%s: PeerConnectionImpl constructor for %s", __FUNCTION__,
mHandle.c_str());
Expand Down Expand Up @@ -473,7 +468,6 @@ nsresult PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,

mJsepSession =
MakeUnique<JsepSessionImpl>(mName, MakeUnique<PCUuidGenerator>());
mJsepSession->SetRtxIsAllowed(mRtxIsAllowed);

res = mJsepSession->Init();
if (NS_FAILED(res)) {
Expand Down Expand Up @@ -1032,8 +1026,6 @@ already_AddRefed<TransceiverImpl> PeerConnectionImpl::CreateTransceiverImpl(
return nullptr;
}

jsepTransceiver->SetRtxIsAllowed(mRtxIsAllowed);

// Do this last, since it is not possible to roll back.
nsresult rv = AddRtpTransceiverToJsepSession(jsepTransceiver);
if (NS_FAILED(rv)) {
Expand Down Expand Up @@ -1706,73 +1698,6 @@ void PeerConnectionImpl::DumpPacket_m(size_t level, dom::mozPacketDumpType type,
mPCObserver->OnPacket(level, type, sending, arrayBuffer, jrv);
}

bool PeerConnectionImpl::HostnameInPref(const char* aPref, nsIURI* aDocURI) {
auto HostInDomain = [](const nsCString& aHost, const nsCString& aPattern) {
int32_t patternOffset = 0;
int32_t hostOffset = 0;

// Act on '*.' wildcard in the left-most position in a domain pattern.
if (StringBeginsWith(aPattern, nsCString("*."))) {
patternOffset = 2;

// Ignore the lowest level sub-domain for the hostname.
hostOffset = aHost.FindChar('.') + 1;

if (hostOffset <= 1) {
// Reject a match between a wildcard and a TLD or '.foo' form.
return false;
}
}

nsDependentCString hostRoot(aHost, hostOffset);
return hostRoot.EqualsIgnoreCase(aPattern.BeginReading() + patternOffset);
};

if (!aDocURI) {
return false;
}

nsCString hostName;
aDocURI->GetAsciiHost(hostName); // normalize UTF8 to ASCII equivalent
nsCString domainList;
nsresult nr = Preferences::GetCString(aPref, domainList);

if (NS_FAILED(nr)) {
return false;
}

domainList.StripWhitespace();

if (domainList.IsEmpty() || hostName.IsEmpty()) {
return false;
}

// Get UTF8 to ASCII domain name normalization service
nsresult rv;
nsCOMPtr<nsIIDNService> idnService =
do_GetService("@mozilla.org/network/idn-service;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}

// Test each domain name in the comma separated list
// after converting from UTF8 to ASCII. Each domain
// must match exactly or have a single leading '*.' wildcard.
for (const nsACString& each : domainList.Split(',')) {
nsCString domainName;
rv = idnService->ConvertUTF8toACE(each, domainName);
if (NS_SUCCEEDED(rv)) {
if (HostInDomain(hostName, domainName)) {
return true;
}
} else {
NS_WARNING("Failed to convert UTF-8 host to ASCII");
}
}

return false;
}

nsresult PeerConnectionImpl::EnablePacketDump(unsigned long level,
dom::mozPacketDumpType type,
bool sending) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,6 @@ class PeerConnectionImpl final
return mTimestampMaker;
}

// Utility function, given a string pref and an URI, returns whether or not
// the URI occurs in the pref. Wildcards are supported (e.g. *.example.com)
// and multiple hostnames can be present, separated by commas.
static bool HostnameInPref(const char* aPrefList, nsIURI* aDocURI);

private:
virtual ~PeerConnectionImpl();
PeerConnectionImpl(const PeerConnectionImpl& rhs);
Expand Down Expand Up @@ -614,9 +609,6 @@ class PeerConnectionImpl final
DOMMediaStream* GetReceiveStream(const std::string& aId) const;
DOMMediaStream* CreateReceiveStream(const std::string& aId);

// See Bug 1642419, this can be removed when all sites are working with RTX.
bool mRtxIsAllowed = true;

public:
// these are temporary until the DataChannel Listen/Connect API is removed
unsigned short listenPort;
Expand Down
87 changes: 84 additions & 3 deletions media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,88 @@ bool PeerConnectionMedia::GetPrefDefaultAddressOnly() const {
return default_address_only;
}

static bool HostInDomain(const nsCString& aHost, const nsCString& aPattern) {
int32_t patternOffset = 0;
int32_t hostOffset = 0;

// Act on '*.' wildcard in the left-most position in a domain pattern.
if (aPattern.Length() > 2 && aPattern[0] == '*' && aPattern[1] == '.') {
patternOffset = 2;

// Ignore the lowest level sub-domain for the hostname.
hostOffset = aHost.FindChar('.') + 1;

if (hostOffset <= 1) {
// Reject a match between a wildcard and a TLD or '.foo' form.
return false;
}
}

nsDependentCString hostRoot(aHost, hostOffset);
return hostRoot.EqualsIgnoreCase(aPattern.BeginReading() + patternOffset);
}

static bool HostInObfuscationWhitelist(nsIURI* docURI) {
if (!docURI) {
return false;
}

nsCString hostName;
docURI->GetAsciiHost(hostName); // normalize UTF8 to ASCII equivalent
nsCString domainWhiteList;
nsresult nr = Preferences::GetCString(
"media.peerconnection.ice.obfuscate_host_addresses.whitelist",
domainWhiteList);

if (NS_FAILED(nr)) {
return false;
}

domainWhiteList.StripWhitespace();

if (domainWhiteList.IsEmpty() || hostName.IsEmpty()) {
return false;
}

// Get UTF8 to ASCII domain name normalization service
nsresult rv;
nsCOMPtr<nsIIDNService> idnService =
do_GetService("@mozilla.org/network/idn-service;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}

uint32_t begin = 0;
uint32_t end = 0;
nsCString domainName;
/*
Test each domain name in the comma separated list
after converting from UTF8 to ASCII. Each domain
must match exactly or have a single leading '*.' wildcard
*/
do {
end = domainWhiteList.FindChar(',', begin);
if (end == (uint32_t)-1) {
// Last or only domain name in the comma separated list
end = domainWhiteList.Length();
}

rv = idnService->ConvertUTF8toACE(
Substring(domainWhiteList, begin, end - begin), domainName);
if (NS_SUCCEEDED(rv)) {
if (HostInDomain(hostName, domainName)) {
return true;
}
} else {
NS_WARNING("Failed to convert UTF-8 host to ASCII");
}

begin = end + 1;
} while (end < domainWhiteList.Length());

return false;
}

bool PeerConnectionMedia::GetPrefObfuscateHostAddresses() const {
ASSERT_ON_THREAD(mMainThread); // will crash on STS thread

Expand All @@ -337,9 +419,8 @@ bool PeerConnectionMedia::GetPrefObfuscateHostAddresses() const {
"media.peerconnection.ice.obfuscate_host_addresses", false);
obfuscate_host_addresses &=
!MediaManager::Get()->IsActivelyCapturingOrHasAPermission(winId);
obfuscate_host_addresses &= !PeerConnectionImpl::HostnameInPref(
"media.peerconnection.ice.obfuscate_host_addresses.whitelist",
mParent->GetWindow()->GetDocumentURI());
obfuscate_host_addresses &=
!HostInObfuscationWhitelist(mParent->GetWindow()->GetDocumentURI());
obfuscate_host_addresses &= XRE_IsContentProcess();

return obfuscate_host_addresses;
Expand Down
4 changes: 1 addition & 3 deletions modules/libpref/init/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,10 @@ pref("media.videocontrols.picture-in-picture.video-toggle.min-video-secs", 45);
pref("media.navigator.video.use_remb", true);
#ifdef EARLY_BETA_OR_EARLIER
pref("media.navigator.video.use_transport_cc", true);
pref("media.peerconnection.video.use_rtx", true);
#else
pref("media.navigator.video.use_transport_cc", false);
pref("media.peerconnection.video.use_rtx", false);
#endif
pref("media.peerconnection.video.use_rtx.blocklist", "*.google.com");
pref("media.peerconnection.video.use_rtx", false);
pref("media.navigator.video.use_tmmbr", false);
pref("media.navigator.audio.use_fec", true);
pref("media.navigator.video.red_ulpfec_enabled", false);
Expand Down

0 comments on commit 8257764

Please sign in to comment.