uvcserviceplugin.cpp 1.44 KB
Newer Older
Thiago Santini's avatar
Thiago Santini committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#include "uvcserviceplugin.h"

QMediaService* UVCServicePlugin::create(const QString &key)
{
    if (key == Q_MEDIASERVICE_CAMERA)
        return new UVCCameraService();
    return NULL;
}

void UVCServicePlugin::release(QMediaService *service)
{
    qDebug() << "Plugin release";
}

QByteArray UVCServicePlugin::defaultDevice(const QByteArray &service) const
{
    if (service == Q_MEDIASERVICE_CAMERA) {
       // const QList<UVCVideoDeviceControl> &devs = UVCVideoDeviceControl::availableDevices();
       // if (!devs.isEmpty())
       //     return devs.first().first;
    }

    return QByteArray();
}

QList<QByteArray> UVCServicePlugin::devices(const QByteArray &service) const
{
    QList<QByteArray> result;

    if (service == Q_MEDIASERVICE_CAMERA) {
        const QList<UVCVideoDeviceInfo> &devs = UVCVideoDeviceControl::availableDevices();
        for (const UVCVideoDeviceInfo &info : devs)
            result.append(info.first);
    }

    return result;
}

QString UVCServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
{
    if (service == Q_MEDIASERVICE_CAMERA) {
        const QList<UVCVideoDeviceInfo> &devs = UVCVideoDeviceControl::availableDevices();
        for (const UVCVideoDeviceInfo &info : devs)
            if (info.first == device)
                return info.second;
    }

    return QString();
}

#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2(uvcengine, UVCServicePlugin)
#endif // QT_VERSION < 0x050000