Backed out changesets 1e581e74878d, 7d2138e87ca0, and 7cc66aee4341 (bug 942367) for B2G mochitest failures.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2014-04-17 22:26:07 -04:00
Родитель b22f8622e0
Коммит ecb85b74fb
24 изменённых файлов: 277 добавлений и 1152 удалений

Просмотреть файл

@ -11,10 +11,9 @@
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "StreamBuffer.h" #include "StreamBuffer.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsIPrincipal.h"
#include "mozilla/PeerIdentity.h"
class nsXPCClassInfo; class nsXPCClassInfo;
class nsIPrincipal;
// GetCurrentTime is defined in winbase.h as zero argument macro forwarding to // GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
// GetTickCount() and conflicts with NS_DECL_NSIDOMMEDIASTREAM, containing // GetTickCount() and conflicts with NS_DECL_NSIDOMMEDIASTREAM, containing
@ -96,17 +95,6 @@ public:
*/ */
nsIPrincipal* GetPrincipal() { return mPrincipal; } nsIPrincipal* GetPrincipal() { return mPrincipal; }
/**
* These are used in WebRTC. A peerIdentity constrained MediaStream cannot be sent
* across the network to anything other than a peer with the provided identity.
* If this is set, then mPrincipal should be an instance of nsNullPrincipal.
*/
PeerIdentity* GetPeerIdentity() const { return mPeerIdentity; }
void SetPeerIdentity(PeerIdentity* aPeerIdentity)
{
mPeerIdentity = aPeerIdentity;
}
/** /**
* Indicate that data will be contributed to this stream from origin aPrincipal. * Indicate that data will be contributed to this stream from origin aPrincipal.
* If aPrincipal is null, this is ignored. Otherwise, from now on the contents * If aPrincipal is null, this is ignored. Otherwise, from now on the contents
@ -115,13 +103,6 @@ public:
*/ */
bool CombineWithPrincipal(nsIPrincipal* aPrincipal); bool CombineWithPrincipal(nsIPrincipal* aPrincipal);
/**
* This is used in WebRTC to move from a protected state (nsNullPrincipal) to
* one where the stream is accessible to script. Don't call this.
* CombineWithPrincipal is almost certainly more appropriate.
*/
void SetPrincipal(nsIPrincipal* aPrincipal) { mPrincipal = aPrincipal; }
/** /**
* Called when this stream's MediaStreamGraph has been shut down. Normally * Called when this stream's MediaStreamGraph has been shut down. Normally
* MSGs are only shut down when all streams have been removed, so this * MSGs are only shut down when all streams have been removed, so this
@ -219,9 +200,6 @@ protected:
// Principal identifying who may access the contents of this stream. // Principal identifying who may access the contents of this stream.
// If null, this stream can be used by anyone because it has no content yet. // If null, this stream can be used by anyone because it has no content yet.
nsCOMPtr<nsIPrincipal> mPrincipal; nsCOMPtr<nsIPrincipal> mPrincipal;
// this is used in gUM and WebRTC to identify peers that this stream
// is allowed to be sent to
nsAutoPtr<PeerIdentity> mPeerIdentity;
nsAutoTArray<nsRefPtr<MediaStreamTrack>,2> mTracks; nsAutoTArray<nsRefPtr<MediaStreamTrack>,2> mTracks;
nsRefPtr<StreamListener> mListener; nsRefPtr<StreamListener> mListener;

Просмотреть файл

@ -1,84 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=2 sts=2 expandtab
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "PeerIdentity.h"
#include "nsCOMPtr.h"
#include "nsIIDNService.h"
#include "nsNetCID.h"
#include "nsServiceManagerUtils.h"
namespace mozilla {
bool
PeerIdentity::Equals(const PeerIdentity& aOther) const
{
return Equals(aOther.mPeerIdentity);
}
bool
PeerIdentity::Equals(const nsAString& aOtherString) const
{
nsString user;
GetUser(mPeerIdentity, user);
nsString otherUser;
GetUser(aOtherString, otherUser);
if (user != otherUser) {
return false;
}
nsString host;
GetHost(mPeerIdentity, host);
nsString otherHost;
GetHost(aOtherString, otherHost);
nsresult rv;
nsCOMPtr<nsIIDNService> idnService
= do_GetService("@mozilla.org/network/idn-service;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return host == otherHost;
}
nsCString normHost;
GetNormalizedHost(idnService, host, normHost);
nsCString normOtherHost;
GetNormalizedHost(idnService, otherHost, normOtherHost);
return normHost == normOtherHost;
}
/* static */ void
PeerIdentity::GetUser(const nsAString& aPeerIdentity, nsAString& aUser)
{
int32_t at = aPeerIdentity.FindChar('@');
if (at >= 0) {
aUser = Substring(aPeerIdentity, 0, at);
} else {
aUser.Truncate();
}
}
/* static */ void
PeerIdentity::GetHost(const nsAString& aPeerIdentity, nsAString& aHost)
{
int32_t at = aPeerIdentity.FindChar('@');
if (at >= 0) {
aHost = Substring(aPeerIdentity, at + 1);
} else {
aHost = aPeerIdentity;
}
}
/* static */ void
PeerIdentity::GetNormalizedHost(const nsCOMPtr<nsIIDNService>& aIdnService,
const nsAString& aHost,
nsACString& aNormalizedHost)
{
nsCString chost = NS_ConvertUTF16toUTF8(aHost);
nsresult rv = aIdnService->ConvertUTF8toACE(chost, aNormalizedHost);
NS_WARN_IF(NS_FAILED(rv));
}
} /* namespace mozilla */

Просмотреть файл

@ -1,79 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=2 sts=2 expandtab
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef PeerIdentity_h
#define PeerIdentity_h
#ifdef MOZILLA_INTERNAL_API
#include "nsString.h"
#else
#include "nsStringAPI.h"
#endif
template <class T> class nsCOMPtr;
class nsIIDNService;
namespace mozilla {
/**
* This class implements the identifier used in WebRTC identity. Peers are
* identified using a string in the form [<user>@]<domain>, for instance,
* "user@example.com'. The (optional) user portion is a site-controlled string
* containing any character other than '@'. The domain portion is a valid IDN
* domain name and is compared accordingly.
*
* See: http://tools.ietf.org/html/draft-ietf-rtcweb-security-arch-09#section-5.6.5.3.3.1
*/
class PeerIdentity MOZ_FINAL
{
public:
PeerIdentity(const nsAString& aPeerIdentity)
: mPeerIdentity(aPeerIdentity) {}
~PeerIdentity() {}
bool Equals(const PeerIdentity& aOther) const;
bool Equals(const nsAString& aOtherString) const;
const nsString& ToString() const { return mPeerIdentity; }
private:
static void GetUser(const nsAString& aPeerIdentity, nsAString& aUser);
static void GetHost(const nsAString& aPeerIdentity, nsAString& aHost);
static void GetNormalizedHost(const nsCOMPtr<nsIIDNService>& aIdnService,
const nsAString& aHost,
nsACString& aNormalizedHost);
nsString mPeerIdentity;
};
inline bool
operator==(const PeerIdentity& aOne, const PeerIdentity& aTwo)
{
return aOne.Equals(aTwo);
}
inline bool
operator==(const PeerIdentity& aOne, const nsAString& aString)
{
return aOne.Equals(aString);
}
inline bool
operator!=(const PeerIdentity& aOne, const PeerIdentity& aTwo)
{
return !aOne.Equals(aTwo);
}
inline bool
operator!=(const PeerIdentity& aOne, const nsAString& aString)
{
return !aOne.Equals(aString);
}
} /* namespace mozilla */
#endif /* PeerIdentity_h */

Просмотреть файл

