зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1634703 - Return nsIMediaDevice active devices list from mediaCaptureWindowState. r=jib,geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D73479
This commit is contained in:
Родитель
55da00290c
Коммит
f77df842d7
|
@ -428,7 +428,8 @@ function getTabStateForContentWindow(aContentWindow, aForRemove = false) {
|
|||
microphone = {},
|
||||
screen = {},
|
||||
window = {},
|
||||
browser = {};
|
||||
browser = {},
|
||||
devices = {};
|
||||
MediaManagerService.mediaCaptureWindowState(
|
||||
aContentWindow,
|
||||
camera,
|
||||
|
@ -436,6 +437,7 @@ function getTabStateForContentWindow(aContentWindow, aForRemove = false) {
|
|||
screen,
|
||||
window,
|
||||
browser,
|
||||
devices,
|
||||
false
|
||||
);
|
||||
|
||||
|
|
|
@ -678,6 +678,17 @@ class GetUserMediaWindowListener {
|
|||
return result;
|
||||
}
|
||||
|
||||
void GetDevices(
|
||||
const RefPtr<MediaManager::MediaDeviceSetRefCnt>& aOutDevices) {
|
||||
for (auto& l : mActiveListeners) {
|
||||
if (RefPtr<MediaDevice> device = l->GetAudioDevice()) {
|
||||
aOutDevices->AppendElement(device);
|
||||
} else if (RefPtr<MediaDevice> device = l->GetVideoDevice()) {
|
||||
aOutDevices->AppendElement(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t WindowID() const { return mWindowID; }
|
||||
|
||||
PrincipalHandle GetPrincipalHandle() const { return mPrincipalHandle; }
|
||||
|
@ -3851,11 +3862,10 @@ struct CaptureWindowStateData {
|
|||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
MediaManager::MediaCaptureWindowState(nsIDOMWindow* aCapturedWindow,
|
||||
uint16_t* aCamera, uint16_t* aMicrophone,
|
||||
uint16_t* aScreen, uint16_t* aWindow,
|
||||
uint16_t* aBrowser,
|
||||
bool aIncludeDescendants) {
|
||||
MediaManager::MediaCaptureWindowState(
|
||||
nsIDOMWindow* aCapturedWindow, uint16_t* aCamera, uint16_t* aMicrophone,
|
||||
uint16_t* aScreen, uint16_t* aWindow, uint16_t* aBrowser,
|
||||
nsTArray<RefPtr<nsIMediaDevice>>& aDevices, bool aIncludeDescendants) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
CaptureState camera = CaptureState::Off;
|
||||
|
@ -3863,12 +3873,13 @@ MediaManager::MediaCaptureWindowState(nsIDOMWindow* aCapturedWindow,
|
|||
CaptureState screen = CaptureState::Off;
|
||||
CaptureState window = CaptureState::Off;
|
||||
CaptureState browser = CaptureState::Off;
|
||||
auto devices = MakeRefPtr<MediaDeviceSetRefCnt>();
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> piWin = do_QueryInterface(aCapturedWindow);
|
||||
if (piWin) {
|
||||
auto combineCaptureState =
|
||||
[&camera, µphone, &screen, &window,
|
||||
&browser](const RefPtr<GetUserMediaWindowListener>& aListener) {
|
||||
[&camera, µphone, &screen, &window, &browser,
|
||||
&devices](const RefPtr<GetUserMediaWindowListener>& aListener) {
|
||||
camera = CombineCaptureState(
|
||||
camera, aListener->CapturingSource(MediaSourceEnum::Camera));
|
||||
microphone = CombineCaptureState(
|
||||
|
@ -3880,6 +3891,8 @@ MediaManager::MediaCaptureWindowState(nsIDOMWindow* aCapturedWindow,
|
|||
window, aListener->CapturingSource(MediaSourceEnum::Window));
|
||||
browser = CombineCaptureState(
|
||||
browser, aListener->CapturingSource(MediaSourceEnum::Browser));
|
||||
|
||||
aListener->GetDevices(devices);
|
||||
};
|
||||
|
||||
if (aIncludeDescendants) {
|
||||
|
@ -3899,6 +3912,9 @@ MediaManager::MediaCaptureWindowState(nsIDOMWindow* aCapturedWindow,
|
|||
*aScreen = FromCaptureState(screen);
|
||||
*aWindow = FromCaptureState(window);
|
||||
*aBrowser = FromCaptureState(browser);
|
||||
for (auto& device : *devices) {
|
||||
aDevices.AppendElement(device);
|
||||
}
|
||||
|
||||
LOG("%s: window %" PRIu64 " capturing %s %s %s %s %s", __FUNCTION__,
|
||||
piWin ? piWin->WindowID() : -1,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
interface nsIArray;
|
||||
interface nsIDOMWindow;
|
||||
interface nsIMediaDevice;
|
||||
|
||||
%{C++
|
||||
#define NS_MEDIAMANAGERSERVICE_CID {0xabc622ea, 0x9655, 0x4123, {0x80, 0xd9, 0x22, 0x62, 0x1b, 0xdd, 0x54, 0x65}}
|
||||
|
@ -33,6 +34,7 @@ interface nsIMediaManagerService : nsISupports
|
|||
out unsigned short aScreenShare,
|
||||
out unsigned short aWindowShare,
|
||||
out unsigned short aBrowserShare,
|
||||
out Array<nsIMediaDevice> devices,
|
||||
in boolean aIncludeDescendants);
|
||||
|
||||
/* Clear per-orgin list of persistent DeviceIds stored for enumerateDevices
|
||||
|
|
|
@ -93,6 +93,7 @@ const GeckoViewRecordingMedia = {
|
|||
const screen = {};
|
||||
const window = {};
|
||||
const browser = {};
|
||||
const devices = {};
|
||||
MediaManagerService.mediaCaptureWindowState(
|
||||
win,
|
||||
hasCamera,
|
||||
|
@ -100,6 +101,7 @@ const GeckoViewRecordingMedia = {
|
|||
screen,
|
||||
window,
|
||||
browser,
|
||||
devices,
|
||||
true
|
||||
);
|
||||
var cameraStatus = getStatusString(hasCamera.value);
|
||||
|
|
Загрузка…
Ссылка в новой задаче