Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r?mt
MozReview-Commit-ID: FhEyMxreaIx
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -796,25 +796,31 @@ public:
window->SetAudioCapture(true);
} else {
class LocalTrackSource : public MediaStreamTrackSource
{
public:
LocalTrackSource(nsIPrincipal* aPrincipal,
GetUserMediaCallbackMediaStreamListener* aListener,
const MediaSourceEnum aSource,
- const TrackID aTrackID)
+ const TrackID aTrackID,
+ const PeerIdentity* aPeerIdentity)
: MediaStreamTrackSource(aPrincipal, false), mListener(aListener),
- mSource(aSource), mTrackID(aTrackID) {}
+ mSource(aSource), mTrackID(aTrackID), mPeerIdentity(aPeerIdentity) {}
MediaSourceEnum GetMediaSource() const override
{
return mSource;
}
+ const PeerIdentity* GetPeerIdentity() const override
+ {
+ return mPeerIdentity;
+ }
+
already_AddRefed<Promise>
ApplyConstraints(nsPIDOMWindowInner* aWindow,
const MediaTrackConstraints& aConstraints,
ErrorResult &aRv) override
{
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(aWindow);
RefPtr<Promise> promise = Promise::Create(go, aRv);
@@ -848,52 +854,51 @@ public:
}
protected:
~LocalTrackSource() {}
RefPtr<GetUserMediaCallbackMediaStreamListener> mListener;
const MediaSourceEnum mSource;
const TrackID mTrackID;
+ const RefPtr<const PeerIdentity> mPeerIdentity;
};
nsCOMPtr<nsIPrincipal> principal;
if (mPeerIdentity) {
principal = nsNullPrincipal::Create();
} else {
principal = window->GetExtantDoc()->NodePrincipal();
}
// Normal case, connect the source stream to the track union stream to
// avoid us blocking. Pass a null TrackSourceGetter since gUM should never
// add tracks dynamically.
domStream =
DOMLocalMediaStream::CreateSourceStream(window, msg, nullptr);
- if (mPeerIdentity) {
- domStream->SetPeerIdentity(mPeerIdentity);
- }
-
if (mAudioDevice) {
nsString audioDeviceName;
mAudioDevice->GetName(audioDeviceName);
const MediaSourceEnum source =
mAudioDevice->GetSource()->GetMediaSource();
RefPtr<MediaStreamTrackSource> audioSource =
- new LocalTrackSource(principal, mListener, source, kAudioTrack);
+ new LocalTrackSource(principal, mListener, source, kAudioTrack,
+ mPeerIdentity);
domStream->CreateDOMTrack(kAudioTrack, MediaSegment::AUDIO,
audioDeviceName, audioSource);
}
if (mVideoDevice) {
nsString videoDeviceName;
mVideoDevice->GetName(videoDeviceName);
const MediaSourceEnum source =
mVideoDevice->GetSource()->GetMediaSource();
RefPtr<MediaStreamTrackSource> videoSource =
- new LocalTrackSource(principal, mListener, source, kVideoTrack);
+ new LocalTrackSource(principal, mListener, source, kVideoTrack,
+ mPeerIdentity);
domStream->CreateDOMTrack(kVideoTrack, MediaSegment::VIDEO,
videoDeviceName, videoSource);
}
stream = domStream->GetInputStream()->AsSourceStream();
}
if (!domStream || sInShutdown) {
nsCOMPtr<nsIDOMGetUserMediaErrorCallback> onFailure = mOnFailure.forget();