зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1152401 - Use mKind member of MediaDevice in MediaDeviceInfo to avoid string comparisons. r=jib
MozReview-Commit-ID: Kfqb7DZlwO2 --HG-- extra : rebase_source : 9e3ec1b4df4d90a20ff270f0e83a789631890cbe
This commit is contained in:
Родитель
c893b1d98d
Коммит
0237439056
|
@ -113,24 +113,21 @@ public:
|
|||
}
|
||||
nsTArray<RefPtr<MediaDeviceInfo>> infos;
|
||||
for (auto& device : devices) {
|
||||
MediaDevice* dev = static_cast<MediaDevice*>(device.get());
|
||||
bool isVideo = dev->mKind == dom::MediaDeviceKind::Videoinput;
|
||||
bool isAudio = dev->mKind == dom::MediaDeviceKind::Audioinput;
|
||||
if (isVideo || isAudio) {
|
||||
MediaDeviceKind kind = isVideo ?
|
||||
MediaDeviceKind::Videoinput : MediaDeviceKind::Audioinput;
|
||||
nsString id;
|
||||
nsString name;
|
||||
device->GetId(id);
|
||||
// Include name only if page currently has a gUM stream active or
|
||||
// persistent permissions (audio or video) have been granted
|
||||
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(mWindowId) ||
|
||||
Preferences::GetBool("media.navigator.permission.disabled", false)) {
|
||||
device->GetName(name);
|
||||
}
|
||||
RefPtr<MediaDeviceInfo> info = new MediaDeviceInfo(id, kind, name);
|
||||
infos.AppendElement(info);
|
||||
MediaDeviceKind kind = static_cast<MediaDevice*>(device.get())->mKind;
|
||||
MOZ_ASSERT(kind == dom::MediaDeviceKind::Audioinput
|
||||
|| kind == dom::MediaDeviceKind::Videoinput
|
||||
|| kind == dom::MediaDeviceKind::Audiooutput);
|
||||
nsString id;
|
||||
nsString name;
|
||||
device->GetId(id);
|
||||
// Include name only if page currently has a gUM stream active or
|
||||
// persistent permissions (audio or video) have been granted
|
||||
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(mWindowId) ||
|
||||
Preferences::GetBool("media.navigator.permission.disabled", false)) {
|
||||
device->GetName(name);
|
||||
}
|
||||
RefPtr<MediaDeviceInfo> info = new MediaDeviceInfo(id, kind, name);
|
||||
infos.AppendElement(info);
|
||||
}
|
||||
mPromise->MaybeResolve(infos);
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче