mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 870678 - remove nsIDOMCameraManager r=bz
This commit is contained in:
parent
aed9eba249
commit
1e767d04d1
@ -1502,7 +1502,7 @@ Navigator::GetMozTime(nsIDOMMozTimeManager** aTime)
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
Navigator::GetMozCameras(nsIDOMCameraManager** aCameraManager)
|
||||
Navigator::GetMozCameras(nsISupports** aCameraManager)
|
||||
{
|
||||
if (!mCameraManager) {
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryReferent(mWindow);
|
||||
@ -1516,7 +1516,7 @@ Navigator::GetMozCameras(nsIDOMCameraManager** aCameraManager)
|
||||
NS_ENSURE_TRUE(mCameraManager, NS_OK);
|
||||
}
|
||||
|
||||
nsRefPtr<nsDOMCameraManager> cameraManager = mCameraManager;
|
||||
nsCOMPtr<nsIObserver> cameraManager = mCameraManager.get();
|
||||
cameraManager.forget(aCameraManager);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -783,8 +783,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
#endif
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(CameraManager, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CameraControl, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CameraCapabilities, nsDOMGenericSH,
|
||||
@ -1966,10 +1964,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_END
|
||||
#endif
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CameraManager, nsIDOMCameraManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCameraManager)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CameraControl, nsICameraControl)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsICameraControl)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -182,7 +182,6 @@ DOMCI_CLASS(BluetoothAdapter)
|
||||
DOMCI_CLASS(BluetoothDevice)
|
||||
#endif
|
||||
|
||||
DOMCI_CLASS(CameraManager)
|
||||
DOMCI_CLASS(CameraControl)
|
||||
DOMCI_CLASS(CameraCapabilities)
|
||||
|
||||
|
@ -18,15 +18,11 @@
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
DOMCI_DATA(CameraManager, nsIDOMCameraManager)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsDOMCameraManager, mWindow)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCameraManager)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMCameraManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMCameraManager)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CameraManager)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
@ -105,37 +101,6 @@ nsDOMCameraManager::CheckPermissionAndCreateInstance(nsPIDOMWindow* aWindow)
|
||||
return cameraManager.forget();
|
||||
}
|
||||
|
||||
/* [implicit_jscontext] void getCamera ([optional] in jsval aOptions, in nsICameraGetCameraCallback onSuccess, [optional] in nsICameraErrorCallback onError); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraManager::GetCamera(const JS::Value& aOptions, nsICameraGetCameraCallback* onSuccess, nsICameraErrorCallback* onError, JSContext* cx)
|
||||
{
|
||||
NS_ENSURE_TRUE(onSuccess, NS_ERROR_INVALID_ARG);
|
||||
|
||||
uint32_t cameraId = 0; // back (or forward-facing) camera by default
|
||||
mozilla::idl::CameraSelector selector;
|
||||
|
||||
nsresult rv = selector.Init(cx, &aOptions);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (selector.camera.EqualsASCII("front")) {
|
||||
cameraId = 1;
|
||||
}
|
||||
|
||||
// reuse the same camera thread to conserve resources
|
||||
if (!mCameraThread) {
|
||||
rv = NS_NewThread(getter_AddRefs(mCameraThread));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
|
||||
|
||||
// Creating this object will trigger the onSuccess handler
|
||||
nsCOMPtr<nsDOMCameraControl> cameraControl = new nsDOMCameraControl(cameraId, mCameraThread, onSuccess, onError, mWindowId);
|
||||
|
||||
Register(cameraControl);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMCameraManager::GetCamera(JSContext* aCx, const JS::Value aOptions,
|
||||
nsICameraGetCameraCallback* onSuccess,
|
||||
|
@ -32,16 +32,14 @@ typedef nsTArray<nsRefPtr<mozilla::nsDOMCameraControl> > CameraControls;
|
||||
typedef nsClassHashtable<nsUint64HashKey, CameraControls> WindowTable;
|
||||
|
||||
class nsDOMCameraManager MOZ_FINAL
|
||||
: public nsIDOMCameraManager
|
||||
, public nsIObserver
|
||||
: public nsIObserver
|
||||
, public nsSupportsWeakReference
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMCameraManager,
|
||||
nsIDOMCameraManager)
|
||||
NS_DECL_NSIDOMCAMERAMANAGER
|
||||
nsIObserver)
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
static already_AddRefed<nsDOMCameraManager>
|
||||
|
@ -21,13 +21,6 @@ nsDOMCameraManager::GetCameraName(uint32_t aDeviceNum, nsCString& aDeviceName)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void getListOfCameras ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aCameras); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraManager::GetListOfCameras(uint32_t *aCount, char * **aCameras)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMCameraManager::GetListOfCameras(nsTArray<nsString>& aList, ErrorResult& aRv)
|
||||
{
|
||||
|
@ -66,74 +66,6 @@ nsDOMCameraManager::GetCameraName(uint32_t aDeviceNum, nsCString& aDeviceName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getListOfCameras ([optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aCameras); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraManager::GetListOfCameras(uint32_t *aCount, char * **aCameras)
|
||||
{
|
||||
int32_t count = android::Camera::getNumberOfCameras();
|
||||
|
||||
DOM_CAMERA_LOGI("GetListOfCameras : getNumberOfCameras() returned %d\n", count);
|
||||
if (count < 1) {
|
||||
*aCameras = nullptr;
|
||||
*aCount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Allocate 2 extra slots to reserve space for 'front' and 'back' cameras
|
||||
// at the front of the array--we will collapse any empty slots below.
|
||||
int32_t arraySize = count + 2;
|
||||
char** cameras = static_cast<char**>(NS_Alloc(arraySize * sizeof(char*)));
|
||||
for (int32_t i = 0; i < arraySize; ++i) {
|
||||
cameras[i] = nullptr;
|
||||
}
|
||||
|
||||
uint32_t extraIndex = 2;
|
||||
bool gotFront = false;
|
||||
bool gotBack = false;
|
||||
|
||||
for (int32_t i = 0; i < count; ++i) {
|
||||
nsCString cameraName;
|
||||
nsresult result = GetCameraName(i, cameraName);
|
||||
if (result != NS_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The first camera we find named 'back' gets slot 0; and the first
|
||||
// we find named 'front' gets slot 1. All others appear after these.
|
||||
uint32_t index;
|
||||
if (!gotBack && !cameraName.Compare("back")) {
|
||||
index = 0;
|
||||
gotBack = true;
|
||||
} else if (!gotFront && !cameraName.Compare("front")) {
|
||||
index = 1;
|
||||
gotFront = true;
|
||||
} else {
|
||||
index = extraIndex++;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(index < arraySize);
|
||||
cameras[index] = ToNewCString(cameraName);
|
||||
}
|
||||
|
||||
// Make a forward pass over the array to compact it; after this loop,
|
||||
// 'offset' will contain the number of nullptrs in the array, which
|
||||
// we use to adjust the value returned in 'aCount'.
|
||||
int32_t offset = 0;
|
||||
for (int32_t i = 0; i < arraySize; ++i) {
|
||||
if (cameras[i] == nullptr) {
|
||||
offset++;
|
||||
} else if (offset != 0) {
|
||||
cameras[i - offset] = cameras[i];
|
||||
cameras[i] = nullptr;
|
||||
}
|
||||
}
|
||||
MOZ_ASSERT(offset >= 2);
|
||||
|
||||
*aCameras = cameras;
|
||||
*aCount = arraySize - offset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMCameraManager::GetListOfCameras(nsTArray<nsString>& aList, ErrorResult& aRv)
|
||||
{
|
||||
|
@ -378,21 +378,3 @@ interface nsICameraGetCameraCallback : nsISupports
|
||||
{
|
||||
void handleEvent(in nsICameraControl camera);
|
||||
};
|
||||
|
||||
[scriptable, uuid(f01aabcd-b822-423a-b077-3d0748296428)]
|
||||
interface nsIDOMCameraManager : nsISupports
|
||||
{
|
||||
/* get a camera instance; options will be used to specify which
|
||||
camera to get from the list returned by getListOfCameras(), e.g.:
|
||||
{
|
||||
camera: "front"
|
||||
}
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
void getCamera([optional] in jsval aOptions, in nsICameraGetCameraCallback onSuccess, [optional] in nsICameraErrorCallback onError);
|
||||
|
||||
/* return an array of camera identifiers, e.g.
|
||||
[ "front", "back" ]
|
||||
*/
|
||||
void getListOfCameras([optional] out unsigned long aCount, [retval, array, size_is(aCount)] out string aCameras);
|
||||
};
|
||||
|
@ -8,8 +8,9 @@
|
||||
|
||||
interface nsIDOMCameraManager;
|
||||
|
||||
[scriptable, uuid(bbb2456a-a6c8-42c8-8f52-6de071097e4b)]
|
||||
[scriptable,
|
||||
uuid(46a5710b-8dfb-430e-8705-90bea31c55aa)]
|
||||
interface nsIDOMNavigatorCamera : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMCameraManager mozCameras;
|
||||
readonly attribute nsISupports mozCameras;
|
||||
};
|
||||
|
@ -52,9 +52,19 @@ interface GetCameraCallback;
|
||||
interface CameraErrorCallback;
|
||||
|
||||
interface CameraManager {
|
||||
/* get a camera instance; options will be used to specify which
|
||||
camera to get from the list returned by getListOfCameras(), e.g.:
|
||||
{
|
||||
camera: "front"
|
||||
}
|
||||
*/
|
||||
[Throws]
|
||||
void getCamera(any options, GetCameraCallback callback,
|
||||
optional CameraErrorCallback errorCallback);
|
||||
|
||||
/* return an array of camera identifiers, e.g.
|
||||
[ "front", "back" ]
|
||||
*/
|
||||
[Throws]
|
||||
sequence<DOMString> getListOfCameras();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user