mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 926289 - Part 2, Carry recording type and request URL in recording-device-events in gUM API. r=jesup.
This commit is contained in:
parent
aa4a1a0c66
commit
c96458439b
@ -6,9 +6,11 @@
|
||||
|
||||
#include "MediaStreamGraph.h"
|
||||
#include "GetUserMediaRequest.h"
|
||||
#include "nsHashPropertyBag.h"
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include "nsIAudioManager.h"
|
||||
#endif
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsIDOMFile.h"
|
||||
#include "nsIEventTarget.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
@ -19,7 +21,8 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/dom/MediaStreamTrackBinding.h"
|
||||
#include "mozilla/dom/GetUserMediaRequestBinding.h"
|
||||
|
||||
@ -138,6 +141,45 @@ static nsresult ValidateTrackConstraints(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static already_AddRefed<nsHashPropertyBag>
|
||||
CreateRecordingDeviceEventsSubject(nsPIDOMWindow* aWindow,
|
||||
const bool aIsAudio,
|
||||
const bool aIsVideo)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
|
||||
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
|
||||
props->SetPropertyAsBool(NS_LITERAL_STRING("isAudio"), aIsAudio);
|
||||
props->SetPropertyAsBool(NS_LITERAL_STRING("isVideo"), aIsVideo);
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell = aWindow->GetDocShell();
|
||||
if (docShell) {
|
||||
bool isApp;
|
||||
DebugOnly<nsresult> rv = docShell->GetIsApp(&isApp);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
nsString requestURL;
|
||||
if (isApp) {
|
||||
rv = docShell->GetAppManifestURL(requestURL);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
} else {
|
||||
nsCString pageURL;
|
||||
nsCOMPtr<nsIURI> docURI = aWindow->GetDocumentURI();
|
||||
MOZ_ASSERT(docURI);
|
||||
|
||||
rv = docURI->GetSpec(pageURL);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
requestURL = NS_ConvertUTF8toUTF16(pageURL);
|
||||
}
|
||||
|
||||
props->SetPropertyAsAString(NS_LITERAL_STRING("requestURL"), requestURL);
|
||||
props->SetPropertyAsBool(NS_LITERAL_STRING("isApp"), isApp);
|
||||
}
|
||||
|
||||
return props.forget();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an error back to content. The error is the form a string.
|
||||
* Do this only on the main thread. The success callback is also passed here
|
||||
@ -584,7 +626,7 @@ public:
|
||||
nsRefPtr<MediaOperationRunnable> runnable(
|
||||
new MediaOperationRunnable(MEDIA_START, mListener, trackunion,
|
||||
tracksAvailableCallback,
|
||||
mAudioSource, mVideoSource, false));
|
||||
mAudioSource, mVideoSource, false, mWindowID));
|
||||
mediaThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
|
||||
|
||||
#ifdef MOZ_WEBRTC
|
||||
@ -1730,7 +1772,7 @@ GetUserMediaCallbackMediaStreamListener::Invalidate()
|
||||
runnable = new MediaOperationRunnable(MEDIA_STOP,
|
||||
this, nullptr, nullptr,
|
||||
mAudioSource, mVideoSource,
|
||||
mFinished);
|
||||
mFinished, mWindowID);
|
||||
mMediaThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
@ -1787,13 +1829,20 @@ GetUserMediaNotificationEvent::Run()
|
||||
}
|
||||
break;
|
||||
}
|
||||
obs->NotifyObservers(nullptr,
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = nsGlobalWindow::GetInnerWindowWithId(mWindowID);
|
||||
MOZ_ASSERT(window);
|
||||
|
||||
nsRefPtr<nsHashPropertyBag> props =
|
||||
CreateRecordingDeviceEventsSubject(window, mIsAudio, mIsVideo);
|
||||
|
||||
obs->NotifyObservers(static_cast<nsIPropertyBag2*>(props),
|
||||
"recording-device-events",
|
||||
msg.get());
|
||||
// Forward recording events to parent process.
|
||||
// The events are gathered in chrome process and used for recording indicator
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
unused << dom::ContentChild::GetSingleton()->SendRecordingDeviceEvents(msg);
|
||||
unused << dom::TabChild::GetFrom(window)->SendRecordingDeviceEvents(msg, mIsAudio, mIsVideo);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -204,14 +204,17 @@ class GetUserMediaNotificationEvent: public nsRunnable
|
||||
STOPPING
|
||||
};
|
||||
GetUserMediaNotificationEvent(GetUserMediaCallbackMediaStreamListener* aListener,
|
||||
GetUserMediaStatus aStatus)
|
||||
: mListener(aListener), mStatus(aStatus) {}
|
||||
GetUserMediaStatus aStatus,
|
||||
bool aIsAudio, bool aIsVideo, uint64_t aWindowID)
|
||||
: mListener(aListener) , mStatus(aStatus) , mIsAudio(aIsAudio)
|
||||
, mIsVideo(aIsVideo), mWindowID(aWindowID) {}
|
||||
|
||||
GetUserMediaNotificationEvent(GetUserMediaStatus aStatus,
|
||||
already_AddRefed<DOMMediaStream> aStream,
|
||||
DOMMediaStream::OnTracksAvailableCallback* aOnTracksAvailableCallback)
|
||||
DOMMediaStream::OnTracksAvailableCallback* aOnTracksAvailableCallback,
|
||||
bool aIsAudio, bool aIsVideo, uint64_t aWindowID)
|
||||
: mStream(aStream), mOnTracksAvailableCallback(aOnTracksAvailableCallback),
|
||||
mStatus(aStatus) {}
|
||||
mStatus(aStatus), mIsAudio(aIsAudio), mIsVideo(aIsVideo), mWindowID(aWindowID) {}
|
||||
virtual ~GetUserMediaNotificationEvent()
|
||||
{
|
||||
|
||||
@ -224,6 +227,9 @@ class GetUserMediaNotificationEvent: public nsRunnable
|
||||
nsRefPtr<DOMMediaStream> mStream;
|
||||
nsAutoPtr<DOMMediaStream::OnTracksAvailableCallback> mOnTracksAvailableCallback;
|
||||
GetUserMediaStatus mStatus;
|
||||
bool mIsAudio;
|
||||
bool mIsVideo;
|
||||
uint64_t mWindowID;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@ -244,7 +250,8 @@ public:
|
||||
DOMMediaStream::OnTracksAvailableCallback* aOnTracksAvailableCallback,
|
||||
MediaEngineSource* aAudioSource,
|
||||
MediaEngineSource* aVideoSource,
|
||||
bool aNeedsFinish)
|
||||
bool aNeedsFinish,
|
||||
uint64_t aWindowID)
|
||||
: mType(aType)
|
||||
, mStream(aStream)
|
||||
, mOnTracksAvailableCallback(aOnTracksAvailableCallback)
|
||||
@ -252,6 +259,7 @@ public:
|
||||
, mVideoSource(aVideoSource)
|
||||
, mListener(aListener)
|
||||
, mFinish(aNeedsFinish)
|
||||
, mWindowID(aWindowID)
|
||||
{}
|
||||
|
||||
~MediaOperationRunnable()
|
||||
@ -303,7 +311,10 @@ public:
|
||||
nsRefPtr<GetUserMediaNotificationEvent> event =
|
||||
new GetUserMediaNotificationEvent(GetUserMediaNotificationEvent::STARTING,
|
||||
mStream.forget(),
|
||||
mOnTracksAvailableCallback.forget());
|
||||
mOnTracksAvailableCallback.forget(),
|
||||
mAudioSource != nullptr,
|
||||
mVideoSource != nullptr,
|
||||
mWindowID);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
break;
|
||||
@ -324,7 +335,11 @@ public:
|
||||
source->Finish();
|
||||
}
|
||||
nsRefPtr<GetUserMediaNotificationEvent> event =
|
||||
new GetUserMediaNotificationEvent(mListener, GetUserMediaNotificationEvent::STOPPING);
|
||||
new GetUserMediaNotificationEvent(mListener,
|
||||
GetUserMediaNotificationEvent::STOPPING,
|
||||
mAudioSource != nullptr,
|
||||
mVideoSource != nullptr,
|
||||
mWindowID);
|
||||
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
@ -345,6 +360,7 @@ private:
|
||||
nsRefPtr<MediaEngineSource> mVideoSource; // threadsafe
|
||||
nsRefPtr<GetUserMediaCallbackMediaStreamListener> mListener; // threadsafe
|
||||
bool mFinish;
|
||||
uint64_t mWindowID;
|
||||
};
|
||||
|
||||
typedef nsTArray<nsRefPtr<GetUserMediaCallbackMediaStreamListener> > StreamListeners;
|
||||
|
Loading…
Reference in New Issue
Block a user