Merge branch 'master' of https://gitee.com/drabel/LibQQt
@ -80,10 +80,11 @@ SUBDIRS += test/qqtdicttest2
|
||||
#SUBDIRS += test/giftest
|
||||
|
||||
#必开 这个例子是关于LibQQt MultiMedia的最好展示
|
||||
#
|
||||
greaterThan(QT_VERSION, 4.6.0):SUBDIRS += test/voicetest
|
||||
#
|
||||
mac:lessThan(QT_MAJOR_VERSION , 5):SUBDIRS -= test/voicetest
|
||||
SUBDIRS += test/voicetest
|
||||
SUBDIRS += test/voicetest2
|
||||
SUBDIRS += test/videotest
|
||||
SUBDIRS += test/videotest2
|
||||
SUBDIRS += test/videotest3
|
||||
|
||||
#这边是个组合项,客户端和服务器一起的。必看
|
||||
#SUBDIRS += examples/qqtclientexample
|
||||
|
@ -109,10 +109,11 @@ SUBDIRS += test/qqtdicttest2
|
||||
SUBDIRS += test/giftest
|
||||
|
||||
#必开 这个例子是关于LibQQt MultiMedia的最好展示
|
||||
#
|
||||
greaterThan(QT_VERSION, 4.6.0):SUBDIRS += test/voicetest
|
||||
#
|
||||
mac:lessThan(QT_MAJOR_VERSION , 5):SUBDIRS -= test/voicetest
|
||||
SUBDIRS += test/voicetest
|
||||
SUBDIRS += test/voicetest2
|
||||
SUBDIRS += test/videotest
|
||||
SUBDIRS += test/videotest2
|
||||
SUBDIRS += test/videotest3
|
||||
#
|
||||
SUBDIRS += examples/qqtclientexample
|
||||
#
|
||||
|
10
README.md
@ -90,7 +90,7 @@ github link: https://github.com/AbelTian/LibQQt
|
||||
- *全在frame文件夹*
|
||||
8. 支持多页表格 [QQtMultiPageTableWidget](src/widgets/qqtmultipagetablewidget.h)
|
||||
9. 添加 [QQtApplication](src/frame/qqtapplication.h),支持入门级、通用级、专用级嵌入式App所必须的初始化内容
|
||||
5. 支持Qt5.9.2
|
||||
5. 支持Qt5.8,Qt5.9.2
|
||||
- 建议桌面使用这个版本,对三大桌面,和IOS Android e-linux支持都很好。
|
||||
0. 跨平台支持macOS、iOS、Android、Windows、Linux、MIPS、ARM等。
|
||||
1. 添加矢量图形widgets
|
||||
@ -108,9 +108,13 @@ github link: https://github.com/AbelTian/LibQQt
|
||||
- 添加内存服务器(一套Input(Reader),Output(Writer)),处理内存和设备之间的数据交互。(这部分的功能完全按照为内存服务的思路设计研发。)
|
||||
- [QQtAudioManager](src/multimedia/qqtaudiomanager.h)、
|
||||
- 将 AudioInputDevice 和 AudioOutputDevice 当做一个设备进行读写,App处理获取到的声音。
|
||||
- 增加QQtWavAudioManager、QQtWavSoundEffect、QQtWavSound,
|
||||
- 像操作一个设备一样读、写wav文件。
|
||||
- 增加QQtVideoManager、QQtLogicVideoManager,
|
||||
- 支持桌面摄像头采集画面,支持模拟摄像头采集画面。
|
||||
6. 添加Http功能支持工具
|
||||
- QQtWebAccessManager,支持管理Session、Cookies。
|
||||
- 添加GumboQuery爬虫工具。
|
||||
- 添加GumboQuery爬虫工具,爬取网页信息。
|
||||
- 支持webservice (QtSoap)
|
||||
8. 添加Qt没有的组件QQtTitleBar
|
||||
- 可以组完全自定义的Form。
|
||||
@ -194,7 +198,7 @@ LibQQt R3支持Qt5,由于使用Multi-link 2,不支持Qt4。
|
||||
|
||||
邮箱: tianduanrui@163.com
|
||||
QQ: 2657635903
|
||||
|
||||
LibQQt技术分享和交流群: 560584206
|
||||
|
||||
========================================================================
|
||||
# 用户使用协议
|
||||
|
@ -38,7 +38,7 @@ QQtOsdForm::QQtOsdForm ( QWidget* parent ) :
|
||||
//setWindowFlag ( Qt::WindowSystemMenuHint, true );
|
||||
//setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
setPixmap ( qrc ( "rose.png" ) );
|
||||
setPixmap ( conf_qrc ( "rose.png" ) );
|
||||
}
|
||||
|
||||
QQtOsdForm::~QQtOsdForm()
|
||||
|
BIN
examples/qqtaudioexample/AppRoot/res/9763.wav
Normal file
82
examples/qqtaudioexample/android/AndroidManifest.xml
Normal file
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0"?>
|
||||
<manifest package="org.qtproject.example.qqtaudioexample" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
|
||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="qqtaudioexample" android:icon="@drawable/icon">
|
||||
<activity android:configChanges="navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="QQtAudioExample" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<!-- Application arguments -->
|
||||
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
|
||||
<!-- Application arguments -->
|
||||
|
||||
<meta-data android:name="android.app.lib_name" android:value="qqtaudioexample"/>
|
||||
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
||||
<meta-data android:name="android.app.repository" android:value="default"/>
|
||||
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
|
||||
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
|
||||
<!-- Deploy Qt libs as part of package -->
|
||||
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
|
||||
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
|
||||
<!-- Run with local libs -->
|
||||
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
||||
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
|
||||
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
|
||||
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
|
||||
<!-- Messages maps -->
|
||||
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
||||
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
||||
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
||||
<!-- Messages maps -->
|
||||
|
||||
<!-- Splash screen -->
|
||||
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
|
||||
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
|
||||
<!-- Splash screen -->
|
||||
|
||||
<!-- Background running -->
|
||||
<!-- Warning: changing this value to true may cause unexpected crashes if the
|
||||
application still try to draw after
|
||||
"applicationStateChanged(Qt::ApplicationSuspended)"
|
||||
signal is sent! -->
|
||||
<meta-data android:name="android.app.background_running" android:value="false"/>
|
||||
<!-- Background running -->
|
||||
|
||||
<!-- auto screen scale factor -->
|
||||
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
|
||||
<!-- auto screen scale factor -->
|
||||
|
||||
<!-- extract android style -->
|
||||
<!-- available android:values :
|
||||
* full - useful QWidget & Quick Controls 1 apps
|
||||
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
|
||||
* none - useful for apps that don't use any of the above Qt modules
|
||||
-->
|
||||
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
|
||||
<!-- extract android style -->
|
||||
</activity>
|
||||
|
||||
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
|
||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default permissions. -->
|
||||
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default features. -->
|
||||
|
||||
|
||||
<!-- %%INSERT_PERMISSIONS -->
|
||||
<!-- %%INSERT_FEATURES -->
|
||||
<uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.DEVICE_POWER"/>
|
||||
</manifest>
|
BIN
examples/qqtaudioexample/android/res/drawable-hdpi/icon.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
examples/qqtaudioexample/android/res/drawable-ldpi/icon.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
examples/qqtaudioexample/android/res/drawable-mdpi/icon.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
25
examples/qqtaudioexample/android/res/values/libs.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<resources>
|
||||
<array name="qt_sources">
|
||||
<item>https://download.qt.io/ministro/android/qt5/qt-5.9</item>
|
||||
</array>
|
||||
|
||||
<!-- The following is handled automatically by the deployment tool. It should
|
||||
not be edited manually. -->
|
||||
|
||||
<array name="bundled_libs">
|
||||
<!-- %%INSERT_EXTRA_LIBS%% -->
|
||||
</array>
|
||||
|
||||
<array name="qt_libs">
|
||||
<!-- %%INSERT_QT_LIBS%% -->
|
||||
</array>
|
||||
|
||||
<array name="bundled_in_lib">
|
||||
<!-- %%INSERT_BUNDLED_IN_LIB%% -->
|
||||
</array>
|
||||
<array name="bundled_in_assets">
|
||||
<!-- %%INSERT_BUNDLED_IN_ASSETS%% -->
|
||||
</array>
|
||||
|
||||
</resources>
|
12
examples/qqtaudioexample/main.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QQtApplication>
|
||||
|
||||
int main ( int argc, char* argv[] )
|
||||
{
|
||||
QQtApplication a ( argc, argv );
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
45
examples/qqtaudioexample/mainwindow.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <qqtframe.h>
|
||||
|
||||
MainWindow::MainWindow ( QWidget* parent ) :
|
||||
QMainWindow ( parent ),
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
|
||||
//wavManager设置待播放的文件,inputFormat起效
|
||||
wavManager.setInputSourceFile ( conf_res ( "9763.wav" ) );
|
||||
//audManager设置输出设备,也就是设置输出喇叭,并且,这里的并且很重要,设置输出格式,等于wav里的音频的格式。
|
||||
audManager.outputDeviceInfo() = QQtAudioManager::defaultOutputDevice();
|
||||
audManager.outputAudioFormat() = wavManager.inputAudioFormat();
|
||||
|
||||
//连接wavManager的音频帧接收槽,这里其实是个接收器,在接收器里播放。
|
||||
connect ( &wavManager, SIGNAL ( readyRead() ), this, SLOT ( on_play_frame() ) );
|
||||
;
|
||||
|
||||
//这个是专门为使用机械硬盘设置的,减慢读取timer,要不有滋滋的噪音。
|
||||
wavManager.inputManager()->setTimerInterval ( 100 );
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_clicked()
|
||||
{
|
||||
wavManager.stopInput();
|
||||
audManager.stopOutput();
|
||||
|
||||
audManager.startDefaultOutput();
|
||||
wavManager.startInput();
|
||||
}
|
||||
|
||||
void MainWindow::on_play_frame()
|
||||
{
|
||||
//这里readAll就是读一帧,(wavManger内部对音频进行了切帧)。
|
||||
QByteArray bytes = wavManager.readAll();
|
||||
//播放
|
||||
audManager.write ( bytes );
|
||||
}
|
34
examples/qqtaudioexample/mainwindow.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "qqtwavaudiomanager.h"
|
||||
#include "qqtaudiomanager.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow ( QWidget* parent = 0 );
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void on_play_frame();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
|
||||
QQtWavAudioManager wavManager;
|
||||
QQtAudioManager audManager;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
35
examples/qqtaudioexample/mainwindow.ui
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>229</width>
|
||||
<height>351</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>50</y>
|
||||
<width>111</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Play</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
69
examples/qqtaudioexample/qqtaudioexample.pro
Normal file
@ -0,0 +1,69 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2018-04-19T07:52:51
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = qqtaudioexample
|
||||
TEMPLATE = app
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
CONFIG += mobility
|
||||
MOBILITY =
|
||||
|
||||
system(touch main.cpp)
|
||||
|
||||
include(../../multi-link/multi-link/add_base_manager.pri)
|
||||
|
||||
|
||||
|
||||
contains(QSYS_PRIVATE, Android|AndroidX86) {
|
||||
CONFIG += mobility
|
||||
MOBILITY =
|
||||
DISTFILES += \
|
||||
android/AndroidManifest.xml
|
||||
|
||||
ANDROID_PACKAGE_SOURCE_DIR = $${PWD}/android
|
||||
}
|
||||
|
||||
RESOURCES += \
|
||||
qqtaudioexample.qrc
|
||||
|
||||
#这个的设置有特点,要先设置
|
||||
add_version (1,0,0,0)
|
||||
|
||||
#先发布App
|
||||
#app从build到deploy
|
||||
add_deploy()
|
||||
|
||||
#后发布依赖
|
||||
#libQQt从sdk到build和deploy
|
||||
add_dependent_manager(QQt)
|
||||
|
||||
#发布配置文件 把AppRoot里的配置项目拷贝到运行目录和发布目录
|
||||
add_deploy_config($${PWD}/AppRoot)
|
5
examples/qqtaudioexample/qqtaudioexample.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/res">
|
||||
<file alias="9763.wav">AppRoot/res/9763.wav</file>
|
||||
</qresource>
|
||||
</RCC>
|
118
multi-environ/README.md
Normal file
@ -0,0 +1,118 @@
|
||||
# Multi-environ Technology
|
||||
|
||||
为了方便用户在命令行里工作,我开发了多环境管理器Multi-environ Manager(即PyMake),
|
||||
在此为LibQQt提供多环境编译支持,具备方便的同时编译能力。
|
||||
|
||||
# 安装PyMake
|
||||
|
||||
如果电脑上没有PyMake,需要先安装,
|
||||
PyMake可以帮助用户在命令行里做各种工作,不仅仅限于此处编译,所以,请自行事先安装。
|
||||
|
||||
#### 下载PyMake安装包
|
||||
######国内
|
||||
PyMake Gitee Clone:[https://gitee.com/drabel/PyMake.git](https://gitee.com/drabel/PyMake.git)
|
||||
PyMake V7.8.2 Zip包:[https://gitee.com/drabel/PyMake/repository/archive/v7.8.2](https://gitee.com/drabel/PyMake/repository/archive/v7.8.2)
|
||||
######国外
|
||||
PyMake Github Clone:[https://github.com/AbelTian/PyMake.git](https://github.com/AbelTian/PyMake.git)
|
||||
|
||||
#### 安装PyMake
|
||||
1. 需要管理员权限,切换到PyMake目录,install.bat %*。Unix系统install.sh。
|
||||
|
||||
#### 配置PyMake
|
||||
```bash
|
||||
|
||||
# 更改多环境根目录到自己定义的目录。
|
||||
pymake source root <user-set-root>
|
||||
|
||||
# 更改环境文件到自己私有的环境配置文件,一般一台电脑用一个环境文件。
|
||||
pymake source config <user-set-config.json>
|
||||
|
||||
# 使用我在Windows上的环境配置文件,初始化自己的环境文件。
|
||||
pymake port file <pymake-source-dir>/example/pymake7-win-tai5.json <user-set-root>/<user-set-config.json>
|
||||
|
||||
# 修改<user-set-root>/<user-set-config.json>环境文件里的几个命名路径。
|
||||
pymake source config --edit
|
||||
|
||||
# 查看一次所有设置
|
||||
pymake get all settings -a -r
|
||||
|
||||
# 修改以下字段,不限于这些字段,建议用户一次配置好长期使用。
|
||||
# path-assemblage:
|
||||
# root路径,一系列根路径
|
||||
# cc路径,这个路径下有PyMake
|
||||
# wincc路径,这个路径下有cmake和很多品种语言的解释器
|
||||
# qt路径
|
||||
# android路径
|
||||
# java路径
|
||||
# 人工检查配置其他路径
|
||||
|
||||
# 修改<user-set-root>/custom.path+.ini
|
||||
# ${cmake.bin} 添加一行,用于支持cmake编译。如果需要,还可以增加很多其他路径。
|
||||
|
||||
# 修改完路径后,查看一下环境,你需要编译几个环境的,就查看几个环境
|
||||
pymake env mingw32
|
||||
pymake env mingw64
|
||||
pymake env android.mobile
|
||||
pymake env android.x86
|
||||
pymake env msvc2015
|
||||
pymake env msvc2015.x64
|
||||
pymake env mscos
|
||||
pymake env ios
|
||||
pymake env gcc
|
||||
pymake env armhf32
|
||||
pymake env mips32
|
||||
|
||||
# 查看一遍以后,检查一下环境配置的是否正确,如果不正确及时修改,你需要编译几个环境的,就检查几个环境,还可以检查path、cmd配置是否正确
|
||||
pymake chk -slc
|
||||
pymake chk path -a
|
||||
pymake chk cmd -a
|
||||
pymake chk mingw32
|
||||
pymake chk mingw64
|
||||
pymake chk android.mobile
|
||||
pymake chk android.x86
|
||||
pymake chk msvc2015
|
||||
pymake chk msvc2015.x64
|
||||
pymake chk mscos
|
||||
pymake chk ios
|
||||
pymake chk gcc
|
||||
pymake chk armhf32
|
||||
pymake chk mips32
|
||||
|
||||
```
|
||||
|
||||
# 使用PyMake开始编译
|
||||
|
||||
PyMake只需要配置一次,以后,直接开始编译即可。
|
||||
|
||||
```bash
|
||||
|
||||
# 环境检查无误,修改<user-set-root>/<user-set-config.json>里的qqt.build.all命令
|
||||
set MODULEARRAY=QQt ...还有其他的库才会需要添加其他的库名,用空格分隔
|
||||
set ENVARRAY=mingw32 ...需要编译几个环境的就添加几个环境,用空格分隔
|
||||
|
||||
# 切换到LibQQt的上一层目录,开始编译
|
||||
# 导出qqt.build.all这一个命令
|
||||
pymake type here qqt.build.all to qqt.build.all
|
||||
# 开始
|
||||
qqt.build.all.bat
|
||||
# 如果一切正常,会开启多个编译命令行。实现同时多环境编译。 这个脚本可以多次使用。我测试的开启52个编译环境命令行,正常编译。这取决于你的电脑的能力。
|
||||
|
||||
# 如果不希望导出这个命令,那么执行以下命令,
|
||||
pymake system ccvp here qqt.build.all
|
||||
# 如果一切正常,现象同上。
|
||||
|
||||
# 如果仅仅编译一个环境的目标,那么执行以下命令,
|
||||
# 切换到LibQQt源代码目录,编译mingw32环境的目标
|
||||
pymake use mingw32 ccvp here build.qmake QQt
|
||||
|
||||
# 如果需要其他功能支持,在<user-set-root>/<user-set-config.json>里command组下,添加自己的命令即可。PyMake提供多种模式的ccvp直接执行。
|
||||
```
|
||||
|
||||
# 编译截图
|
||||
|
||||
![](a0.png)
|
||||
![](a1.png)
|
||||
![](b0.png)
|
||||
![](b1.png)
|
||||
![](b2.png)
|
||||
![](c0.png)
|
BIN
multi-environ/a0.png
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
multi-environ/a1.png
Normal file
After Width: | Height: | Size: 284 KiB |
BIN
multi-environ/b0.png
Normal file
After Width: | Height: | Size: 98 KiB |
BIN
multi-environ/b1.png
Normal file
After Width: | Height: | Size: 96 KiB |
BIN
multi-environ/b2.png
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
multi-environ/c0.png
Normal file
After Width: | Height: | Size: 349 KiB |
@ -1 +1 @@
|
||||
Subproject commit dbb43fa39b64a4c1a713edcc8c05dee2a5209e27
|
||||
Subproject commit 131c27f39bbffe61498ca33c54e836430122307c
|
@ -5,11 +5,11 @@
|
||||
|LibQQt(主库)| [工程链接](https://gitee.com/drabel/LibQQt) |Commercial,GPL Series|
|
||||
|QQtExquisite|[工程链接](https://gitee.com/drabel/QQtExquisite)|Commercial,GPL Series|
|
||||
|QQtHighGrade|[工程链接](https://gitee.com/drabel/QQtHighGrade)|Commercial,GPL Series|
|
||||
|QQtInput|[工程链接](https://gitee.com/drabel/QQtInput)|Commercial,GPL Series|
|
||||
|QQtRuntimeExtention|[工程链接](https://gitee.com/drabel/QQtRuntimeExtention)|Commercial,GPL Series|
|
||||
|QQtInstallFramework|[工程链接](https://gitee.com/drabel/QQtInstallFramework)|Commercial,GPL Series|
|
||||
|QQtTool|[工程链接](https://gitee.com/drabel/QQtTool)|Commercial,GPL Series|
|
||||
|QQtMediaExtention|[工程链接](https://gitee.com/drabel/QQtMediaExtention)|Commercial|
|
||||
|QQtInput|[工程链接](https://gitee.com/drabel/QQtInput)|Commercial|
|
||||
|QQtSupport|[工程链接](https://gitee.com/drabel/QQtSupport)|Commercial|
|
||||
|QQtExquisitePlugin|[工程链接](https://gitee.com/drabel/QQtExquisitePlugin)|Commercial|
|
||||
|QQtIndustrialControl|[工程链接](https://gitee.com/drabel/QQtIndustrialControl)|Commercial|
|
||||
|
@ -18,7 +18,7 @@
|
||||
#################################################################
|
||||
##Usage
|
||||
#################################################################
|
||||
#Suggest Qt 5.9.2/4.8.6/4.8.7
|
||||
#Suggest Qt 5.8/5.9.2/4.8.6/4.8.7
|
||||
#please dont use Qt 5.9.1, it is broken with android and ios.
|
||||
#please dont modify this pro
|
||||
#use LibQQt you need change Qt Creator default build directory: your-pc-build-station/%{CurrentProject:Name}/%{CurrentKit:FileSystemName}/%{Qt:Version}/%{CurrentBuild:Name} (Only Once)
|
||||
|
@ -533,13 +533,28 @@ void QQtDictionary::parseDictionaryToJsonValue ( const QQtDictionary& node, QJso
|
||||
QList<QQtDictionary>& l = node.getList();
|
||||
QJsonValue value;
|
||||
parseDictionaryToJsonValue ( l[i], value );
|
||||
array.append ( value );
|
||||
//array.append ( value );
|
||||
array.push_back ( value );
|
||||
}
|
||||
result = array;
|
||||
break;
|
||||
}
|
||||
case DictMap:
|
||||
{
|
||||
//"name": {"a":"b", "a2":"b2", "a3":["b31", "b32"], "a4":{"a41":"b41", "a42":"b42"}, ...}
|
||||
QJsonObject object;
|
||||
for ( QMap<QString, QQtDictionary>::Iterator itor = node.getMap().begin(); itor != node.getMap().end(); itor++ )
|
||||
{
|
||||
//QMap<QString, QQtDictionary>& m = node.getMap();
|
||||
const QString& key = itor.key();
|
||||
const QQtDictionary& srcvalue = itor.value();
|
||||
QJsonValue value;
|
||||
parseDictionaryToJsonValue ( srcvalue, value );
|
||||
object.insert ( key, value );
|
||||
}
|
||||
result = object;
|
||||
break;
|
||||
}
|
||||
case DictMax:
|
||||
default:
|
||||
break;
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <qqtorderedmap.h>
|
||||
#include <qqtcore.h>
|
||||
#include <qqt-local.h>
|
||||
|
||||
@ -14,11 +14,11 @@
|
||||
class QQtDictionary;
|
||||
typedef QMap<QString, QQtDictionary> QQtDictionaryMap;
|
||||
typedef QMapIterator<QString, QQtDictionary> QQtDictionaryMapIterator;
|
||||
typedef QMutableMapIterator<QString, QQtDictionary> QQtDictionaryMutableMapIterator;
|
||||
typedef QMutableMapIterator<QString, QQtDictionary> QQtDictionaryMapConstIterator;
|
||||
|
||||
typedef QList<QQtDictionary> QQtDictionaryList;
|
||||
typedef QListIterator<QQtDictionary> QQtDictionaryListIterator;
|
||||
typedef QMutableListIterator<QQtDictionary> QQtDictionaryMutableListIterator;
|
||||
typedef QMutableListIterator<QQtDictionary> QQtDictionaryListConstIterator;
|
||||
|
||||
/**
|
||||
* @brief The QQtDictionary class
|
||||
@ -30,8 +30,8 @@ typedef QMutableListIterator<QQtDictionary> QQtDictionaryMutableListIterator;
|
||||
* 接受嵌套访问 操作方式 dict["cccc"][0]["eeeee"]
|
||||
* 通过重载函数来实现类型的变化,不建议使用中更改类型。
|
||||
* 比json和xml的数据结构要庞大。toJson toXML fromJson fromXML
|
||||
* QVariant 不能直接获取到真实数据,改变必须使用临时变量。
|
||||
* 而且,接口设计也不够灵活,存入和取出都不太方便。
|
||||
* QVariant 不能直接获取到真实数据,改变必须使用临时变量,而且,接口设计也不够灵活,存入和取出都不太方便。
|
||||
* QQtDictionary封装了QVariant,实现直接操作真实数据。提供大量操作符。存取数据方便快捷,类型多样。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtDictionary
|
||||
{
|
||||
|
1
src/core/qqtorderedmap.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include <qqtorderedmap.h>
|
6
src/core/qqtorderedmap.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef QQTORDEREDMAP_H
|
||||
#define QQTORDEREDMAP_H
|
||||
|
||||
#include <QMap>
|
||||
|
||||
#endif // QQTORDEREDMAP_H
|
@ -58,11 +58,11 @@ void QQtPictureTabBar::setSelectedTextColor ( QColor selectedTextColor )
|
||||
|
||||
void QQtPictureTabBar::tabPixmap ( int index, QImage& img, QImage& imgSel )
|
||||
{
|
||||
if ( index < 0 || index + 1 > count() || index + 1 > imgList.size() )
|
||||
if ( index < 0 || index + 1 > count() || index + 1 > dict1["image"].size() )
|
||||
return;
|
||||
|
||||
img = QImage ( imgList[index][BTN_NORMAL] );
|
||||
imgSel = QImage ( imgList[index][BTN_PRESS] );
|
||||
img = QImage ( dict1["image"][index][BTN_NORMAL].getValue().toString() );
|
||||
imgSel = QImage ( dict1["image"][index][BTN_PRESS].getValue().toString() );
|
||||
|
||||
return ;
|
||||
}
|
||||
@ -72,20 +72,20 @@ void QQtPictureTabBar::setTabPixmap ( int index, const QString& img, const QStri
|
||||
if ( index < 0 || index + 1 > count() )
|
||||
return;
|
||||
|
||||
TBtnIconTable table;
|
||||
table[BTN_NORMAL] = img;
|
||||
table[BTN_PRESS] = imgSel;
|
||||
|
||||
imgList.insert ( index, table );
|
||||
dict1["image"][index][BTN_NORMAL] = img;
|
||||
dict1["image"][index][BTN_PRESS] = imgSel;
|
||||
}
|
||||
|
||||
void QQtPictureTabBar::tabIcon ( int index, QImage& icon, QImage& iconSel )
|
||||
{
|
||||
if ( index < 0 || index + 1 > count() || index + 1 > imgList.size() )
|
||||
if ( index < 0 || index + 1 > count() || index + 1 > dict1["icon"].size() )
|
||||
return;
|
||||
|
||||
icon = QImage ( iconList[index][BTN_NORMAL] );
|
||||
iconSel = QImage ( iconList[index][BTN_PRESS] );
|
||||
icon = QImage ( dict1["icon"][index][BTN_NORMAL].getValue().toString() );
|
||||
iconSel = QImage ( dict1["icon"][index][BTN_PRESS].getValue().toString() );
|
||||
//pline() << icon;
|
||||
//pline() << iconSel;
|
||||
|
||||
return ;
|
||||
}
|
||||
@ -95,11 +95,13 @@ void QQtPictureTabBar::setTabIcon ( int index, const QString& icon, const QStrin
|
||||
if ( index < 0 || index + 1 > count() )
|
||||
return;
|
||||
|
||||
TBtnIconTable table;
|
||||
table[BTN_NORMAL] = icon;
|
||||
table[BTN_PRESS] = iconSel;
|
||||
|
||||
iconList.insert ( index, table );
|
||||
dict1["icon"][index][BTN_NORMAL] = icon;
|
||||
dict1["icon"][index][BTN_PRESS] = iconSel;
|
||||
|
||||
//pline() << dict1["icon"][index][BTN_NORMAL];
|
||||
//pline() << dict1["icon"][index][BTN_PRESS];
|
||||
|
||||
}
|
||||
|
||||
void QQtPictureTabBar::setBackgroundColor ( QColor backgroundColor )
|
||||
@ -154,20 +156,20 @@ void QQtPictureTabBar::drawPicture ( QPainter* p )
|
||||
{
|
||||
QRect tRect0 = tabRect ( index );
|
||||
|
||||
if ( imgList.size() > index )
|
||||
if ( dict1["image"].size() > index )
|
||||
{
|
||||
p->save();
|
||||
int sel = currentIndex() == index ? BTN_PRESS : BTN_NORMAL;
|
||||
#if 1
|
||||
//tabRect = rect()?
|
||||
p->drawPixmap ( tRect0, QIcon ( imgList[index][sel] ).pixmap ( tRect0.size(), QIcon::Normal, QIcon::On ) );
|
||||
p->drawPixmap ( tRect0, QIcon ( dict1["image"][index][sel].getValue().toString() ).pixmap ( tRect0.size(), QIcon::Normal, QIcon::On ) );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 失真不明显,使用以下方法
|
||||
*/
|
||||
#if 0
|
||||
QImage image ( iconList[index][sel] );
|
||||
QImage image ( dict1["image"][index][sel].getValue().toString() );
|
||||
p.drawItemPixmap ( tabRectValue, Qt::AlignLeft | Qt::AlignTop, QPixmap::fromImage ( image.scaled ( tabRectValue.size(),
|
||||
Qt::KeepAspectRatio ) ) );
|
||||
#endif
|
||||
@ -176,7 +178,7 @@ void QQtPictureTabBar::drawPicture ( QPainter* p )
|
||||
//为什么不用这个呢?因为上边那个QIcon直接缩放到了完整的符合Icon大小的图.直接居中.
|
||||
//这个不需要,多次一举.
|
||||
#if 0
|
||||
p->drawItemPixmap ( tRect0, Qt::AlignCenter, QIcon ( imgList[index][sel] ).pixmap ( tRect0.size(), QIcon::Normal,
|
||||
p->drawItemPixmap ( tRect0, Qt::AlignCenter, QIcon ( dict1["image"][index][sel].getValue().toString() ).pixmap ( tRect0.size(), QIcon::Normal,
|
||||
QIcon::On ) );
|
||||
#endif
|
||||
p->restore();
|
||||
@ -252,17 +254,17 @@ void QQtPictureTabBar::drawIcon ( QPainter* p )
|
||||
int sel = BTN_NORMAL;
|
||||
sel = currentIndex() == index ? BTN_PRESS : BTN_NORMAL;
|
||||
|
||||
//pline() << iconList.size() << index << iconList[index][sel];
|
||||
//pline() << dict1["icon"].size() << index << dict1["icon"][index][sel].getValue().toString();
|
||||
|
||||
if ( iconList.size() > index )
|
||||
if ( dict1["icon"].size() > index )
|
||||
{
|
||||
p->save();
|
||||
//tabRect = rect()?
|
||||
p->drawPixmap ( tRect0, QIcon ( iconList[index][sel] ).pixmap ( tRect0.size(), mode, QIcon::On ) );
|
||||
p->drawPixmap ( tRect0, QIcon ( dict1["icon"][index][sel].getValue().toString() ).pixmap ( tRect0.size(), mode, QIcon::On ) );
|
||||
/*
|
||||
* 失真不明显,使用以下方法
|
||||
*/
|
||||
//QImage image(iconList[index][sel]);
|
||||
//QImage image(dict1["icon"][index][sel].getValue().toString());
|
||||
//p.drawItemPixmap(tabRectValue, Qt::AlignLeft |Qt::AlignTop, QPixmap::fromImage(image.scaled(tabRectValue.size(), Qt::KeepAspectRatio)));
|
||||
p->restore();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "qqtwidgets.h"
|
||||
#include "qqttabbar.h"
|
||||
#include "qqt-local.h"
|
||||
#include "qqtdictionary.h"
|
||||
|
||||
class QQTSHARED_EXPORT QQtPictureTabBar : public QQtTabBar
|
||||
{
|
||||
@ -27,6 +28,7 @@ public:
|
||||
/*
|
||||
* 依赖iconSize,layoutSpacing设置图片位置
|
||||
*/
|
||||
//default
|
||||
IconStyle_Left_And_RightText,
|
||||
IconStyle_Right_And_LeftText,
|
||||
IconStyle_MiddleText,
|
||||
@ -85,8 +87,7 @@ protected:
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QList<TBtnIconTable> imgList;
|
||||
QList<TBtnIconTable> iconList;
|
||||
QQtDictionary dict1;
|
||||
IconStyle iconStyle;
|
||||
QFont textFont;
|
||||
QColor textColor;
|
||||
|
@ -52,7 +52,7 @@ QQtApplication::QQtApplication ( int& argc, char** argv ) :
|
||||
#endif
|
||||
|
||||
qDebug() << tr ( "QQt Application Framework Software [LibQQt]" );
|
||||
qDebug() << tr ( "Copyright © 2017 Tianduanrui. All rights reserved." );
|
||||
qDebug() << tr ( "Copyright (C) 2017 Tianduanrui. All rights reserved." );
|
||||
qDebug() << tr ( "Assigned by Dezhou." );
|
||||
|
||||
pline() << "Qt version:" << QT_VERSION_STR;
|
||||
@ -165,7 +165,7 @@ void QQtApplication::setHighDpiScaling ( bool open )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
|
||||
setAttribute ( Qt::AA_EnableHighDpiScaling, open );
|
||||
//setAttribute ( Qt::AA_UseHighDpiPixmaps, open );
|
||||
setAttribute ( Qt::AA_UseHighDpiPixmaps, open );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ bool QQtApplication::setTextFont ( QString fontfile, int fontsize )
|
||||
/*这个函数没有任何问题,检测完毕。过去的报错是工作目录不对,无法加载其他数据库*/
|
||||
/*此处,改为使用QFontDatabase的经典静态方法调用方式*/
|
||||
//ignored
|
||||
QFontDatabase db;
|
||||
QFontDatabase fontdb0;
|
||||
|
||||
int fontID = QFontDatabase::addApplicationFont ( fontfile );
|
||||
pline() << "font file:" << fontfile;
|
||||
@ -229,8 +229,8 @@ bool QQtApplication::setTextFont ( QString fontfile, int fontsize )
|
||||
QString ziti = QFontDatabase::applicationFontFamilies ( fontID ).at ( 0 );
|
||||
pline() << "font name:" << ziti;
|
||||
|
||||
QFont font ( ziti, fontsize );
|
||||
QApplication::setFont ( font );
|
||||
QFont font1 ( ziti, fontsize );
|
||||
QApplication::setFont ( font1 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -22,43 +22,6 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
enum
|
||||
{
|
||||
Lib_Id = 0,
|
||||
Lib_Name,
|
||||
Lib_Creater,
|
||||
Lib_CreateTime,
|
||||
Lib_Comment,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Method_Id = 0,
|
||||
Method_Name,
|
||||
Method_Type,
|
||||
Method_Vessel,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Stage_Id = 0,
|
||||
Stage_Index,
|
||||
Stage_Vessel,
|
||||
Stage_Timeramp,
|
||||
Stage_Presspsi,
|
||||
Stage_Tempture,
|
||||
Stage_Hold,
|
||||
Stage_MethodId,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Type_Standard = 0,
|
||||
Type_Temprature,
|
||||
Type_Stressure,
|
||||
Type_Extract,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Login_Request,
|
||||
@ -73,19 +36,6 @@ enum
|
||||
};
|
||||
|
||||
|
||||
typedef enum tagSampleEnum
|
||||
{
|
||||
ESampleId,
|
||||
ESampleMingcheng,
|
||||
ESampleBianhao,
|
||||
ESampleYangpinliang,
|
||||
ESampleYangpindanwei,
|
||||
ESampleJieguo,
|
||||
ESampleJieguodanwei,
|
||||
ESampleCeshiren,
|
||||
ESampleCeshishijian,
|
||||
} ESampleColomn;
|
||||
|
||||
enum
|
||||
{
|
||||
Language_English,
|
||||
@ -114,37 +64,42 @@ enum
|
||||
};
|
||||
|
||||
|
||||
#define CONFIG_ROOT "."
|
||||
#define CONFIG_PATH "./conf"
|
||||
#define LOG_PATH "./log"
|
||||
#define AV_PATH "./res"
|
||||
#define SKIN_PATH "./skin"
|
||||
#define CONFIG_ROOT QString(".")
|
||||
#define CONFIG_PATH QString(CONFIG_ROOT + "/conf")
|
||||
#define LOG_PATH QString(CONFIG_ROOT + "/log")
|
||||
#define AV_PATH QString(CONFIG_ROOT + "/res")
|
||||
#define SKIN_PATH QString(CONFIG_ROOT + "/skin")
|
||||
#define FONT_PATH QString(CONFIG_ROOT + "/font")
|
||||
#define DB_PATH QString(CONFIG_ROOT + "/db")
|
||||
#define LANG_PATH QString(CONFIG_ROOT + "/lang")
|
||||
|
||||
#if defined (__ANDROIDX86__)
|
||||
#define qrc(file) QString("%1/%2").arg("assets:/").arg(file)
|
||||
#define res(file) QString("%1/%2").arg("assets:/res").arg(file)
|
||||
#define skin(file) QString("%1/%2").arg("assets:/skin").arg(file)
|
||||
#define conf_qrc(file) QString("%1/%2").arg("assets:/").arg(file)
|
||||
#define conf_res(file) QString("%1/%2").arg("assets:/res").arg(file)
|
||||
#define conf_skin(file) QString("%1/%2").arg("assets:/skin").arg(file)
|
||||
#define conf_font(file) QString("%1/%2").arg("assets:/font").arg(file)
|
||||
#define conf_db(file) QString("%1/%2").arg("assets:/db").arg(file)
|
||||
#define conf_lang(file) QString("%1/%2").arg("assets:/lang").arg(file)
|
||||
#elif defined (__ANDROID__)
|
||||
#define qrc(file) QString("%1/%2").arg("://").arg(file)
|
||||
#define res(file) QString("%1/%2").arg("://res").arg(file)
|
||||
#define skin(file) QString("%1/%2").arg("://skin").arg(file)
|
||||
#define conf_qrc(file) QString("%1/%2").arg("://").arg(file)
|
||||
#define conf_res(file) QString("%1/%2").arg("://res").arg(file)
|
||||
#define conf_skin(file) QString("%1/%2").arg("://skin").arg(file)
|
||||
#define conf_font(file) QString("%1/%2").arg("://font").arg(file)
|
||||
#define conf_db(file) QString("%1/%2").arg("://db").arg(file)
|
||||
#define conf_lang(file) QString("%1/%2").arg("://lang").arg(file)
|
||||
#else
|
||||
#define qrc(file) QDir(qApp->applicationDirPath()).relativeFilePath(QString("%1/%2").arg(CONFIG_ROOT).arg(file))
|
||||
#define res(file) QDir(qApp->applicationDirPath()).relativeFilePath(QString("%1/%2").arg(AV_PATH).arg(file))
|
||||
#define skin(file) QDir(qApp->applicationDirPath()).relativeFilePath(QString("%1/%2").arg(SKIN_PATH).arg(file))
|
||||
#define conf_qrc(file) QDir().absoluteFilePath(QString("%1/%2").arg(CONFIG_ROOT).arg(file))
|
||||
#define conf_res(file) QDir().absoluteFilePath(QString("%1/%2").arg(AV_PATH).arg(file))
|
||||
#define conf_skin(file) QDir().absoluteFilePath(QString("%1/%2").arg(SKIN_PATH).arg(file))
|
||||
#define conf_font(file) QDir().absoluteFilePath(QString("%1/%2").arg(FONT_PATH).arg(file))
|
||||
#define conf_db(file) QDir().absoluteFilePath(QString("%1/%2").arg(DB_PATH).arg(file))
|
||||
#define conf_lang(file) QDir().absoluteFilePath(QString("%1/%2").arg(LANG_PATH).arg(file))
|
||||
#endif
|
||||
|
||||
|
||||
#define TABLE_LIBRARY "Library"
|
||||
#define TABLE_METHOD "Method"
|
||||
#define TABLE_STAGE "Stage"
|
||||
#define TABLE_EVTYPE "Type"
|
||||
|
||||
extern QString gUserName;
|
||||
extern QString gPassword;
|
||||
extern int gAuthority;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
@ -1,6 +1,9 @@
|
||||
#include "qqtqssmanager.h"
|
||||
#include "qqtcore.h"
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
QQtQSSManager::QQtQSSManager ( QObject* parent )
|
||||
QQtQSSManager::QQtQSSManager ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
|
||||
}
|
||||
@ -14,7 +17,7 @@ QList<QString> QQtQSSManager::styleList()
|
||||
{
|
||||
while ( mStyleList.count() > 0 )
|
||||
mStyleList.removeAt ( 0 );
|
||||
QDir d ( SKIN_PATH );
|
||||
QDir d ( conf_skin ( "." ) );
|
||||
foreach ( QFileInfo mfi, d.entryInfoList() )
|
||||
{
|
||||
if ( mfi.isFile() )
|
||||
@ -24,41 +27,52 @@ QList<QString> QQtQSSManager::styleList()
|
||||
//不包括default.qss
|
||||
if ( mfi.baseName() == "default" )
|
||||
continue;
|
||||
if ( mfi.baseName() == "current" )
|
||||
continue;
|
||||
QString styleName = mfi.completeBaseName();
|
||||
mStyleList.push_back ( styleName );
|
||||
}
|
||||
}
|
||||
//pline() << d.absolutePath();
|
||||
//pline() << mStyleList;
|
||||
return mStyleList;
|
||||
}
|
||||
|
||||
void QQtQSSManager::setCurrentStyle ( QString styleName )
|
||||
{
|
||||
if ( !QDir ( skin ( "default.qss" ) ).exists() )
|
||||
return;
|
||||
if ( !QDir ( skin ( QString ( "%1.qss" ).arg ( styleName ) ) ).exists() )
|
||||
return;
|
||||
//pline() << "set style";
|
||||
//pline() << conf_skin ( "default.qss" );
|
||||
//pline() << QFile ( conf_skin ( "default.qss" ) ).exists() << QDir ( conf_skin ( "default.qss" ) ).exists();
|
||||
//pline() << conf_skin ( QString ( "%1.qss" ).arg ( styleName ) );
|
||||
//pline() << QFile ( conf_skin ( QString ( "%1.qss" ).arg ( styleName ) ) ).exists() << QDir ( conf_skin ( QString ( "%1.qss" ).arg ( styleName ) ) ).exists();
|
||||
|
||||
if ( !QFile ( conf_skin ( "default.qss" ) ).exists() )
|
||||
return;
|
||||
if ( !QFile ( conf_skin ( QString ( "%1.qss" ).arg ( styleName ) ) ).exists() )
|
||||
return;
|
||||
//pline() << "set style 2" << styleName;
|
||||
#ifdef __EMBEDDED_LINUX__
|
||||
QString cmd = QString ( "touch %1" ).arg ( skin ( "current.qss" ) );
|
||||
QString cmd = QString ( "touch %1" ).arg ( conf_skin ( "current.qss" ) );
|
||||
system ( cmd.toLocal8Bit().constData() );
|
||||
#endif
|
||||
|
||||
QByteArray bytes;
|
||||
|
||||
QFile f1 ( skin ( "default.qss" ) );
|
||||
QFile f1 ( conf_skin ( "default.qss" ) );
|
||||
f1.open ( QFile::ReadOnly );
|
||||
bytes = f1.readAll();
|
||||
f1.close();
|
||||
|
||||
QFile f2 ( skin ( QString ( "%1.qss" ).arg ( styleName ) ) );
|
||||
QFile f2 ( conf_skin ( QString ( "%1.qss" ).arg ( styleName ) ) );
|
||||
f2.open ( QFile::ReadOnly );
|
||||
bytes += f2.readAll();
|
||||
f2.close();
|
||||
|
||||
QFile file ( skin ( "current.qss" ) );
|
||||
QFile file ( conf_skin ( "current.qss" ) );
|
||||
file.open ( QFile::Truncate | QFile::WriteOnly );
|
||||
file.write ( bytes );
|
||||
file.close();
|
||||
|
||||
qqtApp->setQSSStyle ( skin ( "current.qss" ) );
|
||||
//pline() << conf_skin ( "current.qss" );
|
||||
qqtApp->setQSSStyle ( conf_skin ( "current.qss" ) );
|
||||
}
|
||||
|
202
src/multimedia/libqwav/libqwav.cpp
Normal file
@ -0,0 +1,202 @@
|
||||
#include "libqwav.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
||||
//header data tail
|
||||
bool addWavHeader ( QIODevice& outputDevice, const QAudioFormat& format )
|
||||
{
|
||||
// 开始设置WAV的文件头
|
||||
// 这里具体的数据代表什么含义请看上一篇文章(Qt之WAV文件解析)中对wav文件头的介绍
|
||||
WAVFILEHEADER WavFileHeader;
|
||||
qstrcpy ( WavFileHeader.RiffName, "RIFF" );
|
||||
qstrcpy ( WavFileHeader.WavName, "WAVE" );
|
||||
qstrcpy ( WavFileHeader.FmtName, "fmt " );
|
||||
qstrcpy ( WavFileHeader.DATANAME, "data" );
|
||||
|
||||
// 表示 FMT块 的长度
|
||||
WavFileHeader.nFmtLength = 16;
|
||||
|
||||
// 表示 按照PCM 编码;
|
||||
WavFileHeader.nAudioFormat = 1;
|
||||
// 声道数目;
|
||||
WavFileHeader.nChannleNumber = format.channelCount();
|
||||
// 采样频率;
|
||||
WavFileHeader.nSampleRate = format.sampleRate();
|
||||
//这个地方,int到unsinged int数据没有丢失。
|
||||
//pline() << WavFileHeader.nSampleRate << mFormat.sampleRate();
|
||||
// 每次采样得到的样本数据位数;
|
||||
WavFileHeader.nBitsPerSample = format.sampleSize();
|
||||
|
||||
// nBytesPerSample 和 nBytesPerSecond这两个值通过设置的参数计算得到;
|
||||
// 数据块对齐单位(每个采样需要的字节数 = 通道数 × 每次采样得到的样本数据位数 / 8 )
|
||||
WavFileHeader.nBlockAlign = WavFileHeader.nChannleNumber * WavFileHeader.nBitsPerSample / 8;
|
||||
// 波形数据传输速率
|
||||
// (每秒平均字节数 = 采样频率 × 通道数 × 每次采样得到的样本数据位数 / 8 = 采样频率 × 每个采样需要的字节数 )
|
||||
WavFileHeader.nBytesPerSecond = WavFileHeader.nSampleRate * WavFileHeader.nChannleNumber *
|
||||
WavFileHeader.nBitsPerSample / 8;
|
||||
|
||||
outputDevice.seek ( 0 );
|
||||
//riff 8 + 4
|
||||
WavFileHeader.nRiffLength = outputDevice.size() - 8;
|
||||
outputDevice.write ( WavFileHeader.RiffName, sizeof ( WavFileHeader.RiffName ) - 1 );
|
||||
outputDevice.write ( ( char* ) &WavFileHeader.nRiffLength, sizeof ( WavFileHeader.nRiffLength ) );
|
||||
outputDevice.write ( WavFileHeader.WavName, sizeof ( WavFileHeader.WavName ) - 1 );
|
||||
|
||||
//fmt 8 + 16
|
||||
outputDevice.write ( WavFileHeader.FmtName, 4 );
|
||||
outputDevice.write ( ( char* ) &WavFileHeader.nFmtLength, 4 );
|
||||
|
||||
outputDevice.write ( ( char* ) &WavFileHeader.nAudioFormat, sizeof ( WavFileHeader.nAudioFormat ) );
|
||||
outputDevice.write ( ( char* ) &WavFileHeader.nChannleNumber, sizeof ( WavFileHeader.nChannleNumber ) );
|
||||
outputDevice.write ( ( char* ) &WavFileHeader.nSampleRate, sizeof ( WavFileHeader.nSampleRate ) );
|
||||
outputDevice.write ( ( char* ) &WavFileHeader.nBytesPerSecond, sizeof ( WavFileHeader.nBytesPerSecond ) );
|
||||
outputDevice.write ( ( char* ) &WavFileHeader.nBlockAlign, sizeof ( WavFileHeader.nBlockAlign ) );
|
||||
outputDevice.write ( ( char* ) &WavFileHeader.nBitsPerSample, sizeof ( WavFileHeader.nBitsPerSample ) );
|
||||
|
||||
//data 8
|
||||
outputDevice.write ( WavFileHeader.DATANAME, 4 );
|
||||
outputDevice.write ( ( char* ) &WavFileHeader.nDataLength, 4 );
|
||||
|
||||
WavFileHeader.fileHeaderSize = outputDevice.pos();
|
||||
|
||||
//44
|
||||
//int headerSize = WavFileHeader.fileHeaderSize;
|
||||
//qDebug() << headerSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool addWavTail ( QIODevice& outputDevice )
|
||||
{
|
||||
QByteArray tailBytes;
|
||||
tailBytes += "q\xFCq\xFC";
|
||||
tailBytes += "a\xFB";
|
||||
tailBytes += "a\xFB";
|
||||
//8
|
||||
//pline() << tailBytes << tailBytes.size();
|
||||
outputDevice.write ( tailBytes );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool addWavDataBytes ( QIODevice& outputDevice, const QByteArray& bytes )
|
||||
{
|
||||
outputDevice.write ( bytes );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wavParse ( QString fileName, WAVFILEHEADER& WavFileHeader )
|
||||
{
|
||||
QFile fileInfo ( fileName );
|
||||
|
||||
if ( !fileInfo.open ( QIODevice::ReadOnly ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 警告:每一次读,都不seek的!用户调用了seek不会引发pos变化,read会。
|
||||
|
||||
// 读取 资源交换文件标志 "RIFF";
|
||||
fileInfo.read ( WavFileHeader.RiffName, sizeof ( WavFileHeader.RiffName ) - 1 );
|
||||
|
||||
// 读取 RIFF 头后字节数;
|
||||
fileInfo.read ( ( char* ) &WavFileHeader.nRiffLength, sizeof ( WavFileHeader.nRiffLength ) );
|
||||
// 读取 波形文件标识符 "WAVE";
|
||||
fileInfo.read ( WavFileHeader.WavName, sizeof ( WavFileHeader.WavName ) - 1 );
|
||||
|
||||
// 警告:每一次读,都不seek的!用户调用了seek不会引发pos变化,read会。
|
||||
while ( 1 )
|
||||
{
|
||||
char tempName[5] = {0};
|
||||
unsigned int tempSize = 0;
|
||||
|
||||
fileInfo.read ( tempName, 4 );
|
||||
fileInfo.read ( ( char* ) &tempSize, 4 );
|
||||
|
||||
QString strTempName ( tempName );
|
||||
|
||||
if ( 0 == strTempName.compare ( "fmt ", Qt::CaseInsensitive ) )
|
||||
{
|
||||
strcpy ( WavFileHeader.FmtName, tempName );
|
||||
WavFileHeader.nFmtLength = tempSize;
|
||||
// 读取 格式种类;
|
||||
fileInfo.read ( ( char* ) &WavFileHeader.nAudioFormat, sizeof ( WavFileHeader.nAudioFormat ) );
|
||||
// 读取 音频通道数目;
|
||||
fileInfo.read ( ( char* ) &WavFileHeader.nChannleNumber, sizeof ( WavFileHeader.nChannleNumber ) );
|
||||
// 读取 采样频率;
|
||||
fileInfo.read ( ( char* ) &WavFileHeader.nSampleRate, sizeof ( WavFileHeader.nSampleRate ) );
|
||||
// 读取 波形数据传输速率;
|
||||
fileInfo.read ( ( char* ) &WavFileHeader.nBytesPerSecond, sizeof ( WavFileHeader.nBytesPerSecond ) );
|
||||
// 读取 数据块对齐单位;
|
||||
fileInfo.read ( ( char* ) &WavFileHeader.nBlockAlign, sizeof ( WavFileHeader.nBlockAlign ) );
|
||||
// 读取 每次采样得到的样本数据位数值;
|
||||
fileInfo.read ( ( char* ) &WavFileHeader.nBitsPerSample, sizeof ( WavFileHeader.nBitsPerSample ) );
|
||||
// 如果有扩展字节
|
||||
fileInfo.read ( tempSize - 16 );
|
||||
}
|
||||
else if ( 0 == strTempName.compare ( "fact", Qt::CaseInsensitive ) )
|
||||
{
|
||||
// 存在fact块,读取数据;
|
||||
strcpy ( WavFileHeader.FactName, tempName );
|
||||
// fact块长度;
|
||||
WavFileHeader.nFactLength = tempSize;
|
||||
// 读取fact块数据;但是不处理
|
||||
fileInfo.read ( tempSize );
|
||||
qDebug() << "fact data" << tempName << tempSize;
|
||||
}
|
||||
else if ( 0 == strTempName.compare ( "data", Qt::CaseInsensitive ) )
|
||||
{
|
||||
strcpy ( WavFileHeader.DATANAME, tempName );
|
||||
WavFileHeader.nDataLength = tempSize;
|
||||
|
||||
// 读取 音频数据大小;
|
||||
WavFileHeader.fileDataSize = tempSize;
|
||||
//文件头大小;
|
||||
WavFileHeader.fileHeaderSize = fileInfo.pos();
|
||||
|
||||
// 注意:这里的总大小,包括结尾8个字节,wav文件有8个结尾字节。"q\xFCq\xFC""a\xFB""a\xFB"
|
||||
// 文件总大小;
|
||||
WavFileHeader.fileTotalSize = WavFileHeader.nRiffLength + 8;
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "unhandled chunk" << tempName << tempSize;
|
||||
fileInfo.read ( tempSize );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//测试OK
|
||||
// pline() << "filesize" << WavFileHeader.fileTotalSize;
|
||||
// pline() << "fileheadersize" << WavFileHeader.fileHeaderSize;
|
||||
// pline() << "filedatasize" << WavFileHeader.fileDataSize;
|
||||
// pline() << "filetailsize" << WavFileHeader.fileTailSize;
|
||||
// pline() << WavFileHeader.nChannleNumber << WavFileHeader.nSampleRate << WavFileHeader.nBitsPerSample;
|
||||
|
||||
fileInfo.close();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 解析方法2 支援Qt 资源文件
|
||||
*/
|
||||
bool anlysisWavFileHeader ( QString fileName, QAudioFormat& format, TWavFileInfo& fileinfo )
|
||||
{
|
||||
WAVFILEHEADER WavFileHeader;
|
||||
bool ret = wavParse ( fileName, WavFileHeader );
|
||||
|
||||
format.setChannelCount ( WavFileHeader.nChannleNumber );
|
||||
format.setSampleRate ( WavFileHeader.nSampleRate );
|
||||
format.setSampleSize ( WavFileHeader.nBitsPerSample );
|
||||
format.setByteOrder ( QAudioFormat::LittleEndian );
|
||||
format.setCodec ( "audio/pcm" );
|
||||
format.setSampleType ( QAudioFormat::SignedInt );
|
||||
|
||||
fileinfo.fileTotalSize = WavFileHeader.fileTotalSize;
|
||||
fileinfo.fileHeaderSize = WavFileHeader.fileHeaderSize;
|
||||
fileinfo.fileDataSize = WavFileHeader.fileDataSize;
|
||||
fileinfo.fileTailSize = WavFileHeader.fileTailSize;
|
||||
return true;
|
||||
}
|
98
src/multimedia/libqwav/libqwav.h
Normal file
@ -0,0 +1,98 @@
|
||||
#ifndef LIBQWAV_H
|
||||
#define LIBQWAV_H
|
||||
|
||||
#include "libqwav_global.h"
|
||||
|
||||
#include "string.h"
|
||||
#include <QAudioFormat>
|
||||
#include <QIODevice>
|
||||
|
||||
//dll __imp_ lib no __imp_
|
||||
//跟这个extern没关系。
|
||||
//动态导出、导入时就是有__imp_
|
||||
//静态导出、导入时就是没有__imp_,导出的是函数原型。
|
||||
|
||||
//这个extern的作用是在导出库源文件是.c文件时,使用者必须使用extern "C"包含对应的头文件。
|
||||
//就这么一个作用。
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
//#endif
|
||||
|
||||
/*
|
||||
* 解析方法2 使用QtFile接口,支持Qt资源文件
|
||||
*/
|
||||
// wav文件头信息结构
|
||||
struct WAVFILEHEADER
|
||||
{
|
||||
// RIFF 头;
|
||||
char RiffName[5];//RIFF
|
||||
int nRiffLength;//fileLen-8
|
||||
// 数据类型标识符;
|
||||
char WavName[5];//WAVE
|
||||
|
||||
// 格式块中的块头;
|
||||
char FmtName[5];//fmt
|
||||
int nFmtLength;
|
||||
// 格式块中的块数据;
|
||||
short nAudioFormat;
|
||||
short nChannleNumber;
|
||||
int nSampleRate;
|
||||
int nBytesPerSecond;
|
||||
short nBlockAlign;
|
||||
short nBitsPerSample;
|
||||
|
||||
// 附加信息(可选),根据 nFmtLength 来判断;
|
||||
// 扩展域大小;
|
||||
short nAppendMessage;
|
||||
|
||||
//Fact块,可选字段,一般当wav文件由某些软件转化而成,则包含该Chunk;
|
||||
char FactName[5];
|
||||
int nFactLength;
|
||||
|
||||
// DATA块,数据块中的块头;
|
||||
char DATANAME[5];
|
||||
int nDataLength;//fileDataSize
|
||||
|
||||
// 以下是附加的一些计算信息;
|
||||
int fileDataSize; // 文件音频数据大小;
|
||||
int fileHeaderSize; // 文件头大小;
|
||||
int fileTailSize; // 文件尾大小; 一般忽略。
|
||||
int fileTotalSize; // 文件总大小;
|
||||
|
||||
|
||||
// 理论上应该将所有数据初始化,这里只初始化可选的数据;
|
||||
WAVFILEHEADER() {
|
||||
fileTailSize = 8;
|
||||
memset ( RiffName, 0, 5 );
|
||||
memset ( WavName, 0, 5 );
|
||||
memset ( FmtName, 0, 5 );
|
||||
memset ( FactName, 0, 5 );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//44 固定的
|
||||
LIBQWAVSHARED_EXPORT bool addWavHeader ( QIODevice& outputDevice, const QAudioFormat& format );
|
||||
//8 固定的
|
||||
LIBQWAVSHARED_EXPORT bool addWavTail ( QIODevice& outputDevice );
|
||||
LIBQWAVSHARED_EXPORT bool addWavDataBytes ( QIODevice& outputDevice, const QByteArray& bytes );
|
||||
|
||||
|
||||
typedef struct _TWavFileInfo
|
||||
{
|
||||
int fileDataSize; // 文件音频数据大小;
|
||||
int fileHeaderSize; // 文件头大小;
|
||||
int fileTailSize; // 文件尾大小; 一般忽略。
|
||||
int fileTotalSize; // 文件总大小;
|
||||
} TWavFileInfo;
|
||||
|
||||
|
||||
LIBQWAVSHARED_EXPORT bool wavParse ( QString fileName, WAVFILEHEADER& WavFileHeader );
|
||||
LIBQWAVSHARED_EXPORT bool anlysisWavFileHeader ( QString fileName, QAudioFormat& format, TWavFileInfo& fileinfo );
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//}
|
||||
//#endif
|
||||
|
||||
#endif // LIBQWAV_H
|
18
src/multimedia/libqwav/libqwav_global.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef LIBQWAV_GLOBAL_H
|
||||
#define LIBQWAV_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#if defined(LIBQWAV_LIBRARY)
|
||||
# define LIBQWAVSHARED_EXPORT Q_DECL_EXPORT
|
||||
#elif defined(LIBQWAV_STATIC_LIBRARY)
|
||||
# define LIBQWAVSHARED_EXPORT
|
||||
#else
|
||||
# define LIBQWAVSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#else
|
||||
# define LIBQWAVSHARED_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // LIBQWAV_GLOBAL_H
|
646
src/multimedia/qqtcamera.cpp
Normal file
@ -0,0 +1,646 @@
|
||||
#include <qqtcamera.h>
|
||||
|
||||
QQtCameraExposure::QQtCameraExposure ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
mExposure = 0;
|
||||
}
|
||||
|
||||
QQtCameraExposure::~QQtCameraExposure() {}
|
||||
|
||||
void QQtCameraExposure::setCameraExposure ( QCameraExposure* object )
|
||||
{
|
||||
Q_ASSERT ( object );
|
||||
|
||||
if ( mExposure )
|
||||
{
|
||||
disconnect ( mExposure, SIGNAL ( flashReady ( bool ) ), this, SIGNAL ( flashReady ( bool ) ) );
|
||||
disconnect ( mExposure, SIGNAL ( apertureChanged ( qreal ) ), this, SIGNAL ( apertureChanged ( qreal ) ) );
|
||||
disconnect ( mExposure, SIGNAL ( apertureRangeChanged() ), this, SIGNAL ( apertureRangeChanged() ) );
|
||||
disconnect ( mExposure, SIGNAL ( shutterSpeedChanged ( qreal ) ), this, SIGNAL ( shutterSpeedChanged ( qreal ) ) );
|
||||
disconnect ( mExposure, SIGNAL ( shutterSpeedRangeChanged() ), this, SIGNAL ( shutterSpeedRangeChanged() ) );
|
||||
disconnect ( mExposure, SIGNAL ( isoSensitivityChanged ( int ) ), this, SIGNAL ( isoSensitivityChanged ( int ) ) );
|
||||
disconnect ( mExposure, SIGNAL ( exposureCompensationChanged ( qreal ) ), this, SIGNAL ( exposureCompensationChanged ( qreal ) ) );
|
||||
|
||||
mExposure->deleteLater();
|
||||
}
|
||||
|
||||
mExposure = object;
|
||||
|
||||
connect ( mExposure, SIGNAL ( flashReady ( bool ) ), this, SIGNAL ( flashReady ( bool ) ) );
|
||||
connect ( mExposure, SIGNAL ( apertureChanged ( qreal ) ), this, SIGNAL ( apertureChanged ( qreal ) ) );
|
||||
connect ( mExposure, SIGNAL ( apertureRangeChanged() ), this, SIGNAL ( apertureRangeChanged() ) );
|
||||
connect ( mExposure, SIGNAL ( shutterSpeedChanged ( qreal ) ), this, SIGNAL ( shutterSpeedChanged ( qreal ) ) );
|
||||
connect ( mExposure, SIGNAL ( shutterSpeedRangeChanged() ), this, SIGNAL ( shutterSpeedRangeChanged() ) );
|
||||
connect ( mExposure, SIGNAL ( isoSensitivityChanged ( int ) ), this, SIGNAL ( isoSensitivityChanged ( int ) ) );
|
||||
connect ( mExposure, SIGNAL ( exposureCompensationChanged ( qreal ) ), this, SIGNAL ( exposureCompensationChanged ( qreal ) ) );
|
||||
|
||||
}
|
||||
|
||||
QCameraExposure* QQtCameraExposure::exposure()
|
||||
{
|
||||
return mExposure;
|
||||
}
|
||||
|
||||
bool QQtCameraExposure::isAvailable() const
|
||||
{
|
||||
return mExposure->isAvailable();
|
||||
}
|
||||
|
||||
QCameraExposure::FlashModes QQtCameraExposure::flashMode() const
|
||||
{
|
||||
return mExposure->flashMode();
|
||||
}
|
||||
|
||||
bool QQtCameraExposure::isFlashModeSupported ( QCameraExposure::FlashModes mode ) const
|
||||
{
|
||||
return mExposure->isFlashModeSupported ( mode );
|
||||
}
|
||||
|
||||
bool QQtCameraExposure::isFlashReady() const
|
||||
{
|
||||
return mExposure->isFlashReady();
|
||||
}
|
||||
|
||||
QCameraExposure::ExposureMode QQtCameraExposure::exposureMode() const
|
||||
{
|
||||
return mExposure->exposureMode();
|
||||
}
|
||||
|
||||
bool QQtCameraExposure::isExposureModeSupported ( QCameraExposure::ExposureMode mode ) const
|
||||
{
|
||||
return mExposure->isExposureModeSupported ( mode );
|
||||
}
|
||||
|
||||
qreal QQtCameraExposure::exposureCompensation() const
|
||||
{
|
||||
return mExposure->exposureCompensation();
|
||||
}
|
||||
|
||||
QCameraExposure::MeteringMode QQtCameraExposure::meteringMode() const
|
||||
{
|
||||
return mExposure->meteringMode();
|
||||
}
|
||||
|
||||
bool QQtCameraExposure::isMeteringModeSupported ( QCameraExposure::MeteringMode mode ) const
|
||||
{
|
||||
return mExposure->isMeteringModeSupported ( mode );
|
||||
}
|
||||
|
||||
QPointF QQtCameraExposure::spotMeteringPoint() const
|
||||
{
|
||||
return mExposure->spotMeteringPoint();
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setSpotMeteringPoint ( const QPointF& point )
|
||||
{
|
||||
return mExposure->setSpotMeteringPoint ( point );
|
||||
}
|
||||
|
||||
int QQtCameraExposure::isoSensitivity() const
|
||||
{
|
||||
return mExposure->isoSensitivity();
|
||||
}
|
||||
|
||||
qreal QQtCameraExposure::aperture() const
|
||||
{
|
||||
return mExposure->aperture();
|
||||
}
|
||||
|
||||
qreal QQtCameraExposure::shutterSpeed() const
|
||||
{
|
||||
return mExposure->shutterSpeed();
|
||||
}
|
||||
|
||||
int QQtCameraExposure::requestedIsoSensitivity() const
|
||||
{
|
||||
return mExposure->requestedIsoSensitivity();
|
||||
}
|
||||
|
||||
qreal QQtCameraExposure::requestedAperture() const
|
||||
{
|
||||
return mExposure->requestedAperture();
|
||||
}
|
||||
|
||||
qreal QQtCameraExposure::requestedShutterSpeed() const
|
||||
{
|
||||
return mExposure->requestedShutterSpeed();
|
||||
}
|
||||
|
||||
QList<int> QQtCameraExposure::supportedIsoSensitivities ( bool* continuous ) const
|
||||
{
|
||||
return mExposure->supportedIsoSensitivities ( continuous );
|
||||
}
|
||||
|
||||
QList<qreal> QQtCameraExposure::supportedApertures ( bool* continuous ) const
|
||||
{
|
||||
return mExposure->supportedApertures ( continuous );
|
||||
}
|
||||
|
||||
QList<qreal> QQtCameraExposure::supportedShutterSpeeds ( bool* continuous ) const
|
||||
{
|
||||
return mExposure->supportedShutterSpeeds ( continuous );
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setFlashMode ( QCameraExposure::FlashModes mode )
|
||||
{
|
||||
return mExposure->setFlashMode ( mode );
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setExposureMode ( QCameraExposure::ExposureMode mode )
|
||||
{
|
||||
return mExposure->setExposureMode ( mode );
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setMeteringMode ( QCameraExposure::MeteringMode mode )
|
||||
{
|
||||
return mExposure->setMeteringMode ( mode );
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setExposureCompensation ( qreal ev )
|
||||
{
|
||||
return mExposure->setExposureCompensation ( ev );
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setManualIsoSensitivity ( int iso )
|
||||
{
|
||||
return mExposure->setManualIsoSensitivity ( iso );
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setAutoIsoSensitivity()
|
||||
{
|
||||
return mExposure->setAutoIsoSensitivity ( );
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setManualAperture ( qreal aperture )
|
||||
{
|
||||
return mExposure->setManualAperture ( aperture );
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setAutoAperture()
|
||||
{
|
||||
return mExposure->setAutoAperture ( );
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setManualShutterSpeed ( qreal seconds )
|
||||
{
|
||||
return mExposure->setManualShutterSpeed ( seconds );
|
||||
}
|
||||
|
||||
void QQtCameraExposure::setAutoShutterSpeed()
|
||||
{
|
||||
return mExposure->setAutoShutterSpeed ( );
|
||||
}
|
||||
|
||||
|
||||
QQtCameraFocus::QQtCameraFocus ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
mFocus = 0;
|
||||
}
|
||||
|
||||
QQtCameraFocus::~QQtCameraFocus() {}
|
||||
|
||||
void QQtCameraFocus::setCameraFocus ( QCameraFocus* object )
|
||||
{
|
||||
Q_ASSERT ( object );
|
||||
|
||||
if ( mFocus )
|
||||
{
|
||||
disconnect ( mFocus, SIGNAL ( opticalZoomChanged ( qreal ) ), this, SIGNAL ( opticalZoomChanged ( qreal ) ) );
|
||||
disconnect ( mFocus, SIGNAL ( digitalZoomChanged ( qreal ) ), this, SIGNAL ( digitalZoomChanged ( qreal ) ) );
|
||||
disconnect ( mFocus, SIGNAL ( focusZonesChanged ( ) ), this, SIGNAL ( focusZonesChanged ( ) ) );
|
||||
disconnect ( mFocus, SIGNAL ( maximumOpticalZoomChanged ( qreal ) ), this, SIGNAL ( maximumOpticalZoomChanged ( qreal ) ) );
|
||||
disconnect ( mFocus, SIGNAL ( maximumDigitalZoomChanged ( qreal ) ), this, SIGNAL ( maximumDigitalZoomChanged ( qreal ) ) );
|
||||
mFocus->deleteLater();
|
||||
}
|
||||
|
||||
mFocus = object;
|
||||
|
||||
connect ( mFocus, SIGNAL ( opticalZoomChanged ( qreal ) ), this, SIGNAL ( opticalZoomChanged ( qreal ) ) );
|
||||
connect ( mFocus, SIGNAL ( digitalZoomChanged ( qreal ) ), this, SIGNAL ( digitalZoomChanged ( qreal ) ) );
|
||||
connect ( mFocus, SIGNAL ( focusZonesChanged ( ) ), this, SIGNAL ( focusZonesChanged ( ) ) );
|
||||
connect ( mFocus, SIGNAL ( maximumOpticalZoomChanged ( qreal ) ), this, SIGNAL ( maximumOpticalZoomChanged ( qreal ) ) );
|
||||
connect ( mFocus, SIGNAL ( maximumDigitalZoomChanged ( qreal ) ), this, SIGNAL ( maximumDigitalZoomChanged ( qreal ) ) );
|
||||
|
||||
}
|
||||
|
||||
QCameraFocus* QQtCameraFocus::focus()
|
||||
{
|
||||
return mFocus;
|
||||
}
|
||||
|
||||
bool QQtCameraFocus::isAvailable() const
|
||||
{
|
||||
return mFocus->isAvailable();
|
||||
}
|
||||
|
||||
QCameraFocus::FocusModes QQtCameraFocus::focusMode() const
|
||||
{
|
||||
return mFocus->focusMode();
|
||||
}
|
||||
|
||||
void QQtCameraFocus::setFocusMode ( QCameraFocus::FocusModes mode )
|
||||
{
|
||||
return mFocus->setFocusMode ( mode );
|
||||
}
|
||||
|
||||
bool QQtCameraFocus::isFocusModeSupported ( QCameraFocus::FocusModes mode ) const
|
||||
{
|
||||
return mFocus->isFocusModeSupported ( mode );
|
||||
}
|
||||
|
||||
QCameraFocus::FocusPointMode QQtCameraFocus::focusPointMode() const
|
||||
{
|
||||
return mFocus->focusPointMode ( );
|
||||
}
|
||||
|
||||
void QQtCameraFocus::setFocusPointMode ( QCameraFocus::FocusPointMode mode )
|
||||
{
|
||||
return mFocus->setFocusPointMode ( mode );
|
||||
}
|
||||
|
||||
bool QQtCameraFocus::isFocusPointModeSupported ( QCameraFocus::FocusPointMode mode ) const
|
||||
{
|
||||
return mFocus->isFocusPointModeSupported ( mode );
|
||||
}
|
||||
|
||||
QPointF QQtCameraFocus::customFocusPoint() const
|
||||
{
|
||||
return mFocus->customFocusPoint ( );
|
||||
}
|
||||
|
||||
void QQtCameraFocus::setCustomFocusPoint ( const QPointF& point )
|
||||
{
|
||||
return mFocus->setCustomFocusPoint ( point );
|
||||
}
|
||||
|
||||
QCameraFocusZoneList QQtCameraFocus::focusZones() const
|
||||
{
|
||||
return mFocus->focusZones ( );
|
||||
}
|
||||
|
||||
qreal QQtCameraFocus::maximumOpticalZoom() const
|
||||
{
|
||||
return mFocus->maximumOpticalZoom ( );
|
||||
}
|
||||
|
||||
qreal QQtCameraFocus::maximumDigitalZoom() const
|
||||
{
|
||||
return mFocus->maximumDigitalZoom ( );
|
||||
}
|
||||
|
||||
qreal QQtCameraFocus::opticalZoom() const
|
||||
{
|
||||
return mFocus->opticalZoom ( );
|
||||
}
|
||||
|
||||
qreal QQtCameraFocus::digitalZoom() const
|
||||
{
|
||||
return mFocus->digitalZoom ( );
|
||||
}
|
||||
|
||||
void QQtCameraFocus::zoomTo ( qreal opticalZoom, qreal digitalZoom )
|
||||
{
|
||||
return mFocus->zoomTo ( opticalZoom, digitalZoom );
|
||||
}
|
||||
|
||||
|
||||
QQtCameraImageProcessing::QQtCameraImageProcessing ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
mImageProcessing = 0;
|
||||
}
|
||||
|
||||
QQtCameraImageProcessing::~QQtCameraImageProcessing() {}
|
||||
|
||||
void QQtCameraImageProcessing::setCameraImageProcessing ( QCameraImageProcessing* object )
|
||||
{
|
||||
Q_ASSERT ( object );
|
||||
|
||||
if ( mImageProcessing )
|
||||
{
|
||||
mImageProcessing->deleteLater();
|
||||
}
|
||||
|
||||
mImageProcessing = object;
|
||||
}
|
||||
|
||||
bool QQtCameraImageProcessing::isAvailable() const
|
||||
{
|
||||
return mImageProcessing->isAvailable();
|
||||
}
|
||||
|
||||
QCameraImageProcessing::WhiteBalanceMode QQtCameraImageProcessing::whiteBalanceMode() const
|
||||
{
|
||||
return mImageProcessing->whiteBalanceMode();
|
||||
}
|
||||
|
||||
void QQtCameraImageProcessing::setWhiteBalanceMode ( QCameraImageProcessing::WhiteBalanceMode mode )
|
||||
{
|
||||
return mImageProcessing->setWhiteBalanceMode ( mode );
|
||||
}
|
||||
|
||||
bool QQtCameraImageProcessing::isWhiteBalanceModeSupported ( QCameraImageProcessing::WhiteBalanceMode mode ) const
|
||||
{
|
||||
return mImageProcessing->isWhiteBalanceModeSupported ( mode );
|
||||
}
|
||||
|
||||
qreal QQtCameraImageProcessing::manualWhiteBalance() const
|
||||
{
|
||||
return mImageProcessing->manualWhiteBalance();
|
||||
}
|
||||
|
||||
void QQtCameraImageProcessing::setManualWhiteBalance ( qreal colorTemperature )
|
||||
{
|
||||
return mImageProcessing->setManualWhiteBalance ( colorTemperature );
|
||||
}
|
||||
|
||||
qreal QQtCameraImageProcessing::brightness() const
|
||||
{
|
||||
return mImageProcessing->brightness();
|
||||
}
|
||||
|
||||
void QQtCameraImageProcessing::setBrightness ( qreal value )
|
||||
{
|
||||
return mImageProcessing->setManualWhiteBalance ( value );
|
||||
}
|
||||
|
||||
qreal QQtCameraImageProcessing::contrast() const
|
||||
{
|
||||
return mImageProcessing->contrast();
|
||||
}
|
||||
|
||||
void QQtCameraImageProcessing::setContrast ( qreal value )
|
||||
{
|
||||
return mImageProcessing->setContrast ( value );
|
||||
}
|
||||
|
||||
qreal QQtCameraImageProcessing::saturation() const
|
||||
{
|
||||
return mImageProcessing->saturation();
|
||||
}
|
||||
|
||||
void QQtCameraImageProcessing::setSaturation ( qreal value )
|
||||
{
|
||||
return mImageProcessing->setSaturation ( value );
|
||||
}
|
||||
|
||||
qreal QQtCameraImageProcessing::sharpeningLevel() const
|
||||
{
|
||||
return mImageProcessing->sharpeningLevel();
|
||||
}
|
||||
|
||||
void QQtCameraImageProcessing::setSharpeningLevel ( qreal value )
|
||||
{
|
||||
return mImageProcessing->setSharpeningLevel ( value );
|
||||
}
|
||||
|
||||
qreal QQtCameraImageProcessing::denoisingLevel() const
|
||||
{
|
||||
return mImageProcessing->denoisingLevel();
|
||||
}
|
||||
|
||||
void QQtCameraImageProcessing::setDenoisingLevel ( qreal value )
|
||||
{
|
||||
return mImageProcessing->setDenoisingLevel ( value );
|
||||
}
|
||||
|
||||
QCameraImageProcessing::ColorFilter QQtCameraImageProcessing::colorFilter() const
|
||||
{
|
||||
return mImageProcessing->colorFilter();
|
||||
}
|
||||
|
||||
void QQtCameraImageProcessing::setColorFilter ( QCameraImageProcessing::ColorFilter filter )
|
||||
{
|
||||
return mImageProcessing->setColorFilter ( filter );
|
||||
}
|
||||
|
||||
bool QQtCameraImageProcessing::isColorFilterSupported ( QCameraImageProcessing::ColorFilter filter ) const
|
||||
{
|
||||
return mImageProcessing->isColorFilterSupported ( filter );
|
||||
}
|
||||
|
||||
QQtCamera::QQtCamera ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
//初始化Camera。
|
||||
mCamera = 0;
|
||||
//初始化CameraInfo。
|
||||
mCameraInfo = QCameraInfo::defaultCamera();
|
||||
|
||||
//mCamera 句柄持续为真。
|
||||
setCameraInfo ( QCameraInfo::defaultCamera() );
|
||||
}
|
||||
|
||||
QQtCamera::~QQtCamera() {}
|
||||
|
||||
void QQtCamera::setCameraInfo ( const QCameraInfo& camInfo )
|
||||
{
|
||||
//更新mCamera
|
||||
if ( mCamera )
|
||||
{
|
||||
disconnect ( mCamera, SIGNAL ( stateChanged ( QCamera::State ) ), this, SIGNAL ( stateChanged ( QCamera::State ) ) );
|
||||
disconnect ( mCamera, SIGNAL ( captureModeChanged ( QCamera::CaptureModes ) ), this, SIGNAL ( captureModeChanged ( QCamera::CaptureModes ) ) );
|
||||
disconnect ( mCamera, SIGNAL ( statusChanged ( QCamera::Status ) ), this, SIGNAL ( statusChanged ( QCamera::Status ) ) );
|
||||
disconnect ( mCamera, SIGNAL ( locked() ), this, SIGNAL ( locked() ) );
|
||||
disconnect ( mCamera, SIGNAL ( lockFailed() ), this, SIGNAL ( lockFailed() ) );
|
||||
disconnect ( mCamera, SIGNAL ( lockStatusChanged ( QCamera::LockStatus, QCamera::LockChangeReason ) ), this, SIGNAL ( lockStatusChanged ( QCamera::LockStatus, QCamera::LockChangeReason ) ) );
|
||||
disconnect ( mCamera, SIGNAL ( lockStatusChanged ( QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason ) ), this, SIGNAL ( lockStatusChanged ( QCamera::LockType, QCamera::LockStatus,
|
||||
QCamera::LockChangeReason ) ) );
|
||||
disconnect ( mCamera, SIGNAL ( error ( QCamera::Error ) ), this, SIGNAL ( error ( QCamera::Error ) ) );
|
||||
mCamera->stop();
|
||||
mCamera->deleteLater();
|
||||
}
|
||||
|
||||
mCameraInfo = camInfo;
|
||||
mCamera = new QCamera ( mCameraInfo, this );
|
||||
|
||||
#if 0
|
||||
//更新 Viewfinder
|
||||
setViewfinder ( m_vw_viewfinder );
|
||||
setViewfinder ( m_gv_viewfinder );
|
||||
setViewfinder ( m_avs_viewfinder );
|
||||
|
||||
//更新 ViewfinderSettings
|
||||
setViewfinderSettings ( mVfSettings );
|
||||
#endif
|
||||
|
||||
//更新信号、槽的连接
|
||||
connect ( mCamera, SIGNAL ( stateChanged ( QCamera::State ) ), this, SIGNAL ( stateChanged ( QCamera::State ) ) );
|
||||
connect ( mCamera, SIGNAL ( captureModeChanged ( QCamera::CaptureModes ) ), this, SIGNAL ( captureModeChanged ( QCamera::CaptureModes ) ) );
|
||||
connect ( mCamera, SIGNAL ( statusChanged ( QCamera::Status ) ), this, SIGNAL ( statusChanged ( QCamera::Status ) ) );
|
||||
connect ( mCamera, SIGNAL ( locked() ), this, SIGNAL ( locked() ) );
|
||||
connect ( mCamera, SIGNAL ( lockFailed() ), this, SIGNAL ( lockFailed() ) );
|
||||
connect ( mCamera, SIGNAL ( lockStatusChanged ( QCamera::LockStatus, QCamera::LockChangeReason ) ), this, SIGNAL ( lockStatusChanged ( QCamera::LockStatus, QCamera::LockChangeReason ) ) );
|
||||
connect ( mCamera, SIGNAL ( lockStatusChanged ( QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason ) ), this, SIGNAL ( lockStatusChanged ( QCamera::LockType, QCamera::LockStatus,
|
||||
QCamera::LockChangeReason ) ) );
|
||||
connect ( mCamera, SIGNAL ( error ( QCamera::Error ) ), this, SIGNAL ( error ( QCamera::Error ) ) );
|
||||
|
||||
}
|
||||
|
||||
QCameraInfo QQtCamera::cameraInfo() const
|
||||
{
|
||||
return mCameraInfo;
|
||||
}
|
||||
|
||||
QCamera* QQtCamera::camera() const
|
||||
{
|
||||
return mCamera;
|
||||
}
|
||||
|
||||
QMultimedia::AvailabilityStatus QQtCamera::availability() const
|
||||
{
|
||||
return mCamera->availability();
|
||||
}
|
||||
|
||||
QCamera::State QQtCamera::state() const
|
||||
{
|
||||
return mCamera->state();
|
||||
}
|
||||
|
||||
QCamera::Status QQtCamera::status() const
|
||||
{
|
||||
return mCamera->status();
|
||||
}
|
||||
|
||||
QCamera::CaptureModes QQtCamera::captureMode() const
|
||||
{
|
||||
return mCamera->captureMode();
|
||||
}
|
||||
|
||||
bool QQtCamera::isCaptureModeSupported ( QCamera::CaptureModes mode ) const
|
||||
{
|
||||
return mCamera->isCaptureModeSupported ( mode );
|
||||
}
|
||||
|
||||
QCameraExposure* QQtCamera::exposure() const
|
||||
{
|
||||
return mCamera->exposure();
|
||||
}
|
||||
|
||||
QCameraFocus* QQtCamera::focus() const
|
||||
{
|
||||
return mCamera->focus();
|
||||
}
|
||||
|
||||
QCameraImageProcessing* QQtCamera::imageProcessing() const
|
||||
{
|
||||
return mCamera->imageProcessing();
|
||||
}
|
||||
|
||||
void QQtCamera::setViewfinder ( QVideoWidget* viewfinder )
|
||||
{
|
||||
mCamera->setViewfinder ( viewfinder );
|
||||
}
|
||||
|
||||
void QQtCamera::setViewfinder ( QGraphicsVideoItem* viewfinder )
|
||||
{
|
||||
mCamera->setViewfinder ( viewfinder );
|
||||
}
|
||||
|
||||
void QQtCamera::setViewfinder ( QAbstractVideoSurface* surface )
|
||||
{
|
||||
mCamera->setViewfinder ( surface );
|
||||
}
|
||||
|
||||
QCameraViewfinderSettings QQtCamera::viewfinderSettings() const
|
||||
{
|
||||
return mCamera->viewfinderSettings();
|
||||
}
|
||||
|
||||
void QQtCamera::setViewfinderSettings ( const QCameraViewfinderSettings& settings )
|
||||
{
|
||||
return mCamera->setViewfinderSettings ( settings );
|
||||
}
|
||||
|
||||
QList<QCameraViewfinderSettings> QQtCamera::supportedViewfinderSettings ( const QCameraViewfinderSettings& settings ) const
|
||||
{
|
||||
return mCamera->supportedViewfinderSettings ( settings );
|
||||
}
|
||||
|
||||
QList<QSize> QQtCamera::supportedViewfinderResolutions ( const QCameraViewfinderSettings& settings ) const
|
||||
{
|
||||
return mCamera->supportedViewfinderResolutions ( settings );
|
||||
}
|
||||
|
||||
QList<QCamera::FrameRateRange> QQtCamera::supportedViewfinderFrameRateRanges ( const QCameraViewfinderSettings& settings ) const
|
||||
{
|
||||
return mCamera->supportedViewfinderFrameRateRanges ( settings );
|
||||
}
|
||||
|
||||
QList<QVideoFrame::PixelFormat> QQtCamera::supportedViewfinderPixelFormats ( const QCameraViewfinderSettings& settings ) const
|
||||
{
|
||||
return mCamera->supportedViewfinderPixelFormats ( settings );
|
||||
}
|
||||
|
||||
QCamera::Error QQtCamera::error() const
|
||||
{
|
||||
return mCamera->error ( );
|
||||
}
|
||||
|
||||
QString QQtCamera::errorString() const
|
||||
{
|
||||
return mCamera->errorString ( );
|
||||
}
|
||||
|
||||
QCamera::LockTypes QQtCamera::supportedLocks() const
|
||||
{
|
||||
return mCamera->supportedLocks ( );
|
||||
}
|
||||
|
||||
QCamera::LockTypes QQtCamera::requestedLocks() const
|
||||
{
|
||||
return mCamera->requestedLocks ( );
|
||||
}
|
||||
|
||||
QCamera::LockStatus QQtCamera::lockStatus() const
|
||||
{
|
||||
return mCamera->lockStatus ( );
|
||||
}
|
||||
|
||||
QCamera::LockStatus QQtCamera::lockStatus ( QCamera::LockType lock ) const
|
||||
{
|
||||
return mCamera->lockStatus ( lock );
|
||||
}
|
||||
|
||||
void QQtCamera::setCaptureMode ( QCamera::CaptureModes mode )
|
||||
{
|
||||
return mCamera->setCaptureMode ( mode );
|
||||
}
|
||||
|
||||
void QQtCamera::load()
|
||||
{
|
||||
return mCamera->load();
|
||||
}
|
||||
|
||||
void QQtCamera::unload()
|
||||
{
|
||||
return mCamera->unload();
|
||||
}
|
||||
|
||||
void QQtCamera::start()
|
||||
{
|
||||
return mCamera->start();
|
||||
}
|
||||
|
||||
void QQtCamera::stop()
|
||||
{
|
||||
return mCamera->stop();
|
||||
}
|
||||
|
||||
void QQtCamera::searchAndLock()
|
||||
{
|
||||
return mCamera->searchAndLock();
|
||||
}
|
||||
|
||||
void QQtCamera::unlock()
|
||||
{
|
||||
return mCamera->unlock();
|
||||
}
|
||||
|
||||
void QQtCamera::searchAndLock ( QCamera::LockTypes locks )
|
||||
{
|
||||
return mCamera->searchAndLock ( locks );
|
||||
}
|
||||
|
||||
void QQtCamera::unlock ( QCamera::LockTypes locks )
|
||||
{
|
||||
return mCamera->unlock ( locks );
|
||||
}
|
283
src/multimedia/qqtcamera.h
Normal file
@ -0,0 +1,283 @@
|
||||
#ifndef QQTCAMERA_H
|
||||
#define QQTCAMERA_H
|
||||
|
||||
/**
|
||||
* 包装类
|
||||
* 为QQtVideoManager提供包装类,促使句柄、信号、槽,外部在使用时,不变。
|
||||
* 用户感兴趣可以使用。
|
||||
*/
|
||||
|
||||
#include <QCamera>
|
||||
#include <QCameraInfo>
|
||||
|
||||
#include <qqt-local.h>
|
||||
|
||||
/**
|
||||
* @brief The QQtCameraExposure class
|
||||
* 为QCameraExposure提供能够保持的句柄。
|
||||
* 不应该管理句柄的删除。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtCameraExposure : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQtCameraExposure ( QObject* parent = 0 );
|
||||
virtual ~QQtCameraExposure();
|
||||
|
||||
//决定exposure句柄
|
||||
void setCameraExposure ( QCameraExposure* object );
|
||||
QCameraExposure* exposure();
|
||||
|
||||
bool isAvailable() const;
|
||||
|
||||
QCameraExposure::FlashModes flashMode() const;
|
||||
bool isFlashModeSupported ( QCameraExposure::FlashModes mode ) const;
|
||||
bool isFlashReady() const;
|
||||
|
||||
QCameraExposure::ExposureMode exposureMode() const;
|
||||
bool isExposureModeSupported ( QCameraExposure::ExposureMode mode ) const;
|
||||
|
||||
qreal exposureCompensation() const;
|
||||
|
||||
QCameraExposure::MeteringMode meteringMode() const;
|
||||
bool isMeteringModeSupported ( QCameraExposure::MeteringMode mode ) const;
|
||||
|
||||
QPointF spotMeteringPoint() const;
|
||||
void setSpotMeteringPoint ( const QPointF& point );
|
||||
|
||||
int isoSensitivity() const;
|
||||
qreal aperture() const;
|
||||
qreal shutterSpeed() const;
|
||||
|
||||
int requestedIsoSensitivity() const;
|
||||
qreal requestedAperture() const;
|
||||
qreal requestedShutterSpeed() const;
|
||||
|
||||
QList<int> supportedIsoSensitivities ( bool* continuous = Q_NULLPTR ) const;
|
||||
QList<qreal> supportedApertures ( bool* continuous = Q_NULLPTR ) const;
|
||||
QList<qreal> supportedShutterSpeeds ( bool* continuous = Q_NULLPTR ) const;
|
||||
|
||||
public slots:
|
||||
void setFlashMode ( QCameraExposure::FlashModes mode );
|
||||
void setExposureMode ( QCameraExposure::ExposureMode mode );
|
||||
void setMeteringMode ( QCameraExposure::MeteringMode mode );
|
||||
|
||||
void setExposureCompensation ( qreal ev );
|
||||
|
||||
void setManualIsoSensitivity ( int iso );
|
||||
void setAutoIsoSensitivity();
|
||||
|
||||
void setManualAperture ( qreal aperture );
|
||||
void setAutoAperture();
|
||||
|
||||
void setManualShutterSpeed ( qreal seconds );
|
||||
void setAutoShutterSpeed();
|
||||
|
||||
signals:
|
||||
void flashReady ( bool );
|
||||
|
||||
void apertureChanged ( qreal );
|
||||
void apertureRangeChanged();
|
||||
void shutterSpeedChanged ( qreal );
|
||||
void shutterSpeedRangeChanged();
|
||||
void isoSensitivityChanged ( int );
|
||||
void exposureCompensationChanged ( qreal );
|
||||
|
||||
private:
|
||||
QCameraExposure* mExposure;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The QQtCameraFocus class
|
||||
* QCameraFocus的包装,保持句柄。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtCameraFocus : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQtCameraFocus ( QObject* parent = 0 );
|
||||
virtual ~QQtCameraFocus();
|
||||
|
||||
void setCameraFocus ( QCameraFocus* object );
|
||||
QCameraFocus* focus();
|
||||
|
||||
bool isAvailable() const;
|
||||
|
||||
QCameraFocus::FocusModes focusMode() const;
|
||||
void setFocusMode ( QCameraFocus::FocusModes mode );
|
||||
bool isFocusModeSupported ( QCameraFocus::FocusModes mode ) const;
|
||||
|
||||
QCameraFocus::FocusPointMode focusPointMode() const;
|
||||
void setFocusPointMode ( QCameraFocus::FocusPointMode mode );
|
||||
bool isFocusPointModeSupported ( QCameraFocus::FocusPointMode mode ) const;
|
||||
QPointF customFocusPoint() const;
|
||||
void setCustomFocusPoint ( const QPointF& point );
|
||||
|
||||
QCameraFocusZoneList focusZones() const;
|
||||
|
||||
qreal maximumOpticalZoom() const;
|
||||
qreal maximumDigitalZoom() const;
|
||||
qreal opticalZoom() const;
|
||||
qreal digitalZoom() const;
|
||||
|
||||
void zoomTo ( qreal opticalZoom, qreal digitalZoom );
|
||||
|
||||
signals:
|
||||
void opticalZoomChanged ( qreal );
|
||||
void digitalZoomChanged ( qreal );
|
||||
|
||||
void focusZonesChanged();
|
||||
|
||||
void maximumOpticalZoomChanged ( qreal );
|
||||
void maximumDigitalZoomChanged ( qreal );
|
||||
|
||||
private:
|
||||
QCameraFocus* mFocus;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The QQtCameraImageProcessing class
|
||||
* QCameraImageProcessing的包装类,保持句柄。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtCameraImageProcessing : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQtCameraImageProcessing ( QObject* parent = 0 );
|
||||
virtual ~QQtCameraImageProcessing();
|
||||
|
||||
void setCameraImageProcessing ( QCameraImageProcessing* object );
|
||||
|
||||
bool isAvailable() const;
|
||||
|
||||
QCameraImageProcessing::WhiteBalanceMode whiteBalanceMode() const;
|
||||
void setWhiteBalanceMode ( QCameraImageProcessing::WhiteBalanceMode mode );
|
||||
bool isWhiteBalanceModeSupported ( QCameraImageProcessing::WhiteBalanceMode mode ) const;
|
||||
|
||||
qreal manualWhiteBalance() const;
|
||||
void setManualWhiteBalance ( qreal colorTemperature );
|
||||
|
||||
qreal brightness() const;
|
||||
void setBrightness ( qreal value );
|
||||
|
||||
qreal contrast() const;
|
||||
void setContrast ( qreal value );
|
||||
|
||||
qreal saturation() const;
|
||||
void setSaturation ( qreal value );
|
||||
|
||||
qreal sharpeningLevel() const;
|
||||
void setSharpeningLevel ( qreal value );
|
||||
|
||||
qreal denoisingLevel() const;
|
||||
void setDenoisingLevel ( qreal value );
|
||||
|
||||
QCameraImageProcessing::ColorFilter colorFilter() const;
|
||||
void setColorFilter ( QCameraImageProcessing::ColorFilter filter );
|
||||
bool isColorFilterSupported ( QCameraImageProcessing::ColorFilter filter ) const;
|
||||
|
||||
private:
|
||||
QCameraImageProcessing* mImageProcessing;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The QQtCamera class
|
||||
* 封装QCamera
|
||||
* 已预置defaultCamera,
|
||||
* 句柄保持不变。
|
||||
* 包装类的句柄不变,信号和槽就可以持续使用了。
|
||||
* 内部句柄在变化,但是从外部看,无所谓,外部使用的句柄、信号、槽都是稳定的。
|
||||
* 功能丰富、齐全。
|
||||
* 多线程不安全。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtCamera : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQtCamera ( QObject* parent = 0 );
|
||||
virtual ~QQtCamera();
|
||||
|
||||
//QQt setCameraInfo 决定以下所有关系照相机的操作。
|
||||
//更改 CameraInfo,QQtCamera 会切换到新Camera的默认输出设置,用户需要重新设置 ViewfinderSettings 达到输出设置目的。
|
||||
//更改 CameraInfo,QQtCamera 会舍弃过去的Viewfinder,用户需要重新设置 Viewfinder。
|
||||
void setCameraInfo ( const QCameraInfo& camInfo );
|
||||
QCameraInfo cameraInfo() const;
|
||||
|
||||
//optional
|
||||
//以下函数可选使用,句柄处于持续变动之中。
|
||||
QCamera* camera() const;
|
||||
|
||||
QMultimedia::AvailabilityStatus availability() const;
|
||||
|
||||
QCamera::State state() const;
|
||||
QCamera::Status status() const;
|
||||
|
||||
QCamera::CaptureModes captureMode() const;
|
||||
bool isCaptureModeSupported ( QCamera::CaptureModes mode ) const;
|
||||
|
||||
QCameraExposure* exposure() const;
|
||||
QCameraFocus* focus() const;
|
||||
QCameraImageProcessing* imageProcessing() const;
|
||||
|
||||
void setViewfinder ( QVideoWidget* viewfinder );
|
||||
void setViewfinder ( QGraphicsVideoItem* viewfinder );
|
||||
void setViewfinder ( QAbstractVideoSurface* surface );
|
||||
|
||||
QCameraViewfinderSettings viewfinderSettings() const;
|
||||
void setViewfinderSettings ( const QCameraViewfinderSettings& settings );
|
||||
|
||||
QList<QCameraViewfinderSettings> supportedViewfinderSettings (
|
||||
const QCameraViewfinderSettings& settings = QCameraViewfinderSettings() ) const;
|
||||
|
||||
QList<QSize> supportedViewfinderResolutions (
|
||||
const QCameraViewfinderSettings& settings = QCameraViewfinderSettings() ) const;
|
||||
|
||||
QList<QCamera::FrameRateRange> supportedViewfinderFrameRateRanges (
|
||||
const QCameraViewfinderSettings& settings = QCameraViewfinderSettings() ) const;
|
||||
|
||||
QList<QVideoFrame::PixelFormat> supportedViewfinderPixelFormats (
|
||||
const QCameraViewfinderSettings& settings = QCameraViewfinderSettings() ) const;
|
||||
|
||||
QCamera::Error error() const;
|
||||
QString errorString() const;
|
||||
|
||||
QCamera::LockTypes supportedLocks() const;
|
||||
QCamera::LockTypes requestedLocks() const;
|
||||
|
||||
QCamera::LockStatus lockStatus() const;
|
||||
QCamera::LockStatus lockStatus ( QCamera::LockType lock ) const;
|
||||
|
||||
public slots:
|
||||
void setCaptureMode ( QCamera::CaptureModes mode );
|
||||
|
||||
void load();
|
||||
void unload();
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
void searchAndLock();
|
||||
void unlock();
|
||||
|
||||
void searchAndLock ( QCamera::LockTypes locks );
|
||||
void unlock ( QCamera::LockTypes locks );
|
||||
|
||||
signals:
|
||||
void stateChanged ( QCamera::State );
|
||||
void captureModeChanged ( QCamera::CaptureModes );
|
||||
void statusChanged ( QCamera::Status );
|
||||
|
||||
void locked();
|
||||
void lockFailed();
|
||||
|
||||
void lockStatusChanged ( QCamera::LockStatus, QCamera::LockChangeReason );
|
||||
void lockStatusChanged ( QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason );
|
||||
|
||||
void error ( QCamera::Error );
|
||||
|
||||
private:
|
||||
QCamera* mCamera;
|
||||
QCameraInfo mCameraInfo;
|
||||
};
|
||||
|
||||
#endif // QQTCAMERA_H
|
342
src/multimedia/qqtlogicvideomanager.cpp
Normal file
@ -0,0 +1,342 @@
|
||||
#include "qqtlogicvideomanager.h"
|
||||
|
||||
QQtLogicVideoManager::QQtLogicVideoManager ( QWidget* parent ) :
|
||||
QWidget ( parent ),
|
||||
ui ( new Ui::QQtLogicVideoManager )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
|
||||
memset ( &sinfo, 0, sizeof ( struct sensor_info ) );
|
||||
pre_bpp = 16;
|
||||
rate = 15; /* default to 15fps */
|
||||
addr = 0;
|
||||
phys = 0;
|
||||
|
||||
pre_size.w = 720;
|
||||
pre_size.h = 480;
|
||||
|
||||
fd = 0;
|
||||
|
||||
memset ( & pre_memory, 0, sizeof ( struct camera_memory ) );
|
||||
memset ( & pre_buf, 0, sizeof ( struct camera_buffer ) );
|
||||
memset ( & pre_size, 0, sizeof ( struct frm_size ) );
|
||||
|
||||
tlb_base_phys = 0;
|
||||
format = HAL_PIXEL_FORMAT_YCbCr_422_I;
|
||||
|
||||
bFullScreen = false;
|
||||
m_parent = parent;
|
||||
|
||||
timer = new QTimer ( this );
|
||||
timer->setSingleShot ( false );
|
||||
connect ( timer, SIGNAL ( timeout() ), this, SLOT ( update() ) );
|
||||
}
|
||||
|
||||
QQtLogicVideoManager::~QQtLogicVideoManager()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
int QQtLogicVideoManager::play()
|
||||
{
|
||||
/*
|
||||
* 这块代码放在哪里
|
||||
*/
|
||||
dmmu_init();
|
||||
dmmu_get_page_table_base_phys ( &tlb_base_phys );
|
||||
|
||||
fd = ::open ( "/dev/cim", O_RDWR ); //av
|
||||
|
||||
if ( fd < 0 )
|
||||
{
|
||||
qDebug() << "Open device fail\n";
|
||||
}
|
||||
|
||||
ioctl ( fd, CIMIO_SELECT_SENSOR, sinfo.sensor_id );
|
||||
|
||||
ioctl ( fd, CIMIO_GET_SENSORINFO, &sinfo );
|
||||
|
||||
ioctl ( fd, CIMIO_SET_TLB_BASE, tlb_base_phys ); //?????????
|
||||
|
||||
int i = 0;
|
||||
|
||||
if ( pre_buf.common && pre_buf.common->data )
|
||||
{
|
||||
dmmu_unmap_user_memory ( & ( pre_buf.dmmu_info ) );
|
||||
free ( pre_buf.common->data );
|
||||
}
|
||||
|
||||
pre_buf.fd = fd;
|
||||
pre_buf.nr = 5;
|
||||
pre_buf.size = pre_size.w * pre_size.h * 3;
|
||||
pre_buf.common = &pre_memory;
|
||||
pre_buf.common->size = pre_buf.size * pre_buf.nr;
|
||||
pre_buf.common->data = memalign ( 4096, pre_buf.size * pre_buf.nr );
|
||||
memset ( pre_buf.common->data, 0xa5, ( pre_buf.size * pre_buf.nr ) );
|
||||
|
||||
if ( pre_buf.common->data == NULL )
|
||||
{
|
||||
printf ( "==<%s L%d: null pointer!\n", __func__, __LINE__ );
|
||||
return false;
|
||||
}
|
||||
|
||||
pre_buf.paddr = 0;
|
||||
pre_buf.dmmu_info.vaddr = pre_buf.common->data;
|
||||
pre_buf.dmmu_info.size = pre_buf.common->size;
|
||||
|
||||
for ( i = 0; i < ( int ) ( pre_buf.common->size ); i += 0x1000 )
|
||||
{
|
||||
( ( uint8_t* ) ( pre_buf.common->data ) ) [i] = 0xff;
|
||||
}
|
||||
|
||||
( ( uint8_t* ) ( pre_buf.common->data ) ) [pre_buf.common->size - 1] = 0xff;
|
||||
dmmu_map_user_memory ( & ( pre_buf.dmmu_info ) );
|
||||
|
||||
for ( i = 0; i < pre_buf.nr; ++i )
|
||||
{
|
||||
pre_buf.yuvMeta[i].index = i;
|
||||
pre_buf.yuvMeta[i].width = pre_size.w;
|
||||
pre_buf.yuvMeta[i].height = pre_size.h;
|
||||
pre_buf.yuvMeta[i].format = format;
|
||||
pre_buf.yuvMeta[i].count = pre_buf.nr;
|
||||
#ifdef __LINUX64__
|
||||
pre_buf.yuvMeta[i].yAddr = ( int64_t ) pre_buf.common->data + ( pre_buf.size ) * i;
|
||||
#else
|
||||
pre_buf.yuvMeta[i].yAddr = ( int32_t ) pre_buf.common->data + ( pre_buf.size ) * i;
|
||||
#endif
|
||||
pre_buf.yuvMeta[i].yPhy = pre_buf.paddr + i * ( pre_buf.size );
|
||||
|
||||
if ( pre_buf.yuvMeta[i].format == HAL_PIXEL_FORMAT_YCbCr_422_I ) //yuv422 packed
|
||||
{
|
||||
pre_buf.yuvMeta[i].uAddr = pre_buf.yuvMeta[i].yAddr;
|
||||
pre_buf.yuvMeta[i].vAddr = pre_buf.yuvMeta[i].uAddr;
|
||||
pre_buf.yuvMeta[i].uPhy = pre_buf.yuvMeta[i].yPhy;
|
||||
pre_buf.yuvMeta[i].vPhy = pre_buf.yuvMeta[i].uPhy;
|
||||
pre_buf.yuvMeta[i].yStride = pre_buf.yuvMeta[i].width << 1;
|
||||
pre_buf.yuvMeta[i].uStride = pre_buf.yuvMeta[i].yStride;
|
||||
pre_buf.yuvMeta[i].vStride = pre_buf.yuvMeta[i].yStride;
|
||||
}
|
||||
else if ( pre_buf.yuvMeta[i].format == HAL_PIXEL_FORMAT_JZ_YUV_420_P ) //yuv420 planar
|
||||
{
|
||||
pre_buf.yuvMeta[i].uAddr = pre_buf.yuvMeta[i].yAddr + pre_size.w * pre_size.h;
|
||||
pre_buf.yuvMeta[i].vAddr = pre_buf.yuvMeta[i].uAddr + pre_size.w * pre_size.h / 4;
|
||||
pre_buf.yuvMeta[i].uPhy = pre_buf.yuvMeta[i].yPhy + pre_size.w * pre_size.h;
|
||||
pre_buf.yuvMeta[i].vPhy = pre_buf.yuvMeta[i].uPhy + pre_size.w * pre_size.h / 4;
|
||||
pre_buf.yuvMeta[i].yStride = pre_buf.yuvMeta[i].width << 1;
|
||||
pre_buf.yuvMeta[i].uStride = pre_buf.yuvMeta[i].width / 2;
|
||||
pre_buf.yuvMeta[i].vStride = pre_buf.yuvMeta[i].width / 2;
|
||||
}
|
||||
else if ( pre_buf.yuvMeta[i].format == HAL_PIXEL_FORMAT_RAW_SENSOR ) //raw bayer
|
||||
{
|
||||
pre_buf.yuvMeta[i].uAddr = pre_buf.yuvMeta[i].yAddr + pre_size.w * pre_size.h;
|
||||
pre_buf.yuvMeta[i].vAddr = pre_buf.yuvMeta[i].uAddr;
|
||||
pre_buf.yuvMeta[i].uPhy = pre_buf.yuvMeta[i].yPhy;
|
||||
pre_buf.yuvMeta[i].vPhy = pre_buf.yuvMeta[i].uPhy;
|
||||
pre_buf.yuvMeta[i].yStride = pre_buf.yuvMeta[i].width;
|
||||
pre_buf.yuvMeta[i].uStride = pre_buf.yuvMeta[i].yStride;
|
||||
pre_buf.yuvMeta[i].vStride = pre_buf.yuvMeta[i].yStride;
|
||||
}
|
||||
}
|
||||
|
||||
ioctl ( fd, CIMIO_SET_PREVIEW_FMT, format );
|
||||
ioctl ( fd, CIMIO_SET_PREVIEW_SIZE, &pre_size );
|
||||
|
||||
ioctl ( fd, CIMIO_SET_PREVIEW_MEM, ( unsigned long ) ( pre_buf.yuvMeta ) );
|
||||
|
||||
ioctl ( fd, CIMIO_START_PREVIEW );
|
||||
|
||||
pp = ( unsigned char* ) malloc ( pre_size.w * pre_size.h * 3 * sizeof ( char ) );
|
||||
frame = new QImage ( pp, pre_size.w, pre_size.h, QImage::Format_RGB888 );
|
||||
timer->start ( 100 );
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int QQtLogicVideoManager::close()
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if ( fd <= 0 )
|
||||
printf ( "fd < 0\n" );
|
||||
|
||||
ret = ioctl ( fd, CIMIO_SHUTDOWN );
|
||||
|
||||
::close ( fd );
|
||||
fd = 0;
|
||||
|
||||
dmmu_unmap_user_memory ( & ( pre_buf.dmmu_info ) );
|
||||
dmmu_deinit();
|
||||
|
||||
memset ( pre_buf.yuvMeta, 0, pre_buf.nr * sizeof ( CameraYUVMeta ) );
|
||||
pre_buf.size = 0;
|
||||
pre_buf.nr = 0;
|
||||
pre_buf.paddr = 0;
|
||||
pre_buf.fd = -1;
|
||||
|
||||
if ( ( pre_buf.common != NULL ) && ( pre_buf.common->data != NULL ) )
|
||||
{
|
||||
free ( pre_buf.common->data );
|
||||
pre_buf.common->data = NULL;
|
||||
}
|
||||
|
||||
phys = 0;
|
||||
|
||||
timer->stop();
|
||||
free ( pp );
|
||||
delete frame;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int QQtLogicVideoManager::convert_yuv_to_rgb_pixel ( int y, int u, int v )
|
||||
{
|
||||
unsigned int pixel32 = 0;
|
||||
unsigned char* pixel = ( unsigned char* ) &pixel32;
|
||||
int r, g, b;
|
||||
b = y + ( ( 443 * ( u - 128 ) ) >> 8 );
|
||||
b = ( b < 0 ) ? 0 : ( ( b > 255 ) ? 255 : b );
|
||||
g = y - ( ( 179 * ( v - 128 ) + 86 * ( u - 128 ) ) >> 8 );
|
||||
g = ( g < 0 ) ? 0 : ( ( g > 255 ) ? 255 : g );
|
||||
r = y + ( ( 351 * ( v - 128 ) ) >> 8 );
|
||||
r = ( r < 0 ) ? 0 : ( ( r > 255 ) ? 255 : r );
|
||||
pixel[0] = r;
|
||||
pixel[1] = g;
|
||||
pixel[2] = b;
|
||||
return pixel32;
|
||||
}
|
||||
|
||||
int QQtLogicVideoManager::convert_yuv_to_rgb_buffer ( unsigned char* yuv, unsigned char* rgb, unsigned int width,
|
||||
unsigned int height )
|
||||
{
|
||||
unsigned int in, out = 0;
|
||||
unsigned int pixel_16;
|
||||
unsigned char pixel_24[3];
|
||||
unsigned int pixel32;
|
||||
int y0, u, y1, v;
|
||||
|
||||
for ( in = 0; in < width * height * 2; in += 4 )
|
||||
{
|
||||
pixel_16 =
|
||||
yuv[in + 3] << 24 |
|
||||
yuv[in + 2] << 16 |
|
||||
yuv[in + 1] << 8 |
|
||||
yuv[in + 0];
|
||||
y0 = ( pixel_16 & 0x000000ff );
|
||||
u = ( pixel_16 & 0x0000ff00 ) >> 8;
|
||||
y1 = ( pixel_16 & 0x00ff0000 ) >> 16;
|
||||
v = ( pixel_16 & 0xff000000 ) >> 24;
|
||||
pixel32 = convert_yuv_to_rgb_pixel ( y0, u, v );
|
||||
pixel_24[0] = ( pixel32 & 0x000000ff );
|
||||
pixel_24[1] = ( pixel32 & 0x0000ff00 ) >> 8;
|
||||
pixel_24[2] = ( pixel32 & 0x00ff0000 ) >> 16;
|
||||
rgb[out++] = pixel_24[0];
|
||||
rgb[out++] = pixel_24[1];
|
||||
rgb[out++] = pixel_24[2];
|
||||
pixel32 = convert_yuv_to_rgb_pixel ( y1, u, v );
|
||||
pixel_24[0] = ( pixel32 & 0x000000ff );
|
||||
pixel_24[1] = ( pixel32 & 0x0000ff00 ) >> 8;
|
||||
pixel_24[2] = ( pixel32 & 0x00ff0000 ) >> 16;
|
||||
rgb[out++] = pixel_24[0];
|
||||
rgb[out++] = pixel_24[1];
|
||||
rgb[out++] = pixel_24[2];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void QQtLogicVideoManager::paintEvent ( QPaintEvent* )
|
||||
{
|
||||
if ( fd <= 0 )
|
||||
return;
|
||||
|
||||
QStylePainter painter ( this );
|
||||
|
||||
/*
|
||||
* 此处采集视频为多线程采集 上边的log证明 数据已经被修改
|
||||
*/
|
||||
addr = ioctl ( fd, CIMIO_GET_FRAME );
|
||||
p = ( uchar* ) addr;
|
||||
|
||||
/*
|
||||
* 不具备优化能力,yuv缺少alpha。
|
||||
*/
|
||||
convert_yuv_to_rgb_buffer ( p, pp, pre_size.w, pre_size.h );
|
||||
//frame->loadFromData((uchar *)pp, w * h * 3 * sizeof(char));
|
||||
/*
|
||||
* 采集的图像左边上边有黑边 更换摄像头或许回有所改善 待调试
|
||||
*/
|
||||
QRect srcRect ( 2, 6, pre_size.w, pre_size.h );
|
||||
QRect dstRect = rect();
|
||||
painter.scale ( 1.01, 1.02 );
|
||||
/*
|
||||
* 缩放OK
|
||||
*/
|
||||
painter.drawImage ( dstRect, *frame, srcRect );
|
||||
//painter.drawPixmap(dstRect,QPixmap::fromImage(*frame,Qt::AutoColor),srcRect);;
|
||||
/*
|
||||
* 裁切OK
|
||||
*/
|
||||
//painter.drawItemPixmap(srcRect, Qt::AlignCenter, QPixmap::fromImage(*frame,Qt::AutoColor));
|
||||
/*
|
||||
* 30ms 屏幕有闪烁
|
||||
*/
|
||||
//update();
|
||||
}
|
||||
|
||||
|
||||
void QQtLogicVideoManager::mousePressEvent ( QMouseEvent* e )
|
||||
{
|
||||
static bool bGInit = false;
|
||||
|
||||
if ( !bGInit && !bFullScreen )
|
||||
{
|
||||
flags = windowFlags();
|
||||
flags |= Qt::FramelessWindowHint;
|
||||
geome = geometry();
|
||||
bGInit = true;
|
||||
}
|
||||
|
||||
#ifdef __EMBEDDED_LINUX__
|
||||
|
||||
//pline() << e->pos() << e->globalPos();
|
||||
if ( e->pos().x() < 0 || e->pos().y() < 0 ||
|
||||
e->pos().x() > geome.width() || e->pos().y() > geome.height() )
|
||||
{
|
||||
//在mips板上,全屏返回的时候,点击其他位置,会多响应一次,在此处过滤。
|
||||
pline() << "warning!";
|
||||
Q_UNUSED ( e );
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
setAttribute ( Qt::WA_TranslucentBackground, true );
|
||||
setAttribute ( Qt::WA_NoMousePropagation, true );
|
||||
setAttribute ( Qt::WA_OpaquePaintEvent, true );
|
||||
|
||||
if ( bFullScreen )
|
||||
{
|
||||
flags ^= Qt::Window;
|
||||
flags |= Qt::Widget;
|
||||
setParent ( m_parent, flags );
|
||||
setGeometry ( geome );
|
||||
show();
|
||||
bFullScreen = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int QQT_SCRN_WIDTH = QApplication::desktop()->availableGeometry().width();
|
||||
int QQT_SCRN_HEIGHT = QApplication::desktop()->availableGeometry().height();
|
||||
flags ^= Qt::Widget;
|
||||
flags |= Qt::Window;
|
||||
setParent ( 0, flags );
|
||||
setGeometry ( 0, 0, QQT_SCRN_WIDTH, QQT_SCRN_HEIGHT );
|
||||
show();
|
||||
bFullScreen = true;
|
||||
}
|
||||
|
||||
pline() << flags;
|
||||
QWidget::mousePressEvent ( e );
|
||||
}
|
75
src/multimedia/qqtlogicvideomanager.h
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
#ifndef QQTLOGICVIDEOMANAGER_H
|
||||
#define QQTLOGICVIDEOMANAGER_H
|
||||
|
||||
#include "qqt-qt.h"
|
||||
#include "qqtlinux.h"
|
||||
#include "qqtcore.h"
|
||||
#include "qqt-local.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "graphics.h"
|
||||
#include "dmmu.h"
|
||||
#include "hal.h"
|
||||
#include "jz_cim.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/**
|
||||
* @brief The QQtLogicVideoManager class
|
||||
* QQt模拟摄像头预览控件
|
||||
* 省略dmmu的Qt Wrapper类
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtLogicVideoManager : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtLogicVideoManager ( QWidget* parent = 0 );
|
||||
~QQtLogicVideoManager();
|
||||
int play();
|
||||
int close();
|
||||
|
||||
private:
|
||||
Ui::QQtLogicVideoManager* ui;
|
||||
|
||||
struct sensor_info sinfo;
|
||||
int pre_bpp;
|
||||
int rate; /* default to 15fps */
|
||||
unsigned int addr;
|
||||
unsigned int phys;
|
||||
|
||||
int fd;
|
||||
int format;
|
||||
|
||||
struct camera_memory pre_memory;
|
||||
struct camera_buffer pre_buf;
|
||||
struct frm_size pre_size;
|
||||
unsigned int tlb_base_phys;
|
||||
|
||||
uchar* pp;
|
||||
uchar* p;
|
||||
QImage* frame;
|
||||
QTimer* timer;
|
||||
|
||||
bool bFullScreen;
|
||||
QWidget* m_parent;
|
||||
QRect geome;
|
||||
Qt::WindowFlags flags;
|
||||
|
||||
int convert_yuv_to_rgb_pixel ( int y, int u, int v );
|
||||
int convert_yuv_to_rgb_buffer ( unsigned char* yuv, unsigned char* rgb, unsigned int width, unsigned int height );
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void paintEvent ( QPaintEvent* );
|
||||
void mousePressEvent ( QMouseEvent* e );
|
||||
};
|
||||
|
||||
#endif // QQTLOGICVIDEOMANAGER_H
|
497
src/multimedia/qqtvideomanager.cpp
Normal file
@ -0,0 +1,497 @@
|
||||
#include <qqtvideomanager.h>
|
||||
#include <qqtcore.h>
|
||||
|
||||
QQtCameraVideoSurface::QQtCameraVideoSurface ( QObject* parent ) : QAbstractVideoSurface ( parent )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QQtCameraVideoSurface::~QQtCameraVideoSurface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QList<QVideoFrame::PixelFormat> QQtCameraVideoSurface::supportedPixelFormats ( QAbstractVideoBuffer::HandleType handleType ) const
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
//Android NV21
|
||||
return QList<QVideoFrame::PixelFormat>()
|
||||
<< QVideoFrame::Format_NV21;
|
||||
#endif
|
||||
|
||||
//桌面
|
||||
return QList<QVideoFrame::PixelFormat>()
|
||||
<< QVideoFrame::Format_RGB24
|
||||
<< QVideoFrame::Format_RGB32;
|
||||
}
|
||||
|
||||
bool QQtCameraVideoSurface::present ( const QVideoFrame& frame )
|
||||
{
|
||||
if ( !frame.isValid() )
|
||||
return false;
|
||||
|
||||
QVideoFrame cloneFrame ( frame );
|
||||
/**
|
||||
* frame 可读
|
||||
*/
|
||||
if ( !cloneFrame.map ( QAbstractVideoBuffer::ReadOnly ) )
|
||||
return false;
|
||||
|
||||
/**
|
||||
* 处理frame
|
||||
*/
|
||||
|
||||
//Android下的视频格式是怎么回事?需要转换吗?
|
||||
|
||||
const QImage _image ( cloneFrame.bits(),
|
||||
cloneFrame.width(),
|
||||
cloneFrame.height(),
|
||||
QVideoFrame::imageFormatFromPixelFormat ( cloneFrame.pixelFormat() ) );
|
||||
|
||||
//需要对水平方向反转。
|
||||
//Windows,现在的图像保存能成功,直接显示,程序会异常退出。使用QImage的mirrored函数进行了水平翻转,可以正常显示。
|
||||
//水平翻转是为了不崩溃,正常显示图像。必选。
|
||||
//垂直翻转是为了上下显示正常。
|
||||
const QImage image = _image.mirrored ( true, true );
|
||||
|
||||
/**
|
||||
* frame 不可读
|
||||
*/
|
||||
cloneFrame.unmap();
|
||||
|
||||
emit readyRead ( image );
|
||||
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 QQtVideoProbe ( this );
|
||||
connect ( mSurface, SIGNAL ( readyRead ( QImage ) ), this, SIGNAL ( readyRead ( QImage ) ) );
|
||||
connect ( mSurface, SIGNAL ( readyRead ( QImage ) ), this, SLOT ( slotImageCaptured ( QImage ) ) );
|
||||
|
||||
/**
|
||||
* 设置照相机
|
||||
*/
|
||||
mCamera = new QQtCamera ( this );
|
||||
|
||||
//QQtCamera 默认就是使用默认照相机,所以,这里不必设置了。
|
||||
mCamInfo = defaultCamera();
|
||||
mCamera->setCameraInfo ( mCamInfo );
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
mSurface->setMediaObject ( mCamera->camera() );
|
||||
#else
|
||||
mCamera->setViewfinder ( mSurface );
|
||||
#endif
|
||||
|
||||
//
|
||||
mExposure = new QQtCameraExposure ( this );
|
||||
mFocus = new QQtCameraFocus ( this );
|
||||
mImageProcessing = new QQtCameraImageProcessing ( this );
|
||||
mExposure->setCameraExposure ( mCamera->exposure() );
|
||||
mFocus->setCameraFocus ( mCamera->focus() );
|
||||
mImageProcessing->setCameraImageProcessing ( mCamera->imageProcessing() );
|
||||
|
||||
mAutoSearchMilliSeconds = 200;
|
||||
mAutoSearchTimer = new QTimer ( this );
|
||||
connect ( mAutoSearchTimer, SIGNAL ( timeout() ), this, SLOT ( slotTimeout() ) );
|
||||
mAutoSearchTimer->setInterval ( mAutoSearchMilliSeconds );
|
||||
mAutoSearchTimer->setSingleShot ( false );
|
||||
|
||||
//默认开启自动对焦
|
||||
mAutoSearchFlag = true ;
|
||||
//默认不截图
|
||||
mCaptureFlag = false;
|
||||
}
|
||||
|
||||
QQtVideoInput::~QQtVideoInput()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QCameraInfo QQtVideoInput::defaultCamera()
|
||||
{
|
||||
return QCameraInfo::defaultCamera();
|
||||
}
|
||||
|
||||
QList<QCameraInfo> QQtVideoInput::availableCameras ( QCamera::Position position )
|
||||
{
|
||||
return QCameraInfo::availableCameras ( position );
|
||||
}
|
||||
|
||||
QCameraInfo& QQtVideoInput::cameraInfo()
|
||||
{
|
||||
return mCamInfo;
|
||||
}
|
||||
|
||||
QCameraViewfinderSettings QQtVideoInput::viewFinderSettings()
|
||||
{
|
||||
if ( !mCamera )
|
||||
return QCameraViewfinderSettings();
|
||||
return mCamera->viewfinderSettings();
|
||||
}
|
||||
|
||||
void QQtVideoInput::setViewfinderSettings ( const QCameraViewfinderSettings& settings )
|
||||
{
|
||||
if ( !mCamera )
|
||||
return;
|
||||
mCamera->setViewfinderSettings ( settings );
|
||||
}
|
||||
|
||||
QList<QCameraViewfinderSettings> QQtVideoInput::supportedViewFinderSettings ( const QCameraInfo& camInfo )
|
||||
{
|
||||
QCamera camera ( camInfo );
|
||||
return camera.supportedViewfinderSettings();
|
||||
}
|
||||
|
||||
QQtCamera* QQtVideoInput::camera() const
|
||||
{
|
||||
return mCamera;
|
||||
}
|
||||
|
||||
QQtCameraExposure* QQtVideoInput::expose() const
|
||||
{
|
||||
return mExposure;
|
||||
}
|
||||
|
||||
QQtCameraFocus* QQtVideoInput::focus() const
|
||||
{
|
||||
return mFocus;
|
||||
}
|
||||
|
||||
QQtCameraImageProcessing* QQtVideoInput::imageProcessing() const
|
||||
{
|
||||
return mImageProcessing;
|
||||
}
|
||||
|
||||
void QQtVideoInput::start()
|
||||
{
|
||||
stop();
|
||||
|
||||
//初始化截图Flag
|
||||
mCaptureFlag = false;
|
||||
|
||||
//初始化照相机句柄
|
||||
mCamera->setCameraInfo ( mCamInfo );
|
||||
|
||||
//初始化照相机图像控制句柄
|
||||
mExposure->setCameraExposure ( mCamera->exposure() );
|
||||
mFocus->setCameraFocus ( mCamera->focus() );
|
||||
mImageProcessing->setCameraImageProcessing ( mCamera->imageProcessing() );
|
||||
|
||||
/**
|
||||
* 设置相机
|
||||
* 程序内部持续使用Capture Video。
|
||||
*/
|
||||
//Windows 打印不支持,但是其实支持。
|
||||
if ( !mCamera->isCaptureModeSupported ( QCamera::CaptureVideo ) )
|
||||
{
|
||||
pline() << mCamInfo.deviceName();
|
||||
//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
|
||||
//启动后设置...
|
||||
|
||||
//启动
|
||||
mCamera->start();
|
||||
pline() << mCamInfo.deviceName();
|
||||
pline() << mCamera << "Camera start to capture video";
|
||||
|
||||
//设置自动对焦
|
||||
if ( mAutoSearchFlag )
|
||||
mAutoSearchTimer->start();
|
||||
}
|
||||
|
||||
void QQtVideoInput::stop()
|
||||
{
|
||||
mAutoSearchTimer->stop();
|
||||
|
||||
if ( mCamera )
|
||||
{
|
||||
mCamera->stop();
|
||||
//mCamera->deleteLater();
|
||||
}
|
||||
|
||||
//mCamera = NULL;
|
||||
}
|
||||
|
||||
void QQtVideoInput::load()
|
||||
{
|
||||
mCamera->load();
|
||||
}
|
||||
|
||||
void QQtVideoInput::unload()
|
||||
{
|
||||
mCamera->unload();
|
||||
}
|
||||
|
||||
void QQtVideoInput::startDefaultCamera()
|
||||
{
|
||||
mCamInfo = defaultCamera();
|
||||
start();
|
||||
}
|
||||
|
||||
void QQtVideoInput::setPrepareInterval ( int milliSeconds )
|
||||
{
|
||||
mAutoSearchMilliSeconds = milliSeconds;
|
||||
}
|
||||
|
||||
int QQtVideoInput::prepareInterval() const
|
||||
{
|
||||
return mAutoSearchMilliSeconds;
|
||||
}
|
||||
|
||||
void QQtVideoInput::capture()
|
||||
{
|
||||
//现在使用截图Flag,将来可能要使用ImageCapture类,可以调整Shutter速度。
|
||||
//对外提供一个简化的截图功能。
|
||||
QMutexLocker locker ( &mMutexCaptureFlag );
|
||||
mCaptureFlag = true;
|
||||
}
|
||||
|
||||
void QQtVideoInput::setAutoPrepare ( bool autosearch )
|
||||
{
|
||||
mAutoSearchFlag = autosearch;
|
||||
|
||||
if ( autosearch )
|
||||
mAutoSearchTimer->start();
|
||||
else
|
||||
mAutoSearchTimer->stop();
|
||||
}
|
||||
|
||||
void QQtVideoInput::prepare ( QCamera::LockTypes locks )
|
||||
{
|
||||
if ( !mCamera )
|
||||
return;
|
||||
mCamera->searchAndLock ( locks );
|
||||
}
|
||||
|
||||
void QQtVideoInput::cancelPrepare ( QCamera::LockTypes locks )
|
||||
{
|
||||
if ( !mCamera )
|
||||
return;
|
||||
mCamera->unlock();
|
||||
}
|
||||
|
||||
void QQtVideoInput::slotTimeout()
|
||||
{
|
||||
if ( !mCamera )
|
||||
return;
|
||||
mCamera->searchAndLock();
|
||||
}
|
||||
|
||||
void QQtVideoInput::slotImageCaptured ( QImage image )
|
||||
{
|
||||
QMutexLocker locker ( &mMutexCaptureFlag );
|
||||
|
||||
if ( !mCaptureFlag )
|
||||
return;
|
||||
mCaptureFlag = false;
|
||||
|
||||
emit readyReadCapture ( image );
|
||||
}
|
||||
|
||||
QQtVideoOutput::QQtVideoOutput ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
mWidget = 0;
|
||||
mStartFlag = false;
|
||||
}
|
||||
|
||||
QQtVideoOutput::~QQtVideoOutput() {}
|
||||
|
||||
QQtWidget*& QQtVideoOutput::viewFinder()
|
||||
{
|
||||
return mWidget;
|
||||
}
|
||||
|
||||
void QQtVideoOutput::start()
|
||||
{
|
||||
QMutexLocker locker ( &mMutexStartFlag );
|
||||
mStartFlag = true;
|
||||
}
|
||||
|
||||
void QQtVideoOutput::stop()
|
||||
{
|
||||
QMutexLocker locker ( &mMutexStartFlag );
|
||||
mStartFlag = false;
|
||||
}
|
||||
|
||||
void QQtVideoOutput::setPixmap ( QImage image )
|
||||
{
|
||||
QMutexLocker locker ( &mMutexStartFlag );
|
||||
if ( !mStartFlag )
|
||||
return;
|
||||
if ( !mWidget )
|
||||
return;
|
||||
mWidget->setPixmap ( image );
|
||||
}
|
||||
|
||||
QQtVideoManager::QQtVideoManager ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
mInput = new QQtVideoInput ( this );
|
||||
mOutput = new QQtVideoOutput ( this );
|
||||
|
||||
connect ( mInput, SIGNAL ( readyRead ( QImage ) ), this, SIGNAL ( readyRead ( QImage ) ) );
|
||||
connect ( mInput, SIGNAL ( readyReadCapture ( QImage ) ), this, SIGNAL ( readyReadCapture ( QImage ) ) );
|
||||
}
|
||||
|
||||
QQtVideoManager::~QQtVideoManager() {}
|
||||
|
||||
QCameraInfo QQtVideoManager::defaultCamera()
|
||||
{
|
||||
return QQtVideoInput::defaultCamera();
|
||||
}
|
||||
|
||||
QList<QCameraInfo> QQtVideoManager::availableCameras ( QCamera::Position position )
|
||||
{
|
||||
return QQtVideoInput::availableCameras ( position );
|
||||
}
|
||||
|
||||
QCameraInfo& QQtVideoManager::cameraInfo()
|
||||
{
|
||||
return mInput->cameraInfo();
|
||||
}
|
||||
|
||||
QQtWidget*& QQtVideoManager::viewFinder() const
|
||||
{
|
||||
return mOutput->viewFinder();
|
||||
}
|
||||
|
||||
QCameraViewfinderSettings QQtVideoManager::viewFinderSettings() const
|
||||
{
|
||||
return mInput->viewFinderSettings();
|
||||
}
|
||||
|
||||
void QQtVideoManager::setViewfinderSettings ( const QCameraViewfinderSettings& settings )
|
||||
{
|
||||
return mInput->setViewfinderSettings ( settings );
|
||||
}
|
||||
|
||||
QList<QCameraViewfinderSettings> QQtVideoManager::supportedViewFinderSettings()
|
||||
{
|
||||
return mInput->supportedViewFinderSettings();
|
||||
}
|
||||
|
||||
QQtCamera* QQtVideoManager::camera() const
|
||||
{
|
||||
return mInput->camera();
|
||||
}
|
||||
|
||||
QQtCameraExposure* QQtVideoManager::expose() const
|
||||
{
|
||||
return mInput->expose();
|
||||
}
|
||||
|
||||
QQtCameraFocus* QQtVideoManager::focus() const
|
||||
{
|
||||
return mInput->focus();
|
||||
}
|
||||
|
||||
QQtCameraImageProcessing* QQtVideoManager::imageProcessing() const
|
||||
{
|
||||
return mInput->imageProcessing();
|
||||
}
|
||||
|
||||
void QQtVideoManager::startInput()
|
||||
{
|
||||
mInput->start();
|
||||
}
|
||||
|
||||
void QQtVideoManager::stopInput()
|
||||
{
|
||||
mInput->stop();
|
||||
}
|
||||
|
||||
QQtVideoInput* QQtVideoManager::inputManager()
|
||||
{
|
||||
return mInput;
|
||||
}
|
||||
|
||||
void QQtVideoManager::startOutput()
|
||||
{
|
||||
mOutput->start();
|
||||
}
|
||||
|
||||
void QQtVideoManager::stopOutput()
|
||||
{
|
||||
mOutput->stop();
|
||||
}
|
||||
|
||||
QQtVideoOutput* QQtVideoManager::outputManager()
|
||||
{
|
||||
return mOutput;
|
||||
}
|
||||
|
||||
void QQtVideoManager::startDefaultInput()
|
||||
{
|
||||
mInput->startDefaultCamera();
|
||||
}
|
||||
|
||||
void QQtVideoManager::startDefaultOutput()
|
||||
{
|
||||
mOutput->start();
|
||||
}
|
||||
|
||||
void QQtVideoManager::capture()
|
||||
{
|
||||
mInput->capture();
|
||||
}
|
||||
|
||||
void QQtVideoManager::outputImage ( QImage image )
|
||||
{
|
||||
mOutput->setPixmap ( image );
|
||||
}
|
300
src/multimedia/qqtvideomanager.h
Normal file
@ -0,0 +1,300 @@
|
||||
#ifndef QQTVIDEOMANAGER_H
|
||||
#define QQTVIDEOMANAGER_H
|
||||
|
||||
#include <QCamera>
|
||||
#include <QCameraInfo>
|
||||
#include <QCameraImageCapture>
|
||||
#include <QAbstractVideoSurface>
|
||||
#include <QVideoSurfaceFormat>
|
||||
#include <QCameraViewfinderSettings>
|
||||
#include <QVideoProbe>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
|
||||
#include <qqt-local.h>
|
||||
|
||||
#include <qqtwidget.h>
|
||||
|
||||
#include <qqtcamera.h>
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------------------------------------------------------------
|
||||
* | 使用方式 | Parent | Property Class | Childen | 备注
|
||||
* ---------------------------------------------------------------------------------------------------------------------
|
||||
* | setViewfinder | QAbstractVideoSurface | QQtCameraVideoSurface | | 视频,快,Buffer
|
||||
* | | | | QQtVideoProbe | 视频,快,Buffer,+Android支持
|
||||
* ---------------------------------------------------------------------------------------------------------------------
|
||||
* | setViewfinder | QMediaBindableInterface | QGraphicsVideoItem | | QGraphicsItem 系统专用
|
||||
* | | | QVideoWidget | QCameraViewfinder | 视频,快,属于输出位置上的
|
||||
* ---------------------------------------------------------------------------------------------------------------------
|
||||
* | setMetaObject | QMediaBindableInterface | QCameraImageCapture | | 截图,慢,默认保存文件
|
||||
* | | | QMediaRecorder | QAudioRecorder | 录像,快,保存文件,音视频
|
||||
* ---------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* 功能:
|
||||
* 对视频设备进行管理。
|
||||
* 输入:摄像头
|
||||
* 输出:绘图设备(窗口)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief The QQtVideoSurface class
|
||||
* 从metaObject获取视频数据,帧。
|
||||
* Buffer,快速。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtCameraVideoSurface : public QAbstractVideoSurface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQtCameraVideoSurface ( QObject* parent = 0 );
|
||||
virtual ~QQtCameraVideoSurface();
|
||||
|
||||
signals:
|
||||
void readyRead ( QImage );
|
||||
|
||||
// QAbstractVideoSurface interface
|
||||
public:
|
||||
virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats ( QAbstractVideoBuffer::HandleType handleType ) const override;
|
||||
virtual bool present ( const QVideoFrame& frame ) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The QQtVideoProbe class
|
||||
* 这是个数字摄像机管理器,这个类是为Android等需要Probe的数字录像设备准备的。
|
||||
* 我在VideoManager内部使用这个类来兼容桌面和Android系统,
|
||||
* 但是我发现,无论如何Probe在Android上都不能正常执行,所以现在暂时不支持Android。
|
||||
* Qt5.9.2,何时支持,待定。
|
||||
*/
|
||||
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
|
||||
* 图像输入
|
||||
* 从照相机输入,输出QImage序。
|
||||
* 从照相机输入,支持截图,输出QImage。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtVideoInput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQtVideoInput ( QObject* parent = 0 );
|
||||
virtual ~QQtVideoInput();
|
||||
|
||||
/**
|
||||
* 选择输入设备
|
||||
*/
|
||||
static QCameraInfo defaultCamera();
|
||||
static QList<QCameraInfo> availableCameras ( QCamera::Position position = QCamera::UnspecifiedPosition );
|
||||
//决定使用哪个Camera
|
||||
//QQtVideoInput不会立即生效,只有在开启后才会生效。
|
||||
QCameraInfo& cameraInfo ( void );
|
||||
|
||||
/**
|
||||
* 选择输入格式,启动后设置。
|
||||
*/
|
||||
QCameraViewfinderSettings viewFinderSettings();
|
||||
//设置采集的图像的PixFormat,帧率等信息。
|
||||
void setViewfinderSettings ( const QCameraViewfinderSettings& settings = QCameraViewfinderSettings() );
|
||||
//获取照相机支持的设置。默认查询defaultCamera的。
|
||||
static QList<QCameraViewfinderSettings> supportedViewFinderSettings ( const QCameraInfo& camInfo = defaultCamera() );
|
||||
|
||||
/**
|
||||
* 控制输入设备
|
||||
*/
|
||||
QQtCamera* camera() const;
|
||||
QQtCameraExposure* expose() const;
|
||||
QQtCameraFocus* focus() const;
|
||||
QQtCameraImageProcessing* imageProcessing() const;
|
||||
|
||||
public slots:
|
||||
void start();
|
||||
void stop();
|
||||
void load();
|
||||
void unload();
|
||||
|
||||
void startDefaultCamera();
|
||||
|
||||
//自动对焦,手动对焦切换。默认,自动,200ms
|
||||
void setAutoPrepare ( bool autosearch = true );
|
||||
void setPrepareInterval ( int milliSeconds );
|
||||
int prepareInterval() const;
|
||||
|
||||
public slots:
|
||||
//用这个函数手动对焦。
|
||||
void prepare ( QCamera::LockTypes locks = QCamera::LockFocus );
|
||||
//放弃对焦、对焦停止、对焦完成
|
||||
void cancelPrepare ( QCamera::LockTypes locks = QCamera::LockFocus );
|
||||
|
||||
//截图
|
||||
void capture();
|
||||
|
||||
/**
|
||||
* 输出图像
|
||||
*/
|
||||
signals:
|
||||
//输出QImage序
|
||||
void readyRead ( QImage );
|
||||
//输出QImage
|
||||
void readyReadCapture ( QImage );
|
||||
|
||||
/**
|
||||
* 以下与用户无关
|
||||
*/
|
||||
private slots:
|
||||
void slotTimeout();
|
||||
void slotImageCaptured ( QImage );
|
||||
private:
|
||||
//经过调试,QCamera句柄,一个进程只能存在一个。
|
||||
QQtCamera* mCamera;
|
||||
QCameraInfo mCamInfo;
|
||||
QQtVideoProbe* mSurface;
|
||||
QQtCameraExposure* mExposure;
|
||||
QQtCameraFocus* mFocus;
|
||||
QQtCameraImageProcessing* mImageProcessing;
|
||||
|
||||
//自动对焦
|
||||
bool mAutoSearchFlag;
|
||||
QTimer* mAutoSearchTimer;
|
||||
int mAutoSearchMilliSeconds;
|
||||
|
||||
//需要加锁吗?如果用户把这个类 moveToThread,并且不使用信号和槽模式调用 capture,那么需要加锁。
|
||||
QMutex mMutexCaptureFlag;
|
||||
bool mCaptureFlag;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The QQtVideoOutput class
|
||||
* 视频输出
|
||||
* 把QImage输出到取景器。
|
||||
* QWidget、QQtWidget都能完成。QVideoWidget QCameraViewfinder QGraphicsVideoItem这些需要QCamera。
|
||||
* QCamera可以有多个吗?各自设置不同的?不可以。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtVideoOutput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQtVideoOutput ( QObject* parent = 0 );
|
||||
virtual ~QQtVideoOutput();
|
||||
|
||||
/**
|
||||
* 设置输出设备
|
||||
*/
|
||||
QQtWidget*& viewFinder();
|
||||
|
||||
/**
|
||||
* 控制输出设备
|
||||
*/
|
||||
public slots:
|
||||
//开启后才能使用。
|
||||
void start();
|
||||
//关闭后停止显示。
|
||||
void stop();
|
||||
//对窗口输出图像。
|
||||
void setPixmap ( QImage image );
|
||||
|
||||
private:
|
||||
QQtWidget* mWidget;
|
||||
//需要加锁吗?如果用户把这个类 moveToThread,并且不使用信号和槽模式调用 start stop,那么需要加锁。
|
||||
QMutex mMutexStartFlag;
|
||||
bool mStartFlag;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The QQtVideoManager class
|
||||
* 视频设备管理器
|
||||
* 输入:照相机
|
||||
* 输出:取景器。
|
||||
*
|
||||
* 功能:
|
||||
* 获取录像机的每一帧,输出给用户处理,
|
||||
* 提供输出设备的管理,辅助用户输出到确定的窗口。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtVideoManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQtVideoManager ( QObject* parent = 0 );
|
||||
virtual ~QQtVideoManager();
|
||||
|
||||
/**
|
||||
* 选择输入、输出设备
|
||||
*/
|
||||
static QCameraInfo defaultCamera();
|
||||
static QList<QCameraInfo> availableCameras ( QCamera::Position position = QCamera::UnspecifiedPosition );
|
||||
//输入设备信息
|
||||
QCameraInfo& cameraInfo ( void );
|
||||
//输出设备信息
|
||||
QQtWidget*& viewFinder ( void ) const;
|
||||
|
||||
/**
|
||||
* 设置输入、输出设备格式
|
||||
*/
|
||||
//输入设备设置
|
||||
QCameraViewfinderSettings viewFinderSettings() const;
|
||||
void setViewfinderSettings ( const QCameraViewfinderSettings& settings );
|
||||
QList<QCameraViewfinderSettings> supportedViewFinderSettings();
|
||||
//输入设备的格式,决定输出设备的格式。
|
||||
|
||||
/**
|
||||
* 控制输入、输出设备
|
||||
*/
|
||||
QQtCamera* camera() const;
|
||||
QQtCameraExposure* expose() const;
|
||||
QQtCameraFocus* focus() const;
|
||||
QQtCameraImageProcessing* imageProcessing() const;
|
||||
|
||||
QQtVideoInput* inputManager();
|
||||
QQtVideoOutput* outputManager();
|
||||
|
||||
public slots:
|
||||
void startInput();
|
||||
void stopInput();
|
||||
|
||||
void startOutput();
|
||||
void stopOutput();
|
||||
|
||||
void startDefaultInput();
|
||||
//等于start()。输出没有默认设备。
|
||||
void startDefaultOutput();
|
||||
|
||||
void capture();
|
||||
|
||||
/**
|
||||
* 输出图像
|
||||
*/
|
||||
signals:
|
||||
//从输入设备获得图像。用户处理这些图像。
|
||||
void readyRead ( QImage );
|
||||
void readyReadCapture ( QImage );
|
||||
|
||||
public slots:
|
||||
//把图像输出到输出设备。
|
||||
void outputImage ( QImage );
|
||||
|
||||
private:
|
||||
QQtVideoInput* mInput;
|
||||
QQtVideoOutput* mOutput;
|
||||
};
|
||||
|
||||
#endif // QQTVIDEOMANAGER_H
|
317
src/multimedia/qqtwavaudiomanager.cpp
Normal file
@ -0,0 +1,317 @@
|
||||
#include "qqtwavaudiomanager.h"
|
||||
#include "libqwav.h"
|
||||
|
||||
QQtWavAudioInput::QQtWavAudioInput ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
mTimer = new QTimer ( this );
|
||||
connect ( mTimer, SIGNAL ( timeout() ), SLOT ( slotTimeout() ) );
|
||||
|
||||
mFileBytes.clear();
|
||||
mBytes.clear();
|
||||
mBytesBuffer.setBuffer ( &mBytes );
|
||||
|
||||
mTimerInterval = 20;
|
||||
}
|
||||
|
||||
QIODevice* QQtWavAudioInput::setSourceFile ( const QString& localFile )
|
||||
{
|
||||
//如果开着,不管。
|
||||
mSourceFile = localFile;
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
|
||||
|
||||
//判断文件类型是否接受
|
||||
QMimeDatabase mimedb;
|
||||
QMimeType mimetype = mimedb.mimeTypeForFile ( mSourceFile );
|
||||
|
||||
if ( !QSoundEffect::supportedMimeTypes().contains ( mimetype.name(), Qt::CaseInsensitive ) )
|
||||
{
|
||||
pline() << "filename" << localFile << "mimetype" << mimetype.name()
|
||||
<< QSoundEffect::supportedMimeTypes().contains ( mimetype.name(), Qt::CaseInsensitive ) ;
|
||||
pline() << "can't play file";
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
//判断音频具体格式
|
||||
//支持qrc文件
|
||||
TWavFileInfo info;
|
||||
bool ret = anlysisWavFileHeader ( mSourceFile, mFormat, info );
|
||||
//仅仅支持本地文件
|
||||
//bool ret = anlysisWavFileHeader_C ( localFile );
|
||||
|
||||
if ( !ret )
|
||||
{
|
||||
pline() << "wav format parse fail";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mFileTotalSize = info.fileTotalSize;
|
||||
mFileHeaderSize = info.fileHeaderSize;
|
||||
mFileDataSize = info.fileDataSize;
|
||||
mFileTailSize = info.fileTailSize;
|
||||
|
||||
return &mBytesBuffer;
|
||||
}
|
||||
|
||||
void QQtWavAudioInput::setTimerInterval ( int millSecond ) { mTimerInterval = millSecond; }
|
||||
|
||||
|
||||
void QQtWavAudioInput::start()
|
||||
{
|
||||
stop();
|
||||
|
||||
mChannelCount = mFormat.channelCount();
|
||||
mSampleSize = mFormat.sampleSize();
|
||||
mSampleRate = mFormat.sampleRate();
|
||||
|
||||
//读取到数据
|
||||
QFile f ( mSourceFile );
|
||||
f.open ( QFile::ReadOnly );
|
||||
QByteArray b = f.read ( mFileHeaderSize );
|
||||
//这个地方测试完成:内部解析wav头,两个都很成功。C Qt 都OK.
|
||||
//pline() << b;
|
||||
mFileBytes = f.read ( mFileDataSize );
|
||||
f.close();
|
||||
|
||||
mBytesBuffer.open ( QIODevice::ReadWrite );
|
||||
mTimer->start ( mTimerInterval );
|
||||
return;
|
||||
}
|
||||
|
||||
void QQtWavAudioInput::stop()
|
||||
{
|
||||
//如果正在播放,先关闭写入音频数据流。
|
||||
mTimer->stop();
|
||||
//如果存在,则清空。
|
||||
//这两个变量Buffer是什么操作关系?QBuffer是QByteArray的QIODevice套。
|
||||
//改变QByteArray,会直接影响QBuffer的读写。QBuffer也会影响QByteArray的内容。
|
||||
mFileBytes.clear();
|
||||
mBytes.clear();
|
||||
|
||||
if ( mBytesBuffer.isOpen() )
|
||||
mBytesBuffer.close();
|
||||
}
|
||||
|
||||
int QQtWavAudioInput::fileTotalSize() {return mFileTotalSize;}
|
||||
|
||||
int QQtWavAudioInput::fileHeaderSize() { return mFileHeaderSize; }
|
||||
|
||||
int QQtWavAudioInput::fileDataSize() {return mFileDataSize;}
|
||||
|
||||
int QQtWavAudioInput::fileTailSize() {return mFileTailSize;}
|
||||
|
||||
|
||||
void QQtWavAudioInput::slotTimeout()
|
||||
{
|
||||
//1s 字节数 = 采样率 * 采样深度(位宽)* 通道数 / 8
|
||||
//mTimerInterval ms 字节数 = 1s 字节数 / (1000/mTimerInterval)
|
||||
//每个音符 字节数 = 采样深度(位宽)* 通道数 / 8;
|
||||
int frameSize = mSampleRate * mSampleSize * mChannelCount / 8 / ( 1000 / mTimerInterval );
|
||||
QByteArray tempBytes;
|
||||
|
||||
if ( mFileBytes.size() > frameSize )
|
||||
{
|
||||
tempBytes.resize ( frameSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
tempBytes.resize ( mFileBytes.size() );
|
||||
}
|
||||
|
||||
//pline() << mFileBytes.size() << tempBytes.size() << frameSize;
|
||||
//mFileBytes 逐渐减少
|
||||
mFileBytes >> tempBytes;
|
||||
//这是给用户的。
|
||||
mBytes = tempBytes;
|
||||
//回到初始位置
|
||||
mBytesBuffer.seek ( 0 );
|
||||
//激发readyRead信号
|
||||
mBytesBuffer.write ( 0 );
|
||||
|
||||
if ( mFileBytes.isEmpty() )
|
||||
{
|
||||
//pline() << mFileBytes.size() << 0 << frameSize;
|
||||
//这里不要关闭Buffer,客户一般还没用完。
|
||||
mTimer->stop();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QQtWavAudioOutput::QQtWavAudioOutput ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
mFileBytes.clear();
|
||||
mBytesBuffer.setBuffer ( &mFileBytes );
|
||||
|
||||
mFormat.setByteOrder ( QAudioFormat::LittleEndian );
|
||||
mFormat.setChannelCount ( 2 );
|
||||
mFormat.setCodec ( "audio/pcm" );
|
||||
mFormat.setSampleRate ( 44100 );
|
||||
mFormat.setSampleSize ( 16 );
|
||||
mFormat.setSampleType ( QAudioFormat::SignedInt );
|
||||
}
|
||||
|
||||
QIODevice* QQtWavAudioOutput::setSourceFile ( const QString& localFile )
|
||||
{
|
||||
mSourceFile = localFile;
|
||||
return &mBytesBuffer;
|
||||
}
|
||||
|
||||
QAudioFormat& QQtWavAudioOutput::format() { return mFormat; }
|
||||
|
||||
void QQtWavAudioOutput::start()
|
||||
{
|
||||
if ( mSourceFile.isEmpty() )
|
||||
return;
|
||||
|
||||
//这里清空文件,不会发生保存?不会,这里清空Buffer。
|
||||
mFileBytes.clear();
|
||||
|
||||
if ( mBytesBuffer.isOpen() )
|
||||
mBytesBuffer.close();
|
||||
|
||||
mBytesBuffer.open ( QIODevice::WriteOnly );
|
||||
}
|
||||
|
||||
void QQtWavAudioOutput::stop()
|
||||
{
|
||||
//在stop的时候,才会把数据全部存储到wav文件
|
||||
if ( mSourceFile.isEmpty() )
|
||||
return;
|
||||
|
||||
//防止多次关闭导致音频文件被破坏。
|
||||
if ( mFileBytes.isEmpty() )
|
||||
return;
|
||||
|
||||
QFile file ( mSourceFile );
|
||||
file.open ( QFile::Truncate | QFile::WriteOnly );
|
||||
|
||||
addWavHeader ( file, mFormat );
|
||||
file.write ( mFileBytes );
|
||||
addWavTail ( file );
|
||||
//这个时候,Header里面RiffLength是错误的。改写
|
||||
file.seek ( 0 );
|
||||
addWavHeader ( file, mFormat );
|
||||
//现在纠正好了。
|
||||
file.close();
|
||||
|
||||
mFileBytes.clear();
|
||||
|
||||
if ( mBytesBuffer.isOpen() )
|
||||
mBytesBuffer.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
QQtWavAudioManager::QQtWavAudioManager ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
mInputManager = new QQtWavAudioInput ( this );
|
||||
mOutputManager = new QQtWavAudioOutput ( this );
|
||||
|
||||
mInputDevice = mInputManager->device();
|
||||
mOutputDevice = mOutputManager->device();
|
||||
|
||||
connect ( mInputDevice, SIGNAL ( readyRead() ),
|
||||
this, SIGNAL ( readyRead() ) );
|
||||
|
||||
}
|
||||
|
||||
QQtWavAudioManager::~QQtWavAudioManager()
|
||||
{
|
||||
stopInput();
|
||||
stopOutput();
|
||||
}
|
||||
|
||||
void QQtWavAudioManager::setInputSourceFile ( const QString& localFile )
|
||||
{
|
||||
QIODevice* ioDev = mInputManager->setSourceFile ( localFile );
|
||||
|
||||
if ( !ioDev )
|
||||
{
|
||||
pline() << mInputManager->sourceFile()
|
||||
<< inputAudioFormat().sampleSize()
|
||||
<< inputAudioFormat().sampleRate()
|
||||
<< inputAudioFormat().channelCount()
|
||||
<< "open failed, errcode:"
|
||||
<< "-1";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QString QQtWavAudioManager::inputSourceFile() { return mInputManager->sourceFile(); }
|
||||
|
||||
void QQtWavAudioManager::setOutputSourceFile ( const QString& localFile )
|
||||
{
|
||||
QIODevice* ioDev = mOutputManager->setSourceFile ( localFile );
|
||||
|
||||
if ( !ioDev )
|
||||
{
|
||||
pline() << mOutputManager->sourceFile()
|
||||
<< outputAudioFormat().sampleSize()
|
||||
<< outputAudioFormat().sampleRate()
|
||||
<< outputAudioFormat().channelCount()
|
||||
<< "open failed, errcode:"
|
||||
<< "-1";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QString QQtWavAudioManager::outputSourceFile() { return mOutputManager->sourceFile(); }
|
||||
|
||||
const QAudioFormat& QQtWavAudioManager::inputAudioFormat() { return mInputManager->format(); }
|
||||
|
||||
QAudioFormat& QQtWavAudioManager::outputAudioFormat() { return mOutputManager->format(); }
|
||||
|
||||
int QQtWavAudioManager::inputFileTotalSize() { return mInputManager->fileTotalSize(); }
|
||||
|
||||
int QQtWavAudioManager::inputFileHeaderSize() { return mInputManager->fileHeaderSize(); }
|
||||
|
||||
int QQtWavAudioManager::inputFileDataSize() { return mInputManager->fileDataSize(); }
|
||||
|
||||
int QQtWavAudioManager::inputFileTailSize() { return mInputManager->fileTailSize(); }
|
||||
|
||||
QQtWavAudioInput* QQtWavAudioManager::inputManager() { return mInputManager; }
|
||||
|
||||
QIODevice* QQtWavAudioManager::inputDevice() { return mInputDevice; }
|
||||
|
||||
QQtWavAudioOutput* QQtWavAudioManager::outputManager() { return mOutputManager; }
|
||||
|
||||
QIODevice* QQtWavAudioManager::outputDevice() { return mOutputDevice; }
|
||||
|
||||
void QQtWavAudioManager::startInput()
|
||||
{
|
||||
stopInput();
|
||||
mInputManager->start();
|
||||
}
|
||||
|
||||
void QQtWavAudioManager::stopInput()
|
||||
{
|
||||
mInputManager->stop();
|
||||
}
|
||||
|
||||
void QQtWavAudioManager::startOutput()
|
||||
{
|
||||
stopOutput();
|
||||
mOutputManager->start();
|
||||
}
|
||||
|
||||
void QQtWavAudioManager::stopOutput()
|
||||
{
|
||||
mOutputManager->stop();
|
||||
}
|
||||
|
||||
QByteArray QQtWavAudioManager::readAll()
|
||||
{
|
||||
return mInputDevice->readAll();
|
||||
}
|
||||
|
||||
QByteArray QQtWavAudioManager::read ( qint64 maxlen )
|
||||
{
|
||||
return mInputDevice->read ( maxlen );
|
||||
}
|
||||
|
||||
void QQtWavAudioManager::write ( const QByteArray& bytes )
|
||||
{
|
||||
mOutputDevice->write ( bytes );
|
||||
}
|
220
src/multimedia/qqtwavaudiomanager.h
Normal file
@ -0,0 +1,220 @@
|
||||
#ifndef QQTWAVAUDIOMANAGER_H
|
||||
#define QQTWAVAUDIOMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <qqtcore.h>
|
||||
#include <qqt-local.h>
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
|
||||
#include <QMimeType>
|
||||
#include <QMimeData>
|
||||
#include <QMimeDatabase>
|
||||
|
||||
#include <QSound>
|
||||
#include <QSoundEffect>
|
||||
#endif
|
||||
|
||||
#include <qqtaudiomanager.h>
|
||||
|
||||
//设计思路:QQtWavAudioInput和QQtWavAudioOutput两边都是内存和wav文件,为内存服务。
|
||||
|
||||
/**
|
||||
* @brief The QQtWavAudioInput class
|
||||
* QQtWavAudioInput具备QAudioInput的能力,可以把wav文件的音频帧,通过readyRead输出。
|
||||
* 每次/10ms一帧,通过QIODevice readyRead发射给用户。
|
||||
* 升级目标:QQtAudioInput里支持的设备比较广泛,文件类型比较多。
|
||||
*
|
||||
* 原理,设置Sourcefile,返回QIODevice,进行读取。一次加载,逐渐读取。
|
||||
*
|
||||
* 不要使用大文件。
|
||||
* Qt 中有一个 QBuffer 类,可以将 QByteArray 包装成一个 QIODevice。QMemIODevice = QBuffer
|
||||
* 如果来的是个QByteArray,那么,用QBuffer封装,
|
||||
* 在 open 函数中调用 QIODevice::open(mode)
|
||||
* 要解析wav,用自定义程序,还是用开源Library(libsndfile)?自定义程序
|
||||
* 要播放wav,是用wav的音频格式来设定输出设备,还是用个输出设备支持的音频格式,wav里选取进行使用?使用wav的。
|
||||
*
|
||||
* 尝试用QAudioDecoder,解码器不支持x-wav,defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.audiodecode"
|
||||
* 为什么QSoundEffect支持那么多wav格式?("audio/x-wav", "audio/wav", "audio/wave", "audio/x-pn-wav")
|
||||
* LibQQt库
|
||||
* QAudioDecoder保存了一个提交,#5643241
|
||||
* QWavAudioEffect保存了一个提交,#5f43622
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtWavAudioInput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtWavAudioInput ( QObject* parent = nullptr );
|
||||
//自动解析格式,和文件大小
|
||||
QIODevice* setSourceFile ( const QString& localFile );
|
||||
QString sourceFile() { return mSourceFile; }
|
||||
|
||||
//读取用。这个是个内部公用的,并不是临时的。碰巧了。
|
||||
QIODevice* device() { return &mBytesBuffer; }
|
||||
|
||||
//设置读文件的时钟快慢(硬盘快,时钟快,每次读的少;硬盘慢,时钟慢,每次读的多)
|
||||
//采样间隔 10-100ms default: macOS SSD 20 ms
|
||||
//windows 机械硬盘 100ms, windows 机械硬盘 is slower than macOS SSD.
|
||||
int timerInterval() const { return mTimerInterval; }
|
||||
void setTimerInterval ( int millSecond = 20 );
|
||||
//可以频繁开启,tip:用完一定要关闭,系统会自动关闭。
|
||||
//已经检查测试,没有文件设备漏开关问题。
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
//每次修改SourceFile,这些都会改变。在不改变SourceFile的时候是内部使用的值。
|
||||
const QAudioFormat& format() { return mFormat; }
|
||||
int fileTotalSize();
|
||||
int fileHeaderSize();
|
||||
int fileDataSize();
|
||||
int fileTailSize();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void slotTimeout();
|
||||
|
||||
private:
|
||||
QString mSourceFile;
|
||||
//用于保存文件全部Bytes
|
||||
QByteArray mFileBytes;
|
||||
//用于和Buffer联系,给用户提供每次读取的帧。
|
||||
QByteArray mBytes;
|
||||
QBuffer mBytesBuffer;
|
||||
|
||||
//每次设置新Source,会改变这些值。
|
||||
QAudioFormat mFormat;
|
||||
int mFileDataSize;
|
||||
int mFileHeaderSize;
|
||||
int mFileTailSize;
|
||||
int mFileTotalSize;
|
||||
//这三个不准公开出来啊。
|
||||
int mSampleRate;
|
||||
int mSampleSize;
|
||||
int mChannelCount;
|
||||
|
||||
QTimer* mTimer;
|
||||
int mTimerInterval;
|
||||
|
||||
public:
|
||||
protected:
|
||||
|
||||
public:
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
class QQTSHARED_EXPORT QQtWavAudioOutput : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtWavAudioOutput ( QObject* parent = nullptr );
|
||||
|
||||
QIODevice* setSourceFile ( const QString& localFile );
|
||||
QString sourceFile() { return mSourceFile; }
|
||||
|
||||
//写入用
|
||||
QIODevice* device() { return &mBytesBuffer; }
|
||||
|
||||
//用户务必设置format,默认值为2 16 44100
|
||||
QAudioFormat& format();
|
||||
|
||||
void start();
|
||||
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
QString mSourceFile;
|
||||
QAudioFormat mFormat;
|
||||
|
||||
QBuffer mBytesBuffer;
|
||||
QByteArray mFileBytes;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The QQtWavAudioManager class
|
||||
* Wav媒体音频管理器
|
||||
*
|
||||
* 这个Wav音频管理器目标为用户提供Wav媒体的音频数据帧,附加音频数据帧输出到Wav媒体的功能。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtWavAudioManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtWavAudioManager ( QObject* parent = nullptr );
|
||||
|
||||
~QQtWavAudioManager();
|
||||
|
||||
/**
|
||||
* 选择输入、输出Wav媒体
|
||||
*/
|
||||
//设置输入或者输出wav文件
|
||||
void setInputSourceFile ( const QString& localFile );
|
||||
QString inputSourceFile();
|
||||
void setOutputSourceFile ( const QString& localFile );
|
||||
QString outputSourceFile();
|
||||
|
||||
/**
|
||||
* 选择音频流的格式
|
||||
*/
|
||||
|
||||
//获取输入文件的音频流格式
|
||||
const QAudioFormat& inputAudioFormat();
|
||||
//设置输出音频流的音频格式,输出保存的时候使用。
|
||||
QAudioFormat& outputAudioFormat();
|
||||
|
||||
//每次修改SourceFile,这些都会改变。
|
||||
int inputFileTotalSize();
|
||||
int inputFileHeaderSize();
|
||||
int inputFileDataSize();
|
||||
int inputFileTailSize();
|
||||
|
||||
|
||||
/**
|
||||
* 操作输入、输出Wav媒体
|
||||
*/
|
||||
|
||||
QQtWavAudioInput* inputManager();
|
||||
//如果输入,从这里读取帧
|
||||
QIODevice* inputDevice();
|
||||
|
||||
QQtWavAudioOutput* outputManager();
|
||||
//如果输出,从这里写入帧,提前设置好格式哦...
|
||||
QIODevice* outputDevice();
|
||||
|
||||
void startInput();
|
||||
void stopInput();
|
||||
|
||||
void startOutput();
|
||||
void stopOutput();
|
||||
|
||||
//这两个是方便函数,一般都用这几个进行读写,不使用上边的。
|
||||
QByteArray readAll();
|
||||
QByteArray read ( qint64 maxlen );
|
||||
void write ( const QByteArray& bytes );
|
||||
|
||||
signals:
|
||||
/*音频数据准备就绪,readAll即可读取。*/
|
||||
void readyRead();
|
||||
public slots:
|
||||
|
||||
private:
|
||||
|
||||
QQtWavAudioInput* mInputManager;
|
||||
QQtWavAudioOutput* mOutputManager;
|
||||
|
||||
QIODevice* mInputDevice;
|
||||
QIODevice* mOutputDevice;
|
||||
|
||||
//这三个不准公开出来。
|
||||
int mSampleRate;
|
||||
int mSampleSize;
|
||||
int mChannelCount;
|
||||
};
|
||||
|
||||
#endif // QQTWAVAUDIOMANAGER_H
|
163
src/multimedia/qqtwavsoundeffect.cpp
Normal file
@ -0,0 +1,163 @@
|
||||
#include "qqtwavsoundeffect.h"
|
||||
|
||||
|
||||
QQtWavSoundEffect* QQtWavSoundEffect::msInstance = NULL;
|
||||
|
||||
QQtWavSoundEffect* QQtWavSoundEffect::Instance ( QObject* parent )
|
||||
{
|
||||
if ( !msInstance )
|
||||
msInstance = new QQtWavSoundEffect ( parent );
|
||||
|
||||
return msInstance;
|
||||
}
|
||||
|
||||
QQtWavSoundEffect::QQtWavSoundEffect ( QObject* parent ) : QObject ( parent )
|
||||
{
|
||||
mVolume = 1;
|
||||
mIOInput = NULL;
|
||||
mLooping = 1;
|
||||
mLoops = 1;
|
||||
}
|
||||
|
||||
void QQtWavSoundEffect::setOutputDevice ( const QAudioDeviceInfo& output )
|
||||
{
|
||||
if ( output.isNull() )
|
||||
manager.outputDeviceInfo() = QQtAudioManager::defaultOutputDevice();
|
||||
else
|
||||
manager.outputDeviceInfo() = output;
|
||||
}
|
||||
|
||||
void QQtWavSoundEffect::useDefaultOutputDevice()
|
||||
{
|
||||
manager.outputDeviceInfo() = QQtAudioManager::defaultOutputDevice();
|
||||
}
|
||||
|
||||
void QQtWavSoundEffect::useCustomOutputDevice ( const QAudioDeviceInfo& output )
|
||||
{
|
||||
manager.outputDeviceInfo() = output;
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
QDebug& operator << ( QDebug& dbg, const QAudioFormat& fmt )
|
||||
{
|
||||
return dbg;
|
||||
}
|
||||
#endif
|
||||
|
||||
void QQtWavSoundEffect::play ( QString localFile )
|
||||
{
|
||||
#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
|
||||
|
||||
//判断文件类型是否接受
|
||||
QMimeDatabase mimedb;
|
||||
QMimeType mimetype = mimedb.mimeTypeForFile ( localFile );
|
||||
|
||||
if ( !QSoundEffect::supportedMimeTypes().contains ( mimetype.name(), Qt::CaseInsensitive ) )
|
||||
{
|
||||
pline() << "filename" << localFile << "mimetype" << mimetype.name()
|
||||
<< QSoundEffect::supportedMimeTypes().contains ( mimetype.name(), Qt::CaseInsensitive ) ;
|
||||
pline() << "can't play file";
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
mSourceFile = localFile;
|
||||
|
||||
stop();
|
||||
|
||||
mIOInput = mWavInput.setSourceFile ( localFile );
|
||||
connect ( mIOInput, SIGNAL ( readyRead() ),
|
||||
this, SLOT ( readyRead() ) );
|
||||
|
||||
QAudioDeviceInfo& usingOutput = manager.outputDeviceInfo();
|
||||
|
||||
QAudioFormat fmt = mWavInput.format();
|
||||
|
||||
//输出设备是否支持格式是否支持
|
||||
if ( !usingOutput.isFormatSupported ( fmt ) )
|
||||
{
|
||||
//当前使用设备是否支持
|
||||
pline() << "output cant support" << fmt;
|
||||
fmt = usingOutput.nearestFormat ( fmt ); //转换为最接近格式
|
||||
pline() << "use format" << fmt;
|
||||
}
|
||||
|
||||
manager.outputAudioFormat() = fmt;
|
||||
|
||||
manager.startOutput();
|
||||
#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
|
||||
|
||||
//默认是静音的。
|
||||
manager.outputManager()->setVolume ( mVolume );
|
||||
#endif
|
||||
|
||||
//不响,音频输出设备接受顺序的间隔的输出,不接受一股脑输出。
|
||||
//manager.write ( bytes );
|
||||
//OK, 达到QSound效果。
|
||||
mWavInput.start();
|
||||
}
|
||||
|
||||
void QQtWavSoundEffect::stop()
|
||||
{
|
||||
//如果正在播放,先关闭
|
||||
if ( mIOInput )
|
||||
{
|
||||
mWavInput.stop();
|
||||
manager.stopOutput();
|
||||
disconnect ( mIOInput, SIGNAL ( readyRead() ),
|
||||
this, SLOT ( readyRead() ) );
|
||||
mIOInput = NULL;
|
||||
}
|
||||
|
||||
mLooping = 1;
|
||||
mDataSize = 0;
|
||||
}
|
||||
|
||||
void QQtWavSoundEffect::setVolume ( qreal volume )
|
||||
{
|
||||
mVolume = volume;
|
||||
#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
|
||||
|
||||
manager.outputManager()->setVolume ( mVolume );
|
||||
#endif
|
||||
}
|
||||
|
||||
int QQtWavSoundEffect::loops() const { return mLoops; }
|
||||
|
||||
int QQtWavSoundEffect::loopsRemaining() const
|
||||
{
|
||||
return mLoops - mLooping;
|
||||
}
|
||||
|
||||
void QQtWavSoundEffect::setLoops ( int loops )
|
||||
{
|
||||
mLoops = loops;
|
||||
}
|
||||
|
||||
void QQtWavSoundEffect::readyRead()
|
||||
{
|
||||
QByteArray bytes = mIOInput->readAll();
|
||||
//pline() << bytes.size();
|
||||
manager.write ( bytes );
|
||||
|
||||
mDataSize += bytes.size();
|
||||
|
||||
if ( mDataSize == mWavInput.fileDataSize() )
|
||||
{
|
||||
int loop = mLooping;
|
||||
|
||||
if ( loop < loops() )
|
||||
play ( mSourceFile );
|
||||
|
||||
mLooping = loop + 1;
|
||||
}
|
||||
}
|
||||
|
||||
QQtWavSoundEffect* QQtWavSound ( QString localFile )
|
||||
{
|
||||
if ( !localFile.isEmpty() )
|
||||
QQtWavSoundEffect::Instance ( )->play ( localFile );
|
||||
|
||||
return QQtWavSoundEffect::Instance();
|
||||
}
|
||||
|
80
src/multimedia/qqtwavsoundeffect.h
Normal file
@ -0,0 +1,80 @@
|
||||
#ifndef QQTAUDIOEFFECT_H
|
||||
#define QQTAUDIOEFFECT_H
|
||||
|
||||
|
||||
#include <qqtwavaudiomanager.h>
|
||||
|
||||
#include <qqtcore.h>
|
||||
#include <qqt-local.h>
|
||||
/*
|
||||
* QQtWavSoundEffect = QSoundEffect + QSound +...
|
||||
* QQtWavSoundEffect支持从wav获取声音并输出,弥补QSoundEffect(+他的高级点的封装QSound)不能支持选择设备的缺失。
|
||||
* QQtWavSoundEffect默认使用默认输出设备。
|
||||
*/
|
||||
class QQTSHARED_EXPORT QQtWavSoundEffect : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//这样做的目的,在于使用一个实例去播放音效。
|
||||
//如果是个临时变量,函数执行返回了,但是还没播放完,甚至还没来得及开始呢,这时,播放不出来的。
|
||||
static QQtWavSoundEffect* Instance ( QObject* parent = nullptr );
|
||||
|
||||
explicit QQtWavSoundEffect ( QObject* parent = nullptr );
|
||||
~QQtWavSoundEffect() {
|
||||
stop();
|
||||
}
|
||||
|
||||
//设置设备以后,不需要每次都设置
|
||||
//更换设备不会引发播放更改,只会更改内部设备记录。调用play才会导致播放更改。
|
||||
void setOutputDevice ( const QAudioDeviceInfo& output = QAudioDeviceInfo() );
|
||||
|
||||
void useDefaultOutputDevice();
|
||||
|
||||
void useCustomOutputDevice ( const QAudioDeviceInfo& output );
|
||||
|
||||
void play ( QString localFile );
|
||||
|
||||
void stop();
|
||||
|
||||
//设置声音以后,不需要每次都要设置。
|
||||
void setVolume ( qreal volume );
|
||||
|
||||
//设置loop会保存下来,不需要每次设置。
|
||||
int loops() const;
|
||||
int loopsRemaining() const;
|
||||
void setLoops ( int loops );
|
||||
|
||||
//设置读文件的时钟快慢(硬盘快,时钟快,每次读的少;硬盘慢,时钟慢,每次读的多)
|
||||
//默认使用 macOS SSD 20ms
|
||||
//Windows上,机械硬盘,可能会延迟,可以设置100ms。
|
||||
void setTimerInterval ( int millSecond = 20 ) {
|
||||
mWavInput.setTimerInterval ( millSecond );
|
||||
}
|
||||
|
||||
private slots:
|
||||
void readyRead();
|
||||
|
||||
private:
|
||||
//不需要额外初始化的地方
|
||||
//mingw32 5.3 静态成员不准导出?作为静态类这块编译出现错误
|
||||
//error: definition of static data member 'QQtWavSoundEffect::msInstance' of dllimport'd class
|
||||
//这个已经查出来了,在qqt_header.pri有一个WIN64的宏缺失,导致QQT_STATIC_LIBRARY缺失,引发QQt在QQTSHAREDEXPORT=import下编译,所以引发这个变量重新定义的错误,而报错是在导入的类里面定义了静态成员,也就是说导入类不准许静态成员的定义初始化代码出现,引入类的静态成员在自己的实现文件里出现了定义。变量重定义了。
|
||||
static QQtWavSoundEffect* msInstance;
|
||||
|
||||
QQtWavAudioInput mWavInput;
|
||||
QIODevice* mIOInput;
|
||||
QQtAudioManager manager;
|
||||
QString mSourceFile;
|
||||
int mDataSize;
|
||||
//volume会被记住。
|
||||
qreal mVolume;
|
||||
int mLoops;
|
||||
int mLooping;
|
||||
};
|
||||
|
||||
//在使用QQtWavSound等函数之前,调用类的instance函数,+parent 初始化一下实例。
|
||||
//=QSound::play()
|
||||
QQTSHARED_EXPORT QQtWavSoundEffect* QQtWavSound ( QString localFile = "" );
|
||||
|
||||
#endif // QQTAUDIOEFFECT_H
|
@ -122,6 +122,11 @@ contains (DEFINES, __MULTIMEDIA__) {
|
||||
$$PWD/multimedia/dmmu/jz_cim.h \
|
||||
$$PWD/multimedia/dmmu/graphics.h \
|
||||
$$PWD/multimedia/dmmu/hal.h
|
||||
|
||||
#logic video manager
|
||||
SOURCES += $$PWD/multimedia/qqtlogicvideomanager.cpp
|
||||
HEADERS += $$PWD/multimedia/qqtlogicvideomanager.h
|
||||
|
||||
SOURCES += $$PWD/multimedia/qqtlogicpreviewwidget.cpp
|
||||
HEADERS += $$PWD/multimedia/qqtlogicpreviewwidget.h
|
||||
FORMS += $$PWD/multimedia/qqtlogicpreviewwidget.ui
|
||||
|
@ -33,6 +33,7 @@ defineTest(add_include_QQt){
|
||||
#multimedia
|
||||
command += $${header_path}/multimedia
|
||||
command += $${header_path}/multimedia/dmmu
|
||||
command += $${header_path}/multimedia/libqwav
|
||||
|
||||
#charts
|
||||
command += $${header_path}/charts
|
||||
@ -219,6 +220,22 @@ defineTest(add_defines_QQt){
|
||||
contains (DEFINES, __MULTIMEDIA__) {
|
||||
QT += multimedia
|
||||
|
||||
#AUDIO MODULE
|
||||
#depend on libqwav
|
||||
DEFINES += __QQTAUDIOSUPPORT__
|
||||
contains(DEFINES, __QQTAUDIOSUPPORT__) {
|
||||
win32 {
|
||||
contains (DEFINES, QQT_LIBRARY) {
|
||||
DEFINES += LIBQWAV_LIBRARY
|
||||
} else:contains (DEFINES, QQT_STATIC_LIBRARY) {
|
||||
DEFINES += LIBQWAV_STATIC_LIBRARY
|
||||
} else { }
|
||||
}
|
||||
}
|
||||
|
||||
#VIDEO MODULE
|
||||
DEFINES += __QQTVIDEOSUPPORT__
|
||||
|
||||
#LOGIC CAMERA PREVIEW
|
||||
#depend on dmmu
|
||||
DEFINES += __LOGICCAMERAMODULE__
|
||||
|
@ -36,10 +36,12 @@ contains (DEFINES, __WIN__) {
|
||||
#core
|
||||
SOURCES += \
|
||||
$$PWD/core/qqtcore.cpp \
|
||||
$$PWD/core/qqtorderedmap.cpp \
|
||||
$$PWD/core/qqtdictionary.cpp \
|
||||
$$PWD/core/qqtobjectmanager.cpp
|
||||
HEADERS += \
|
||||
$$PWD/core/qqtcore.h \
|
||||
$$PWD/core/qqtorderedmap.h \
|
||||
$$PWD/core/qqtdictionary.h \
|
||||
$$PWD/core/qqtobjectmanager.h
|
||||
|
||||
@ -200,8 +202,27 @@ contains (DEFINES, __MULTIMEDIA__) {
|
||||
}
|
||||
|
||||
#audio
|
||||
SOURCES += $$PWD/multimedia/qqtaudiomanager.cpp
|
||||
HEADERS += $$PWD/multimedia/qqtaudiomanager.h
|
||||
contains (DEFINES, __QQTAUDIOSUPPORT__){
|
||||
SOURCES += $$PWD/multimedia/qqtaudiomanager.cpp
|
||||
HEADERS += $$PWD/multimedia/qqtaudiomanager.h
|
||||
|
||||
#wav audio
|
||||
SOURCES += $$PWD/multimedia/libqwav/libqwav.cpp
|
||||
HEADERS += $$PWD/multimedia/libqwav/libqwav.h
|
||||
HEADERS += $$PWD/multimedia/libqwav/libqwav_global.h
|
||||
SOURCES += $$PWD/multimedia/qqtwavaudiomanager.cpp
|
||||
HEADERS += $$PWD/multimedia/qqtwavaudiomanager.h
|
||||
SOURCES += $$PWD/multimedia/qqtwavsoundeffect.cpp
|
||||
HEADERS += $$PWD/multimedia/qqtwavsoundeffect.h
|
||||
}
|
||||
|
||||
#video
|
||||
contains (DEFINES, __QQTVIDEOSUPPORT__){
|
||||
SOURCES += $$PWD/multimedia/qqtcamera.cpp
|
||||
HEADERS += $$PWD/multimedia/qqtcamera.h
|
||||
SOURCES += $$PWD/multimedia/qqtvideomanager.cpp
|
||||
HEADERS += $$PWD/multimedia/qqtvideomanager.h
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,59 +6,59 @@ QSqlDatabase newDatabaseConnection()
|
||||
{
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
//qDebug() << uuid.toString();
|
||||
return QSqlDatabase::addDatabase(DB_TYPE, uuid.toString());
|
||||
return QSqlDatabase::addDatabase ( DB_TYPE, uuid.toString() );
|
||||
}
|
||||
|
||||
|
||||
//opened
|
||||
//useDatabase
|
||||
void setDatabaseName(QSqlDatabase& db, QString dbName)
|
||||
void setDatabaseName ( QSqlDatabase& dbinst, QString dbName )
|
||||
{
|
||||
if (db.isOpen())
|
||||
db.close();
|
||||
if ( dbinst.isOpen() )
|
||||
dbinst.close();
|
||||
|
||||
db.setDatabaseName(QString("%1/%2").arg(DB_PATH).arg(dbName));
|
||||
dbinst.setDatabaseName ( QString ( "%1" ).arg ( dbName ) );
|
||||
|
||||
if (!db.open())
|
||||
if ( !dbinst.open() )
|
||||
{
|
||||
QMessageBox::warning(0, QObject::tr("QSQLITE %1 Error").arg(db.databaseName()),
|
||||
db.lastError().text());
|
||||
QMessageBox::warning ( 0, QObject::tr ( "QSQLITE %1 Error" ).arg ( dbinst.databaseName() ),
|
||||
dbinst.lastError().text() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void openDatabase(QSqlDatabase& db)
|
||||
void openDatabase ( QSqlDatabase& dbinst )
|
||||
{
|
||||
if (db.isOpen())
|
||||
if ( dbinst.isOpen() )
|
||||
return;
|
||||
|
||||
if (!db.open())
|
||||
if ( !dbinst.open() )
|
||||
{
|
||||
QMessageBox::warning(0, QObject::tr("QSQLITE %1 Error").arg(db.databaseName()),
|
||||
db.lastError().text());
|
||||
QMessageBox::warning ( 0, QObject::tr ( "QSQLITE %1 Error" ).arg ( dbinst.databaseName() ),
|
||||
dbinst.lastError().text() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void closeDatabase(QSqlDatabase& db)
|
||||
void closeDatabase ( QSqlDatabase& dbinst )
|
||||
{
|
||||
db.close();
|
||||
dbinst.close();
|
||||
}
|
||||
|
||||
void useDatabase(QSqlDatabase& db, QString dbName)
|
||||
void useDatabase ( QSqlDatabase& dbinst, QString dbName )
|
||||
{
|
||||
setDatabaseName(db, dbName);
|
||||
setDatabaseName ( dbinst, dbName );
|
||||
}
|
||||
|
||||
void deleteDatabaseConnection(QString connectionName)
|
||||
void deleteDatabaseConnection ( QString connectionName )
|
||||
{
|
||||
QSqlDatabase::removeDatabase(connectionName);
|
||||
QSqlDatabase::removeDatabase ( connectionName );
|
||||
}
|
||||
|
||||
void deleteDatabaseConnection(QSqlDatabase &db)
|
||||
void deleteDatabaseConnection ( QSqlDatabase& dbinst )
|
||||
{
|
||||
QString connectionName = db.connectionName();
|
||||
deleteDatabaseConnection(connectionName);
|
||||
QString connectionName = dbinst.connectionName();
|
||||
deleteDatabaseConnection ( connectionName );
|
||||
}
|
||||
|
@ -55,16 +55,9 @@ enum
|
||||
};
|
||||
|
||||
#define DB_TYPE "QSQLITE"
|
||||
#define DB_PATH "./db"
|
||||
|
||||
#define DB_PINYIN "PinYin.db"
|
||||
#define DB_MANAGER "Manager.db"
|
||||
#define DB_EVENT "SysEvent.db"
|
||||
#define DB_METHOD_PATH "Method"
|
||||
#define DB_DATA_PATH "Data"
|
||||
#define DB_QQT "System.db"
|
||||
#define DB_USER "User.db"
|
||||
#define DB_DATA "Data.db"
|
||||
|
||||
#define TABLE_USERINFO "User"
|
||||
#define TABLE_AUTHORITY "Authority"
|
||||
@ -81,14 +74,14 @@ typedef QSqlDatabase QQtSqlDatabaseConnection;
|
||||
QQTSHARED_EXPORT QSqlDatabase newDatabaseConnection();
|
||||
|
||||
/*已经将数据库打开,不必重复打开*/
|
||||
QQTSHARED_EXPORT void setDatabaseName(QSqlDatabase& db, QString dbName);
|
||||
QQTSHARED_EXPORT void setDatabaseName ( QSqlDatabase& dbinst, QString dbName );
|
||||
//=setDatabaseName
|
||||
QQTSHARED_EXPORT void useDatabase(QSqlDatabase& db, QString dbName);
|
||||
QQTSHARED_EXPORT void useDatabase ( QSqlDatabase& dbinst, QString dbName );
|
||||
|
||||
QQTSHARED_EXPORT void openDatabase(QSqlDatabase& db);
|
||||
QQTSHARED_EXPORT void closeDatabase(QSqlDatabase& db);
|
||||
QQTSHARED_EXPORT void openDatabase ( QSqlDatabase& dbinst );
|
||||
QQTSHARED_EXPORT void closeDatabase ( QSqlDatabase& dbinst );
|
||||
|
||||
QQTSHARED_EXPORT void deleteDatabaseConnection(QString connectionName);
|
||||
QQTSHARED_EXPORT void deleteDatabaseConnection(QSqlDatabase& db);
|
||||
QQTSHARED_EXPORT void deleteDatabaseConnection ( QString connectionName );
|
||||
QQTSHARED_EXPORT void deleteDatabaseConnection ( QSqlDatabase& dbinst );
|
||||
|
||||
#endif // QQTSQLDEFINE_H
|
||||
|
@ -50,7 +50,6 @@ typedef struct QQTSHARED_EXPORT tagBtnIconTable
|
||||
QString& operator [] ( int index );
|
||||
} TBtnIconTable;
|
||||
|
||||
|
||||
QQTSHARED_EXPORT void moveCenter ( QWidget* w );
|
||||
QQTSHARED_EXPORT void moveRight ( QWidget* w );
|
||||
QQTSHARED_EXPORT void moveFull ( QWidget* w );
|
||||
|
@ -32,9 +32,9 @@ GifTestDialog::GifTestDialog ( QWidget* parent ) :
|
||||
pline() << res ( "../waiting.gif" );
|
||||
pline() << QDir ( "." ).relativeFilePath ( "skin/yun.png" );
|
||||
pline() << QDir ( res ( "../waiting.gif" ) ).absolutePath();
|
||||
ui->labelGif->setGifFile ( skin ( "waiting.gif" ) );
|
||||
ui->widgetGif->setGifFile ( skin ( "waiting.gif" ) );
|
||||
ui->widgetQQt->setPixmap ( skin ( "yun.png" ) );
|
||||
ui->labelGif->setGifFile ( conf_skin ( "waiting.gif" ) );
|
||||
ui->widgetGif->setGifFile ( conf_skin ( "waiting.gif" ) );
|
||||
ui->widgetQQt->setPixmap ( conf_skin ( "yun.png" ) );
|
||||
|
||||
pline() << QMovie::supportedFormats();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ MainWindow::MainWindow ( QWidget* parent ) :
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
ui->widget_2->setPixmap ( qrc ( "a.png" ) );
|
||||
ui->widget_2->setPixmap ( conf_qrc ( "a.png" ) );
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -13,29 +13,29 @@ MainWindow::MainWindow ( QWidget* parent ) :
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
QString svg = QString ( qrc ( "aa.svg" ) );
|
||||
QString svg = QString ( conf_qrc ( "aa.svg" ) );
|
||||
ui->w->setSvgFile ( svg );
|
||||
|
||||
ui->b0->iconTable() [BTN_NORMAL] = qrc ( "bt_stir.svg" );
|
||||
ui->b0->iconTable() [BTN_HOVER] = qrc ( "bt_stir.svg" );
|
||||
ui->b0->iconTable() [BTN_PRESS] = qrc ( "bt_stir_press.svg" );
|
||||
ui->b0->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->b0->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->b0->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" );
|
||||
ui->b0->renderToVariable();
|
||||
|
||||
ui->c0->iconTable() [BTN_NORMAL] = qrc ( "bt_stir.svg" );
|
||||
ui->c0->iconTable() [BTN_HOVER] = qrc ( "bt_stir.svg" );
|
||||
ui->c0->iconTable() [BTN_PRESS] = qrc ( "bt_stir_press.svg" );
|
||||
ui->c0->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->c0->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->c0->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" );
|
||||
ui->c0->renderToVariable();
|
||||
ui->r0->iconTable() [BTN_NORMAL] = qrc ( "bt_stir.svg" );
|
||||
ui->r0->iconTable() [BTN_HOVER] = qrc ( "bt_stir.svg" );
|
||||
ui->r0->iconTable() [BTN_PRESS] = qrc ( "bt_stir_press.svg" );
|
||||
ui->r0->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->r0->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->r0->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" );
|
||||
ui->r0->renderToVariable();
|
||||
ui->r1->iconTable() [BTN_NORMAL] = qrc ( "bt_stir.svg" );
|
||||
ui->r1->iconTable() [BTN_HOVER] = qrc ( "bt_stir.svg" );
|
||||
ui->r1->iconTable() [BTN_PRESS] = qrc ( "bt_stir_press.svg" );
|
||||
ui->r1->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->r1->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->r1->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" );
|
||||
ui->r1->renderToVariable();
|
||||
|
||||
ui->p0->setSvgFile ( qrc ( "bk_progress_background.svg" ),
|
||||
qrc ( "bk_progress_trunk.svg" ) );
|
||||
ui->p0->setSvgFile ( conf_qrc ( "bk_progress_background.svg" ),
|
||||
conf_qrc ( "bk_progress_trunk.svg" ) );
|
||||
ui->p0->setRange ( 0, 100 );
|
||||
ui->p0->setValue ( 60 );
|
||||
|
||||
|
24
test/videotest/AppRoot/skin/default.qss
Normal file
@ -0,0 +1,24 @@
|
||||
/*spinbox 抬起样式*/
|
||||
QTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button {
|
||||
subcontrol-origin:border;
|
||||
subcontrol-position:right;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
QTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button {
|
||||
subcontrol-origin:border;
|
||||
subcontrol-position:left;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
/*按钮按下样式*/
|
||||
QTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{
|
||||
subcontrol-origin:border;
|
||||
subcontrol-position:right;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
QTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{
|
||||
subcontrol-position:left;
|
||||
width: 12px;
|
||||
}
|
90
test/videotest/android/AndroidManifest.xml
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0"?>
|
||||
<manifest package="org.qtproject.example.videotest" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
|
||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="videotest" android:icon="@drawable/icon">
|
||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="videotest" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<!-- Application arguments -->
|
||||
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
|
||||
<!-- Application arguments -->
|
||||
|
||||
<meta-data android:name="android.app.lib_name" android:value="videotest"/>
|
||||
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
||||
<meta-data android:name="android.app.repository" android:value="default"/>
|
||||
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
|
||||
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
|
||||
<!-- Deploy Qt libs as part of package -->
|
||||
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
|
||||
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
|
||||
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
|
||||
<!-- Run with local libs -->
|
||||
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
|
||||
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
||||
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so"/>
|
||||
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroid-bundled.jar"/>
|
||||
<meta-data android:name="android.app.static_init_classes" android:value=""/>
|
||||
<!-- Messages maps -->
|
||||
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
||||
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
||||
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
||||
<!-- Messages maps -->
|
||||
|
||||
<!-- Splash screen -->
|
||||
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
|
||||
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
|
||||
<!-- Splash screen -->
|
||||
|
||||
<!-- Background running -->
|
||||
<!-- Warning: changing this value to true may cause unexpected crashes if the
|
||||
application still try to draw after
|
||||
"applicationStateChanged(Qt::ApplicationSuspended)"
|
||||
signal is sent! -->
|
||||
<meta-data android:name="android.app.background_running" android:value="false"/>
|
||||
<!-- Background running -->
|
||||
|
||||
<!-- auto screen scale factor -->
|
||||
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
|
||||
<!-- auto screen scale factor -->
|
||||
|
||||
<!-- extract android style -->
|
||||
<!-- available android:values :
|
||||
* full - useful QWidget & Quick Controls 1 apps
|
||||
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
|
||||
* none - useful for apps that don't use any of the above Qt modules
|
||||
-->
|
||||
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
|
||||
<!-- extract android style -->
|
||||
</activity>
|
||||
|
||||
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
|
||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default permissions. -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default features. -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<!-- %%INSERT_PERMISSIONS -->
|
||||
<!-- %%INSERT_FEATURES -->
|
||||
<uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
|
||||
<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>
|
BIN
test/videotest/android/res/drawable-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
test/videotest/android/res/drawable-hdpi/icon.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
test/videotest/android/res/drawable-ldpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
test/videotest/android/res/drawable-ldpi/icon.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/videotest/android/res/drawable-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
test/videotest/android/res/drawable-mdpi/icon.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
test/videotest/android/res/drawable-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/videotest/android/res/drawable-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 82 KiB |
11
test/videotest/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QQtApplication>
|
||||
|
||||
int main ( int argc, char* argv[] )
|
||||
{
|
||||
QQtApplication a ( argc, argv );
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
141
test/videotest/mainwindow.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow ( QWidget* parent ) :
|
||||
QMainWindow ( parent ),
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
|
||||
QVideoProbe* prob = new QVideoProbe ( this );
|
||||
QCamera* camera = new QCamera ( QCameraInfo::defaultCamera() );
|
||||
camera->setCaptureMode ( QCamera::CaptureVideo );
|
||||
prob->setSource ( camera );
|
||||
connect ( prob, SIGNAL ( videoFrameProbed ( const QVideoFrame& ) ),
|
||||
this, SLOT ( slotTestProbe ( const QVideoFrame& ) ) );
|
||||
connect ( ui->pushButton_3, SIGNAL ( released() ), camera, SLOT ( start() ) );
|
||||
|
||||
return;
|
||||
|
||||
input = new QQtVideoInput ( this );
|
||||
pline() << input->defaultCamera();
|
||||
pline() << input ->availableCameras();
|
||||
|
||||
QCameraInfo inf = input->defaultCamera();
|
||||
ui->textBrowser->append ( QString ( "Camera:%1 [default]" ).arg ( inf.deviceName() ) );
|
||||
ui->textBrowser->append ( QString ( " description:%1" ).arg ( inf.description() ) );
|
||||
ui->textBrowser->append ( QString ( " position:%1" ).arg ( inf.position() ) );
|
||||
ui->textBrowser->append ( QString ( " orientation:%1" ).arg ( inf.orientation() ) );
|
||||
ui->textBrowser->append ( QString ( " isNull:%1" ).arg ( inf.isNull() ) );
|
||||
ui->textBrowser->append ( "" );
|
||||
|
||||
QListIterator<QCameraInfo> itor ( input->availableCameras() );
|
||||
while ( itor.hasNext() )
|
||||
{
|
||||
const QCameraInfo& inf = itor.next();
|
||||
ui->textBrowser->append ( QString ( "Camera:%1 [index]" ).arg ( inf.deviceName() ) );
|
||||
ui->textBrowser->append ( QString ( " description:%1" ).arg ( inf.description() ) );
|
||||
ui->textBrowser->append ( QString ( " position:%1" ).arg ( inf.position() ) );
|
||||
ui->textBrowser->append ( QString ( " orientation:%1" ).arg ( inf.orientation() ) );
|
||||
ui->textBrowser->append ( QString ( " isNull:%1" ).arg ( inf.isNull() ) );
|
||||
ui->textBrowser->append ( "" );
|
||||
}
|
||||
|
||||
pline() << input->viewFinderSettings().pixelFormat();
|
||||
pline() << input->camera()->supportedViewfinderPixelFormats();
|
||||
ui->textBrowser->append ( QString ( "Camera PixelFormat: [default]" ) );
|
||||
ui->textBrowser->append ( QString ( " %1" ).arg ( input->viewFinderSettings().pixelFormat() ) );
|
||||
QListIterator<QVideoFrame::PixelFormat> itor1 ( input->camera()->supportedViewfinderPixelFormats() );
|
||||
while ( itor1.hasNext() )
|
||||
{
|
||||
const QVideoFrame::PixelFormat& fmt = itor1.next();
|
||||
ui->textBrowser->append ( QString ( " %1 [index]" ).arg ( fmt ) );
|
||||
}
|
||||
ui->textBrowser->append ( "" );
|
||||
|
||||
connect ( input, SIGNAL ( readyRead ( QImage ) ), this, SLOT ( slotImageComing ( QImage ) ) );
|
||||
connect ( input, SIGNAL ( readyReadCapture ( QImage ) ), this, SLOT ( slotCapture ( QImage ) ) );
|
||||
|
||||
//input2 = new QQtVideoInput ( this );
|
||||
//connect ( input2, SIGNAL ( readyRead ( QImage ) ), this, SLOT ( slotImageComing2 ( QImage ) ) );
|
||||
|
||||
//QThread* thread = new QThread();
|
||||
//input2->moveToThread ( thread );
|
||||
//thread->start();
|
||||
|
||||
connect ( ui->pushButton_3, SIGNAL ( released() ), input, SLOT ( capture() ) );
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::slotImageComing ( QImage img )
|
||||
{
|
||||
ui->qqtwidget->setPixmap ( img );
|
||||
}
|
||||
|
||||
void MainWindow::slotImageComing2 ( QImage img )
|
||||
{
|
||||
ui->qqtwidget_2->setPixmap ( img );
|
||||
ui->qqtwidget_2->update();
|
||||
}
|
||||
|
||||
void MainWindow::slotCapture ( QImage image )
|
||||
{
|
||||
ui->qqtwidget_3->setPixmap ( image );
|
||||
}
|
||||
|
||||
void MainWindow::slotTestProbe ( const QVideoFrame& frame )
|
||||
{
|
||||
if ( !frame.isValid() )
|
||||
return;
|
||||
|
||||
QVideoFrame cloneFrame ( frame );
|
||||
/**
|
||||
* frame 可读
|
||||
*/
|
||||
if ( !cloneFrame.map ( QAbstractVideoBuffer::ReadOnly ) )
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
/**
|
||||
* 处理frame
|
||||
*/
|
||||
|
||||
//Android下的视频格式是怎么回事?需要转换吗?
|
||||
|
||||
const QImage _image ( cloneFrame.bits(),
|
||||
cloneFrame.width(),
|
||||
cloneFrame.height(),
|
||||
QVideoFrame::imageFormatFromPixelFormat ( cloneFrame.pixelFormat() ) );
|
||||
|
||||
//需要对水平方向反转。
|
||||
//Windows,现在的图像保存能成功,直接显示,程序会异常退出。使用QImage的mirrored函数进行了水平翻转,可以正常显示。
|
||||
//水平翻转是为了不崩溃,正常显示图像。必选。
|
||||
//垂直翻转是为了上下显示正常。
|
||||
const QImage image = _image.mirrored ( true, true );
|
||||
|
||||
/**
|
||||
* frame 不可读
|
||||
*/
|
||||
cloneFrame.unmap();
|
||||
|
||||
//emit readyRead ( image );
|
||||
slotImageComing ( image );
|
||||
return ;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_clicked()
|
||||
{
|
||||
input->start();
|
||||
input2->start();
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_2_clicked()
|
||||
{
|
||||
input->stop();
|
||||
input2->stop();
|
||||
}
|
37
test/videotest/mainwindow.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <qqtvideomanager.h>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow ( QWidget* parent = 0 );
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void slotImageComing ( QImage );
|
||||
void slotImageComing2 ( QImage );
|
||||
void slotCapture ( QImage );
|
||||
|
||||
void slotTestProbe ( const QVideoFrame& frame );
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
|
||||
QQtVideoInput* input;
|
||||
QQtVideoInput* input2;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
128
test/videotest/mainwindow.ui
Normal file
@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>475</width>
|
||||
<height>343</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>videotest</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<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>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser"/>
|
||||
</item>
|
||||
</layout>
|
||||
</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" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QQtWidget" name="qqtwidget_3" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QQtWidget" name="qqtwidget" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="2">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Capture</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>475</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QQtWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qqtwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
67
test/videotest/videotest.pro
Normal file
@ -0,0 +1,67 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2018-10-06T08:16:10
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = videotest
|
||||
TEMPLATE = app
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
include($${PWD}/../../multi-link/add_base_manager.pri)
|
||||
|
||||
#-------------------------------------------------
|
||||
#用户工程配置
|
||||
#-------------------------------------------------
|
||||
add_version(1,0,0,0)
|
||||
add_deploy()
|
||||
add_deploy_config($${PWD}/AppRoot)
|
||||
add_dependent_manager(QQt)
|
||||
#add_dependent_manager(QQtMediaExtention)
|
||||
system(touch main.cpp)
|
||||
|
||||
#-------------------------------------------------
|
||||
#用户工程配置
|
||||
#-------------------------------------------------
|
||||
equals(QSYS_PRIVATE, macOS) {
|
||||
CONFIG += app_bundle
|
||||
}
|
||||
|
||||
contains(QSYS_PRIVATE, Android|AndroidX86) {
|
||||
CONFIG += mobility
|
||||
MOBILITY =
|
||||
DISTFILES += \
|
||||
android/AndroidManifest.xml
|
||||
|
||||
ANDROID_PACKAGE_SOURCE_DIR = $${PWD}/android
|
||||
}
|
||||
|
||||
message ($${TARGET} config $${CONFIG})
|
||||
message ($${TARGET} DEFINE $${DEFINES})
|
||||
message ($${TARGET} prelink $${QMAKE_PRE_LINK})
|
||||
message ($${TARGET} postlink $${QMAKE_POST_LINK})
|
24
test/videotest2/AppRoot/skin/default.qss
Normal file
@ -0,0 +1,24 @@
|
||||
/*spinbox 抬起样式*/
|
||||
QTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button {
|
||||
subcontrol-origin:border;
|
||||
subcontrol-position:right;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
QTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button {
|
||||
subcontrol-origin:border;
|
||||
subcontrol-position:left;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
/*按钮按下样式*/
|
||||
QTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{
|
||||
subcontrol-origin:border;
|
||||
subcontrol-position:right;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
QTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{
|
||||
subcontrol-position:left;
|
||||
width: 12px;
|
||||
}
|
90
test/videotest2/android/AndroidManifest.xml
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0"?>
|
||||
<manifest package="org.qtproject.example.videotest2" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
|
||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="videotest2" android:icon="@drawable/icon">
|
||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="videotest2" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<!-- Application arguments -->
|
||||
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
|
||||
<!-- Application arguments -->
|
||||
|
||||
<meta-data android:name="android.app.lib_name" android:value="videotest2"/>
|
||||
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
||||
<meta-data android:name="android.app.repository" android:value="default"/>
|
||||
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
|
||||
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
|
||||
<!-- Deploy Qt libs as part of package -->
|
||||
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
|
||||
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
|
||||
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
|
||||
<!-- Run with local libs -->
|
||||
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
|
||||
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
||||
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so"/>
|
||||
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroid-bundled.jar"/>
|
||||
<meta-data android:name="android.app.static_init_classes" android:value=""/>
|
||||
<!-- Messages maps -->
|
||||
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
||||
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
||||
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
||||
<!-- Messages maps -->
|
||||
|
||||
<!-- Splash screen -->
|
||||
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
|
||||
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
|
||||
<!-- Splash screen -->
|
||||
|
||||
<!-- Background running -->
|
||||
<!-- Warning: changing this value to true may cause unexpected crashes if the
|
||||
application still try to draw after
|
||||
"applicationStateChanged(Qt::ApplicationSuspended)"
|
||||
signal is sent! -->
|
||||
<meta-data android:name="android.app.background_running" android:value="false"/>
|
||||
<!-- Background running -->
|
||||
|
||||
<!-- auto screen scale factor -->
|
||||
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
|
||||
<!-- auto screen scale factor -->
|
||||
|
||||
<!-- extract android style -->
|
||||
<!-- available android:values :
|
||||
* full - useful QWidget & Quick Controls 1 apps
|
||||
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
|
||||
* none - useful for apps that don't use any of the above Qt modules
|
||||
-->
|
||||
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
|
||||
<!-- extract android style -->
|
||||
</activity>
|
||||
|
||||
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
|
||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default permissions. -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default features. -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<!-- %%INSERT_PERMISSIONS -->
|
||||
<!-- %%INSERT_FEATURES -->
|
||||
<uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
|
||||
<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>
|
BIN
test/videotest2/android/res/drawable-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
test/videotest2/android/res/drawable-hdpi/icon.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
test/videotest2/android/res/drawable-ldpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
test/videotest2/android/res/drawable-ldpi/icon.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/videotest2/android/res/drawable-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
test/videotest2/android/res/drawable-mdpi/icon.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
test/videotest2/android/res/drawable-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 82 KiB |
18
test/videotest2/main.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QQtApplication>
|
||||
|
||||
int main ( int argc, char* argv[] )
|
||||
{
|
||||
|
||||
//高DPI下,需要支持
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
|
||||
QApplication::setAttribute ( Qt::AA_EnableHighDpiScaling );
|
||||
QApplication::setAttribute ( Qt::AA_UseHighDpiPixmaps );
|
||||
#endif
|
||||
|
||||
QQtApplication a ( argc, argv );
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
38
test/videotest2/mainwindow.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow ( QWidget* parent ) :
|
||||
QMainWindow ( parent ),
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
|
||||
manager = new QQtVideoManager ( this );
|
||||
pline() << manager->availableCameras();
|
||||
|
||||
//设置输入
|
||||
connect ( ui->pushButton, SIGNAL ( clicked ( bool ) ), manager, SLOT ( startInput() ) );
|
||||
connect ( ui->pushButton_2, SIGNAL ( clicked ( bool ) ), manager, SLOT ( stopInput() ) );
|
||||
connect ( ui->pushButton_3, SIGNAL ( clicked ( bool ) ), manager, SLOT ( capture() ) );
|
||||
|
||||
//设置输出
|
||||
manager->viewFinder() = ui->qqtwidget;
|
||||
|
||||
//设置截图输出
|
||||
//使用Wrapper建立信号和槽关系......
|
||||
QQtVideoOutput* output1 = new QQtVideoOutput ( this );
|
||||
output1->viewFinder() = ui->qqtwidget_2;
|
||||
|
||||
//建立输入、输出关系
|
||||
connect ( manager, SIGNAL ( readyRead ( QImage ) ), manager, SLOT ( outputImage ( QImage ) ) );
|
||||
connect ( manager, SIGNAL ( readyReadCapture ( QImage ) ), output1, SLOT ( setPixmap ( QImage ) ) );
|
||||
|
||||
//输入由页面控制,这里开启输出
|
||||
manager->startOutput();
|
||||
output1->start();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
24
test/videotest2/mainwindow.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <qqtvideomanager.h>
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow ( QWidget* parent = 0 );
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
|
||||
QQtVideoManager* manager;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
111
test/videotest2/mainwindow.ui
Normal file
@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>videotest2</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QQtWidget" name="qqtwidget" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QQtWidget" name="qqtwidget_2" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>81</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>0</y>
|
||||
<width>81</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<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>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QQtWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qqtwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
67
test/videotest2/videotest2.pro
Normal file
@ -0,0 +1,67 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2018-10-06T08:16:10
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = videotest2
|
||||
TEMPLATE = app
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
include($${PWD}/../../multi-link/add_base_manager.pri)
|
||||
|
||||
#-------------------------------------------------
|
||||
#用户工程配置
|
||||
#-------------------------------------------------
|
||||
add_version(1,0,0,0)
|
||||
add_deploy()
|
||||
add_deploy_config($${PWD}/AppRoot)
|
||||
add_dependent_manager(QQt)
|
||||
#add_dependent_manager(QQtMediaExtention)
|
||||
system(touch main.cpp)
|
||||
|
||||
#-------------------------------------------------
|
||||
#用户工程配置
|
||||
#-------------------------------------------------
|
||||
equals(QSYS_PRIVATE, macOS) {
|
||||
CONFIG += app_bundle
|
||||
}
|
||||
|
||||
contains(QSYS_PRIVATE, Android|AndroidX86) {
|
||||
CONFIG += mobility
|
||||
MOBILITY =
|
||||
DISTFILES += \
|
||||
android/AndroidManifest.xml
|
||||
|
||||
ANDROID_PACKAGE_SOURCE_DIR = $${PWD}/android
|
||||
}
|
||||
|
||||
message ($${TARGET} config $${CONFIG})
|
||||
message ($${TARGET} DEFINE $${DEFINES})
|
||||
message ($${TARGET} prelink $${QMAKE_PRE_LINK})
|
||||
message ($${TARGET} postlink $${QMAKE_POST_LINK})
|
24
test/videotest3/AppRoot/skin/default.qss
Normal file
@ -0,0 +1,24 @@
|
||||
/*spinbox 抬起样式*/
|
||||
QTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button {
|
||||
subcontrol-origin:border;
|
||||
subcontrol-position:right;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
QTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button {
|
||||
subcontrol-origin:border;
|
||||
subcontrol-position:left;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
/*按钮按下样式*/
|
||||
QTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{
|
||||
subcontrol-origin:border;
|
||||
subcontrol-position:right;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
QTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{
|
||||
subcontrol-position:left;
|
||||
width: 12px;
|
||||
}
|
90
test/videotest3/android/AndroidManifest.xml
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0"?>
|
||||
<manifest package="org.qtproject.example.videotest3" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
|
||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="videotest3" android:icon="@drawable/icon">
|
||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="videotest3" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<!-- Application arguments -->
|
||||
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
|
||||
<!-- Application arguments -->
|
||||
|
||||
<meta-data android:name="android.app.lib_name" android:value="videotest3"/>
|
||||
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
||||
<meta-data android:name="android.app.repository" android:value="default"/>
|
||||
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
|
||||
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
|
||||
<!-- Deploy Qt libs as part of package -->
|
||||
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
|
||||
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
|
||||
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
|
||||
<!-- Run with local libs -->
|
||||
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
|
||||
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
||||
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so"/>
|
||||
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroid-bundled.jar"/>
|
||||
<meta-data android:name="android.app.static_init_classes" android:value=""/>
|
||||
<!-- Messages maps -->
|
||||
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
||||
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
||||
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
||||
<!-- Messages maps -->
|
||||
|
||||
<!-- Splash screen -->
|
||||
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
|
||||
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
|
||||
<!-- Splash screen -->
|
||||
|
||||
<!-- Background running -->
|
||||
<!-- Warning: changing this value to true may cause unexpected crashes if the
|
||||
application still try to draw after
|
||||
"applicationStateChanged(Qt::ApplicationSuspended)"
|
||||
signal is sent! -->
|
||||
<meta-data android:name="android.app.background_running" android:value="false"/>
|
||||
<!-- Background running -->
|
||||
|
||||
<!-- auto screen scale factor -->
|
||||
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
|
||||
<!-- auto screen scale factor -->
|
||||
|
||||
<!-- extract android style -->
|
||||
<!-- available android:values :
|
||||
* full - useful QWidget & Quick Controls 1 apps
|
||||
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
|
||||
* none - useful for apps that don't use any of the above Qt modules
|
||||
-->
|
||||
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
|
||||
<!-- extract android style -->
|
||||
</activity>
|
||||
|
||||
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
|
||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default permissions. -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
||||
Remove the comment if you do not require these default features. -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<!-- %%INSERT_PERMISSIONS -->
|
||||
<!-- %%INSERT_FEATURES -->
|
||||
<uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
|
||||
<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>
|
BIN
test/videotest3/android/res/drawable-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
test/videotest3/android/res/drawable-hdpi/icon.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
test/videotest3/android/res/drawable-ldpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
test/videotest3/android/res/drawable-ldpi/icon.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/videotest3/android/res/drawable-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
test/videotest3/android/res/drawable-mdpi/icon.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
test/videotest3/android/res/drawable-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 82 KiB |