AVFoundation: fix QCameraInfo::availableCameras() on OS X.
Cameras can be dynamically added or removed on OS X. Make sure the cache is updated often enough so QCameraInfo::availableCameras() return an up to date list. Task-number: QTBUG-39708 Change-Id: Id806d52278e1a29163fcc6707da7f86c0f3e7c0d Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
This commit is contained in:
committed by
Timur Pocheptsov
parent
fa9e829a60
commit
def89d7171
@@ -71,18 +71,26 @@ void AVFServicePlugin::release(QMediaService *service)
|
||||
|
||||
QByteArray AVFServicePlugin::defaultDevice(const QByteArray &service) const
|
||||
{
|
||||
if (service == Q_MEDIASERVICE_CAMERA)
|
||||
return AVFCameraSession::defaultCameraDevice();
|
||||
if (service == Q_MEDIASERVICE_CAMERA) {
|
||||
int i = AVFCameraSession::defaultCameraIndex();
|
||||
if (i != -1)
|
||||
return AVFCameraSession::availableCameraDevices().at(i).deviceId;
|
||||
}
|
||||
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
QList<QByteArray> AVFServicePlugin::devices(const QByteArray &service) const
|
||||
{
|
||||
if (service == Q_MEDIASERVICE_CAMERA)
|
||||
return AVFCameraSession::availableCameraDevices();
|
||||
QList<QByteArray> devs;
|
||||
|
||||
return QList<QByteArray>();
|
||||
if (service == Q_MEDIASERVICE_CAMERA) {
|
||||
const QList<AVFCameraInfo> &cameras = AVFCameraSession::availableCameraDevices();
|
||||
Q_FOREACH (const AVFCameraInfo &info, cameras)
|
||||
devs.append(info.deviceId);
|
||||
}
|
||||
|
||||
return devs;
|
||||
}
|
||||
|
||||
QString AVFServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
|
||||
|
||||
Reference in New Issue
Block a user