@ -47,11 +47,6 @@ XPIDL_SOURCES += [
UNIFIED_SOURCES += [ UNIFIED_SOURCES += [
'MediaEngineDefault.cpp', 'MediaEngineDefault.cpp',
'PeerIdentity.cpp',
]
EXPORTS.mozilla += [
'PeerIdentity.h',
] ]
include('/ipc/chromium/chromium-config.mozbuild') include('/ipc/chromium/chromium-config.mozbuild')

Просмотреть файл

@ -23,7 +23,6 @@
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
#include "mozilla/PeerIdentity.h"
#include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/MediaStreamBinding.h" #include "mozilla/dom/MediaStreamBinding.h"
#include "mozilla/dom/MediaStreamTrackBinding.h" #include "mozilla/dom/MediaStreamTrackBinding.h"
@ -38,8 +37,6 @@
#include "nsDOMFile.h" #include "nsDOMFile.h"
#include "nsGlobalWindow.h" #include "nsGlobalWindow.h"
#include "mozilla/Preferences.h"
/* Using WebRTC backend on Desktops (Mac, Windows, Linux), otherwise default */ /* Using WebRTC backend on Desktops (Mac, Windows, Linux), otherwise default */
#include "MediaEngineDefault.h" #include "MediaEngineDefault.h"
#if defined(MOZ_WEBRTC) #if defined(MOZ_WEBRTC)
@ -90,7 +87,7 @@ using dom::OwningBooleanOrMediaTrackConstraintsInternal;
static nsresult CompareDictionaries(JSContext* aCx, JSObject *aA, static nsresult CompareDictionaries(JSContext* aCx, JSObject *aA,
const MediaTrackConstraintSet &aB, const MediaTrackConstraintSet &aB,
nsAString &aDifference) nsString *aDifference)
{ {
JS::Rooted<JSObject*> a(aCx, aA); JS::Rooted<JSObject*> a(aCx, aA);
JSAutoCompartment ac(aCx, aA); JSAutoCompartment ac(aCx, aA);
@ -117,11 +114,11 @@ static nsresult CompareDictionaries(JSContext* aCx, JSObject *aA,
JS::Rooted<JSString*> namestr(aCx, JS::ToString(aCx, nameval)); JS::Rooted<JSString*> namestr(aCx, JS::ToString(aCx, nameval));
NS_ENSURE_TRUE(namestr, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(namestr, NS_ERROR_UNEXPECTED);
aDifference.Assign(JS_GetStringCharsZ(aCx, namestr)); aDifference->Assign(JS_GetStringCharsZ(aCx, namestr));
return NS_OK; return NS_OK;
} }
} }
aDifference.Truncate(); aDifference->Truncate();
return NS_OK; return NS_OK;
} }
@ -505,13 +502,11 @@ public:
uint64_t aWindowID, uint64_t aWindowID,
GetUserMediaCallbackMediaStreamListener* aListener, GetUserMediaCallbackMediaStreamListener* aListener,
MediaEngineSource* aAudioSource, MediaEngineSource* aAudioSource,
MediaEngineSource* aVideoSource, MediaEngineSource* aVideoSource)
PeerIdentity* aPeerIdentity)
: mAudioSource(aAudioSource) : mAudioSource(aAudioSource)
, mVideoSource(aVideoSource) , mVideoSource(aVideoSource)
, mWindowID(aWindowID) , mWindowID(aWindowID)
, mListener(aListener) , mListener(aListener)
, mPeerIdentity(aPeerIdentity)
, mManager(MediaManager::GetInstance()) , mManager(MediaManager::GetInstance())
{ {
mSuccess.swap(aSuccess); mSuccess.swap(aSuccess);
@ -630,16 +625,9 @@ public:
reinterpret_cast<uint64_t>(stream.get()), reinterpret_cast<uint64_t>(stream.get()),
reinterpret_cast<int64_t>(trackunion->GetStream())); reinterpret_cast<int64_t>(trackunion->GetStream()));
nsCOMPtr<nsIPrincipal> principal; trackunion->CombineWithPrincipal(window->GetExtantDoc()->NodePrincipal());
if (mPeerIdentity) {
principal = do_CreateInstance("@mozilla.org/nullprincipal;1");
trackunion->SetPeerIdentity(mPeerIdentity.forget());
} else {
principal = window->GetExtantDoc()->NodePrincipal();
}
trackunion->CombineWithPrincipal(principal);
// The listener was added at the beginning in an inactive state. // The listener was added at the begining in an inactive state.
// Activate our listener. We'll call Start() on the source when get a callback // Activate our listener. We'll call Start() on the source when get a callback
// that the MediaStream has started consuming. The listener is freed // that the MediaStream has started consuming. The listener is freed
// when the page is invalidated (on navigation or close). // when the page is invalidated (on navigation or close).
@ -680,7 +668,6 @@ private:
nsRefPtr<MediaEngineSource> mVideoSource; nsRefPtr<MediaEngineSource> mVideoSource;
uint64_t mWindowID; uint64_t mWindowID;
nsRefPtr<GetUserMediaCallbackMediaStreamListener> mListener; nsRefPtr<GetUserMediaCallbackMediaStreamListener> mListener;
nsAutoPtr<PeerIdentity> mPeerIdentity;
nsRefPtr<MediaManager> mManager; // get ref to this when creating the runnable nsRefPtr<MediaManager> mManager; // get ref to this when creating the runnable
}; };
@ -1050,14 +1037,9 @@ public:
return; return;
} }
} }
PeerIdentity* peerIdentity = nullptr;
if (!mConstraints.mPeerIdentity.IsEmpty()) {
peerIdentity = new PeerIdentity(mConstraints.mPeerIdentity);
}
NS_DispatchToMainThread(new GetUserMediaStreamRunnable( NS_DispatchToMainThread(new GetUserMediaStreamRunnable(
mSuccess, mError, mWindowID, mListener, aAudioSource, aVideoSource, mSuccess, mError, mWindowID, mListener, aAudioSource, aVideoSource
peerIdentity
)); ));
MOZ_ASSERT(!mSuccess); MOZ_ASSERT(!mSuccess);
@ -1352,13 +1334,13 @@ MediaManager::GetUserMedia(JSContext* aCx, bool aPrivileged,
if (audioObj) { if (audioObj) {
nsresult rv = CompareDictionaries(aCx, audioObj, nsresult rv = CompareDictionaries(aCx, audioObj,
c.mAudio.GetAsMediaTrackConstraintsInternal().mMandatory, c.mAudio.GetAsMediaTrackConstraintsInternal().mMandatory,
unknownConstraintFound); &unknownConstraintFound);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
if (videoObj) { if (videoObj) {
nsresult rv = CompareDictionaries(aCx, videoObj, nsresult rv = CompareDictionaries(aCx, videoObj,
c.mVideo.GetAsMediaTrackConstraintsInternal().mMandatory, c.mVideo.GetAsMediaTrackConstraintsInternal().mMandatory,
unknownConstraintFound); &unknownConstraintFound);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
@ -1699,7 +1681,8 @@ MediaManager::RemoveFromWindowList(uint64_t aWindowID,
// Notify the UI that this window no longer has gUM active // Notify the UI that this window no longer has gUM active
char windowBuffer[32]; char windowBuffer[32];
PR_snprintf(windowBuffer, sizeof(windowBuffer), "%llu", outerID); PR_snprintf(windowBuffer, sizeof(windowBuffer), "%llu", outerID);
nsString data = NS_ConvertUTF8toUTF16(windowBuffer); nsAutoString data;
data.Append(NS_ConvertUTF8toUTF16(windowBuffer));
nsCOMPtr<nsIObserverService> obs = services::GetObserverService(); nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
obs->NotifyObservers(nullptr, "recording-window-ended", data.get()); obs->NotifyObservers(nullptr, "recording-window-ended", data.get());

Просмотреть файл

@ -291,8 +291,8 @@ RTCPeerConnection.prototype = {
this._trickleIce = Services.prefs.getBoolPref("media.peerconnection.trickle_ice"); this._trickleIce = Services.prefs.getBoolPref("media.peerconnection.trickle_ice");
if (!rtcConfig.iceServers || if (!rtcConfig.iceServers ||
!Services.prefs.getBoolPref("media.peerconnection.use_document_iceservers")) { !Services.prefs.getBoolPref("media.peerconnection.use_document_iceservers")) {
rtcConfig.iceServers = rtcConfig = {iceServers:
JSON.parse(Services.prefs.getCharPref("media.peerconnection.default_iceservers")); JSON.parse(Services.prefs.getCharPref("media.peerconnection.default_iceservers"))};
} }
this._mustValidateRTCConfiguration(rtcConfig, this._mustValidateRTCConfiguration(rtcConfig,
"RTCPeerConnection constructor passed invalid RTCConfiguration"); "RTCPeerConnection constructor passed invalid RTCConfiguration");
@ -347,19 +347,6 @@ RTCPeerConnection.prototype = {
return this._pc; return this._pc;
}, },
callCB: function(callback, arg) {
if (callback) {
try {
callback(arg);
} catch(e) {
// A content script (user-provided) callback threw an error. We don't
// want this to take down peerconnection, but we still want the user
// to see it, so we catch it, report it, and move on.
this.reportError(e.message, e.fileName, e.lineNumber);
}
}
},
_initIdp: function() { _initIdp: function() {
let prefName = "media.peerconnection.identity.timeout"; let prefName = "media.peerconnection.identity.timeout";
let idpTimeout = Services.prefs.getIntPref(prefName); let idpTimeout = Services.prefs.getIntPref(prefName);
@ -672,6 +659,15 @@ RTCPeerConnection.prototype = {
"Invalid type " + desc.type + " provided to setRemoteDescription"); "Invalid type " + desc.type + " provided to setRemoteDescription");
} }
try {
let processIdentity = this._processIdentity.bind(this);
this._remoteIdp.verifyIdentityFromSDP(desc.sdp, processIdentity);
} catch (e) {
this.reportWarning(e.message, e.fileName, e.lineNumber);
// only happens if processing the SDP for identity doesn't work
// let _setRemoteDescription do the error reporting
}
this._queueOrRun({ this._queueOrRun({
func: this._setRemoteDescription, func: this._setRemoteDescription,
args: [type, desc.sdp, onSuccess, onError], args: [type, desc.sdp, onSuccess, onError],
@ -680,84 +676,18 @@ RTCPeerConnection.prototype = {
}); });
}, },
/** _processIdentity: function(message) {
* Takes a result from the IdP and checks it against expectations. if (message) {
* If OK, generates events.
* Returns true if it is either present and valid, or if there is no
* need for identity.
*/
_processIdpResult: function(message) {
let good = !!message;
// This might be a valid assertion, but if we are constrained to a single peer
// identity, then we also need to make sure that the assertion matches
if (good && this._impl.peerIdentity) {
good = (message.identity === this._impl.peerIdentity);
}
if (good) {
this._impl.peerIdentity = message.identity;
this._peerIdentity = new this._win.RTCIdentityAssertion( this._peerIdentity = new this._win.RTCIdentityAssertion(
this._remoteIdp.provider, message.identity); this._remoteIdp.provider, message.identity);
let args = { peerIdentity: this._peerIdentity };
this.dispatchEvent(new this._win.Event("peeridentity")); this.dispatchEvent(new this._win.Event("peeridentity"));
} }
return good;
}, },
_setRemoteDescription: function(type, sdp, onSuccess, onError) { _setRemoteDescription: function(type, sdp, onSuccess, onError) {
let idpComplete = false; this._onSetRemoteDescriptionSuccess = onSuccess;
let setRemoteComplete = false;
let idpError = null;
// we can run the IdP validation in parallel with setRemoteDescription this
// complicates much more than would be ideal, but it ensures that the IdP
// doesn't hold things up too much when it's not on the critical path
let allDone = () => {
if (!setRemoteComplete || !idpComplete || !onSuccess) {
return;
}
this._remoteType = this._pendingType;
this._pendingType = null;
this.callCB(onSuccess);
onSuccess = null;
this._executeNext();
};
let setRemoteDone = () => {
setRemoteComplete = true;
allDone();
};
// If we aren't waiting for something specific, allow this
// to complete asynchronously.
let idpDone;
if (!this._impl.peerIdentity) {
idpDone = this._processIdpResult.bind(this);
idpComplete = true; // lie about this for allDone()
} else {
idpDone = message => {
let idpGood = this._processIdpResult(message);
if (!idpGood) {
// iff we are waiting for a very specific peerIdentity
// call the error callback directly and then close
idpError = "Peer Identity mismatch, expected: " +
this._impl.peerIdentity;
this.callCB(onError, idpError);
this.close();
} else {
idpComplete = true;
allDone();
}
};
}
try {
this._remoteIdp.verifyIdentityFromSDP(sdp, idpDone);
} catch (e) {
// if processing the SDP for identity doesn't work
this.reportWarning(e.message, e.fileName, e.lineNumber);
idpDone(null);
}
this._onSetRemoteDescriptionSuccess = setRemoteDone;
this._onSetRemoteDescriptionFailure = onError; this._onSetRemoteDescriptionFailure = onError;
this._impl.setRemoteDescription(type, sdp); this._impl.setRemoteDescription(type, sdp);
}, },
@ -776,14 +706,14 @@ RTCPeerConnection.prototype = {
getIdentityAssertion: function() { getIdentityAssertion: function() {
this._checkClosed(); this._checkClosed();
var gotAssertion = assertion => { function gotAssertion(assertion) {
if (assertion) { if (assertion) {
this._gotIdentityAssertion(assertion); this._gotIdentityAssertion(assertion);
} }
}; }
this._localIdp.getIdentityAssertion(this._impl.fingerprint, this._localIdp.getIdentityAssertion(this._impl.fingerprint,
gotAssertion); gotAssertion.bind(this));
}, },
updateIce: function(config, constraints) { updateIce: function(config, constraints) {
@ -1037,6 +967,19 @@ PeerConnectionObserver.prototype = {
this._dompc.dispatchEvent(event); this._dompc.dispatchEvent(event);
}, },
callCB: function(callback, arg) {
if (callback) {
try {
callback(arg);
} catch(e) {
// A content script (user-provided) callback threw an error. We don't
// want this to take down peerconnection, but we still want the user
// to see it, so we catch it, report it, and move on.
this._dompc.reportError(e.message, e.fileName, e.lineNumber);
}
}
},
onCreateOfferSuccess: function(sdp) { onCreateOfferSuccess: function(sdp) {
let pc = this._dompc; let pc = this._dompc;
let fp = pc._impl.fingerprint; let fp = pc._impl.fingerprint;
@ -1044,7 +987,7 @@ PeerConnectionObserver.prototype = {
if (assertion) { if (assertion) {
pc._gotIdentityAssertion(assertion); pc._gotIdentityAssertion(assertion);
} }
pc.callCB(pc._onCreateOfferSuccess, this.callCB(pc._onCreateOfferSuccess,
new pc._win.mozRTCSessionDescription({ type: "offer", new pc._win.mozRTCSessionDescription({ type: "offer",
sdp: sdp })); sdp: sdp }));
pc._executeNext(); pc._executeNext();
@ -1052,7 +995,7 @@ PeerConnectionObserver.prototype = {
}, },
onCreateOfferError: function(code, message) { onCreateOfferError: function(code, message) {
this._dompc.callCB(this._dompc._onCreateOfferFailure, new RTCError(code, message)); this.callCB(this._dompc._onCreateOfferFailure, new RTCError(code, message));
this._dompc._executeNext(); this._dompc._executeNext();
}, },
@ -1063,7 +1006,7 @@ PeerConnectionObserver.prototype = {
if (assertion) { if (assertion) {
pc._gotIdentityAssertion(assertion); pc._gotIdentityAssertion(assertion);
} }
pc.callCB(pc._onCreateAnswerSuccess, this.callCB (pc._onCreateAnswerSuccess,
new pc._win.mozRTCSessionDescription({ type: "answer", new pc._win.mozRTCSessionDescription({ type: "answer",
sdp: sdp })); sdp: sdp }));
pc._executeNext(); pc._executeNext();
@ -1071,15 +1014,14 @@ PeerConnectionObserver.prototype = {
}, },
onCreateAnswerError: function(code, message) { onCreateAnswerError: function(code, message) {
this._dompc.callCB(this._dompc._onCreateAnswerFailure, this.callCB(this._dompc._onCreateAnswerFailure, new RTCError(code, message));
new RTCError(code, message));
this._dompc._executeNext(); this._dompc._executeNext();
}, },
onSetLocalDescriptionSuccess: function() { onSetLocalDescriptionSuccess: function() {
this._dompc._localType = this._dompc._pendingType; this._dompc._localType = this._dompc._pendingType;
this._dompc._pendingType = null; this._dompc._pendingType = null;
this._dompc.callCB(this._dompc._onSetLocalDescriptionSuccess); this.callCB(this._dompc._onSetLocalDescriptionSuccess);
if (this._dompc._iceGatheringState == "complete") { if (this._dompc._iceGatheringState == "complete") {
// If we are not trickling or we completed gathering prior // If we are not trickling or we completed gathering prior
@ -1091,33 +1033,35 @@ PeerConnectionObserver.prototype = {
}, },
onSetRemoteDescriptionSuccess: function() { onSetRemoteDescriptionSuccess: function() {
this._dompc._onSetRemoteDescriptionSuccess(); this._dompc._remoteType = this._dompc._pendingType;
this._dompc._pendingType = null;
this.callCB(this._dompc._onSetRemoteDescriptionSuccess);
this._dompc._executeNext();
}, },
onSetLocalDescriptionError: function(code, message) { onSetLocalDescriptionError: function(code, message) {
this._dompc._pendingType = null; this._dompc._pendingType = null;
this._dompc.callCB(this._dompc._onSetLocalDescriptionFailure, this.callCB(this._dompc._onSetLocalDescriptionFailure,
new RTCError(code, message)); new RTCError(code, message));
this._dompc._executeNext(); this._dompc._executeNext();
}, },
onSetRemoteDescriptionError: function(code, message) { onSetRemoteDescriptionError: function(code, message) {
this._dompc._pendingType = null; this._dompc._pendingType = null;
this._dompc.callCB(this._dompc._onSetRemoteDescriptionFailure, this.callCB(this._dompc._onSetRemoteDescriptionFailure,
new RTCError(code, message)); new RTCError(code, message));
this._dompc._executeNext(); this._dompc._executeNext();
}, },
onAddIceCandidateSuccess: function() { onAddIceCandidateSuccess: function() {
this._dompc._pendingType = null; this._dompc._pendingType = null;
this._dompc.callCB(this._dompc._onAddIceCandidateSuccess); this.callCB(this._dompc._onAddIceCandidateSuccess);
this._dompc._executeNext(); this._dompc._executeNext();
}, },
onAddIceCandidateError: function(code, message) { onAddIceCandidateError: function(code, message) {
this._dompc._pendingType = null; this._dompc._pendingType = null;
this._dompc.callCB(this._dompc._onAddIceCandidateError, this.callCB(this._dompc._onAddIceCandidateError, new RTCError(code, message));
new RTCError(code, message));
this._dompc._executeNext(); this._dompc._executeNext();
}, },
@ -1217,7 +1161,7 @@ PeerConnectionObserver.prototype = {
onStateChange: function(state) { onStateChange: function(state) {
switch (state) { switch (state) {
case "SignalingState": case "SignalingState":
this._dompc.callCB(this._dompc.onsignalingstatechange, this.callCB(this._dompc.onsignalingstatechange,
this._dompc.signalingState); this._dompc.signalingState);
break; break;
@ -1252,20 +1196,18 @@ PeerConnectionObserver.prototype = {
let webidlobj = this._dompc._win.RTCStatsReport._create(this._dompc._win, let webidlobj = this._dompc._win.RTCStatsReport._create(this._dompc._win,
chromeobj); chromeobj);
chromeobj.makeStatsPublic(); chromeobj.makeStatsPublic();
this._dompc.callCB(this._dompc._onGetStatsSuccess, webidlobj); this.callCB(this._dompc._onGetStatsSuccess, webidlobj);
this._dompc._executeNext(); this._dompc._executeNext();
}, },
onGetStatsError: function(code, message) { onGetStatsError: function(code, message) {
this._dompc.callCB(this._dompc._onGetStatsFailure, this.callCB(this._dompc._onGetStatsFailure, new RTCError(code, message));
new RTCError(code, message));
this._dompc._executeNext(); this._dompc._executeNext();
}, },
onAddStream: function(stream) { onAddStream: function(stream) {
let ev = new this._dompc._win.MediaStreamEvent("addstream", this.dispatchEvent(new this._dompc._win.MediaStreamEvent("addstream",
{ stream: stream }); { stream: stream }));
this._dompc.dispatchEvent(ev);
}, },
onRemoveStream: function(stream, type) { onRemoveStream: function(stream, type) {

Просмотреть файл

@ -60,7 +60,6 @@ FAIL_ON_WARNINGS = True
LOCAL_INCLUDES += [ LOCAL_INCLUDES += [
'../base', '../base',
'../camera', '../camera',
'/caps/include',
] ]
include('/ipc/chromium/chromium-config.mozbuild') include('/ipc/chromium/chromium-config.mozbuild')

Просмотреть файл

@ -5,8 +5,8 @@ support-files =
/.well-known/idp-proxy/idp-proxy.js /.well-known/idp-proxy/idp-proxy.js
identityevent.js identityevent.js
# All tests are disabled on android&b2g due to lack of https support in # All tests are disabled on android due to lack of https support in mochitest
# mochitests (Bug 907770) # (Bug 975149)
# All tests are disabled on b2g due to lack of e10s support in WebRTC identity # All tests are disabled on b2g due to lack of e10s support in WebRTC identity
# (Bug 975144) # (Bug 975144)
[test_idpproxy.html] [test_idpproxy.html]
@ -17,7 +17,5 @@ skip-if = os == "android" || appname == "b2g"
skip-if = os == "android" || appname == "b2g" skip-if = os == "android" || appname == "b2g"
[test_setIdentityProviderWithErrors.html] [test_setIdentityProviderWithErrors.html]
skip-if = os == "android" || appname == "b2g" skip-if = os == "android" || appname == "b2g"
[test_peerConnection_peerIdentity.html]
skip-if = os == "android" || appname == "b2g"
[../mochitest/test_zmedia_cleanup.html] [../mochitest/test_zmedia_cleanup.html]
skip-if = os == "android" || appname == "b2g" skip-if = os == "android" || appname == "b2g"

Просмотреть файл

@ -26,7 +26,6 @@ var test;
function theTest() { function theTest() {
test = new PeerConnectionTest(); test = new PeerConnectionTest();
test.setMediaConstraints([{audio: true}], [{audio: true}]); test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.removeAfter('PC_REMOTE_CHECK_INITIAL_SIGNALINGSTATE');
test.chain.append([ test.chain.append([
[ [
"GET_IDENTITY_ASSERTION_FAILS_WITHOUT_PROVIDER", "GET_IDENTITY_ASSERTION_FAILS_WITHOUT_PROVIDER",

Просмотреть файл

@ -1,90 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="../mochitest/head.js"></script>
<script type="application/javascript" src="../mochitest/pc.js"></script>
<script type="application/javascript" src="../mochitest/templates.js"></script>
<script type="application/javascript" src="../mochitest/blacksilence.js"></script>
</head>
<body>
<div id="display"></div>
<pre id="test">
<script type="application/javascript">
createHTML({
title: "setIdentityProvider leads to peerIdentity and assertions in SDP"
});
var test;
function theTest() {
var id1 = 'someone@test1.example.com';
var id2 = 'someone@test2.example.com';
test = new PeerConnectionTest({
config_pc1: {
peerIdentity: id2
},
config_pc2: {
peerIdentity: id1
}
});
test.setMediaConstraints([{
audio: true,
peerIdentity: id2
}, {
video: true,
peerIdentity: id2
}], [{
audio: true,
fake: true,
peerIdentity: id1
}, {
video: true,
fake: true,
peerIdentity: id1
}]);
test.setIdentityProvider(test.pcLocal, 'test1.example.com', 'idp.html');
test.setIdentityProvider(test.pcRemote, 'test2.example.com', 'idp.html');
test.chain.append([
[
"PEER_IDENTITY_IS_SET_CORRECTLY",
function(test) {
// no need to wait to check identity in this case,
// setRemoteDescription should wait for the IdP to complete
function checkIdentity(pc, pfx, idp, name) {
is(pc.peerIdentity.idp, idp, pfx + "IdP is correct");
is(pc.peerIdentity.name, name + "@" + idp, pfx + "identity is correct");
}
checkIdentity(test.pcLocal._pc, "local: ", "test2.example.com", "someone");
checkIdentity(test.pcRemote._pc, "remote: ", "test1.example.com", "someone");
test.next();
}
],
[
"REMOTE_STREAMS_ARE_RESTRICTED",
function(test) {
var remoteStream = test.pcLocal._pc.getRemoteStreams()[0];
var oneDone = false;
function done() {
if (!oneDone) {
oneDone = true;
return;
}
test.next();
}
audioIsSilence(true, remoteStream, done);
videoIsBlack(true, remoteStream, done);
}
],
]);
test.run();
}
runTest(theTest);
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -1,114 +0,0 @@
(function(global) {
'use strict';
// an invertible check on the condition.
// if the constraint is applied, then the check is direct
// if not applied, then the result should be reversed
function check(constraintApplied, condition, message) {
var good = constraintApplied ? condition : !condition;
message = (constraintApplied ? 'with' : 'without') +
' constraint: should ' + (constraintApplied ? '' : 'not ') +
message + ' = ' + (good ? 'OK' : 'waiting...');
info(message);
return good;
}
function isSilence(audioData) {
var silence = true;
for (var i = 0; i < audioData.length; ++i) {
if (audioData[i] !== 128) {
silence = false;
}
}
return silence;
}
function periodicCheck(type, checkFunc, successMessage, done) {
var interval = setInterval(function periodic() {
if (checkFunc()) {
ok(true, type + ' is ' + successMessage);
clearInterval(interval);
interval = null;
done();
}
}, 50);
return function cancel() {
if (interval) {
ok(false, 'timed out waiting for audio check');
clearInterval(interval);
done();
}
};
}
function checkAudio(constraintApplied, stream, done) {
var context = new AudioContext();
var source = context.createMediaStreamSource(stream);
var analyser = context.createAnalyser();
source.connect(analyser);
analyser.connect(context.destination);
function testAudio() {
var sampleCount = analyser.frequencyBinCount;
info('got some audio samples: ' + sampleCount);
var bucket = new ArrayBuffer(sampleCount);
var view = new Uint8Array(bucket);
analyser.getByteTimeDomainData(view);
var silent = check(constraintApplied, isSilence(view), 'be silence for audio');
// TODO: silence cross origin input to webaudio, bug 966066
silent ^= constraintApplied;
return sampleCount > 0 && silent;
}
return periodicCheck('audio', testAudio,
(constraintApplied ? '' : 'not ') + 'silent', done);
}
function mkElement(type) {
var display = document.getElementById('display');
var e = document.createElement(type);
e.width = 32;
e.height = 24;
display.appendChild(e);
return e;
}
function checkVideo(constraintApplied, stream, done) {
var video = mkElement('video');
video.mozSrcObject = stream;
video.play();
var ready = false;
video.onplaying = function() {
ready = true;
}
function tryToRenderToCanvas() {
if (!ready) {
info('waiting for video to start');
return false;
}
try {
// every try needs a new canvas, otherwise a taint from an earlier call
// will affect subsequent calls
var canvas = mkElement('canvas');
var ctx = canvas.getContext('2d');
// have to guard drawImage with the try as well, due to bug 879717
// if we get an error, this round fails, but that failure is usually
// just transitory
ctx.drawImage(video, 0, 0);
ctx.getImageData(0, 0, 1, 1);
return check(constraintApplied, false, 'throw on getImageData for video');
} catch (e) {
return check(constraintApplied, e.name === 'SecurityError', 'get a security error');
}
}
return periodicCheck('video', tryToRenderToCanvas,
(constraintApplied ? '' : 'not ') + 'protected', done);
}
global.audioIsSilence = checkAudio;
global.videoIsBlack = checkVideo;
}(this));

Просмотреть файл

@ -5,7 +5,6 @@ support-files =
pc.js pc.js
templates.js templates.js
NetworkPreparationChromeScript.js NetworkPreparationChromeScript.js
blacksilence.js
[test_dataChannel_basicAudio.html] [test_dataChannel_basicAudio.html]
skip-if = (toolkit == 'gonk' && debug) #Bug 962984, test fail on b2g debug build skip-if = (toolkit == 'gonk' && debug) #Bug 962984, test fail on b2g debug build
@ -39,7 +38,6 @@ skip-if = (toolkit == 'gonk' && debug) #debug-only failure
[test_getUserMedia_stopVideoAudioStreamWithFollowupVideoAudio.html] [test_getUserMedia_stopVideoAudioStreamWithFollowupVideoAudio.html]
[test_getUserMedia_stopVideoStream.html] [test_getUserMedia_stopVideoStream.html]
[test_getUserMedia_stopVideoStreamWithFollowupVideo.html] [test_getUserMedia_stopVideoStreamWithFollowupVideo.html]
[test_getUserMedia_peerIdentity.html]
[test_peerConnection_addCandidateInHaveLocalOffer.html] [test_peerConnection_addCandidateInHaveLocalOffer.html]
[test_peerConnection_basicAudio.html] [test_peerConnection_basicAudio.html]
skip-if = (toolkit == 'gonk' && debug) #Bug 962984, test fail on b2g debug build skip-if = (toolkit == 'gonk' && debug) #Bug 962984, test fail on b2g debug build

Просмотреть файл

@ -1,59 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=942367
-->
<head>
<meta charset="utf-8">
<title>Test mozGetUserMedia peerIdentity Constraint</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="blacksilence.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=942367">Test mozGetUserMedia peerIdentity Constraint</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
function theTest() {
function testPeerIdentityConstraint(withConstraint, done) {
var config = { audio: true, video: true, fake: true };
if (withConstraint) {
config.peerIdentity = 'user@example.com';
}
info('getting media with constraints: ' + JSON.stringify(config));
navigator.mozGetUserMedia(config, function(stream) {
var oneDone = false;
function checkDone() {
if (oneDone) {
done();
}
oneDone = true;
}
var cancelAudioCheck = audioIsSilence(withConstraint, stream, checkDone);
var cancelVideoCheck = videoIsBlack(withConstraint, stream, checkDone);
setTimeout(cancelAudioCheck, 1200);
setTimeout(cancelVideoCheck, 1200);
}, function(e) {
ok(false, 'gUM error: ' + e);
});
};
// without constraint
testPeerIdentityConstraint(false, function() {
// with the constraint
testPeerIdentityConstraint(true, SimpleTest.finish.bind(SimpleTest));
});
}
runTest(theTest);
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -18,7 +18,6 @@ dictionary MediaStreamConstraints {
(boolean or MediaTrackConstraints) video = false; (boolean or MediaTrackConstraints) video = false;
boolean picture = false; boolean picture = false;
boolean fake = false; boolean fake = false;
DOMString? peerIdentity = null;
}; };
dictionary MediaStreamConstraintsInternal { dictionary MediaStreamConstraintsInternal {
@ -26,7 +25,6 @@ dictionary MediaStreamConstraintsInternal {
(boolean or MediaTrackConstraintsInternal) video; (boolean or MediaTrackConstraintsInternal) video;
boolean picture = false; boolean picture = false;
boolean fake = false; boolean fake = false;
DOMString? peerIdentity = null;
}; };
interface MediaStream { interface MediaStream {

Просмотреть файл

@ -72,9 +72,6 @@ interface PeerConnectionImpl {
readonly attribute PCImplSignalingState signalingState; readonly attribute PCImplSignalingState signalingState;
readonly attribute PCImplSipccState sipccState; readonly attribute PCImplSipccState sipccState;
attribute DOMString peerIdentity;
readonly attribute boolean privacyRequested;
/* Data channels */ /* Data channels */
[Throws] [Throws]
DataChannel createDataChannel(DOMString label, DOMString protocol, DataChannel createDataChannel(DOMString label, DOMString protocol,

Просмотреть файл

@ -15,5 +15,4 @@ dictionary RTCIceServer {
dictionary RTCConfiguration { dictionary RTCConfiguration {
sequence<RTCIceServer> iceServers; sequence<RTCIceServer> iceServers;
DOMString? peerIdentity = null;
}; };

Просмотреть файл

@ -30,10 +30,6 @@
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsIPrefService.h" #include "nsIPrefService.h"
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
#ifdef MOZILLA_INTERNAL_API
#include "nsIPrincipal.h"
#include "nsIDocument.h"
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -1646,7 +1642,7 @@ static int vcmRxStartICE_m(cc_mcapid_t mcap_id,
return VCM_ERROR; return VCM_ERROR;
// Now we have all the pieces, create the pipeline // Now we have all the pieces, create the pipeline
mozilla::RefPtr<mozilla::MediaPipelineReceiveAudio> pipeline = mozilla::RefPtr<mozilla::MediaPipeline> pipeline =
new mozilla::MediaPipelineReceiveAudio( new mozilla::MediaPipelineReceiveAudio(
pc.impl()->GetHandle(), pc.impl()->GetHandle(),
pc.impl()->GetMainThread().get(), pc.impl()->GetMainThread().get(),
@ -1704,7 +1700,7 @@ static int vcmRxStartICE_m(cc_mcapid_t mcap_id,
return VCM_ERROR; return VCM_ERROR;
// Now we have all the pieces, create the pipeline // Now we have all the pieces, create the pipeline
mozilla::RefPtr<mozilla::MediaPipelineReceiveVideo> pipeline = mozilla::RefPtr<mozilla::MediaPipeline> pipeline =
new mozilla::MediaPipelineReceiveVideo( new mozilla::MediaPipelineReceiveVideo(
pc.impl()->GetHandle(), pc.impl()->GetHandle(),
pc.impl()->GetMainThread().get(), pc.impl()->GetMainThread().get(),
@ -2217,97 +2213,6 @@ int vcmTxStart(cc_mcapid_t mcap_id,
return VCM_ERROR; return VCM_ERROR;
} }
/**
* Create a conduit for audio transmission.
*
* @param[in] level - the m-line index
* @param[in] payload - codec info
* @param[in] pc - the peer connection
* @param [in] attrs - additional audio attributes
* @param[out] conduit - the conduit to create
*/
static int vcmTxCreateAudioConduit(int level,
const vcm_payload_info_t *payload,
sipcc::PeerConnectionWrapper &pc,
const vcm_mediaAttrs_t *attrs,
mozilla::RefPtr<mozilla::MediaSessionConduit> &conduit)
{
mozilla::AudioCodecConfig *config_raw =
new mozilla::AudioCodecConfig(
payload->remote_rtp_pt,
ccsdpCodecName(payload->codec_type),
payload->audio.frequency,
payload->audio.packet_size,
payload->audio.channels,
payload->audio.bitrate,
pc.impl()->load_manager());
// Take possession of this pointer
mozilla::ScopedDeletePtr<mozilla::AudioCodecConfig> config(config_raw);
// Instantiate an appropriate conduit
mozilla::RefPtr<mozilla::MediaSessionConduit> rx_conduit =
pc.impl()->media()->GetConduit(level, true);
MOZ_ASSERT_IF(rx_conduit, rx_conduit->type() == MediaSessionConduit::AUDIO);
// The two sides of a send/receive pair of conduits each keep a raw pointer to the other,
// and are responsible for cleanly shutting down.
mozilla::RefPtr<mozilla::AudioSessionConduit> tx_conduit =
mozilla::AudioSessionConduit::Create(
static_cast<AudioSessionConduit *>(rx_conduit.get()));
if (!tx_conduit || tx_conduit->ConfigureSendMediaCodec(config) ||
tx_conduit->EnableAudioLevelExtension(attrs->audio_level,
attrs->audio_level_id)) {
return VCM_ERROR;
}
CSFLogError(logTag, "Created audio pipeline audio level %d %d",
attrs->audio_level, attrs->audio_level_id);
conduit = tx_conduit;
return 0;
}
/**
* Create a conduit for video transmission.
*
* @param[in] level - the m-line index
* @param[in] payload - codec info
* @param[in] pc - the peer connection
* @param[out] conduit - the conduit to create
*/
static int vcmTxCreateVideoConduit(int level,
const vcm_payload_info_t *payload,
sipcc::PeerConnectionWrapper &pc,
mozilla::RefPtr<mozilla::MediaSessionConduit> &conduit)
{
mozilla::VideoCodecConfig *config_raw;
config_raw = new mozilla::VideoCodecConfig(
payload->remote_rtp_pt,
ccsdpCodecName(payload->codec_type),
payload->video.rtcp_fb_types,
payload->video.max_fs,
payload->video.max_fr,
pc.impl()->load_manager());
// Take possession of this pointer
mozilla::ScopedDeletePtr<mozilla::VideoCodecConfig> config(config_raw);
// Instantiate an appropriate conduit
mozilla::RefPtr<mozilla::MediaSessionConduit> rx_conduit =
pc.impl()->media()->GetConduit(level, true);
MOZ_ASSERT_IF(rx_conduit, rx_conduit->type() == MediaSessionConduit::VIDEO);
// The two sides of a send/receive pair of conduits each keep a raw pointer to the other,
// and are responsible for cleanly shutting down.
mozilla::RefPtr<mozilla::VideoSessionConduit> tx_conduit =
mozilla::VideoSessionConduit::Create(static_cast<VideoSessionConduit *>(rx_conduit.get()));
if (!tx_conduit || tx_conduit->ConfigureSendMediaCodec(config)) {
return VCM_ERROR;
}
conduit = tx_conduit;
return 0;
}
/** /**
* start tx stream * start tx stream
@ -2318,7 +2223,7 @@ static int vcmTxCreateVideoConduit(int level,
* @param[in] stream_id - stream id of the given media type. * @param[in] stream_id - stream id of the given media type.
* @param[in] level - the m-line index * @param[in] level - the m-line index
* @param[in] pc_stream_id - the media stream index (from PC.addStream()) * @param[in] pc_stream_id - the media stream index (from PC.addStream())
* @param[in] pc_track_id - the track within the media stream * @param[i]n pc_track_id - the track within the media stream
* @param[in] call_handle - call handle * @param[in] call_handle - call handle
* @param[in] peerconnection - the peerconnection in use * @param[in] peerconnection - the peerconnection in use
* @param[in] payload - payload information * @param[in] payload - payload information
@ -2348,7 +2253,7 @@ static int vcmTxStartICE_m(cc_mcapid_t mcap_id,
const char *fingerprint, const char *fingerprint,
vcm_mediaAttrs_t *attrs) vcm_mediaAttrs_t *attrs)
{ {
CSFLogDebug(logTag, "%s(%s) track = %d, stream = %d, level = %d", CSFLogDebug( logTag, "%s(%s) track = %d, stream = %d, level = %d",
__FUNCTION__, __FUNCTION__,
peerconnection, peerconnection,
pc_track_id, pc_track_id,
@ -2358,20 +2263,19 @@ static int vcmTxStartICE_m(cc_mcapid_t mcap_id,
// Find the PC and get the stream // Find the PC and get the stream
sipcc::PeerConnectionWrapper pc(peerconnection); sipcc::PeerConnectionWrapper pc(peerconnection);
ENSURE_PC(pc, VCM_ERROR); ENSURE_PC(pc, VCM_ERROR);
nsRefPtr<sipcc::LocalSourceStreamInfo> stream = nsRefPtr<sipcc::LocalSourceStreamInfo> stream = pc.impl()->media()->
pc.impl()->media()->GetLocalStream(pc_stream_id); GetLocalStream(pc_stream_id);
// Create the transport flows // Create the transport flows
mozilla::RefPtr<TransportFlow> rtp_flow = mozilla::RefPtr<TransportFlow> rtp_flow =
vcmCreateTransportFlow(pc.impl(), level, false, setup_type, vcmCreateTransportFlow(pc.impl(), level, false, setup_type,
fingerprint_alg, fingerprint); fingerprint_alg, fingerprint);
if (!rtp_flow) { if (!rtp_flow) {
CSFLogError(logTag, "Could not create RTP flow"); CSFLogError( logTag, "Could not create RTP flow");
return VCM_ERROR; return VCM_ERROR;
} }
mozilla::RefPtr<TransportFlow> rtcp_flow = nullptr; mozilla::RefPtr<TransportFlow> rtcp_flow = nullptr;
if (!attrs->rtcp_mux) { if(!attrs->rtcp_mux) {
rtcp_flow = vcmCreateTransportFlow(pc.impl(), level, true, setup_type, rtcp_flow = vcmCreateTransportFlow(pc.impl(), level, true, setup_type,
fingerprint_alg, fingerprint); fingerprint_alg, fingerprint);
if (!rtcp_flow) { if (!rtcp_flow) {
@ -2380,26 +2284,40 @@ static int vcmTxStartICE_m(cc_mcapid_t mcap_id,
} }
} }
const char *mediaType;
mozilla::RefPtr<mozilla::MediaSessionConduit> conduit;
int err = VCM_ERROR;
if (CC_IS_AUDIO(mcap_id)) { if (CC_IS_AUDIO(mcap_id)) {
mediaType = "audio"; mozilla::AudioCodecConfig *config_raw;
err = vcmTxCreateAudioConduit(level, payload, pc, attrs, conduit); config_raw = new mozilla::AudioCodecConfig(
} else if (CC_IS_VIDEO(mcap_id)) { payload->remote_rtp_pt,
mediaType = "video"; ccsdpCodecName(payload->codec_type),
err = vcmTxCreateVideoConduit(level, payload, pc, conduit); payload->audio.frequency,
} else { payload->audio.packet_size,
CSFLogError(logTag, "%s: mcap_id unrecognized", __FUNCTION__); payload->audio.channels,
} payload->audio.bitrate,
if (err) { pc.impl()->load_manager());
return err;
} // Take possession of this pointer
mozilla::ScopedDeletePtr<mozilla::AudioCodecConfig> config(config_raw);
// Instantiate an appropriate conduit
mozilla::RefPtr<mozilla::MediaSessionConduit> rx_conduit =
pc.impl()->media()->GetConduit(level, true);
MOZ_ASSERT_IF(rx_conduit, rx_conduit->type() == MediaSessionConduit::AUDIO);
// The two sides of a send/receive pair of conduits each keep a raw pointer to the other,
// and are responsible for cleanly shutting down.
mozilla::RefPtr<mozilla::AudioSessionConduit> conduit =
mozilla::AudioSessionConduit::Create(static_cast<AudioSessionConduit *>(rx_conduit.get()));
if (!conduit || conduit->ConfigureSendMediaCodec(config))
return VCM_ERROR;
CSFLogError(logTag, "Created audio pipeline audio level %d %d",
attrs->audio_level, attrs->audio_level_id);
if (!conduit || conduit->EnableAudioLevelExtension(attrs->audio_level, attrs->audio_level_id))
return VCM_ERROR;
pc.impl()->media()->AddConduit(level, false, conduit); pc.impl()->media()->AddConduit(level, false, conduit);
mozilla::RefPtr<mozilla::MediaPipeline> pipeline =
// Now we have all the pieces, create the pipeline
mozilla::RefPtr<mozilla::MediaPipelineTransmit> pipeline =
new mozilla::MediaPipelineTransmit( new mozilla::MediaPipelineTransmit(
pc.impl()->GetHandle(), pc.impl()->GetHandle(),
pc.impl()->GetMainThread().get(), pc.impl()->GetMainThread().get(),
@ -2411,25 +2329,71 @@ static int vcmTxStartICE_m(cc_mcapid_t mcap_id,
nsresult res = pipeline->Init(); nsresult res = pipeline->Init();
if (NS_FAILED(res)) { if (NS_FAILED(res)) {
CSFLogError(logTag, "Failure initializing %s pipeline", mediaType); CSFLogError(logTag, "Failure initializing audio pipeline");
return VCM_ERROR; return VCM_ERROR;
} }
#ifdef MOZILLA_INTERNAL_API CSFLogDebug(logTag, "Created audio pipeline %p, conduit=%p, pc_stream=%d pc_track=%d",
// implement checking for peerIdentity (where failure == black/silence) pipeline.get(), conduit.get(), pc_stream_id, pc_track_id);
nsIDocument* doc = pc.impl()->GetWindow()->GetExtantDoc();
if (doc) {
pipeline->UpdateSinkIdentity_m(doc->NodePrincipal(), pc.impl()->GetPeerIdentity());
} else {
CSFLogError(logTag, "Initializing pipeline without attached doc");
}
#endif
CSFLogDebug(logTag,
"Created %s pipeline %p, conduit=%p, pc_stream=%d pc_track=%d", // Now we have all the pieces, create the pipeline
mediaType, pipeline.get(), conduit.get(),
pc_stream_id, pc_track_id);
stream->StorePipeline(pc_track_id, pipeline); stream->StorePipeline(pc_track_id, pipeline);
} else if (CC_IS_VIDEO(mcap_id)) {
mozilla::VideoCodecConfig *config_raw;
config_raw = new mozilla::VideoCodecConfig(
payload->remote_rtp_pt,
ccsdpCodecName(payload->codec_type),
payload->video.rtcp_fb_types,
payload->video.max_fs,
payload->video.max_fr,
pc.impl()->load_manager());
// Take possession of this pointer
mozilla::ScopedDeletePtr<mozilla::VideoCodecConfig> config(config_raw);
// Instantiate an appropriate conduit
mozilla::RefPtr<mozilla::MediaSessionConduit> rx_conduit =
pc.impl()->media()->GetConduit(level, true);
MOZ_ASSERT_IF(rx_conduit, rx_conduit->type() == MediaSessionConduit::VIDEO);
// The two sides of a send/receive pair of conduits each keep a raw pointer to the other,
// and are responsible for cleanly shutting down.
mozilla::RefPtr<mozilla::VideoSessionConduit> conduit =
mozilla::VideoSessionConduit::Create(static_cast<VideoSessionConduit *>(rx_conduit.get()));
// Find the appropriate media conduit config
if (!conduit || conduit->ConfigureSendMediaCodec(config))
return VCM_ERROR;
pc.impl()->media()->AddConduit(level, false, conduit);
// Now we have all the pieces, create the pipeline
mozilla::RefPtr<mozilla::MediaPipeline> pipeline =
new mozilla::MediaPipelineTransmit(
pc.impl()->GetHandle(),
pc.impl()->GetMainThread().get(),
pc.impl()->GetSTSThread(),
stream->GetMediaStream(),
pc_track_id,
level,
conduit, rtp_flow, rtcp_flow);
nsresult res = pipeline->Init();
if (NS_FAILED(res)) {
CSFLogError(logTag, "Failure initializing video pipeline");
return VCM_ERROR;
}
CSFLogDebug(logTag, "Created video pipeline %p, conduit=%p, pc_stream=%d pc_track=%d",
pipeline.get(), conduit.get(), pc_stream_id, pc_track_id);
stream->StorePipeline(pc_track_id, pipeline);
} else {
CSFLogError(logTag, "%s: mcap_id unrecognized", __FUNCTION__);
return VCM_ERROR;
}
// This tells the receive MediaPipeline (if there is one) whether we are // This tells the receive MediaPipeline (if there is one) whether we are
// doing bundle, and if so, updates the filter. Once the filter is finalized, // doing bundle, and if so, updates the filter. Once the filter is finalized,
// it is then copied to the transmit pipeline so it can filter RTCP. // it is then copied to the transmit pipeline so it can filter RTCP.
@ -3254,3 +3218,4 @@ short vcmGetVideoMaxFr(uint16_t codec,
&ret)); &ret));
return ret; return ret;
} }

Просмотреть файл

@ -39,9 +39,6 @@
#include "transportlayerice.h" #include "transportlayerice.h"
#include "runnable_utils.h" #include "runnable_utils.h"
#include "libyuv/convert.h" #include "libyuv/convert.h"
#ifdef MOZILLA_INTERNAL_API
#include "mozilla/PeerIdentity.h"
#endif
#include "mozilla/gfx/Point.h" #include "mozilla/gfx/Point.h"
#include "mozilla/gfx/Types.h" #include "mozilla/gfx/Types.h"
@ -656,25 +653,6 @@ nsresult MediaPipelineTransmit::Init() {
return MediaPipeline::Init(); return MediaPipeline::Init();
} }
#ifdef MOZILLA_INTERNAL_API
void MediaPipelineTransmit::UpdateSinkIdentity_m(nsIPrincipal* principal,
const PeerIdentity* sinkIdentity) {
ASSERT_ON_THREAD(main_thread_);
bool enableStream = principal->Subsumes(domstream_->GetPrincipal());
if (!enableStream) {
// first try didn't work, but there's a chance that this is still available
// if our stream is bound to a peerIdentity, and the peer connection (our
// sink) is bound to the same identity, then we can enable the stream
PeerIdentity* streamIdentity = domstream_->GetPeerIdentity();
if (sinkIdentity && streamIdentity) {
enableStream = (*sinkIdentity == *streamIdentity);
}
}
listener_->SetEnabled(enableStream);
}
#endif
nsresult MediaPipelineTransmit::TransportReady_s(TransportInfo &info) { nsresult MediaPipelineTransmit::TransportReady_s(TransportInfo &info) {
ASSERT_ON_THREAD(sts_thread_); ASSERT_ON_THREAD(sts_thread_);
// Call base ready function. // Call base ready function.
@ -683,6 +661,7 @@ nsresult MediaPipelineTransmit::TransportReady_s(TransportInfo &info) {
// Should not be set for a transmitter // Should not be set for a transmitter
MOZ_ASSERT(!possible_bundle_rtp_); MOZ_ASSERT(!possible_bundle_rtp_);
if (&info == &rtp_) { if (&info == &rtp_) {
// TODO(ekr@rtfm.com): Move onto MSG thread.
listener_->SetActive(true); listener_->SetActive(true);
} }
@ -956,7 +935,6 @@ NewData(MediaStreamGraph* graph, TrackID tid,
// Ignore data in case we have a muxed stream // Ignore data in case we have a muxed stream
return; return;
} }
AudioSegment* audio = const_cast<AudioSegment *>( AudioSegment* audio = const_cast<AudioSegment *>(
static_cast<const AudioSegment *>(&media)); static_cast<const AudioSegment *>(&media));
@ -972,7 +950,6 @@ NewData(MediaStreamGraph* graph, TrackID tid,
// Ignore data in case we have a muxed stream // Ignore data in case we have a muxed stream
return; return;
} }
VideoSegment* video = const_cast<VideoSegment *>( VideoSegment* video = const_cast<VideoSegment *>(
static_cast<const VideoSegment *>(&media)); static_cast<const VideoSegment *>(&media));
@ -995,7 +972,7 @@ void MediaPipelineTransmit::PipelineListener::ProcessAudioChunk(
// TODO(ekr@rtfm.com): Do more than one channel // TODO(ekr@rtfm.com): Do more than one channel
nsAutoArrayPtr<int16_t> samples(new int16_t[chunk.mDuration]); nsAutoArrayPtr<int16_t> samples(new int16_t[chunk.mDuration]);
if (enabled_ && chunk.mBuffer) { if (chunk.mBuffer) {
switch (chunk.mBufferFormat) { switch (chunk.mBufferFormat) {
case AUDIO_FORMAT_FLOAT32: case AUDIO_FORMAT_FLOAT32:
{ {
@ -1104,7 +1081,7 @@ void MediaPipelineTransmit::PipelineListener::ProcessVideoChunk(
return; return;
} }
if (!enabled_ || chunk.mFrame.GetForceBlack()) { if (chunk.mFrame.GetForceBlack()) {
uint32_t yPlaneLen = size.width*size.height; uint32_t yPlaneLen = size.width*size.height;
uint32_t cbcrPlaneLen = yPlaneLen/2; uint32_t cbcrPlaneLen = yPlaneLen/2;
uint32_t length = yPlaneLen + cbcrPlaneLen; uint32_t length = yPlaneLen + cbcrPlaneLen;

Просмотреть файл

@ -21,7 +21,6 @@
#include "MediaPipelineFilter.h" #include "MediaPipelineFilter.h"
#include "AudioSegment.h" #include "AudioSegment.h"
#include "mozilla/ReentrantMonitor.h" #include "mozilla/ReentrantMonitor.h"
#include "mozilla/Atomics.h"
#include "SrtpFlow.h" #include "SrtpFlow.h"
#include "databuffer.h" #include "databuffer.h"
#include "runnable_utils.h" #include "runnable_utils.h"
@ -35,8 +34,6 @@
namespace mozilla { namespace mozilla {
class PeerIdentity;
// A class that represents the pipeline of audio and video // A class that represents the pipeline of audio and video
// The dataflow looks like: // The dataflow looks like:
// //
@ -357,7 +354,7 @@ private:
// A specialization of pipeline for reading from an input device // A specialization of pipeline for reading from an input device
// and transmitting to the network. // and transmitting to the network.
class MediaPipelineTransmit : public MediaPipeline { class MediaPipelineTransmit : public MediaPipeline {
public: public:
// Set rtcp_transport to nullptr to use rtcp-mux // Set rtcp_transport to nullptr to use rtcp-mux
MediaPipelineTransmit(const std::string& pc, MediaPipelineTransmit(const std::string& pc,
nsCOMPtr<nsIEventTarget> main_thread, nsCOMPtr<nsIEventTarget> main_thread,
@ -376,14 +373,7 @@ public:
{} {}
// Initialize (stuff here may fail) // Initialize (stuff here may fail)
virtual nsresult Init() MOZ_OVERRIDE; virtual nsresult Init();
#ifdef MOZILLA_INTERNAL_API
// when the principal of the PeerConnection changes, it calls through to here
// so that we can determine whether to enable stream transmission
virtual void UpdateSinkIdentity_m(nsIPrincipal* principal,
const PeerIdentity* sinkIdentity);
#endif
// Called on the main thread. // Called on the main thread.
virtual void DetachMediaStream() { virtual void DetachMediaStream() {
@ -405,7 +395,6 @@ public:
PipelineListener(const RefPtr<MediaSessionConduit>& conduit) PipelineListener(const RefPtr<MediaSessionConduit>& conduit)
: conduit_(conduit), : conduit_(conduit),
active_(false), active_(false),
enabled_(false),
direct_connect_(false), direct_connect_(false),
samples_10ms_buffer_(nullptr), samples_10ms_buffer_(nullptr),
buffer_current_(0), buffer_current_(0),
@ -427,8 +416,11 @@ public:
} }
} }
// XXX. This is not thread-safe but the hazard is just
// that active_ = true takes a while to propagate. Revisit
// when 823600 lands.
void SetActive(bool active) { active_ = active; } void SetActive(bool active) { active_ = active; }
void SetEnabled(bool enabled) { enabled_ = enabled; }
// Implement MediaStreamListener // Implement MediaStreamListener
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* graph, TrackID tid, virtual void NotifyQueuedTrackChanges(MediaStreamGraph* graph, TrackID tid,
@ -459,16 +451,9 @@ public:
TrackRate rate, VideoChunk& chunk); TrackRate rate, VideoChunk& chunk);
#endif #endif
RefPtr<MediaSessionConduit> conduit_; RefPtr<MediaSessionConduit> conduit_;
volatile bool active_;
// active is true if there is a transport to send on
mozilla::Atomic<bool> active_;
// enabled is true if the media access control permits sending
// actual content; when false you get black/silence
mozilla::Atomic<bool> enabled_;
bool direct_connect_; bool direct_connect_;
// These vars handle breaking audio samples into exact 10ms chunks: // These vars handle breaking audio samples into exact 10ms chunks:
// The buffer of 10ms audio samples that we will send once full // The buffer of 10ms audio samples that we will send once full
// (can be carried over from one call to another). // (can be carried over from one call to another).
@ -564,7 +549,7 @@ class MediaPipelineReceiveAudio : public MediaPipelineReceive {
stream_ = nullptr; stream_ = nullptr;
} }
virtual nsresult Init() MOZ_OVERRIDE; virtual nsresult Init();
private: private:
// Separate class to allow ref counting // Separate class to allow ref counting
@ -638,7 +623,7 @@ class MediaPipelineReceiveVideo : public MediaPipelineReceive {
stream_ = nullptr; stream_ = nullptr;
} }
virtual nsresult Init() MOZ_OVERRIDE; virtual nsresult Init();
private: private:
class PipelineRenderer : public VideoRenderer { class PipelineRenderer : public VideoRenderer {

Просмотреть файл

@ -62,8 +62,6 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIDOMDataChannel.h" #include "nsIDOMDataChannel.h"
#include "nsIDOMLocation.h" #include "nsIDOMLocation.h"
#include "nsNullPrincipal.h"
#include "mozilla/PeerIdentity.h"
#include "mozilla/dom/RTCConfigurationBinding.h" #include "mozilla/dom/RTCConfigurationBinding.h"
#include "mozilla/dom/RTCStatsReportBinding.h" #include "mozilla/dom/RTCStatsReportBinding.h"
#include "mozilla/dom/RTCPeerConnectionBinding.h" #include "mozilla/dom/RTCPeerConnectionBinding.h"
@ -477,7 +475,6 @@ PeerConnectionImpl::PeerConnectionImpl(const GlobalObject* aGlobal)
, mSignalingState(PCImplSignalingState::SignalingStable) , mSignalingState(PCImplSignalingState::SignalingStable)
, mIceConnectionState(PCImplIceConnectionState::New) , mIceConnectionState(PCImplIceConnectionState::New)
, mIceGatheringState(PCImplIceGatheringState::New) , mIceGatheringState(PCImplIceGatheringState::New)
, mDtlsConnected(false)
, mWindow(nullptr) , mWindow(nullptr)
, mIdentity(nullptr) , mIdentity(nullptr)
, mSTSThread(nullptr) , mSTSThread(nullptr)
@ -545,27 +542,18 @@ PeerConnectionImpl::~PeerConnectionImpl()
} }
already_AddRefed<DOMMediaStream> already_AddRefed<DOMMediaStream>
PeerConnectionImpl::MakeMediaStream(uint32_t aHint) PeerConnectionImpl::MakeMediaStream(nsPIDOMWindow* aWindow,
uint32_t aHint)
{ {
nsRefPtr<DOMMediaStream> stream = nsRefPtr<DOMMediaStream> stream =
DOMMediaStream::CreateSourceStream(GetWindow(), aHint); DOMMediaStream::CreateSourceStream(aWindow, aHint);
#ifdef MOZILLA_INTERNAL_API #ifdef MOZILLA_INTERNAL_API
// Make the stream data (audio/video samples) accessible to the receiving page. nsIDocument* doc = aWindow->GetExtantDoc();
// We're only certain that privacy hasn't been requested if we're connected.
if (mDtlsConnected && !PrivacyRequested()) {
nsIDocument* doc = GetWindow()->GetExtantDoc();
if (!doc) { if (!doc) {
return nullptr; return nullptr;
} }
// Make the stream data (audio/video samples) accessible to the receiving page.
stream->CombineWithPrincipal(doc->NodePrincipal()); stream->CombineWithPrincipal(doc->NodePrincipal());
} else {
// we're either certain that we need isolation for the streams, OR
// we're not sure and we can fix the stream in SetDtlsConnected
nsCOMPtr<nsIPrincipal> principal =
do_CreateInstance(NS_NULLPRINCIPAL_CONTRACTID);
stream->CombineWithPrincipal(principal);
}
#endif #endif
CSFLogDebug(logTag, "Created media stream %p, inner: %p", stream.get(), stream->GetStream()); CSFLogDebug(logTag, "Created media stream %p, inner: %p", stream.get(), stream->GetStream());
@ -584,7 +572,7 @@ PeerConnectionImpl::CreateRemoteSourceStreamInfo(nsRefPtr<RemoteSourceStreamInfo
// needs to actually propagate a hint for local streams. // needs to actually propagate a hint for local streams.
// TODO(ekr@rtfm.com): Clean up when we have explicit track lists. // TODO(ekr@rtfm.com): Clean up when we have explicit track lists.
// See bug 834835. // See bug 834835.
nsRefPtr<DOMMediaStream> stream = MakeMediaStream(0); nsRefPtr<DOMMediaStream> stream = MakeMediaStream(mWindow, 0);
if (!stream) { if (!stream) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -748,10 +736,6 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
mWindow = aWindow; mWindow = aWindow;
NS_ENSURE_STATE(mWindow); NS_ENSURE_STATE(mWindow);
if (!aRTCConfiguration->mPeerIdentity.IsEmpty()) {
mPeerIdentity = new PeerIdentity(aRTCConfiguration->mPeerIdentity);
mPrivacyRequested = true;
}
#endif // MOZILLA_INTERNAL_API #endif // MOZILLA_INTERNAL_API
PRTime timestamp = PR_Now(); PRTime timestamp = PR_Now();
@ -943,7 +927,7 @@ PeerConnectionImpl::CreateFakeMediaStream(uint32_t aHint, nsIDOMMediaStream** aR
aHint &= ~MEDIA_STREAM_MUTE; aHint &= ~MEDIA_STREAM_MUTE;
} }
nsRefPtr<DOMMediaStream> stream = MakeMediaStream(aHint); nsRefPtr<DOMMediaStream> stream = MakeMediaStream(mWindow, aHint);
if (!stream) { if (!stream) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -1269,17 +1253,6 @@ PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP)
mTimeCard = nullptr; mTimeCard = nullptr;
STAMP_TIMECARD(tc, "Set Local Description"); STAMP_TIMECARD(tc, "Set Local Description");
#ifdef MOZILLA_INTERNAL_API
nsIDocument* doc = GetWindow()->GetExtantDoc();
bool isolated = true;
if (doc) {
isolated = mMedia->AnyLocalStreamIsolated(doc->NodePrincipal());
} else {
CSFLogInfo(logTag, "%s - no document, failing safe", __FUNCTION__);
}
mPrivacyRequested = mPrivacyRequested || isolated;
#endif
mLocalRequestedSDP = aSDP; mLocalRequestedSDP = aSDP;
mInternal->mCall->setLocalDescription((cc_jsep_action_t)aAction, mInternal->mCall->setLocalDescription((cc_jsep_action_t)aAction,
mLocalRequestedSDP, tc); mLocalRequestedSDP, tc);
@ -1399,67 +1372,16 @@ PeerConnectionImpl::CloseStreams() {
return NS_OK; return NS_OK;
} }
#ifdef MOZILLA_INTERNAL_API NS_IMETHODIMP
nsresult
PeerConnectionImpl::SetPeerIdentity(const nsAString& aPeerIdentity)
{
PC_AUTO_ENTER_API_CALL(true);
MOZ_ASSERT(!aPeerIdentity.IsEmpty());
// once set, this can't be changed
if (mPeerIdentity) {
if (!mPeerIdentity->Equals(aPeerIdentity)) {
return NS_ERROR_FAILURE;
}
} else {
mPeerIdentity = new PeerIdentity(aPeerIdentity);
nsIDocument* doc = GetWindow()->GetExtantDoc();
if (!doc) {
CSFLogInfo(logTag, "Can't update principal on streams; document gone");
return NS_ERROR_FAILURE;
}
mMedia->UpdateSinkIdentity_m(doc->NodePrincipal(), mPeerIdentity);
}
return NS_OK;
}
#endif
nsresult
PeerConnectionImpl::SetDtlsConnected(bool aPrivacyRequested)
{
PC_AUTO_ENTER_API_CALL(false);
// For this, as with mPrivacyRequested, once we've connected to a peer, we
// fixate on that peer. Dealing with multiple peers or connections is more
// than this run-down wreck of an object can handle.
// Besides, this is only used to say if we have been connected ever.
#ifdef MOZILLA_INTERNAL_API
if (!mPrivacyRequested && !aPrivacyRequested && !mDtlsConnected) {
// now we know that privacy isn't needed for sure
nsIDocument* doc = GetWindow()->GetExtantDoc();
if (!doc) {
CSFLogInfo(logTag, "Can't update principal on streams; document gone");
return NS_ERROR_FAILURE;
}
mMedia->UpdateRemoteStreamPrincipals_m(doc->NodePrincipal());
}
#endif
mDtlsConnected = true;
mPrivacyRequested = mPrivacyRequested || aPrivacyRequested;
return NS_OK;
}
nsresult
PeerConnectionImpl::AddStream(DOMMediaStream &aMediaStream, PeerConnectionImpl::AddStream(DOMMediaStream &aMediaStream,
const MediaConstraintsInternal& aConstraints) const MediaConstraintsInternal& aConstraints)
{ {
return AddStream(aMediaStream, MediaConstraintsExternal(aConstraints)); return AddStream(aMediaStream, MediaConstraintsExternal(aConstraints));
} }
nsresult NS_IMETHODIMP
PeerConnectionImpl::AddStream(DOMMediaStream &aMediaStream, PeerConnectionImpl::AddStream(DOMMediaStream& aMediaStream,
const MediaConstraintsExternal& aConstraints) const MediaConstraintsExternal& aConstraints) {
{
PC_AUTO_ENTER_API_CALL(true); PC_AUTO_ENTER_API_CALL(true);
uint32_t hints = aMediaStream.GetHintContents(); uint32_t hints = aMediaStream.GetHintContents();
@ -1486,9 +1408,8 @@ PeerConnectionImpl::AddStream(DOMMediaStream &aMediaStream,
uint32_t stream_id; uint32_t stream_id;
nsresult res = mMedia->AddStream(&aMediaStream, &stream_id); nsresult res = mMedia->AddStream(&aMediaStream, &stream_id);
if (NS_FAILED(res)) { if (NS_FAILED(res))
return res; return res;
}
// TODO(ekr@rtfm.com): these integers should be the track IDs // TODO(ekr@rtfm.com): these integers should be the track IDs
if (hints & DOMMediaStream::HINT_CONTENTS_AUDIO) { if (hints & DOMMediaStream::HINT_CONTENTS_AUDIO) {

Просмотреть файл

@ -36,8 +36,6 @@
#include "VideoSegment.h" #include "VideoSegment.h"
#include "nsNSSShutDown.h" #include "nsNSSShutDown.h"
#include "mozilla/dom/RTCStatsReportBinding.h" #include "mozilla/dom/RTCStatsReportBinding.h"
#include "nsIPrincipal.h"
#include "mozilla/PeerIdentity.h"
#endif #endif
namespace test { namespace test {
@ -116,9 +114,6 @@ using mozilla::DtlsIdentity;
using mozilla::ErrorResult; using mozilla::ErrorResult;
using mozilla::NrIceStunServer; using mozilla::NrIceStunServer;
using mozilla::NrIceTurnServer; using mozilla::NrIceTurnServer;
#ifdef MOZILLA_INTERNAL_API
using mozilla::PeerIdentity;
#endif
class PeerConnectionWrapper; class PeerConnectionWrapper;
class PeerConnectionMedia; class PeerConnectionMedia;
@ -231,7 +226,8 @@ public:
static PeerConnectionImpl* CreatePeerConnection(); static PeerConnectionImpl* CreatePeerConnection();
static nsresult ConvertRTCConfiguration(const RTCConfiguration& aSrc, static nsresult ConvertRTCConfiguration(const RTCConfiguration& aSrc,
IceConfiguration *aDst); IceConfiguration *aDst);
already_AddRefed<DOMMediaStream> MakeMediaStream(uint32_t aHint); static already_AddRefed<DOMMediaStream> MakeMediaStream(nsPIDOMWindow* aWindow,
uint32_t aHint);
nsresult CreateRemoteSourceStreamInfo(nsRefPtr<RemoteSourceStreamInfo>* aInfo); nsresult CreateRemoteSourceStreamInfo(nsRefPtr<RemoteSourceStreamInfo>* aInfo);
@ -281,7 +277,7 @@ public:
return mSTSThread; return mSTSThread;
} }
// Get the DTLS identity (local side) // Get the DTLS identity
mozilla::RefPtr<DtlsIdentity> const GetIdentity() const; mozilla::RefPtr<DtlsIdentity> const GetIdentity() const;
std::string GetFingerprint() const; std::string GetFingerprint() const;
std::string GetFingerprintAlgorithm() const; std::string GetFingerprintAlgorithm() const;
@ -375,7 +371,7 @@ public:
rv = AddStream(aMediaStream, aConstraints); rv = AddStream(aMediaStream, aConstraints);
} }
nsresult AddStream(DOMMediaStream &aMediaStream, NS_IMETHODIMP AddStream(DOMMediaStream & aMediaStream,
const MediaConstraintsExternal& aConstraints); const MediaConstraintsExternal& aConstraints);
NS_IMETHODIMP_TO_ERRORRESULT(RemoveStream, ErrorResult &rv, NS_IMETHODIMP_TO_ERRORRESULT(RemoveStream, ErrorResult &rv,
@ -384,28 +380,6 @@ public:
rv = RemoveStream(aMediaStream); rv = RemoveStream(aMediaStream);
} }
nsresult GetPeerIdentity(nsAString& peerIdentity)
{
#ifdef MOZILLA_INTERNAL_API
if (mPeerIdentity) {
peerIdentity = mPeerIdentity->ToString();
return NS_OK;
}
#endif
peerIdentity.SetIsVoid(true);
return NS_OK;
}
#ifdef MOZILLA_INTERNAL_API
const PeerIdentity* GetPeerIdentity() const { return mPeerIdentity; }
nsresult SetPeerIdentity(const nsAString& peerIdentity);
#endif
// this method checks to see if we've made a promise to protect media.
bool PrivacyRequested() const { return mPrivacyRequested; }
NS_IMETHODIMP GetFingerprint(char** fingerprint); NS_IMETHODIMP GetFingerprint(char** fingerprint);
void GetFingerprint(nsAString& fingerprint) void GetFingerprint(nsAString& fingerprint)
{ {
@ -539,8 +513,6 @@ public:
void SetSignalingState_m(mozilla::dom::PCImplSignalingState aSignalingState); void SetSignalingState_m(mozilla::dom::PCImplSignalingState aSignalingState);
bool IsClosed() const; bool IsClosed() const;
// called when DTLS connects; we only need this once
nsresult SetDtlsConnected(bool aPrivacyRequested);
bool HasMedia() const; bool HasMedia() const;
@ -629,10 +601,6 @@ private:
mozilla::dom::PCImplIceConnectionState mIceConnectionState; mozilla::dom::PCImplIceConnectionState mIceConnectionState;
mozilla::dom::PCImplIceGatheringState mIceGatheringState; mozilla::dom::PCImplIceGatheringState mIceGatheringState;
// DTLS
// this is true if we have been connected ever, see SetDtlsConnected
bool mDtlsConnected;
nsCOMPtr<nsIThread> mThread; nsCOMPtr<nsIThread> mThread;
// TODO: Remove if we ever properly wire PeerConnection for cycle-collection. // TODO: Remove if we ever properly wire PeerConnection for cycle-collection.
nsWeakPtr mPCObserver; nsWeakPtr mPCObserver;
@ -650,20 +618,8 @@ private:
std::string mFingerprint; std::string mFingerprint;
std::string mRemoteFingerprint; std::string mRemoteFingerprint;
// identity-related fields // The DTLS identity
mozilla::RefPtr<DtlsIdentity> mIdentity; mozilla::RefPtr<DtlsIdentity> mIdentity;
#ifdef MOZILLA_INTERNAL_API
// The entity on the other end of the peer-to-peer connection;
// void if they are not yet identified, and no constraint has been set
nsAutoPtr<PeerIdentity> mPeerIdentity;
#endif
// Whether an app should be prevented from accessing media produced by the PC
// If this is true, then media will not be sent until mPeerIdentity matches
// local streams PeerIdentity; and remote streams are protected from content
//
// This can be false if mPeerIdentity is set, in the case where identity is
// provided, but the media is not protected from the app on either side
bool mPrivacyRequested;
// A handle to refer to this PC with // A handle to refer to this PC with
std::string mHandle; std::string mHandle;

Просмотреть файл

@ -15,7 +15,6 @@
#include "AudioConduit.h" #include "AudioConduit.h"
#include "VideoConduit.h" #include "VideoConduit.h"
#include "runnable_utils.h" #include "runnable_utils.h"
#include "transportlayerdtls.h"
#ifdef MOZILLA_INTERNAL_API #ifdef MOZILLA_INTERNAL_API
#include "MediaStreamList.h" #include "MediaStreamList.h"
@ -138,6 +137,7 @@ PeerConnectionImpl* PeerConnectionImpl::CreatePeerConnection()
PeerConnectionMedia::PeerConnectionMedia(PeerConnectionImpl *parent) PeerConnectionMedia::PeerConnectionMedia(PeerConnectionImpl *parent)
: mParent(parent), : mParent(parent),
mLocalSourceStreamsLock("PeerConnectionMedia.mLocalSourceStreamsLock"),
mIceCtx(nullptr), mIceCtx(nullptr),
mDNSResolver(new mozilla::NrIceResolver()), mDNSResolver(new mozilla::NrIceResolver()),
mMainThread(mParent->GetMainThread()), mMainThread(mParent->GetMainThread()),
@ -235,8 +235,6 @@ nsresult PeerConnectionMedia::Init(const std::vector<NrIceStunServer>& stun_serv
nsresult nsresult
PeerConnectionMedia::AddStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream_id) PeerConnectionMedia::AddStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream_id)
{ {
ASSERT_ON_THREAD(mMainThread);
if (!aMediaStream) { if (!aMediaStream) {
CSFLogError(logTag, "%s - aMediaStream is NULL", __FUNCTION__); CSFLogError(logTag, "%s - aMediaStream is NULL", __FUNCTION__);
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -265,6 +263,7 @@ PeerConnectionMedia::AddStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream
// allow one of each. // allow one of each.
// TODO(ekr@rtfm.com): remove this when multiple of each stream // TODO(ekr@rtfm.com): remove this when multiple of each stream
// is allowed // is allowed
mozilla::MutexAutoLock lock(mLocalSourceStreamsLock);
for (uint32_t u = 0; u < mLocalSourceStreams.Length(); u++) { for (uint32_t u = 0; u < mLocalSourceStreams.Length(); u++) {
nsRefPtr<LocalSourceStreamInfo> localSourceStream = mLocalSourceStreams[u]; nsRefPtr<LocalSourceStreamInfo> localSourceStream = mLocalSourceStreams[u];
@ -296,13 +295,13 @@ nsresult
PeerConnectionMedia::RemoveStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream_id) PeerConnectionMedia::RemoveStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream_id)
{ {
MOZ_ASSERT(aMediaStream); MOZ_ASSERT(aMediaStream);
ASSERT_ON_THREAD(mMainThread);
DOMMediaStream* stream = static_cast<DOMMediaStream*>(aMediaStream); DOMMediaStream* stream = static_cast<DOMMediaStream*>(aMediaStream);
CSFLogDebug(logTag, "%s: MediaStream: %p", CSFLogDebug(logTag, "%s: MediaStream: %p",
__FUNCTION__, aMediaStream); __FUNCTION__, aMediaStream);
mozilla::MutexAutoLock lock(mLocalSourceStreamsLock);
for (uint32_t u = 0; u < mLocalSourceStreams.Length(); u++) { for (uint32_t u = 0; u < mLocalSourceStreams.Length(); u++) {
nsRefPtr<LocalSourceStreamInfo> localSourceStream = mLocalSourceStreams[u]; nsRefPtr<LocalSourceStreamInfo> localSourceStream = mLocalSourceStreams[u];
if (localSourceStream->GetMediaStream() == stream) { if (localSourceStream->GetMediaStream() == stream) {
@ -358,11 +357,6 @@ PeerConnectionMedia::ShutdownMediaTransport_s()
CSFLogDebug(logTag, "%s: ", __FUNCTION__); CSFLogDebug(logTag, "%s: ", __FUNCTION__);
// Here we access m{Local|Remote}SourceStreams off the main thread.
// That's OK because by here PeerConnectionImpl has forgotten about us,
// so there is no chance of getting a call in here from outside.
// The dispatches from SelfDestruct() and to SelfDestruct_m() provide
// memory barriers that protect us from badness.
for (uint32_t i=0; i < mLocalSourceStreams.Length(); ++i) { for (uint32_t i=0; i < mLocalSourceStreams.Length(); ++i) {
mLocalSourceStreams[i]->DetachTransport_s(); mLocalSourceStreams[i]->DetachTransport_s();
} }
@ -383,7 +377,6 @@ PeerConnectionMedia::ShutdownMediaTransport_s()
LocalSourceStreamInfo* LocalSourceStreamInfo*
PeerConnectionMedia::GetLocalStream(int aIndex) PeerConnectionMedia::GetLocalStream(int aIndex)
{ {
ASSERT_ON_THREAD(mMainThread);
if(aIndex < 0 || aIndex >= (int) mLocalSourceStreams.Length()) { if(aIndex < 0 || aIndex >= (int) mLocalSourceStreams.Length()) {
return nullptr; return nullptr;
} }
@ -395,7 +388,6 @@ PeerConnectionMedia::GetLocalStream(int aIndex)
RemoteSourceStreamInfo* RemoteSourceStreamInfo*
PeerConnectionMedia::GetRemoteStream(int aIndex) PeerConnectionMedia::GetRemoteStream(int aIndex)
{ {
ASSERT_ON_THREAD(mMainThread);
if(aIndex < 0 || aIndex >= (int) mRemoteSourceStreams.Length()) { if(aIndex < 0 || aIndex >= (int) mRemoteSourceStreams.Length()) {
return nullptr; return nullptr;
} }
@ -480,7 +472,6 @@ nsresult
PeerConnectionMedia::AddRemoteStream(nsRefPtr<RemoteSourceStreamInfo> aInfo, PeerConnectionMedia::AddRemoteStream(nsRefPtr<RemoteSourceStreamInfo> aInfo,
int *aIndex) int *aIndex)
{ {
ASSERT_ON_THREAD(mMainThread);
MOZ_ASSERT(aIndex); MOZ_ASSERT(aIndex);
*aIndex = mRemoteSourceStreams.Length(); *aIndex = mRemoteSourceStreams.Length();
@ -533,113 +524,9 @@ PeerConnectionMedia::IceStreamReady(NrIceMediaStream *aStream)
CSFLogDebug(logTag, "%s: %s", __FUNCTION__, aStream->name().c_str()); CSFLogDebug(logTag, "%s: %s", __FUNCTION__, aStream->name().c_str());
} }
void void
PeerConnectionMedia::DtlsConnected(TransportLayer *dtlsLayer, LocalSourceStreamInfo::StorePipeline(int aTrack,
TransportLayer::State state) mozilla::RefPtr<mozilla::MediaPipeline> aPipeline)
{
dtlsLayer->SignalStateChange.disconnect(this);
bool privacyRequested = false;
// TODO (Bug 952678) set privacy mode, ask the DTLS layer about that
GetMainThread()->Dispatch(
WrapRunnable(mParent, &PeerConnectionImpl::SetDtlsConnected, privacyRequested),
NS_DISPATCH_NORMAL);
}
void
PeerConnectionMedia::AddTransportFlow(int aIndex, bool aRtcp,
const RefPtr<TransportFlow> &aFlow)
{
int index_inner = aIndex * 2 + (aRtcp ? 1 : 0);
MOZ_ASSERT(!mTransportFlows[index_inner]);
mTransportFlows[index_inner] = aFlow;
GetSTSThread()->Dispatch(
WrapRunnable(this, &PeerConnectionMedia::ConnectDtlsListener_s, aFlow),
NS_DISPATCH_NORMAL);
}
void
PeerConnectionMedia::ConnectDtlsListener_s(const RefPtr<TransportFlow>& aFlow)
{
TransportLayer* dtls = aFlow->GetLayer(TransportLayerDtls::ID());
dtls->SignalStateChange.connect(this, &PeerConnectionMedia::DtlsConnected);
}
#ifdef MOZILLA_INTERNAL_API
/**
* Tells you if any local streams is isolated. Obviously, we want all the
* streams to be isolated equally so that they can all be sent or not. But we
* can't make that determination for certain, because stream principals change.
* Therefore, we check once when we are setting a local description and that
* determines if we flip the "privacy requested" bit on. If a stream cannot be
* sent, then we'll be sending black/silence later; maybe this will correct
* itself and we can send actual content.
*
* @param scriptPrincipal the principal
* @returns true if any stream is isolated
*/
bool
PeerConnectionMedia::AnyLocalStreamIsolated(nsIPrincipal *scriptPrincipal) const
{
ASSERT_ON_THREAD(mMainThread);
for (uint32_t u = 0; u < mLocalSourceStreams.Length(); u++) {
// check if we should be asking for a private call for this stream
DOMMediaStream* stream = mLocalSourceStreams[u]->GetMediaStream();
if (!scriptPrincipal->Subsumes(stream->GetPrincipal())) {
return true;
}
}
return false;
}
void
PeerConnectionMedia::UpdateRemoteStreamPrincipals_m(nsIPrincipal* aPrincipal)
{
ASSERT_ON_THREAD(mMainThread);
for (uint32_t u = 0; u < mRemoteSourceStreams.Length(); u++) {
mRemoteSourceStreams[u]->UpdatePrincipal_m(aPrincipal);
}
}
void
PeerConnectionMedia::UpdateSinkIdentity_m(nsIPrincipal* aPrincipal,
const PeerIdentity* aSinkIdentity)
{
ASSERT_ON_THREAD(mMainThread);
for (uint32_t u = 0; u < mLocalSourceStreams.Length(); u++) {
mLocalSourceStreams[u]->UpdateSinkIdentity_m(aPrincipal, aSinkIdentity);
}
}
void
LocalSourceStreamInfo::UpdateSinkIdentity_m(nsIPrincipal* aPrincipal,
const PeerIdentity* aSinkIdentity)
{
for (auto it = mPipelines.begin(); it != mPipelines.end(); ++it) {
MediaPipelineTransmit* pipeline =
static_cast<MediaPipelineTransmit*>((*it).second.get());
pipeline->UpdateSinkIdentity_m(aPrincipal, aSinkIdentity);
}
}
void RemoteSourceStreamInfo::UpdatePrincipal_m(nsIPrincipal* aPrincipal)
{
// this blasts away the existing principal
// we only do this when we become certain that the stream is safe to make
// accessible to the script principal
mMediaStream->SetPrincipal(aPrincipal);
}
#endif // MOZILLA_INTERNAL_API
void
LocalSourceStreamInfo::StorePipeline(
int aTrack, mozilla::RefPtr<mozilla::MediaPipelineTransmit> aPipeline)
{ {
MOZ_ASSERT(mPipelines.find(aTrack) == mPipelines.end()); MOZ_ASSERT(mPipelines.find(aTrack) == mPipelines.end());
if (mPipelines.find(aTrack) != mPipelines.end()) { if (mPipelines.find(aTrack) != mPipelines.end()) {
@ -652,9 +539,9 @@ LocalSourceStreamInfo::StorePipeline(
} }
void void
RemoteSourceStreamInfo::StorePipeline( RemoteSourceStreamInfo::StorePipeline(int aTrack,
int aTrack, bool aIsVideo, bool aIsVideo,
mozilla::RefPtr<mozilla::MediaPipelineReceive> aPipeline) mozilla::RefPtr<mozilla::MediaPipeline> aPipeline)
{ {
MOZ_ASSERT(mPipelines.find(aTrack) == mPipelines.end()); MOZ_ASSERT(mPipelines.find(aTrack) == mPipelines.end());
if (mPipelines.find(aTrack) != mPipelines.end()) { if (mPipelines.find(aTrack) != mPipelines.end()) {

Просмотреть файл

@ -31,11 +31,8 @@
#include "VideoSegment.h" #include "VideoSegment.h"
#endif #endif
class nsIPrincipal;
namespace mozilla { namespace mozilla {
class DataChannel; class DataChannel;
class PeerIdentity;
namespace dom { namespace dom {
class RTCInboundRTPStreamStats; class RTCInboundRTPStreamStats;
class RTCOutboundRTPStreamStats; class RTCOutboundRTPStreamStats;
@ -218,12 +215,7 @@ public:
DOMMediaStream* GetMediaStream() { DOMMediaStream* GetMediaStream() {
return mMediaStream; return mMediaStream;
} }
void StorePipeline(int aTrack, void StorePipeline(int aTrack, mozilla::RefPtr<mozilla::MediaPipeline> aPipeline);
mozilla::RefPtr<mozilla::MediaPipelineTransmit> aPipeline);
#ifdef MOZILLA_INTERNAL_API
void UpdateSinkIdentity_m(nsIPrincipal* aPrincipal, const PeerIdentity* aSinkIdentity);
#endif
void ExpectAudio(const mozilla::TrackID); void ExpectAudio(const mozilla::TrackID);
void ExpectVideo(const mozilla::TrackID); void ExpectVideo(const mozilla::TrackID);
@ -251,17 +243,13 @@ class RemoteSourceStreamInfo : public SourceStreamInfo {
return mMediaStream; return mMediaStream;
} }
void StorePipeline(int aTrack, bool aIsVideo, void StorePipeline(int aTrack, bool aIsVideo,
mozilla::RefPtr<mozilla::MediaPipelineReceive> aPipeline); mozilla::RefPtr<mozilla::MediaPipeline> aPipeline);
bool SetUsingBundle_m(int aLevel, bool decision); bool SetUsingBundle_m(int aLevel, bool decision);
void DetachTransport_s(); void DetachTransport_s();
void DetachMedia_m(); void DetachMedia_m();
#ifdef MOZILLA_INTERNAL_API
void UpdatePrincipal_m(nsIPrincipal* aPrincipal);
#endif
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteSourceStreamInfo) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteSourceStreamInfo)
public: public:
@ -295,10 +283,10 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
return mIceStreams.size(); return mIceStreams.size();
} }
// Add a stream (main thread only) // Add a stream
nsresult AddStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream_id); nsresult AddStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream_id);
// Remove a stream (main thread only) // Remove a stream
nsresult RemoveStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream_id); nsresult RemoveStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream_id);
// Get a specific local stream // Get a specific local stream
@ -324,19 +312,6 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
nsresult AddRemoteStream(nsRefPtr<RemoteSourceStreamInfo> aInfo, int *aIndex); nsresult AddRemoteStream(nsRefPtr<RemoteSourceStreamInfo> aInfo, int *aIndex);
nsresult AddRemoteStreamHint(int aIndex, bool aIsVideo); nsresult AddRemoteStreamHint(int aIndex, bool aIsVideo);
#ifdef MOZILLA_INTERNAL_API
// In cases where the peer isn't yet identified, we disable the pipeline (not
// the stream, that would potentially affect others), so that it sends
// black/silence. Once the peer is identified, re-enable those streams.
void UpdateSinkIdentity_m(nsIPrincipal* aPrincipal, const PeerIdentity* aSinkIdentity);
// this determines if any stream is isolated, given the current
// document (or script) principal
bool AnyLocalStreamIsolated(nsIPrincipal *scriptPrincipal) const;
// When we finally learn who is on the other end, we need to change the ownership
// on streams
void UpdateRemoteStreamPrincipals_m(nsIPrincipal* aPrincipal);
#endif
const nsCOMPtr<nsIThread>& GetMainThread() const { return mMainThread; } const nsCOMPtr<nsIThread>& GetMainThread() const { return mMainThread; }
const nsCOMPtr<nsIEventTarget>& GetSTSThread() const { return mSTSThread; } const nsCOMPtr<nsIEventTarget>& GetSTSThread() const { return mSTSThread; }
@ -354,10 +329,12 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
// Add a transport flow // Add a transport flow
void AddTransportFlow(int aIndex, bool aRtcp, void AddTransportFlow(int aIndex, bool aRtcp,
const mozilla::RefPtr<mozilla::TransportFlow> &aFlow); const mozilla::RefPtr<mozilla::TransportFlow> &aFlow) {
void ConnectDtlsListener_s(const mozilla::RefPtr<mozilla::TransportFlow>& aFlow); int index_inner = aIndex * 2 + (aRtcp ? 1 : 0);
void DtlsConnected(mozilla::TransportLayer* aFlow,
mozilla::TransportLayer::State state); MOZ_ASSERT(!mTransportFlows[index_inner]);
mTransportFlows[index_inner] = aFlow;
}
mozilla::RefPtr<mozilla::MediaSessionConduit> GetConduit(int aStreamIndex, bool aReceive) { mozilla::RefPtr<mozilla::MediaSessionConduit> GetConduit(int aStreamIndex, bool aReceive) {
int index_inner = aStreamIndex * 2 + (aReceive ? 0 : 1); int index_inner = aStreamIndex * 2 + (aReceive ? 0 : 1);
@ -402,11 +379,10 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
PeerConnectionImpl *mParent; PeerConnectionImpl *mParent;
// A list of streams returned from GetUserMedia // A list of streams returned from GetUserMedia
// This is only accessed on the main thread (with one special exception) mozilla::Mutex mLocalSourceStreamsLock;
nsTArray<nsRefPtr<LocalSourceStreamInfo> > mLocalSourceStreams; nsTArray<nsRefPtr<LocalSourceStreamInfo> > mLocalSourceStreams;
// A list of streams provided by the other side // A list of streams provided by the other side
// This is only accessed on the main thread (with one special exception)
nsTArray<nsRefPtr<RemoteSourceStreamInfo> > mRemoteSourceStreams; nsTArray<nsRefPtr<RemoteSourceStreamInfo> > mRemoteSourceStreams;
// ICE objects // ICE objects

Просмотреть файл

@ -242,8 +242,6 @@ public:
uint32_t GetHintContents() const { return mHintContents; } uint32_t GetHintContents() const { return mHintContents; }
void SetHintContents(uint32_t aHintContents) { mHintContents = aHintContents; } void SetHintContents(uint32_t aHintContents) { mHintContents = aHintContents; }
void SetTrackEnabled(mozilla::TrackID aTrackID, bool aEnabled) {}
private: private:
nsRefPtr<Fake_MediaStream> mMediaStream; nsRefPtr<Fake_MediaStream> mMediaStream;