diff --git a/src/multimedia/private/qqtlogicvideomanager_p.cpp b/src/multimedia/private/qqtlogicvideomanager_p.cpp index 88d750d5..8ca99f4c 100644 --- a/src/multimedia/private/qqtlogicvideomanager_p.cpp +++ b/src/multimedia/private/qqtlogicvideomanager_p.cpp @@ -1,9 +1,9 @@ #include #include -int QQtLogicVideoManagerPrivate::sDmmuRefCount = 0; +int QQtLogicVideoInputPrivate::sDmmuRefCount = 0; -QQtLogicVideoManagerPrivate::QQtLogicVideoManagerPrivate ( QQtLogicVideoManager* q, QObject* parent ) +QQtLogicVideoInputPrivate::QQtLogicVideoInputPrivate ( QQtLogicVideoInput* q, QObject* parent ) : q_ptr ( q ), QObject ( parent ) { memset ( &sinfo, 0, sizeof ( struct sensor_info ) ); @@ -42,7 +42,7 @@ QQtLogicVideoManagerPrivate::QQtLogicVideoManagerPrivate ( QQtLogicVideoManager* sDmmuRefCount++; } -QQtLogicVideoManagerPrivate::~QQtLogicVideoManagerPrivate() +QQtLogicVideoInputPrivate::~QQtLogicVideoInputPrivate() { sDmmuRefCount--; if ( sDmmuRefCount <= 0 ) @@ -51,18 +51,18 @@ QQtLogicVideoManagerPrivate::~QQtLogicVideoManagerPrivate() } } -void QQtLogicVideoManagerPrivate::init_dmmu() +void QQtLogicVideoInputPrivate::init_dmmu() { dmmu_init(); dmmu_get_page_table_base_phys ( &tlb_base_phys ); } -void QQtLogicVideoManagerPrivate::deinit_dmmu() +void QQtLogicVideoInputPrivate::deinit_dmmu() { dmmu_deinit(); } -bool QQtLogicVideoManagerPrivate::open ( QString devName ) +bool QQtLogicVideoInputPrivate::open ( QString devName ) { //待测试 close(); @@ -175,7 +175,7 @@ bool QQtLogicVideoManagerPrivate::open ( QString devName ) return true; } -bool QQtLogicVideoManagerPrivate::close() +bool QQtLogicVideoInputPrivate::close() { timer->stop(); @@ -210,7 +210,7 @@ bool QQtLogicVideoManagerPrivate::close() return true; } -void QQtLogicVideoManagerPrivate::slotSendImageToClient() +void QQtLogicVideoInputPrivate::slotSendImageToClient() { if ( fd <= 0 ) return; diff --git a/src/multimedia/private/qqtlogicvideomanager_p.h b/src/multimedia/private/qqtlogicvideomanager_p.h index 64a730e2..cca55ea7 100644 --- a/src/multimedia/private/qqtlogicvideomanager_p.h +++ b/src/multimedia/private/qqtlogicvideomanager_p.h @@ -23,14 +23,14 @@ extern "C" { #include -class QQtLogicVideoManager; -class QQtLogicVideoManagerPrivate : public QObject +class QQtLogicVideoInput; +class QQtLogicVideoInputPrivate : public QObject { Q_OBJECT public: - explicit QQtLogicVideoManagerPrivate ( QQtLogicVideoManager* q, QObject* parent = 0 ); - virtual ~QQtLogicVideoManagerPrivate(); + explicit QQtLogicVideoInputPrivate ( QQtLogicVideoInput* q, QObject* parent = 0 ); + virtual ~QQtLogicVideoInputPrivate(); bool open ( QString devName ); bool close(); @@ -70,8 +70,8 @@ private: protected: private: - Q_DECLARE_PUBLIC ( QQtLogicVideoManager ) - QQtLogicVideoManager* q_ptr; + Q_DECLARE_PUBLIC ( QQtLogicVideoInput ) + QQtLogicVideoInput* q_ptr; static int sDmmuRefCount; }; diff --git a/src/multimedia/qqtlogicpreviewwidget.cpp b/src/multimedia/qqtlogicpreviewwidget.cpp index 800be251..59c47345 100644 --- a/src/multimedia/qqtlogicpreviewwidget.cpp +++ b/src/multimedia/qqtlogicpreviewwidget.cpp @@ -6,7 +6,7 @@ QQtLogicPreviewWidget::QQtLogicPreviewWidget ( QWidget* parent ) : ui ( new Ui::QQtLogicPreviewWidget ) { ui->setupUi ( this ); - manager = new QQtLogicVideoManager ( this ); + manager = new QQtLogicVideoInput ( this ); connect ( manager, SIGNAL ( readyRead ( const QImage& ) ), this, SLOT ( slotReadyRead ( const QImage& ) ) ); } diff --git a/src/multimedia/qqtlogicpreviewwidget.h b/src/multimedia/qqtlogicpreviewwidget.h index c9d149ea..5ef0a373 100644 --- a/src/multimedia/qqtlogicpreviewwidget.h +++ b/src/multimedia/qqtlogicpreviewwidget.h @@ -41,7 +41,7 @@ private: QRect geome; Qt::WindowFlags flags; - QQtLogicVideoManager* manager; + QQtLogicVideoInput* manager; QImage mImage; // QWidget interface protected: diff --git a/src/multimedia/qqtlogicvideomanager.cpp b/src/multimedia/qqtlogicvideomanager.cpp index 1e82bdc6..1549c2ef 100644 --- a/src/multimedia/qqtlogicvideomanager.cpp +++ b/src/multimedia/qqtlogicvideomanager.cpp @@ -1,25 +1,45 @@ #include "qqtlogicvideomanager.h" #include "qqtlogicvideomanager_p.h" -QQtLogicVideoManager::QQtLogicVideoManager ( QObject* parent ) : - d_ptr ( new QQtLogicVideoManagerPrivate ( this, this ) ), QObject ( parent ) +QQtLogicVideoInput::QQtLogicVideoInput ( QObject* parent ) : + d_ptr ( new QQtLogicVideoInputPrivate ( this, this ) ), QObject ( parent ) { } -QQtLogicVideoManager::~QQtLogicVideoManager() +QQtLogicVideoInput::~QQtLogicVideoInput() { - Q_D ( QQtLogicVideoManager ); + Q_D ( QQtLogicVideoInput ); d->deleteLater(); } -bool QQtLogicVideoManager::open ( QString devName ) +bool QQtLogicVideoInput::open ( QString devName ) { - Q_D ( QQtLogicVideoManager ); + Q_D ( QQtLogicVideoInput ); return d->open ( devName ); } -bool QQtLogicVideoManager::close() +bool QQtLogicVideoInput::close() { - Q_D ( QQtLogicVideoManager ); + Q_D ( QQtLogicVideoInput ); return d->close(); } + +QQtLogicVideoManager::QQtLogicVideoManager ( QObject* parent ) + : QObject ( parent ) +{ + mInputManager = new QQtLogicVideoInput ( this ); + connect ( mInputManager, SIGNAL ( readyRead ( const QImage& ) ), + this, SIGNAL ( readyRead ( const QImage& ) ) ); +} + +QQtLogicVideoManager::~QQtLogicVideoManager() {} + +bool QQtLogicVideoManager::openInput ( QString devName ) +{ + return mInputManager->open ( devName ); +} + +bool QQtLogicVideoManager::closeInput() +{ + return mInputManager->close(); +} diff --git a/src/multimedia/qqtlogicvideomanager.h b/src/multimedia/qqtlogicvideomanager.h index ef180fd3..6638e992 100644 --- a/src/multimedia/qqtlogicvideomanager.h +++ b/src/multimedia/qqtlogicvideomanager.h @@ -6,17 +6,17 @@ #include "qqt-local.h" /** - * @brief The QQtLogicVideoManager class + * @brief The QQtLogicVideoInput class * 模拟摄像头管理器 */ -class QQtLogicVideoManagerPrivate; -class QQTSHARED_EXPORT QQtLogicVideoManager : public QObject +class QQtLogicVideoInputPrivate; +class QQTSHARED_EXPORT QQtLogicVideoInput : public QObject { Q_OBJECT public: - explicit QQtLogicVideoManager ( QObject* parent = 0 ); - virtual ~QQtLogicVideoManager(); + explicit QQtLogicVideoInput ( QObject* parent = 0 ); + virtual ~QQtLogicVideoInput(); //开启某个确定的模拟摄像头 bool open ( QString devName = "/dev/cim" ); @@ -29,8 +29,32 @@ signals: protected: private: - Q_DECLARE_PRIVATE ( QQtLogicVideoManager ) - QQtLogicVideoManagerPrivate* d_ptr; + Q_DECLARE_PRIVATE ( QQtLogicVideoInput ) + QQtLogicVideoInputPrivate* d_ptr; +}; + +/** + * @brief The QQtLogicVideoManager class + */ +class QQTSHARED_EXPORT QQtLogicVideoManager : public QObject +{ + Q_OBJECT +public: + explicit QQtLogicVideoManager ( QObject* parent = 0 ); + virtual ~QQtLogicVideoManager(); + + +public: + //开启某个确定的模拟摄像头 + bool openInput ( QString devName = "/dev/cim" ); + bool closeInput(); + +signals: + //获取图像 + void readyRead ( const QImage& image ); + +private: + QQtLogicVideoInput* mInputManager; }; #endif // QQTLOGICVIDEOMANAGER_H diff --git a/src/qqt_header.pri b/src/qqt_header.pri index 374c2ff1..99e21b21 100644 --- a/src/qqt_header.pri +++ b/src/qqt_header.pri @@ -239,6 +239,7 @@ defineTest(add_defines_QQt){ #LOGIC CAMERA PREVIEW #depend on dmmu #need fix, linux embedded armhf32 mips + #DEFINES += __LOGICCAMERAMODULE__ contains(QSYS_PRIVATE, Embedded|Armhf32|Mips32):DEFINES += __LOGICCAMERAMODULE__ }