зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1299515 - Remove ReleaseMediaOperationResource. r=jib
MozReview-Commit-ID: 184hG8rMCmc --HG-- extra : rebase_source : e4ac7637254baff5ac2cb093c263d5bcd681a37e
This commit is contained in:
Родитель
c7709bb25d
Коммит
85f30b0b5b
|
@ -1061,7 +1061,7 @@ public:
|
|||
MediaStreamGraph* msg =
|
||||
MediaStreamGraph::GetInstance(graphDriverType, window);
|
||||
|
||||
RefPtr<DOMMediaStream> domStream;
|
||||
nsMainThreadPtrHandle<DOMMediaStream> domStream;
|
||||
RefPtr<SourceMediaStream> stream;
|
||||
// AudioCapture is a special case, here, in the sense that we're not really
|
||||
// using the audio source and the SourceMediaStream, which acts as
|
||||
|
@ -1072,8 +1072,9 @@ public:
|
|||
// It should be possible to pipe the capture stream to anything. CORS is
|
||||
// not a problem here, we got explicit user content.
|
||||
nsCOMPtr<nsIPrincipal> principal = window->GetExtantDoc()->NodePrincipal();
|
||||
domStream =
|
||||
DOMMediaStream::CreateAudioCaptureStreamAsInput(window, principal, msg);
|
||||
domStream = new nsMainThreadPtrHolder<DOMMediaStream>(
|
||||
"GetUserMediaStreamRunnable::AudioCaptureDOMStreamMainThreadHolder",
|
||||
DOMMediaStream::CreateAudioCaptureStreamAsInput(window, principal, msg));
|
||||
|
||||
stream = msg->CreateSourceStream(); // Placeholder
|
||||
msg->RegisterCaptureStreamForWindow(
|
||||
|
@ -1168,9 +1169,10 @@ public:
|
|||
// Normal case, connect the source stream to the track union stream to
|
||||
// avoid us blocking. Pass a simple TrackSourceGetter for potential
|
||||
// fake tracks. Apart from them gUM never adds tracks dynamically.
|
||||
domStream =
|
||||
domStream = new nsMainThreadPtrHolder<DOMMediaStream>(
|
||||
"GetUserMediaStreamRunnable::DOMMediaStreamMainThreadHolder",
|
||||
DOMLocalMediaStream::CreateSourceStreamAsInput(window, msg,
|
||||
new FakeTrackSourceGetter(principal));
|
||||
new FakeTrackSourceGetter(principal)));
|
||||
stream = domStream->GetInputStream()->AsSourceStream();
|
||||
|
||||
if (mAudioDevice) {
|
||||
|
@ -1223,8 +1225,15 @@ public:
|
|||
mWindowListener->Activate(mSourceListener, stream, mAudioDevice, mVideoDevice);
|
||||
|
||||
// Note: includes JS callbacks; must be released on MainThread
|
||||
auto callback = MakeRefPtr<Refcountable<UniquePtr<OnTracksAvailableCallback>>>(
|
||||
new TracksAvailableCallback(mManager, mOnSuccess.forget(), mWindowID, domStream));
|
||||
typedef Refcountable<UniquePtr<TracksAvailableCallback>> Callback;
|
||||
nsMainThreadPtrHandle<Callback> callback(
|
||||
new nsMainThreadPtrHolder<Callback>(
|
||||
"GetUserMediaStreamRunnable::TracksAvailableCallbackMainThreadHolder",
|
||||
MakeAndAddRef<Callback>(
|
||||
new TracksAvailableCallback(mManager,
|
||||
mOnSuccess.forget(),
|
||||
mWindowID,
|
||||
domStream))));
|
||||
|
||||
// Dispatch to the media thread to ask it to start the sources,
|
||||
// because that can take a while.
|
||||
|
@ -1264,10 +1273,6 @@ public:
|
|||
}
|
||||
|
||||
if (error) {
|
||||
// The DOM stream and track callback must be released on main thread.
|
||||
NS_DispatchToMainThread(do_AddRef(new ReleaseMediaOperationResource(
|
||||
domStream.forget(), callback.forget())));
|
||||
|
||||
// Dispatch the error callback on main thread.
|
||||
nsCOMPtr<nsIDOMGetUserMediaSuccessCallback> onSuccess;
|
||||
NS_DispatchToMainThread(do_AddRef(
|
||||
|
|
|
@ -127,30 +127,6 @@ public:
|
|||
Source* GetSource() override;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
MEDIA_STOP,
|
||||
MEDIA_STOP_TRACK,
|
||||
MEDIA_DIRECT_LISTENERS,
|
||||
} MediaOperation;
|
||||
|
||||
class ReleaseMediaOperationResource : public Runnable
|
||||
{
|
||||
public:
|
||||
ReleaseMediaOperationResource(
|
||||
already_AddRefed<DOMMediaStream> aStream,
|
||||
already_AddRefed<media::Refcountable<UniquePtr<OnTracksAvailableCallback>>>
|
||||
aOnTracksAvailableCallback)
|
||||
: Runnable("ReleaseMediaOperationResource")
|
||||
, mStream(aStream)
|
||||
, mOnTracksAvailableCallback(aOnTracksAvailableCallback)
|
||||
{
|
||||
}
|
||||
NS_IMETHOD Run() override {return NS_OK;}
|
||||
private:
|
||||
RefPtr<DOMMediaStream> mStream;
|
||||
RefPtr<media::Refcountable<UniquePtr<OnTracksAvailableCallback>>> mOnTracksAvailableCallback;
|
||||
};
|
||||
|
||||
typedef nsRefPtrHashtable<nsUint64HashKey, GetUserMediaWindowListener> WindowTable;
|
||||
|
||||
// we could add MediaManager if needed
|
||||
|
|
Загрузка…
Ссылка в новой задаче