mirror of
https://gitee.com/drabel/LibQQt.git
synced 2025-01-04 10:18:44 +08:00
video manager module, prepare to support android.
This commit is contained in:
parent
640ddc2b48
commit
3c3acecfe4
@ -13,7 +13,7 @@ QQtCameraVideoSurface::~QQtCameraVideoSurface()
|
||||
|
||||
QList<QVideoFrame::PixelFormat> QQtCameraVideoSurface::supportedPixelFormats ( QAbstractVideoBuffer::HandleType handleType ) const
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
#ifdef Q_OS_ANDROID
|
||||
//Android NV21
|
||||
return QList<QVideoFrame::PixelFormat>()
|
||||
<< QVideoFrame::Format_NV21;
|
||||
@ -63,12 +63,52 @@ bool QQtCameraVideoSurface::present ( const QVideoFrame& frame )
|
||||
return true;
|
||||
}
|
||||
|
||||
QQtVideoProbe::QQtVideoProbe ( QObject* parent ) : QQtCameraVideoSurface ( parent )
|
||||
{
|
||||
m_mediaObject = 0;
|
||||
m_AndroidProber = 0;
|
||||
}
|
||||
|
||||
QQtVideoProbe::~QQtVideoProbe()
|
||||
{
|
||||
}
|
||||
|
||||
void QQtVideoProbe::setMediaObject ( QMediaObject* mediaObject )
|
||||
{
|
||||
Q_ASSERT ( mediaObject );
|
||||
#ifdef Q_OS_ANDROID
|
||||
if ( m_AndroidProber )
|
||||
{
|
||||
//m_AndroidProber->setSource ( nullptr );
|
||||
disconnect ( m_AndroidProber, SIGNAL ( videoFrameProbed ( const QVideoFrame& ) ),
|
||||
this, SLOT ( slotVideoFrame ( const QVideoFrame& ) ) );
|
||||
m_AndroidProber->deleteLater();
|
||||
}
|
||||
|
||||
m_mediaObject = mediaObject;
|
||||
m_AndroidProber = new QVideoProbe ( this );
|
||||
connect ( m_AndroidProber, SIGNAL ( videoFrameProbed ( const QVideoFrame& ) ),
|
||||
this, SLOT ( slotVideoFrame ( const QVideoFrame& ) ) );
|
||||
m_AndroidProber->setSource ( m_mediaObject );
|
||||
#endif
|
||||
}
|
||||
|
||||
QMediaObject* QQtVideoProbe::mediaObject() const
|
||||
{
|
||||
return m_mediaObject;
|
||||
}
|
||||
|
||||
void QQtVideoProbe::slotVideoFrame ( const QVideoFrame& frame )
|
||||
{
|
||||
present ( frame );
|
||||
}
|
||||
|
||||
QQtVideoInput::QQtVideoInput ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
/**
|
||||
* 设置视频截图工具
|
||||
*/
|
||||
mSurface = new QQtCameraVideoSurface ( this );
|
||||
mSurface = new QQtVideoProbe ( this );
|
||||
connect ( mSurface, SIGNAL ( readyRead ( QImage ) ), this, SIGNAL ( readyRead ( QImage ) ) );
|
||||
connect ( mSurface, SIGNAL ( readyRead ( QImage ) ), this, SLOT ( slotImageCaptured ( QImage ) ) );
|
||||
|
||||
@ -80,7 +120,12 @@ QQtVideoInput::QQtVideoInput ( QObject* parent ) : QObject ( parent )
|
||||
//QQtCamera 默认就是使用默认照相机,所以,这里不必设置了。
|
||||
mCamInfo = defaultCamera();
|
||||
mCamera->setCameraInfo ( mCamInfo );
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
mSurface->setMediaObject ( mCamera->camera() );
|
||||
#else
|
||||
mCamera->setViewfinder ( mSurface );
|
||||
#endif
|
||||
|
||||
//
|
||||
mExposure = new QQtCameraExposure ( this );
|
||||
@ -185,14 +230,18 @@ void QQtVideoInput::start()
|
||||
if ( !mCamera->isCaptureModeSupported ( QCamera::CaptureVideo ) )
|
||||
{
|
||||
pline() << mCamInfo.deviceName();
|
||||
pline() << mCamera << "Camera cannot capture video";
|
||||
//pline() << mCamera << "Camera cannot capture video";
|
||||
}
|
||||
//播放图像 = QCamera::CaptureStillImage
|
||||
//播放图像 = QCamera::CaptureViewfinder
|
||||
mCamera->setCaptureMode ( QCamera::CaptureVideo );
|
||||
|
||||
//设置输出
|
||||
#ifdef Q_OS_ANDROID
|
||||
mSurface->setMediaObject ( mCamera->camera() );
|
||||
#else
|
||||
mCamera->setViewfinder ( mSurface );
|
||||
#endif
|
||||
|
||||
//设置ViewfinderSettings
|
||||
//启动后设置...
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <QAbstractVideoSurface>
|
||||
#include <QVideoSurfaceFormat>
|
||||
#include <QCameraViewfinderSettings>
|
||||
#include <QVideoProbe>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
@ -22,12 +23,13 @@
|
||||
* | 使用方式 | Parent | Property Class | Childen | 备注
|
||||
* ---------------------------------------------------------------------------------------------------------------------
|
||||
* | setViewfinder | QAbstractVideoSurface | QQtCameraVideoSurface | | 视频,快,Buffer
|
||||
* | | | | QQtVideoProbe | 视频,快,Buffer,+Android支持
|
||||
* ---------------------------------------------------------------------------------------------------------------------
|
||||
* | setViewfinder | QMediaBindableInterface | QGraphicsVideoItem | | QGraphicsItem 系统专用
|
||||
* | | | QVideoWidget | QCameraViewfinder | 视频,快,属于输出位置上的
|
||||
* ---------------------------------------------------------------------------------------------------------------------
|
||||
* | setMetaObject | QMediaBindableInterface | QCameraImageCapture | | 截图,慢,默认保存文件
|
||||
* | | | QMediaRecoder | QAudioRecoder | 录像,快,保存文件,音视频
|
||||
* | | | QMediaRecorder | QAudioRecorder | 录像,快,保存文件,音视频
|
||||
* ---------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@ -42,7 +44,6 @@
|
||||
* @brief The QQtVideoSurface class
|
||||
* 从metaObject获取视频数据,帧。
|
||||
* Buffer,快速。
|
||||
* 还有一个Android平台的,QVideoProbe
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtCameraVideoSurface : public QAbstractVideoSurface
|
||||
{
|
||||
@ -60,6 +61,26 @@ public:
|
||||
virtual bool present ( const QVideoFrame& frame ) override;
|
||||
};
|
||||
|
||||
class QQTSHARED_EXPORT QQtVideoProbe : public QQtCameraVideoSurface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQtVideoProbe ( QObject* parent = 0 );
|
||||
virtual ~QQtVideoProbe();
|
||||
|
||||
void setMediaObject ( QMediaObject* mediaObject );
|
||||
QMediaObject* mediaObject() const;
|
||||
|
||||
/**
|
||||
* 以下与用户无关。
|
||||
*/
|
||||
private slots:
|
||||
void slotVideoFrame ( const QVideoFrame& frame );
|
||||
private:
|
||||
QMediaObject* m_mediaObject;
|
||||
QVideoProbe* m_AndroidProber;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The QQtVideoInput class
|
||||
* 图像输入
|
||||
@ -140,7 +161,7 @@ private:
|
||||
//经过调试,QCamera句柄,一个进程只能存在一个。
|
||||
QQtCamera* mCamera;
|
||||
QCameraInfo mCamInfo;
|
||||
QQtCameraVideoSurface* mSurface;
|
||||
QQtVideoProbe* mSurface;
|
||||
QQtCameraExposure* mExposure;
|
||||
QQtCameraFocus* mFocus;
|
||||
QQtCameraImageProcessing* mImageProcessing;
|
||||
|
@ -86,4 +86,5 @@
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
</manifest>
|
||||
|
@ -10,6 +10,7 @@ MainWindow::MainWindow ( QWidget* parent ) :
|
||||
input = new QQtVideoInput ( this );
|
||||
pline() << input->defaultCamera();
|
||||
pline() << input ->availableCameras();
|
||||
return;
|
||||
|
||||
pline() << input->viewFinderSettings().pixelFormat();
|
||||
pline() << input->camera()->supportedViewfinderPixelFormats();
|
||||
|
@ -17,19 +17,37 @@
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Camera Information</string>
|
||||
</attribute>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>141</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Preview</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QQtWidget" name="qqtwidget_2"/>
|
||||
<widget class="QQtWidget" name="qqtwidget_2" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QQtWidget" name="qqtwidget_3"/>
|
||||
<widget class="QQtWidget" name="qqtwidget_3" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QQtWidget" name="qqtwidget"/>
|
||||
<widget class="QQtWidget" name="qqtwidget" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="2">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
@ -76,11 +94,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Tab 2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -42,7 +42,7 @@ add_version(1,0,0,0)
|
||||
add_deploy()
|
||||
add_deploy_config($${PWD}/AppRoot)
|
||||
add_dependent_manager(QQt)
|
||||
add_dependent_manager(QQtMediaExtention)
|
||||
#add_dependent_manager(QQtMediaExtention)
|
||||
system(touch main.cpp)
|
||||
|
||||
#-------------------------------------------------
|
||||
|
@ -86,4 +86,5 @@
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
</manifest>
|
||||
|
@ -16,10 +16,10 @@
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QQtWidget" name="qqtwidget"/>
|
||||
<widget class="QQtWidget" name="qqtwidget" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QQtWidget" name="qqtwidget_2"/>
|
||||
<widget class="QQtWidget" name="qqtwidget_2" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
@ -32,10 +32,10 @@
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>71</width>
|
||||
<height>16</height>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>81</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -46,9 +46,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>10</y>
|
||||
<width>80</width>
|
||||
<height>16</height>
|
||||
<y>0</y>
|
||||
<width>81</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -59,11 +59,17 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>10</y>
|
||||
<width>80</width>
|
||||
<height>16</height>
|
||||
<y>0</y>
|
||||
<width>81</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Capture</string>
|
||||
</property>
|
||||
|
@ -42,7 +42,7 @@ add_version(1,0,0,0)
|
||||
add_deploy()
|
||||
add_deploy_config($${PWD}/AppRoot)
|
||||
add_dependent_manager(QQt)
|
||||
add_dependent_manager(QQtMediaExtention)
|
||||
#add_dependent_manager(QQtMediaExtention)
|
||||
system(touch main.cpp)
|
||||
|
||||
#-------------------------------------------------
|
||||
|
@ -86,4 +86,5 @@
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
</manifest>
|
||||
|
@ -45,7 +45,7 @@ add_version(1,0,0,0)
|
||||
add_deploy()
|
||||
add_deploy_config($${PWD}/AppRoot)
|
||||
add_dependent_manager(QQt)
|
||||
add_dependent_manager(QQtMediaExtention)
|
||||
#add_dependent_manager(QQtMediaExtention)
|
||||
system(touch main.cpp)
|
||||
|
||||
#-------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user