implement QVideoProbe for iOS camera
This commit allows to use QVideoProbe for QCamera on iOS. The logic for the implementation is taken from the Android plugin. [ChangeLog][Platform Specific Changes][iOS] QVideoProbe support is implemented for QCamera on iOS Change-Id: I1db50defa8518287c4f1f3cc6602881702a95849 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
committed by
Yoann Lopes
parent
9267a7833c
commit
762ff94f67
@@ -54,6 +54,7 @@
|
|||||||
#include "avfvideorenderercontrol.h"
|
#include "avfvideorenderercontrol.h"
|
||||||
#include "avfmediarecordercontrol.h"
|
#include "avfmediarecordercontrol.h"
|
||||||
#include "avfimagecapturecontrol.h"
|
#include "avfimagecapturecontrol.h"
|
||||||
|
#include "avfmediavideoprobecontrol.h"
|
||||||
|
|
||||||
#include <private/qmediaplaylistnavigator_p.h>
|
#include <private/qmediaplaylistnavigator_p.h>
|
||||||
#include <qmediaplaylist.h>
|
#include <qmediaplaylist.h>
|
||||||
@@ -119,6 +120,12 @@ QMediaControl *AVFCameraService::requestControl(const char *name)
|
|||||||
if (qstrcmp(name, QCameraImageCaptureControl_iid) == 0)
|
if (qstrcmp(name, QCameraImageCaptureControl_iid) == 0)
|
||||||
return m_imageCaptureControl;
|
return m_imageCaptureControl;
|
||||||
|
|
||||||
|
if (qstrcmp(name,QMediaVideoProbeControl_iid) == 0) {
|
||||||
|
AVFMediaVideoProbeControl *videoProbe = 0;
|
||||||
|
videoProbe = new AVFMediaVideoProbeControl(this);
|
||||||
|
m_session->addProbe(videoProbe);
|
||||||
|
return videoProbe;
|
||||||
|
}
|
||||||
if (!m_videoOutput) {
|
if (!m_videoOutput) {
|
||||||
if (qstrcmp(name, QVideoRendererControl_iid) == 0)
|
if (qstrcmp(name, QVideoRendererControl_iid) == 0)
|
||||||
m_videoOutput = new AVFVideoRendererControl(this);
|
m_videoOutput = new AVFVideoRendererControl(this);
|
||||||
@@ -139,6 +146,13 @@ void AVFCameraService::releaseControl(QMediaControl *control)
|
|||||||
m_session->setVideoOutput(0);
|
m_session->setVideoOutput(0);
|
||||||
delete control;
|
delete control;
|
||||||
}
|
}
|
||||||
|
AVFMediaVideoProbeControl *videoProbe = qobject_cast<AVFMediaVideoProbeControl *>(control);
|
||||||
|
if (videoProbe) {
|
||||||
|
m_session->removeProbe(videoProbe);
|
||||||
|
delete videoProbe;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_avfcameraservice.cpp"
|
#include "moc_avfcameraservice.cpp"
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <QtCore/qmutex.h>
|
#include <QtCore/qmutex.h>
|
||||||
#include <QtMultimedia/qcamera.h>
|
#include <QtMultimedia/qcamera.h>
|
||||||
|
#include <QVideoFrame>
|
||||||
|
|
||||||
#import <AVFoundation/AVFoundation.h>
|
#import <AVFoundation/AVFoundation.h>
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
class AVFCameraControl;
|
class AVFCameraControl;
|
||||||
class AVFCameraService;
|
class AVFCameraService;
|
||||||
class AVFVideoRendererControl;
|
class AVFVideoRendererControl;
|
||||||
|
class AVFMediaVideoProbeControl;
|
||||||
|
|
||||||
struct AVFCameraInfo
|
struct AVFCameraInfo
|
||||||
{
|
{
|
||||||
@@ -76,6 +78,9 @@ public:
|
|||||||
QCamera::State requestedState() const { return m_state; }
|
QCamera::State requestedState() const { return m_state; }
|
||||||
bool isActive() const { return m_active; }
|
bool isActive() const { return m_active; }
|
||||||
|
|
||||||
|
void addProbe(AVFMediaVideoProbeControl *probe);
|
||||||
|
void removeProbe(AVFMediaVideoProbeControl *probe);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setState(QCamera::State state);
|
void setState(QCamera::State state);
|
||||||
|
|
||||||
@@ -83,6 +88,7 @@ public Q_SLOTS:
|
|||||||
void processSessionStarted();
|
void processSessionStarted();
|
||||||
void processSessionStopped();
|
void processSessionStopped();
|
||||||
|
|
||||||
|
void onCameraFrameFetched(const QVideoFrame &frame);
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void readyToConfigureConnections();
|
void readyToConfigureConnections();
|
||||||
void stateChanged(QCamera::State newState);
|
void stateChanged(QCamera::State newState);
|
||||||
@@ -107,6 +113,10 @@ private:
|
|||||||
AVCaptureDeviceInput *m_videoInput;
|
AVCaptureDeviceInput *m_videoInput;
|
||||||
AVCaptureDeviceInput *m_audioInput;
|
AVCaptureDeviceInput *m_audioInput;
|
||||||
AVFCameraSessionObserver *m_observer;
|
AVFCameraSessionObserver *m_observer;
|
||||||
|
|
||||||
|
QSet<AVFMediaVideoProbeControl *> m_videoProbes;
|
||||||
|
QMutex m_videoProbesMutex;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include "avfvideorenderercontrol.h"
|
#include "avfvideorenderercontrol.h"
|
||||||
#include "avfvideodevicecontrol.h"
|
#include "avfvideodevicecontrol.h"
|
||||||
#include "avfaudioinputselectorcontrol.h"
|
#include "avfaudioinputselectorcontrol.h"
|
||||||
|
#include "avfmediavideoprobecontrol.h"
|
||||||
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
@@ -371,4 +372,30 @@ void AVFCameraSession::attachInputDevices()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AVFCameraSession::addProbe(AVFMediaVideoProbeControl *probe)
|
||||||
|
{
|
||||||
|
m_videoProbesMutex.lock();
|
||||||
|
if (probe)
|
||||||
|
m_videoProbes << probe;
|
||||||
|
m_videoProbesMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AVFCameraSession::removeProbe(AVFMediaVideoProbeControl *probe)
|
||||||
|
{
|
||||||
|
m_videoProbesMutex.lock();
|
||||||
|
m_videoProbes.remove(probe);
|
||||||
|
m_videoProbesMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AVFCameraSession::onCameraFrameFetched(const QVideoFrame &frame)
|
||||||
|
{
|
||||||
|
m_videoProbesMutex.lock();
|
||||||
|
QSet<AVFMediaVideoProbeControl *>::const_iterator i = m_videoProbes.constBegin();
|
||||||
|
while (i != m_videoProbes.constEnd()) {
|
||||||
|
(*i)->newFrameProbed(frame);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
m_videoProbesMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_avfcamerasession.cpp"
|
#include "moc_avfcamerasession.cpp"
|
||||||
|
|||||||
54
src/plugins/avfoundation/camera/avfmediavideoprobecontrol.h
Normal file
54
src/plugins/avfoundation/camera/avfmediavideoprobecontrol.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef AVFMEDIAVIDEOPROBECONTROL_H
|
||||||
|
#define AVFMEDIAVIDEOPROBECONTROL_H
|
||||||
|
|
||||||
|
#include <qmediavideoprobecontrol.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class AVFMediaVideoProbeControl : public QMediaVideoProbeControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit AVFMediaVideoProbeControl(QObject *parent = 0);
|
||||||
|
~AVFMediaVideoProbeControl();
|
||||||
|
|
||||||
|
void newFrameProbed(const QVideoFrame& frame);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // AVFMEDIAVIDEOPROBECONTROL_H
|
||||||
63
src/plugins/avfoundation/camera/avfmediavideoprobecontrol.mm
Normal file
63
src/plugins/avfoundation/camera/avfmediavideoprobecontrol.mm
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Copyright (C) 2013 Integrated Computer Solutions, Inc
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3.0 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU General Public License version 3.0 requirements will be
|
||||||
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "avfmediavideoprobecontrol.h"
|
||||||
|
#include <qvideoframe.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
AVFMediaVideoProbeControl::AVFMediaVideoProbeControl(QObject *parent) :
|
||||||
|
QMediaVideoProbeControl(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AVFMediaVideoProbeControl::~AVFMediaVideoProbeControl()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AVFMediaVideoProbeControl::newFrameProbed(const QVideoFrame &frame)
|
||||||
|
{
|
||||||
|
Q_EMIT videoFrameProbed(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
@@ -240,6 +240,8 @@ void AVFVideoRendererControl::syncHandleViewfinderFrame(const QVideoFrame &frame
|
|||||||
m_lastViewfinderFrame.unmap();
|
m_lastViewfinderFrame.unmap();
|
||||||
m_lastViewfinderFrame = QVideoFrame(mirrored);
|
m_lastViewfinderFrame = QVideoFrame(mirrored);
|
||||||
}
|
}
|
||||||
|
if (m_cameraSession && m_lastViewfinderFrame.isValid())
|
||||||
|
m_cameraSession->onCameraFrameFetched(m_lastViewfinderFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVFVideoRendererControl::handleViewfinderFrame()
|
void AVFVideoRendererControl::handleViewfinderFrame()
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ HEADERS += \
|
|||||||
avfstoragelocation.h \
|
avfstoragelocation.h \
|
||||||
avfvideodevicecontrol.h \
|
avfvideodevicecontrol.h \
|
||||||
avfaudioinputselectorcontrol.h \
|
avfaudioinputselectorcontrol.h \
|
||||||
avfcamerainfocontrol.h
|
avfcamerainfocontrol.h \
|
||||||
|
avfmediavideoprobecontrol.h
|
||||||
|
|
||||||
OBJECTIVE_SOURCES += \
|
OBJECTIVE_SOURCES += \
|
||||||
avfcameraserviceplugin.mm \
|
avfcameraserviceplugin.mm \
|
||||||
@@ -48,5 +49,6 @@ OBJECTIVE_SOURCES += \
|
|||||||
avfstoragelocation.mm \
|
avfstoragelocation.mm \
|
||||||
avfvideodevicecontrol.mm \
|
avfvideodevicecontrol.mm \
|
||||||
avfaudioinputselectorcontrol.mm \
|
avfaudioinputselectorcontrol.mm \
|
||||||
avfcamerainfocontrol.mm
|
avfcamerainfocontrol.mm \
|
||||||
|
avfmediavideoprobecontrol.mm
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user