diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2019-03-18 15:20:09 +0100 | 
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-03-18 15:20:09 +0100 | 
| commit | 5023b54ba76325bb0b5598d59714bdad2d55d81e (patch) | |
| tree | 15cc639eff7dbfa12eeccaa52d7fd251f18969e6 /compat | |
| parent | 3aababf6fd53a7b0312c2c1492bab6b43584b613 (diff) | |
video: add support for camera modules
Issue: #910
Diffstat (limited to 'compat')
| -rw-r--r-- | compat/camera-names.cpp | 102 | ||||
| -rw-r--r-- | compat/camera-names.hpp | 18 | 
2 files changed, 0 insertions, 120 deletions
| diff --git a/compat/camera-names.cpp b/compat/camera-names.cpp deleted file mode 100644 index 246d76ee..00000000 --- a/compat/camera-names.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "camera-names.hpp" - -#ifdef _WIN32 -#   include <cwchar> -#   define NO_DSHOW_STRSAFE -#   include <dshow.h> -#elif defined(__unix) || defined(__linux) || defined(__APPLE__) -#   include <unistd.h> -#endif - -#ifdef __linux -#   include <fcntl.h> -#   include <sys/ioctl.h> -#   include <linux/videodev2.h> -#   include <cerrno> -#   include <cstring> -#endif - -#include <QDebug> - -int camera_name_to_index(const QString &name) -{ -    auto list = get_camera_names(); -    int ret = list.indexOf(name); -    if (ret < 0) -        ret = 0; -    return ret; -} - -QList<QString> get_camera_names() -{ -    QList<QString> ret; -#ifdef _WIN32 -    // Create the System Device Enumerator. -    HRESULT hr; -    CoInitialize(nullptr); -    ICreateDevEnum *pSysDevEnum = nullptr; -    hr = CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); -    if (FAILED(hr)) -    { -        qDebug() << "failed CLSID_SystemDeviceEnum" << hr; -        return ret; -    } -    // Obtain a class enumerator for the video compressor category. -    IEnumMoniker *pEnumCat = nullptr; -    hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); - -    if (hr == S_OK) { -        // Enumerate the monikers. -        IMoniker *pMoniker = nullptr; -        ULONG cFetched; -        while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) -        { -            IPropertyBag *pPropBag; -            hr = pMoniker->BindToStorage(nullptr, nullptr, IID_IPropertyBag, (void **)&pPropBag); -            if (SUCCEEDED(hr))	{ -                // To retrieve the filter's friendly name, do the following: -                VARIANT var; -                VariantInit(&var); -                hr = pPropBag->Read(L"FriendlyName", &var, nullptr); -                if (SUCCEEDED(hr)) -                { -                    // Display the name in your UI somehow. -                    QString str((QChar*)var.bstrVal, int(std::wcslen(var.bstrVal))); -                    ret.append(str); -                } -                VariantClear(&var); -                pPropBag->Release(); -            } -            pMoniker->Release(); -        } -        pEnumCat->Release(); -    } -    else -        qDebug() << "failed CLSID_VideoInputDeviceCategory" << hr; - -    pSysDevEnum->Release(); -#endif - -#ifdef __linux -    for (int i = 0; i < 16; i++) { -        char buf[32]; -        snprintf(buf, sizeof(buf), "/dev/video%d", i); - -        if (access(buf, R_OK | W_OK) == 0) { -            int fd = open(buf, O_RDONLY); -            if (fd == -1) -                continue; -            struct v4l2_capability video_cap; -            if(ioctl(fd, VIDIOC_QUERYCAP, &video_cap) == -1) -            { -                qDebug() << "VIDIOC_QUERYCAP" << errno; -                close(fd); -                continue; -            } -            ret.append(QString{(const char*)video_cap.card}); -            close(fd); -        } -    } -#endif -    return ret; -} diff --git a/compat/camera-names.hpp b/compat/camera-names.hpp deleted file mode 100644 index 97184c8c..00000000 --- a/compat/camera-names.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2014-2015, Stanislaw Halik <sthalik@misaki.pl> - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#pragma once - -#include <QList> -#include <QString> - -#include "export.hpp" - -OTR_COMPAT_EXPORT QList<QString> get_camera_names(); -OTR_COMPAT_EXPORT int camera_name_to_index(const QString &name); - | 
