diff --git a/.github/workflows/backup-to-gitlab.yml b/.github/workflows/backup-to-gitlab.yml index c1763359..9863040f 100644 --- a/.github/workflows/backup-to-gitlab.yml +++ b/.github/workflows/backup-to-gitlab.yml @@ -8,10 +8,8 @@ concurrency: jobs: backup-to-gitlabwh: uses: linuxdeepin/.github/.github/workflows/backup-to-gitlabwh.yml@master - secrets: - BRIDGETOKEN: ${{ secrets.BRIDGETOKEN }} + secrets: inherit backup-to-gitee: uses: linuxdeepin/.github/.github/workflows/backup-to-gitee.yml@master - secrets: - GITEE_SYNC_TOKEN: ${{ secrets.GITEE_SYNC_TOKEN }} + secrets: inherit diff --git a/.github/workflows/call-build-deb.yml b/.github/workflows/call-build-deb.yml deleted file mode 100644 index fd67cbec..00000000 --- a/.github/workflows/call-build-deb.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Call build-deb -on: - pull_request_target: - paths-ignore: - - ".github/workflows/**" - types: [ opened, closed, synchronize ] - -concurrency: - group: ${{ github.workflow }}-pull/${{ github.event.number }} - cancel-in-progress: true - -jobs: - check_job: - if: github.event.action != 'closed' || github.event.pull_request.merged - uses: linuxdeepin/.github/.github/workflows/build-deb.yml@master - secrets: - BridgeToken: ${{ secrets.BridgeToken }} diff --git a/.github/workflows/call-build-distribution.yml b/.github/workflows/call-build-distribution.yml index c4c277ef..a509d5f8 100644 --- a/.github/workflows/call-build-distribution.yml +++ b/.github/workflows/call-build-distribution.yml @@ -10,8 +10,4 @@ on: jobs: check_job: uses: linuxdeepin/.github/.github/workflows/build-distribution.yml@master - secrets: - BUILD_GPG_PRIVATE_KEY: ${{ secrets.BUILD_GPG_PRIVATE_KEY }} - BUILD_SSH_PRIVATE_KEY: ${{ secrets.BUILD_SSH_PRIVATE_KEY }} - WEBDAV_PASSWD: ${{ secrets.WEBDAV_PASSWD }} - WEBDAV_USER: ${{ secrets.WEBDAV_USER }} + secrets: inherit diff --git a/.github/workflows/call-chatOps.yml b/.github/workflows/call-chatOps.yml index 0eb0b7bc..18c76bc3 100644 --- a/.github/workflows/call-chatOps.yml +++ b/.github/workflows/call-chatOps.yml @@ -6,5 +6,4 @@ on: jobs: chatopt: uses: linuxdeepin/.github/.github/workflows/chatOps.yml@master - secrets: - APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} + secrets: inherit diff --git a/.github/workflows/call-clacheck.yml b/.github/workflows/call-clacheck.yml index 3fa07a30..fe16a073 100644 --- a/.github/workflows/call-clacheck.yml +++ b/.github/workflows/call-clacheck.yml @@ -12,5 +12,4 @@ concurrency: jobs: clacheck: uses: linuxdeepin/.github/.github/workflows/cla-check.yml@master - secrets: - APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} + secrets: inherit diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index 6a92b546..e808a89b 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - run: export - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} persist-credentials: false diff --git a/.obs/workflows.yml b/.obs/workflows.yml new file mode 100644 index 00000000..8c18fe03 --- /dev/null +++ b/.obs/workflows.yml @@ -0,0 +1,43 @@ +test_build: + steps: + - link_package: + source_project: deepin:Develop:dde + source_package: %{SCM_REPOSITORY_NAME} + target_project: deepin:CI + + - configure_repositories: + project: deepin:CI + repositories: + - name: deepin_develop + paths: + - target_project: deepin:CI + target_repository: deepin_develop + architectures: + - x86_64 + - aarch64 + + - name: debian + paths: + - target_project: deepin:CI + target_repository: debian_sid + architectures: + - x86_64 + + filters: + event: pull_request + +tag_build: + steps: + - trigger_services: + project: deepin:Unstable:dde + package: %{SCM_REPOSITORY_NAME} + filters: + event: tag_push + +commit_build: + steps: + - trigger_services: + project: deepin:Develop:dde + package: %{SCM_REPOSITORY_NAME} + filters: + event: push diff --git a/.reuse/dep5 b/.reuse/dep5 index 327938af..e812a629 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -4,7 +4,7 @@ Upstream-Contact: UnionTech Software Technology Co., Ltd. <> Source: https://github.com/linuxdeepin/deepin-camera # ci -Files: .github/* +Files: .github/* .obs/workflows.yml Copyright: None License: CC0-1.0 @@ -23,6 +23,11 @@ Files: debian/* Copyright: None License: CC0-1.0 +# patchs +Files: patches/* +Copyright: None +License: CC0-1.0 + # selinux Files: selinux/* Copyright: None diff --git a/debian/changelog b/debian/changelog index 4763c5ee..167fb5d9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,50 +1,81 @@ -deepin-camera (1.4.16) unstable; urgency=medium +deepin-camera (6.0.12) unstable; urgency=medium - * New version 1.4.16 + * tag 6.0.12 - -- xiepengfei Fri, 04 Aug 2023 16:05:28 +0800 + -- shuaijie Mon, 19 Aug 2024 15:32:02 +0800 -deepin-camera (1.4.15) unstable; urgency=medium +deepin-camera (6.0.11) unstable; urgency=medium - * New version 1.4.15 + * tag 6.0.11 - -- xiepengfei Wed, 19 Jul 2023 16:05:28 +0800 + -- zhanghongyuan Thu, 08 Aug 2024 13:56:32 +0800 -deepin-camera (1.4.14) unstable; urgency=medium +deepin-camera (6.0.10) unstable; urgency=medium - * New version 1.4.14 + * tag 6.0.10 - -- xiepengfei Wed, 12 Jul 2023 14:47:36 +0800 + -- shuaijie Sun, 28 Apr 2024 10:41:02 +0800 -deepin-camera (1.4.13) unstable; urgency=medium +deepin-camera (6.0.9) unstable; urgency=medium - * New version 1.4.13 + * Update version to 6.0.9(No code changes!) - -- xiepengfei Tues, 30 May 2023 17:41:09 +0800 + -- lijiaxuan Fri, 12 Apr 2024 15:26:02 +0800 -deepin-camera (1.4.12) unstable; urgency=medium +deepin-camera (6.0.8) unstable; urgency=medium - * New version 1.4.12 + * tag 6.0.8 - -- fengli Mon, 08 May 2023 15:15:09 +0800 + -- shuaijie Tue, 09 Apr 2024 16:12:13 +0800 -deepin-camera (1.4.11) unstable; urgency=medium +deepin-camera (6.0.7) unstable; urgency=medium - * New version 1.4.11 + * fix: Fix the issue of crashing when connecting to a USB camera or a laptop with a built-in camera in v23 and starting the camera(Bug: 238775) + * fix: modify the default video format for recording to webm 2nd(Bug: 237059) - -- fengli Tue, 21 Mar 2023 17:41:33 +0800 + -- houchengqiu Tue, 27 Feb 2024 13:54:19 +0800 -deepin-camera (1.4.10) UNSTABLE; urgency=medium +deepin-camera (6.0.6) unstable; urgency=medium - * New version 1.4.10 + * tag 6.0.6 - -- fengli Thu, 23 Feb 2023 10:50:31 +0800 + -- fengli Wed, 03 Jan 2024 16:12:13 +0800 -deepin-camera (1.4.9) unstable; urgency=medium +deepin-camera (6.0.5) unstable; urgency=medium - * New version 1.4.9 + * fix: modify the default video format for recording to webm + * fix: Resolve the issue of camera icons not being visible in the + help manual - -- xiepengfei Tue, 07 Feb 2023 17:56:54 +0800 + -- fengli Fri, 22 Dec 2023 10:16:55 +0800 + +deepin-camera (6.0.4) unstable; urgency=medium + + * fix: static image appears blow when opening the camera + * fix: quick click on satrt/end button during high-resolution recording + causing crash + * fix: determine single instance execution through DTK interface + + -- fengli Wed, 06 Dec 2023 13:22:50 +0800 + +deepin-camera (6.0.3) unstable; urgency=medium + + * Merge release/eagle branch changes into the master branch. + * Fix some bugs: 198571 198939 200273 207319 217973 + + -- renbin Fri, 13 Oct 2023 16:18:50 +0800 + +deepin-camera (6.0.2) unstable; urgency=medium + + * New version 6.0.2 + + -- shuaijie Fri, 10 March 2023 16:21:00 +0800 + +deepin-camera (6.0.1) unstable; urgency=medium + + * New version 6.0.1 + + -- muyuankai Mon, 13 Jun 2022 10:40:00 +0800 deepin-camera (1.0.0-1) unstable; urgency=medium diff --git a/debian/control b/debian/control index 7204cc45..ba07a007 100644 --- a/debian/control +++ b/debian/control @@ -6,11 +6,13 @@ Build-Depends: debhelper (>=9),cmake, pkg-config,qtbase5-dev,libdtkgui-dev,libdtkwidget-dev,qtmultimedia5-dev, libavutil-dev, libavformat-dev, libavcodec-dev,libavfilter-dev,qttools5-dev, - qttools5-dev-tools,deepin-gettext-tools,libdframeworkdbus-dev, - libv4l-dev,libsdl2-dev,portaudio19-dev,libpng-dev,libasound2-dev, - libkf5wayland-dev, + qttools5-dev-tools,deepin-gettext-tools, + libv4l-dev,libsdl2-dev,portaudio19-dev,libpng-dev,libasound2-dev,libpciaccess-dev, libusb-1.0-0-dev,zlib1g-dev,libudev-dev,libswscale-dev,libswresample-dev,libffmpegthumbnailer-dev, - libx11-dev,libva-dev,libimageeditor-dev,libgstreamer1.0-dev,libgstreamer-plugins-base1.0-dev,gstreamer1.0-plugins-good + libx11-dev,libva-dev,libimageeditor-dev, + libdwayland-dev | libkf5wayland-dev, + libwayland-dev, + libgstreamer1.0-dev,libgstreamer-plugins-base1.0-dev,gstreamer1.0-plugins-good Standards-Version: 4.1.2 Homepage: http://www.deepin.org @@ -19,7 +21,11 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, - libasound2 (>= 1.0.16), libavcodec58 (>= 7:4.0), libavformat58 (>= 7:4.1), libavutil56 (>= 7:4.0), libdtkcore5, libdtkgui5, libdtkwidget5, libffmpegthumbnailer4v5, libgl1, libpng16-16 (>= 1.6.2-1), libportaudio2 (>= 19+svn20101113), libqt5concurrent5 (>= 5.0.2), libqt5core5a (>= 5.11.0~rc1), libqt5dbus5 (>= 5.0.2), libqt5gui5 (>= 5.8.0), libqt5network5 (>= 5.0.2), libqt5printsupport5 (>= 5.0.2), libqt5widgets5 (>= 5.2.0~alpha1), libqt5x11extras5 (>= 5.6.0), libqt5xml5 (>= 5.0.2), libsdl2-2.0-0 (>= 2.0.9), libstdc++6 (>= 7), libswresample3 (>= 7:4.0), libswscale5 (>= 7:4.0), libudev1 (>= 183), libusb-1.0-0 (>= 2:1.0.8), libv4l-0 (>= 0.5.0), zlib1g (>= 1:1.1.4), , libgstreamer-plugins-base1.0-0 (>= 1.0.0), libgstreamer1.0-0 (>= 1.4.0), dde-api + libavcodec58 (>= 7:4.0) | libavcodec60, libavformat58 (>= 7:4.1) | libavformat60, libavutil56 (>= 7:4.0) | libavutil58, libswresample3 (>= 7:4.0) | libswresample4, libswscale5 (>= 7:4.0) | libswscale7, + libdtkcore5, libdtkgui5, libdtkwidget5, libffmpegthumbnailer4v5, libgl1, libpng16-16 (>= 1.6.2-1), libportaudio2 (>= 19+svn20101113), libqt5concurrent5 (>= 5.0.2), libqt5core5a (>= 5.11.0~rc1), + libqt5dbus5 (>= 5.0.2), libqt5gui5 (>= 5.8.0), libqt5network5 (>= 5.0.2), libqt5printsupport5 (>= 5.0.2), libqt5widgets5 (>= 5.2.0~alpha1), libqt5x11extras5 (>= 5.6.0), libasound2 (>= 1.0.16), + libqt5xml5 (>= 5.0.2), libsdl2-2.0-0 (>= 2.0.9), libstdc++6 (>= 7), libudev1 (>= 183), libusb-1.0-0 (>= 2:1.0.8), libv4l-0 (>= 0.5.0), zlib1g (>= 1:1.1.4), libgstreamer-plugins-base1.0-0 (>= 1.0.0), libgstreamer1.0-0 (>= 1.4.0), dde-api, + libdwaylandclient5 | libkf5waylandclient5, libdwaylandserver5 | libkf5waylandserver5 Recommends: libimageeditor, uos-reporter, deepin-event-log Description:this package software for UOS deepin-camera is a tool to view camera, and also a smart take photo and video in life. diff --git a/debian/deepin-camera.lintian-overrides b/debian/deepin-camera.lintian-overrides index b74e0266..1d444347 100644 --- a/debian/deepin-camera.lintian-overrides +++ b/debian/deepin-camera.lintian-overrides @@ -1,2 +1,2 @@ # Maintainer scripts create plugins.dat there. -deepin-camera: non-standard-toplevel-dir temp/ +# deepin-camera: non-standard-toplevel-dir temp/ diff --git a/debian/deepin-camera.postinst b/debian/deepin-camera.postinst deleted file mode 100644 index 5f2a7edd..00000000 --- a/debian/deepin-camera.postinst +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -#set -e -MODULE_NAME=deepin-camera -SELINUX_CONFIG=/etc/selinux/config -SHARE_PATH=/usr/share -SELINUX_PP_TEMP_DIR=/temp/${MODULE_NAME} -#LIB_FILE="/lib/xxx.so /lib/yyy.so" -LIB_FILE="" -#CONFIG_FILE="/etc/${MODULE_NAME}" -CONFIG_FILE="" -#SERVICE_FILE=/lib/systemd/system/${MODULE_NAME}.service -SERVICE_FILE= -EXECUTABLE_FILE=/usr/bin/${MODULE_NAME} -ALL_NEED_RELABELED_FILE="${LIB_FILE} ${CONFIG_FILE} ${EXECUTABLE_FILE} ${SERVICE_FILE}" -SELINUX_DEV=`dpkg -l | grep "ii selinux-policy-dev"` - -if [ -z "$SELINUX_DEV" ];then - rm -rf /temp > /dev/null 2>&1 - exit 0 -fi - -if [ ! -d ${SELINUX_PP_TEMP_DIR} ];then - rm -rf /temp > /dev/null 2>&1 - exit 0 -fi - -if [ -f ${SELINUX_CONFIG} ];then - SELINUX_PP_DIR=`find /usr/share/selinux -name *.pp.bz2 | cut -d '/' -f 5 | uniq` - for i in ${SELINUX_PP_DIR} - do - if [ -d ${SHARE_PATH}/selinux/${i} ];then - install -D -m 644 ${SELINUX_PP_TEMP_DIR}/${MODULE_NAME}.pp.bz2 ${SHARE_PATH}/selinux/${i}/${MODULE_NAME}.pp.bz2 > /dev/null 2>&1 - fi - done - SELINUX_STATUS=`getenforce` - SELINUX_MODE=`cat ${SELINUX_CONFIG} | grep '^SELINUXTYPE=' |tail -n 1|cut -d '=' -f 2` - if [ ! $SELINUX_STATUS = "Disabled" ];then - restorecon -R ${SHARE_PATH}/selinux > /dev/null 2>&1 - semodule -X 100 -i ${SHARE_PATH}/selinux/${SELINUX_MODE}/${MODULE_NAME}.pp.bz2 > /dev/null 2>&1 - restorecon -RF ${ALL_NEED_RELABELED_FILE} - fi -fi - -rm -rf /temp > /dev/null 2>&1 -exit 0 diff --git a/debian/deepin-camera.prerm b/debian/deepin-camera.prerm deleted file mode 100644 index 0e3af1cc..00000000 --- a/debian/deepin-camera.prerm +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -#set -e -MODULE_NAME=deepin-camera -SELINUX_CONFIG=/etc/selinux/config -SHARE_PATH=/usr/share -SELINUX_STATUS=`getenforce` -SELINUX_DEV=`dpkg -l | grep "ii selinux-policy-dev"` - -if [ -z "$SELINUX_DEV" ];then - exit 0 -fi - -if [ -f ${SELINUX_CONFIG} ];then - SELINUX_PP_DIR=`find /usr/share/selinux -name *.pp.bz2 | cut -d '/' -f 5 | uniq` - for i in ${SELINUX_PP_DIR} - do - if [ -d ${SHARE_PATH}/selinux/${i} ];then - rm -f ${SELINUX_PP_TEMP_DIR}/${MODULE_NAME}.pp.bz2 ${SHARE_PATH}/selinux/${i}/${MODULE_NAME}.pp.bz2 > /dev/null 2>&1 - fi - done - - semodule -X 100 -r ${MODULE_NAME} > /dev/null 2>&1 -fi -exit 0 diff --git a/debian/rules b/debian/rules index 11a2f013..0a27c703 100755 --- a/debian/rules +++ b/debian/rules @@ -2,10 +2,9 @@ include /usr/share/dpkg/default.mk export QT_SELECT=5 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) -SELINUX_DEV ?= $(shell dpkg -l | grep "ii selinux-policy-dev") MODULE_NAME=deepin-camera -SELINUX_PP_TEMP_DIR=temp/${MODULE_NAME} + %: dh $@ --parallel @@ -13,10 +12,4 @@ override_dh_auto_configure: dh_auto_configure -- \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ - -DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) - - -override_dh_install: - mkdir -pv debian/${MODULE_NAME}/${SELINUX_PP_TEMP_DIR} > /dev/null 2>&1 - cp selinux/*.pp* debian/${MODULE_NAME}/${SELINUX_PP_TEMP_DIR}/ > /dev/null 2>&1 - dh_install + -DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) diff --git a/libcam/libcam/camview.c b/libcam/libcam/camview.c index 338ff4d9..45687bdd 100644 --- a/libcam/libcam/camview.c +++ b/libcam/libcam/camview.c @@ -104,10 +104,14 @@ static int my_encoder_status = 0; static int is_wayland = 0; //是否是wayland的窗口管理器 +static int is_pgux = 0; //是否是pugx + static uint8_t soundTakePhoto = 1;//拍照声音提示 static char status_message[80]; +static int encode_thread_running = 0; + void set_video_time_capture(double video_time) { @@ -792,7 +796,8 @@ static void *encoder_loop(__attribute__((unused))void *data) v4l2core_get_fps_num(my_vd), v4l2core_get_fps_denom(my_vd), channels, - samprate); + samprate, + get_pugx_status()); /*store external SPS and PPS data if needed*/ if(encoder_ctx->video_codec_ind == 0 && /*raw - direct input*/ @@ -1290,13 +1295,18 @@ void *capture_loop(void *data) */ int start_encoder_thread(void *data) { + if (encode_thread_running) + return 0; + int ret = __THREAD_CREATE(&encoder_thread, encoder_loop, data); - if(ret) + if(ret) { fprintf(stderr, "deepin-camera: encoder thread creation failed (%i)\n", ret); - else if(debug_level > 2) - printf("deepin-camera: created encoder thread with tid: %u\n", - (unsigned int) encoder_thread); + } else { + if(debug_level > 2) + printf("deepin-camera: created encoder thread with tid: %u\n", (unsigned int) encoder_thread); + encode_thread_running = 1; + } return ret; } @@ -1324,6 +1334,8 @@ int stop_encoder_thread() if(debug_level > 1) printf("deepin-camera: encoder thread terminated and joined\n"); + encode_thread_running = 0; + return 0; } @@ -1346,3 +1358,13 @@ int get_sound_of_takeing_photo() { return soundTakePhoto; } + +void set_pugx_status(int status) +{ + is_pgux = status; +} + +int get_pugx_status() +{ + return is_pgux; +} diff --git a/libcam/libcam/camview.h b/libcam/libcam/camview.h index 191a6b56..5efd5b6a 100644 --- a/libcam/libcam/camview.h +++ b/libcam/libcam/camview.h @@ -431,6 +431,9 @@ void set_takeing_photo_sound(uint8_t status); int get_sound_of_takeing_photo(void); +void set_pugx_status(int status); + +int get_pugx_status(); #ifdef __cplusplus } diff --git a/libcam/libcam_encoder/encoder.c b/libcam/libcam_encoder/encoder.c index 94fc3706..e6ff475e 100644 --- a/libcam/libcam_encoder/encoder.c +++ b/libcam/libcam_encoder/encoder.c @@ -43,6 +43,7 @@ /* support for internationalization - i18n */ #include #include +#include #include "cameraconfig.h" #include "gviewencoder.h" @@ -56,6 +57,55 @@ #include #endif + +#include +#include +#include + +#include +#include +#include + +typedef enum _vaapi_status_t +{ + HW_VAAPI_OK = 0, + HW_VAAPI_FAIL1, + HW_VAAPI_FAIL2, + HW_VAAPI_FAIL3, + HW_VAAPI_FAIL4, + HW_VAAPI_FAIL5, + HW_VAAPI_FAIL6, + HW_VAAPI_FAIL7, + HW_VAAPI_FAIL8, + HW_VAAPI_FAIL9, + HW_VAAPI_FAIL10, + HW_VAAPI_FAIL11, + HW_VAAPI_FAIL12, + HW_VAAPI_FAIL13, + HW_VAAPI_FAIL14, + HW_VAAPI_FAIL15, + HW_VAAPI_FAIL16, + HW_VAAPI_FAIL17, + HW_VAAPI_FAIL18, + HW_VAAPI_FAIL19, + HW_VAAPI_FAIL20, + HW_VAAPI_FAIL21, + HW_VAAPI_FAIL22, + HW_VAAPI_FAIL23, + HW_VAAPI_FAIL24, + HW_VAAPI_FAIL25, + HW_VAAPI_FAIL26, + HW_VAAPI_FAIL27, + HW_VAAPI_FAIL28, + HW_VAAPI_FAIL29 +}vaapi_status_t; + +static encoder_video_context_t *encoder_video_init_vaapi(encoder_context_t *encoder_ctx); +int encoder_encode_video_vaapi(encoder_context_t *encoder_ctx, void *input_frame); +void vaapi_over(void); + +static vaapi_status_t is_vaapi = HW_VAAPI_OK; //0=ok + extern int verbosity; extern int encodeenv; @@ -90,7 +140,8 @@ static int64_t video_pause_timestamp = 0; * * returns: none */ -void set_video_pause_timestamp(int64_t timestamp){ +void set_video_pause_timestamp(int64_t timestamp) +{ video_pause_timestamp = timestamp; } @@ -121,7 +172,7 @@ int64_t get_video_pause_timestamp() */ void encoder_set_verbosity(int value) { - verbosity = value; + verbosity = value; } /* @@ -139,38 +190,35 @@ void encoder_set_verbosity(int value) * returns: none */ static void encoder_alloc_video_ring_buffer( - int video_width, - int video_height, - int fps_den, - int fps_num, - int codec_ind) + int video_width, + int video_height, + int fps_den, + int fps_num, + int codec_ind) { - video_ring_buffer_size = (fps_den * 3) / (fps_num * 2); /* 1.5 sec */ - if(video_ring_buffer_size < 20) - video_ring_buffer_size = 20; /*at least 20 frames buffer*/ - video_ring_buffer = calloc(video_ring_buffer_size, sizeof(video_buffer_t)); - if(video_ring_buffer == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_alloc_video_ring_buffer): %s\n", strerror(errno)); - exit(-1); - } - - if(codec_ind > 0) - video_frame_max_size = (video_width * video_height * 3) / 2; - else - video_frame_max_size = video_width * video_height * 3; //RGB formats + video_ring_buffer_size = (fps_den * 3) / (fps_num * 2); /* 1.5 sec */ + if (video_ring_buffer_size < 20) + video_ring_buffer_size = 20; /*at least 20 frames buffer*/ + video_ring_buffer = calloc(video_ring_buffer_size, sizeof(video_buffer_t)); + if (video_ring_buffer == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_alloc_video_ring_buffer): %s\n", strerror(errno)); + exit(-1); + } - int i = 0; - for(i = 0; i < video_ring_buffer_size; ++i) - { - video_ring_buffer[i].frame = calloc(video_frame_max_size, sizeof(uint8_t)); - if(video_ring_buffer[i].frame == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_alloc_video_ring_buffer): %s\n", strerror(errno)); - exit(-1); - } - video_ring_buffer[i].flag = VIDEO_BUFF_FREE; - } + if (codec_ind > 0) + video_frame_max_size = (video_width * video_height * 3) / 2; + else + video_frame_max_size = video_width * video_height * 3; //RGB formats + + int i = 0; + for (i = 0; i < video_ring_buffer_size; ++i) { + video_ring_buffer[i].frame = calloc(video_frame_max_size, sizeof(uint8_t)); + if (video_ring_buffer[i].frame == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_alloc_video_ring_buffer): %s\n", strerror(errno)); + exit(-1); + } + video_ring_buffer[i].flag = VIDEO_BUFF_FREE; + } } /* @@ -185,17 +233,16 @@ static void encoder_alloc_video_ring_buffer( */ static void encoder_clean_video_ring_buffer() { - if(!video_ring_buffer) - return; + if (!video_ring_buffer) + return; - int i = 0; - for(i = 0; i < video_ring_buffer_size; ++i) - { - /*Max: (yuyv) 2 bytes per pixel*/ - free(video_ring_buffer[i].frame); - } - free(video_ring_buffer); - video_ring_buffer = NULL; + int i = 0; + for (i = 0; i < video_ring_buffer_size; ++i) { + /*Max: (yuyv) 2 bytes per pixel*/ + free(video_ring_buffer[i].frame); + } + free(video_ring_buffer); + video_ring_buffer = NULL; } /* @@ -214,18 +261,18 @@ void /*__attribute__ ((constructor)) */gviewencoder_init() return; #if !LIBAVCODEC_VER_AT_LEAST(57,16) - fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)\n"); - return; + fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)\n"); + return; #endif #if !LIBAVCODEC_VER_AT_LEAST(58,9) - //printf("ENCODER: constructor function called\n"); - /* register all the codecs (you can also register only the codec - * you wish to have smaller code) - */ - avcodec_register_all(); + //printf("ENCODER: constructor function called\n"); + /* register all the codecs (you can also register only the codec + * you wish to have smaller code) + */ + avcodec_register_all(); #endif - valid_video_codecs = encoder_set_valid_video_codec_list (); - valid_audio_codecs = encoder_set_valid_audio_codec_list (); + valid_video_codecs = encoder_set_valid_video_codec_list(); + valid_audio_codecs = encoder_set_valid_audio_codec_list(); } @@ -241,10 +288,10 @@ void /*__attribute__ ((constructor)) */gviewencoder_init() */ void /*__attribute__ ((destructor))*/ gviewencoder_fini() { - if(verbosity > 1) - printf("ENCODER: destructor function called\n"); - //make sure to clean the ring buffer - encoder_clean_video_ring_buffer(); + if (verbosity > 1) + printf("ENCODER: destructor function called\n"); + //make sure to clean the ring buffer + encoder_clean_video_ring_buffer(); } /* @@ -260,15 +307,14 @@ void /*__attribute__ ((destructor))*/ gviewencoder_fini() */ static int encoder_check_audio_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt) { - const enum AVSampleFormat *p = codec->sample_fmts; + const enum AVSampleFormat *p = codec->sample_fmts; - while (*p != AV_SAMPLE_FMT_NONE) - { - if (*p == sample_fmt) - return 1; - p++; - } - return 0; + while (*p != AV_SAMPLE_FMT_NONE) { + if (*p == sample_fmt) + return 1; + p++; + } + return 0; } /* * check that a given sample rate is supported by the encoder @@ -283,22 +329,21 @@ static int encoder_check_audio_sample_fmt(AVCodec *codec, enum AVSampleFormat sa */ static int select_sample_rate(const AVCodec *codec, int sample_rate) { - const int *p; - int best_samplerate = 0; + const int *p; + int best_samplerate = 0; - if (!codec->supported_samplerates) - return sample_rate; + if (!codec->supported_samplerates) + return sample_rate; - p = codec->supported_samplerates; - while (*p) - { - if (*p == sample_rate) - return sample_rate; + p = codec->supported_samplerates; + while (*p) { + if (*p == sample_rate) + return sample_rate; - best_samplerate = FFMAX(*p, best_samplerate); - p++; + best_samplerate = FFMAX(*p, best_samplerate); + p++; } - return best_samplerate; + return best_samplerate; } /* * video encoder initialization for raw input @@ -318,64 +363,59 @@ static int select_sample_rate(const AVCodec *codec, int sample_rate) static void encoder_set_raw_video_input( encoder_context_t *encoder_ctx, video_codec_t *video_defaults - ) +) { - //assertions - assert(encoder_ctx != NULL); - assert(encoder_ctx->enc_video_ctx != NULL); + //assertions + assert(encoder_ctx != NULL); + assert(encoder_ctx->enc_video_ctx != NULL); + + encoder_ctx->video_codec_ind = 0; + + switch (encoder_ctx->input_format) { + case V4L2_PIX_FMT_MJPEG: + strncpy(video_defaults->compressor, "MJPG", 5); + video_defaults->mkv_4cc = v4l2_fourcc('M', 'J', 'P', 'G'); + strncpy(video_defaults->mkv_codec, "V_MS/VFW/FOURCC", 25); + encoder_ctx->enc_video_ctx->outbuf_size = (encoder_ctx->video_width * encoder_ctx->video_height) / 2; + encoder_ctx->enc_video_ctx->outbuf = calloc(encoder_ctx->enc_video_ctx->outbuf_size, sizeof(uint8_t)); + if (encoder_ctx->enc_video_ctx->outbuf == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } + break; - encoder_ctx->video_codec_ind = 0; + case V4L2_PIX_FMT_H264: + strncpy(video_defaults->compressor, "H264", 5); + video_defaults->mkv_4cc = v4l2_fourcc('H', '2', '6', '4'); + strncpy(video_defaults->mkv_codec, "V_MPEG4/ISO/AVC", 25); + encoder_ctx->enc_video_ctx->outbuf_size = (encoder_ctx->video_width * encoder_ctx->video_height) / 2; + encoder_ctx->enc_video_ctx->outbuf = calloc(encoder_ctx->enc_video_ctx->outbuf_size, sizeof(uint8_t)); + if (encoder_ctx->enc_video_ctx->outbuf == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } + break; - switch(encoder_ctx->input_format) - { - case V4L2_PIX_FMT_MJPEG: - strncpy(video_defaults->compressor, "MJPG", 5); - video_defaults->mkv_4cc = v4l2_fourcc('M','J','P','G'); - strncpy(video_defaults->mkv_codec, "V_MS/VFW/FOURCC", 25); - encoder_ctx->enc_video_ctx->outbuf_size = (encoder_ctx->video_width * encoder_ctx->video_height) / 2; - encoder_ctx->enc_video_ctx->outbuf = calloc(encoder_ctx->enc_video_ctx->outbuf_size, sizeof(uint8_t)); - if(encoder_ctx->enc_video_ctx->outbuf == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } - break; - - case V4L2_PIX_FMT_H264: - strncpy(video_defaults->compressor, "H264", 5); - video_defaults->mkv_4cc = v4l2_fourcc('H','2','6','4'); - strncpy(video_defaults->mkv_codec, "V_MPEG4/ISO/AVC", 25); - encoder_ctx->enc_video_ctx->outbuf_size = (encoder_ctx->video_width * encoder_ctx->video_height) / 2; - encoder_ctx->enc_video_ctx->outbuf = calloc(encoder_ctx->enc_video_ctx->outbuf_size, sizeof(uint8_t)); - if(encoder_ctx->enc_video_ctx->outbuf == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } - break; - - default: - { - char fourcc[5]; - fourcc[0]= (char) encoder_ctx->input_format & 0xFF; - fourcc[1]= (char) encoder_ctx->input_format & 0xFF00 >> 8; - fourcc[2]= (char) encoder_ctx->input_format & 0xFF0000 >> 16; - fourcc[3]= (char) encoder_ctx->input_format & 0xFF000000 >> 24; - fourcc[4]='\0'; - - strncpy(video_defaults->compressor, fourcc, 5); - video_defaults->mkv_4cc = encoder_ctx->input_format; //v4l2_fourcc('Y','U','Y','2') - strncpy(video_defaults->mkv_codec, "V_MS/VFW/FOURCC", 25); - encoder_ctx->enc_video_ctx->outbuf_size = encoder_ctx->video_width * encoder_ctx->video_height * 3; //max of 3 bytes per pixel - encoder_ctx->enc_video_ctx->outbuf = calloc(encoder_ctx->enc_video_ctx->outbuf_size, sizeof(uint8_t)); - if(encoder_ctx->enc_video_ctx->outbuf == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } - break; - } - } + default: { + char fourcc[5]; + fourcc[0] = (char) encoder_ctx->input_format & 0xFF; + fourcc[1] = (char) encoder_ctx->input_format & 0xFF00 >> 8; + fourcc[2] = (char) encoder_ctx->input_format & 0xFF0000 >> 16; + fourcc[3] = (char) encoder_ctx->input_format & 0xFF000000 >> 24; + fourcc[4] = '\0'; + + strncpy(video_defaults->compressor, fourcc, 5); + video_defaults->mkv_4cc = encoder_ctx->input_format; //v4l2_fourcc('Y','U','Y','2') + strncpy(video_defaults->mkv_codec, "V_MS/VFW/FOURCC", 25); + encoder_ctx->enc_video_ctx->outbuf_size = encoder_ctx->video_width * encoder_ctx->video_height * 3; //max of 3 bytes per pixel + encoder_ctx->enc_video_ctx->outbuf = calloc(encoder_ctx->enc_video_ctx->outbuf_size, sizeof(uint8_t)); + if (encoder_ctx->enc_video_ctx->outbuf == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } + break; + } + } } /* @@ -388,276 +428,263 @@ static void encoder_set_raw_video_input( * * returns: pointer to encoder video context (NULL on none) */ -static encoder_video_context_t *encoder_video_init(encoder_context_t *encoder_ctx) +static encoder_video_context_t *encoder_video_init(encoder_context_t *encoder_ctx, int pgux) { - //assertions - assert(encoder_ctx != NULL); + //assertions + assert(encoder_ctx != NULL); #if !LIBAVCODEC_VER_AT_LEAST(57,16) - fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)\n"); - return NULL; + fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)\n"); + return NULL; #else - if(encoder_ctx->video_codec_ind < 0) - { - if(verbosity > 0) - printf("ENCODER: no video codec set - using raw (direct input)\n"); + if (encoder_ctx->video_codec_ind < 0) { + if (verbosity > 0) + printf("ENCODER: no video codec set - using raw (direct input)\n"); - encoder_ctx->video_codec_ind = 0; - } + encoder_ctx->video_codec_ind = 0; + } + + video_codec_t *video_defaults = encoder_get_video_codec_defaults(encoder_ctx->video_codec_ind); + + if (!video_defaults) { + fprintf(stderr, "ENCODER: defaults for video codec index %i not found: using raw (direct input)\n", + encoder_ctx->video_codec_ind); + encoder_ctx->video_codec_ind = 0; + video_defaults = encoder_get_video_codec_defaults(encoder_ctx->video_codec_ind); + if (!video_defaults) { + /*should never happen*/ + fprintf(stderr, "ENCODER: defaults for raw video not found\n"); + return NULL; + } + } - video_codec_t *video_defaults = encoder_get_video_codec_defaults(encoder_ctx->video_codec_ind); + encoder_video_context_t *enc_video_ctx = calloc(1, sizeof(encoder_video_context_t)); + if (enc_video_ctx == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } - if(!video_defaults) - { - fprintf(stderr, "ENCODER: defaults for video codec index %i not found: using raw (direct input)\n", - encoder_ctx->video_codec_ind); - encoder_ctx->video_codec_ind = 0; - video_defaults = encoder_get_video_codec_defaults(encoder_ctx->video_codec_ind); - if(!video_defaults) - { - /*should never happen*/ - fprintf(stderr, "ENCODER: defaults for raw video not found\n"); - return NULL; - } - } - - encoder_video_context_t *enc_video_ctx = calloc(1, sizeof(encoder_video_context_t)); - if(enc_video_ctx == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } + /* make sure enc_video_ctx is set in encoder_ctx */ + encoder_ctx->enc_video_ctx = enc_video_ctx; - /* make sure enc_video_ctx is set in encoder_ctx */ - encoder_ctx->enc_video_ctx = enc_video_ctx; + if (encoder_ctx->video_codec_ind == 0) { + encoder_set_raw_video_input(encoder_ctx, video_defaults); + return (enc_video_ctx); + } - if(encoder_ctx->video_codec_ind == 0) - { - encoder_set_raw_video_input(encoder_ctx, video_defaults); - return (enc_video_ctx); - } - - /* - * alloc the video codec data - */ - encoder_codec_data_t *video_codec_data = calloc(1, sizeof(encoder_codec_data_t)); - if(video_codec_data == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } - /* - * find the video encoder - * try specific codec (by name) - */ + /* + * alloc the video codec data + */ + encoder_codec_data_t *video_codec_data = calloc(1, sizeof(encoder_codec_data_t)); + if (video_codec_data == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } + /* + * find the video encoder + * try specific codec (by name) + */ video_codec_data->codec = getLoadLibsInstance()->m_avcodec_find_encoder_by_name(video_defaults->codec_name); - /*if it fails try any codec with matching AV_CODEC_ID*/ - if(!video_codec_data->codec) + /*if it fails try any codec with matching AV_CODEC_ID*/ + if (!video_codec_data->codec) video_codec_data->codec = getLoadLibsInstance()->m_avcodec_find_encoder(video_defaults->codec_id); - if(!video_codec_data->codec) - { - /*we will use raw data so free the codec data*/ - free(video_codec_data); - fprintf(stderr, "ENCODER: libav video codec (%i) not found - using raw input\n",video_defaults->codec_id); - video_defaults = encoder_get_video_codec_defaults(0); - encoder_set_raw_video_input(encoder_ctx, video_defaults); - - //alloc outbuf - if(enc_video_ctx->outbuf_size <= 0) - enc_video_ctx->outbuf_size = 240000;//1792 - if(enc_video_ctx->outbuf != NULL) - free(enc_video_ctx->outbuf); - enc_video_ctx->outbuf = calloc(enc_video_ctx->outbuf_size, sizeof(uint8_t)); - if(enc_video_ctx->outbuf == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } - - return (enc_video_ctx); - } + if (!video_codec_data->codec) { + /*we will use raw data so free the codec data*/ + free(video_codec_data); + fprintf(stderr, "ENCODER: libav video codec (%i) not found - using raw input\n", video_defaults->codec_id); + video_defaults = encoder_get_video_codec_defaults(0); + encoder_set_raw_video_input(encoder_ctx, video_defaults); + + //alloc outbuf + if (enc_video_ctx->outbuf_size <= 0) + enc_video_ctx->outbuf_size = 240000;//1792 + if (enc_video_ctx->outbuf != NULL) + free(enc_video_ctx->outbuf); + enc_video_ctx->outbuf = calloc(enc_video_ctx->outbuf_size, sizeof(uint8_t)); + if (enc_video_ctx->outbuf == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } + + return (enc_video_ctx); + } video_codec_data->codec_context = getLoadLibsInstance()->m_avcodec_alloc_context3(video_codec_data->codec); - if(video_codec_data->codec_context == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } - - /*set codec defaults*/ - video_codec_data->codec_context->bit_rate = video_defaults->bit_rate; - video_codec_data->codec_context->width = encoder_ctx->video_width; - video_codec_data->codec_context->height = encoder_ctx->video_height; - - video_codec_data->codec_context->flags |= video_defaults->flags; - if (video_defaults->num_threads > 0) - video_codec_data->codec_context->thread_count = video_defaults->num_threads; - /* - * mb_decision: - * 0 (FF_MB_DECISION_SIMPLE) Use mbcmp (default). - * 1 (FF_MB_DECISION_BITS) Select the MB mode which needs the fewest bits (=vhq). - * 2 (FF_MB_DECISION_RD) Select the MB mode which has the best rate distortion. - */ - video_codec_data->codec_context->mb_decision = video_defaults->mb_decision; - /*use trellis quantization*/ - video_codec_data->codec_context->trellis = video_defaults->trellis; - - /*motion estimation method */ - if( video_defaults->codec_id == AV_CODEC_ID_H264 && video_defaults->me_method > 4) - video_defaults->me_method = X264_ME_HEX; + getLoadLibsInstance()->m_avcodec_get_context_defaults3 && getLoadLibsInstance()->m_avcodec_get_context_defaults3( + video_codec_data->codec_context, + video_codec_data->codec); + + if (video_codec_data->codec_context == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } + + /*set codec defaults*/ + video_codec_data->codec_context->bit_rate = video_defaults->bit_rate; + video_codec_data->codec_context->width = encoder_ctx->video_width; + video_codec_data->codec_context->height = encoder_ctx->video_height; + + video_codec_data->codec_context->flags |= video_defaults->flags; + if (video_defaults->num_threads > 0) + video_codec_data->codec_context->thread_count = video_defaults->num_threads; + /* + * mb_decision: + * 0 (FF_MB_DECISION_SIMPLE) Use mbcmp (default). + * 1 (FF_MB_DECISION_BITS) Select the MB mode which needs the fewest bits (=vhq). + * 2 (FF_MB_DECISION_RD) Select the MB mode which has the best rate distortion. + */ + video_codec_data->codec_context->mb_decision = video_defaults->mb_decision; + /*use trellis quantization*/ + video_codec_data->codec_context->trellis = video_defaults->trellis; + + /*motion estimation method */ + if (video_defaults->codec_id == AV_CODEC_ID_H264 && video_defaults->me_method > 4) + video_defaults->me_method = X264_ME_HEX; getAvutil()->m_av_dict_set_int(&video_codec_data->private_options, "motion-est", video_defaults->me_method, 0); getAvutil()->m_av_dict_set_int(&video_codec_data->private_options, "mpeg_quant", video_defaults->mpeg_quant, 0); getAvutil()->m_av_dict_set_int(&video_codec_data->private_options, "mepre", video_defaults->pre_me, 0); - video_codec_data->codec_context->dia_size = video_defaults->dia; - video_codec_data->codec_context->pre_dia_size = video_defaults->pre_dia; + video_codec_data->codec_context->dia_size = video_defaults->dia; + video_codec_data->codec_context->pre_dia_size = video_defaults->pre_dia; - video_codec_data->codec_context->me_pre_cmp = video_defaults->me_pre_cmp; - video_codec_data->codec_context->me_cmp = video_defaults->me_cmp; - video_codec_data->codec_context->me_sub_cmp = video_defaults->me_sub_cmp; - video_codec_data->codec_context->me_subpel_quality = video_defaults->subq; //NEW - video_codec_data->codec_context->refs = video_defaults->framerefs; //NEW - video_codec_data->codec_context->last_predictor_count = video_defaults->last_pred; + video_codec_data->codec_context->me_pre_cmp = video_defaults->me_pre_cmp; + video_codec_data->codec_context->me_cmp = video_defaults->me_cmp; + video_codec_data->codec_context->me_sub_cmp = video_defaults->me_sub_cmp; + video_codec_data->codec_context->me_subpel_quality = video_defaults->subq; //NEW + video_codec_data->codec_context->refs = video_defaults->framerefs; //NEW + video_codec_data->codec_context->last_predictor_count = video_defaults->last_pred; - video_codec_data->codec_context->qmin = video_defaults->qmin; // best detail allowed - worst compression - video_codec_data->codec_context->qmax = video_defaults->qmax; // worst detail allowed - best compression - video_codec_data->codec_context->max_qdiff = video_defaults->max_qdiff; - video_codec_data->codec_context->max_b_frames = video_defaults->max_b_frames; + video_codec_data->codec_context->qmin = video_defaults->qmin; // best detail allowed - worst compression + video_codec_data->codec_context->qmax = video_defaults->qmax; // worst detail allowed - best compression + video_codec_data->codec_context->max_qdiff = video_defaults->max_qdiff; + video_codec_data->codec_context->max_b_frames = video_defaults->max_b_frames; - video_codec_data->codec_context->qcompress = video_defaults->qcompress; - video_codec_data->codec_context->qblur = video_defaults->qblur; - video_codec_data->codec_context->strict_std_compliance = FF_COMPLIANCE_NORMAL; - video_codec_data->codec_context->codec_id = video_defaults->codec_id; + video_codec_data->codec_context->qcompress = video_defaults->qcompress; + video_codec_data->codec_context->qblur = video_defaults->qblur; + video_codec_data->codec_context->strict_std_compliance = FF_COMPLIANCE_NORMAL; + video_codec_data->codec_context->codec_id = video_defaults->codec_id; - video_codec_data->codec_context->codec_type = AVMEDIA_TYPE_VIDEO; + video_codec_data->codec_context->codec_type = AVMEDIA_TYPE_VIDEO; - video_codec_data->codec_context->pix_fmt = video_defaults->pix_fmt; //only yuv420p available for mpeg - if(video_defaults->fps) - video_codec_data->codec_context->time_base = (AVRational){1, video_defaults->fps}; //use codec properties fps - else if (encoder_ctx->fps_den >= 5) - video_codec_data->codec_context->time_base = (AVRational){encoder_ctx->fps_num, encoder_ctx->fps_den}; //default fps (for gspca this is 1/1) - else - video_codec_data->codec_context->time_base = (AVRational){1,15}; //fallback to 15 fps (e.g gspca) + video_codec_data->codec_context->pix_fmt = video_defaults->pix_fmt; //only yuv420p available for mpeg + if (video_defaults->fps) + video_codec_data->codec_context->time_base = (AVRational) {1, video_defaults->fps}; //use codec properties fps + else if (encoder_ctx->fps_den >= 5) + video_codec_data->codec_context->time_base = (AVRational) {encoder_ctx->fps_num, encoder_ctx->fps_den}; //default fps (for gspca this is 1/1) + else + video_codec_data->codec_context->time_base = (AVRational) {1, 15}; //fallback to 15 fps (e.g gspca) - if(video_defaults->gop_size > 0) - { - video_codec_data->codec_context->gop_size = video_defaults->gop_size; - } - else - { + if (video_defaults->gop_size > 0) { + if (pgux == 1) { + video_codec_data->codec_context->gop_size = 3; + } else { + video_codec_data->codec_context->gop_size = video_defaults->gop_size; + } + } else { video_codec_data->codec_context->gop_size = video_codec_data->codec_context->time_base.den; } - switch (video_defaults->codec_id) - { - case AV_CODEC_ID_H264: - { - video_codec_data->codec_context->me_range = 16; - //av_dict_set(&video_codec_data->private_options, "rc_lookahead", "1", 0); - getAvutil()->m_av_dict_set(&video_codec_data->private_options, "crf", "23", 0); - getAvutil()->m_av_dict_set(&video_codec_data->private_options, "preset", "ultrafast", 0); - getAvutil()->m_av_dict_set(&video_codec_data->private_options,"tune", "zerolatency", 0); - } - break; - case AV_CODEC_ID_HEVC: - { - video_codec_data->codec_context->me_range = 16; - getAvutil()->m_av_dict_set(&video_codec_data->private_options, "crf", "28", 0); - getAvutil()->m_av_dict_set(&video_codec_data->private_options, "preset", "ultrafast", 0); - } - break; - case AV_CODEC_ID_VP8: - { - getAvutil()->m_av_dict_set(&video_codec_data->private_options, "quality", "good", 0); - getAvutil()->m_av_dict_set(&video_codec_data->private_options, "cpu-used","-10",0); - getAvutil()->m_av_dict_set(&video_codec_data->private_options, "speed","10",0); - } - break; + switch (video_defaults->codec_id) { + case AV_CODEC_ID_H264: { + video_codec_data->codec_context->me_range = 16; + //av_dict_set(&video_codec_data->private_options, "rc_lookahead", "1", 0); + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "crf", "23", 0); + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "preset", "ultrafast", 0); + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "tune", "zerolatency", 0); + } + break; + case AV_CODEC_ID_HEVC: { + video_codec_data->codec_context->me_range = 16; + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "crf", "28", 0); + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "preset", "ultrafast", 0); + } + break; + case AV_CODEC_ID_VP8: { + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "quality", "good", 0); + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "cpu-used", "-10", 0); + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "speed", "10", 0); + } + break; default: break; } - int ret = 0; - /* open codec*/ + int ret = 0; + /* open codec*/ if ((ret = getLoadLibsInstance()->m_avcodec_open2( - video_codec_data->codec_context, - video_codec_data->codec, - &video_codec_data->private_options)) < 0) - { - fprintf(stderr, "ENCODER: could not open video codec (%s): %i - using raw input\n", video_defaults->codec_name, ret); - free(video_codec_data->codec_context); - video_codec_data->codec_context = NULL; - video_codec_data->codec = 0; - /*we will use raw data so free the codec data*/ - free(video_codec_data); - video_defaults = encoder_get_video_codec_defaults(0); - encoder_set_raw_video_input(encoder_ctx, video_defaults); - - //alloc outbuf - if(enc_video_ctx->outbuf_size <= 0) - enc_video_ctx->outbuf_size = 240000;//1792 - if(enc_video_ctx->outbuf != NULL) - free(enc_video_ctx->outbuf); - enc_video_ctx->outbuf = calloc(enc_video_ctx->outbuf_size, sizeof(uint8_t)); - if(enc_video_ctx->outbuf == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } - - return (enc_video_ctx); - } + video_codec_data->codec_context, + video_codec_data->codec, + &video_codec_data->private_options)) < 0) { + fprintf(stderr, "ENCODER: could not open video codec (%s): %i - using raw input\n", video_defaults->codec_name, ret); + free(video_codec_data->codec_context); + video_codec_data->codec_context = NULL; + video_codec_data->codec = 0; + /*we will use raw data so free the codec data*/ + free(video_codec_data); + video_defaults = encoder_get_video_codec_defaults(0); + encoder_set_raw_video_input(encoder_ctx, video_defaults); + + //alloc outbuf + if (enc_video_ctx->outbuf_size <= 0) + enc_video_ctx->outbuf_size = 240000;//1792 + if (enc_video_ctx->outbuf != NULL) + free(enc_video_ctx->outbuf); + enc_video_ctx->outbuf = calloc(enc_video_ctx->outbuf_size, sizeof(uint8_t)); + if (enc_video_ctx->outbuf == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } + + return (enc_video_ctx); + } video_codec_data->frame = getAvutil()->m_av_frame_alloc(); - if(video_codec_data->frame == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } - video_codec_data->frame->pts = 0; + if (video_codec_data->frame == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } + video_codec_data->frame->pts = 0; video_codec_data->outpkt = getLoadLibsInstance()->m_av_packet_alloc(); - if(video_codec_data->outpkt == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } + if (video_codec_data->outpkt == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } - /*set the codec data in codec context*/ - enc_video_ctx->codec_data = (void *) video_codec_data; + /*set the codec data in codec context*/ + enc_video_ctx->codec_data = (void *) video_codec_data; - enc_video_ctx->tmpbuf = NULL; //no need to temp buffer input already in yu12 (yuv420p) + enc_video_ctx->tmpbuf = NULL; //no need to temp buffer input already in yu12 (yuv420p) - enc_video_ctx->monotonic_pts = video_defaults->monotonic_pts; + enc_video_ctx->monotonic_pts = video_defaults->monotonic_pts; - //alloc outbuf - enc_video_ctx->outbuf_size = (encoder_ctx->video_width * encoder_ctx->video_height) / 2; - if(enc_video_ctx->outbuf_size <= 0) - enc_video_ctx->outbuf_size = 240000;//1792 - if(enc_video_ctx->outbuf != NULL) - free(enc_video_ctx->outbuf); - enc_video_ctx->outbuf = calloc(enc_video_ctx->outbuf_size, sizeof(uint8_t)); - if(enc_video_ctx->outbuf == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); - exit(-1); - } + //alloc outbuf + enc_video_ctx->outbuf_size = (encoder_ctx->video_width * encoder_ctx->video_height) / 2; + if (enc_video_ctx->outbuf_size <= 0) + enc_video_ctx->outbuf_size = 240000;//1792 + if (enc_video_ctx->outbuf != NULL) + free(enc_video_ctx->outbuf); + enc_video_ctx->outbuf = calloc(enc_video_ctx->outbuf_size, sizeof(uint8_t)); + if (enc_video_ctx->outbuf == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_video_init): %s\n", strerror(errno)); + exit(-1); + } - enc_video_ctx->read_df = -1; - enc_video_ctx->write_df = -1; + enc_video_ctx->read_df = -1; + enc_video_ctx->write_df = -1; - enc_video_ctx->flushed_buffers = 0; - enc_video_ctx->flush_delayed_frames = 0; - enc_video_ctx->flush_done = 0; + enc_video_ctx->flushed_buffers = 0; + enc_video_ctx->flush_delayed_frames = 0; + enc_video_ctx->flush_done = 0; - return (enc_video_ctx); + return (enc_video_ctx); #endif } @@ -673,267 +700,233 @@ static encoder_video_context_t *encoder_video_init(encoder_context_t *encoder_ct */ static encoder_audio_context_t *encoder_audio_init(encoder_context_t *encoder_ctx) { - //assertions - assert(encoder_ctx != NULL); + //assertions + assert(encoder_ctx != NULL); #if !LIBAVCODEC_VER_AT_LEAST(57,16) - fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)"); - return NULL; + fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)"); + return NULL; #else - if(encoder_ctx->audio_codec_ind < 0) - { - if(verbosity > 0) - printf("ENCODER: no audio codec set\n"); + if (encoder_ctx->audio_codec_ind < 0) { + if (verbosity > 0) + printf("ENCODER: no audio codec set\n"); - return NULL; - } + return NULL; + } - if(encoder_ctx->audio_channels <= 0) - { - if(verbosity > 0) - printf("ENCODER: no audio channels set\n"); + if (encoder_ctx->audio_channels <= 0) { + if (verbosity > 0) + printf("ENCODER: no audio channels set\n"); - return NULL; - } + return NULL; + } - audio_codec_t *audio_defaults = encoder_get_audio_codec_defaults(encoder_ctx->audio_codec_ind); + audio_codec_t *audio_defaults = encoder_get_audio_codec_defaults(encoder_ctx->audio_codec_ind); - if(!audio_defaults) - { - fprintf(stderr, "ENCODER: defaults for audio codec index %i not found\n", encoder_ctx->audio_codec_ind); - return NULL; - } + if (!audio_defaults) { + fprintf(stderr, "ENCODER: defaults for audio codec index %i not found\n", encoder_ctx->audio_codec_ind); + return NULL; + } - /*alloc the encoder audio context*/ - encoder_audio_context_t *enc_audio_ctx = calloc(1, sizeof(encoder_audio_context_t)); - if(enc_audio_ctx == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_audio_init): %s\n", strerror(errno)); - exit(-1); - } + /*alloc the encoder audio context*/ + encoder_audio_context_t *enc_audio_ctx = calloc(1, sizeof(encoder_audio_context_t)); + if (enc_audio_ctx == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_audio_init): %s\n", strerror(errno)); + exit(-1); + } - encoder_ctx->enc_audio_ctx = enc_audio_ctx; + encoder_ctx->enc_audio_ctx = enc_audio_ctx; - enc_audio_ctx->flushed_buffers = 0; - enc_audio_ctx->flush_delayed_frames = 0; - enc_audio_ctx->flush_done = 0; + enc_audio_ctx->flushed_buffers = 0; + enc_audio_ctx->flush_delayed_frames = 0; + enc_audio_ctx->flush_done = 0; - /* - * alloc the audio codec data - */ - encoder_codec_data_t *audio_codec_data = calloc(1, sizeof(encoder_codec_data_t)); + /* + * alloc the audio codec data + */ + encoder_codec_data_t *audio_codec_data = calloc(1, sizeof(encoder_codec_data_t)); - /* - * find the audio encoder - * try specific codec (by name) - */ + /* + * find the audio encoder + * try specific codec (by name) + */ audio_codec_data->codec = getLoadLibsInstance()->m_avcodec_find_encoder_by_name(audio_defaults->codec_name); - /*if it fails try any codec with matching AV_CODEC_ID*/ - if(!audio_codec_data->codec) + /*if it fails try any codec with matching AV_CODEC_ID*/ + if (!audio_codec_data->codec) audio_codec_data->codec = getLoadLibsInstance()->m_avcodec_find_encoder(audio_defaults->codec_id); - if(!audio_codec_data->codec) - { - fprintf(stderr, "ENCODER: audio codec (%i) not found\n",audio_defaults->codec_id); - free(audio_codec_data); - free(enc_audio_ctx); - encoder_ctx->enc_audio_ctx = NULL; - return NULL; - } + if (!audio_codec_data->codec) { + fprintf(stderr, "ENCODER: audio codec (%i) not found\n", audio_defaults->codec_id); + free(audio_codec_data); + free(enc_audio_ctx); + encoder_ctx->enc_audio_ctx = NULL; + return NULL; + } audio_codec_data->codec_context = getLoadLibsInstance()->m_avcodec_alloc_context3(audio_codec_data->codec); + getLoadLibsInstance()->m_avcodec_get_context_defaults3 && getLoadLibsInstance()->m_avcodec_get_context_defaults3(audio_codec_data->codec_context, audio_codec_data->codec); - if(audio_codec_data->codec_context == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_audio_init): %s\n", strerror(errno)); - exit(-1); - } + if (audio_codec_data->codec_context == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_audio_init): %s\n", strerror(errno)); + exit(-1); + } - /*defaults*/ - enc_audio_ctx->avi_4cc = audio_defaults->avi_4cc; + /*defaults*/ + enc_audio_ctx->avi_4cc = audio_defaults->avi_4cc; - audio_codec_data->codec_context->bit_rate = audio_defaults->bit_rate; - audio_codec_data->codec_context->profile = audio_defaults->profile; /*for AAC*/ + audio_codec_data->codec_context->bit_rate = audio_defaults->bit_rate; + audio_codec_data->codec_context->profile = audio_defaults->profile; /*for AAC*/ - audio_codec_data->codec_context->flags |= audio_defaults->flags; + audio_codec_data->codec_context->flags |= audio_defaults->flags; - audio_codec_data->codec_context->sample_rate = encoder_ctx->audio_samprate; - audio_codec_data->codec_context->channels = encoder_ctx->audio_channels; + audio_codec_data->codec_context->sample_rate = encoder_ctx->audio_samprate; + audio_codec_data->codec_context->channels = encoder_ctx->audio_channels; - if(encoder_ctx->audio_channels < 2) - audio_codec_data->codec_context->channel_layout = AV_CH_LAYOUT_MONO; - else - audio_codec_data->codec_context->channel_layout = AV_CH_LAYOUT_STEREO; + if (encoder_ctx->audio_channels < 2) + audio_codec_data->codec_context->channel_layout = AV_CH_LAYOUT_MONO; + else + audio_codec_data->codec_context->channel_layout = AV_CH_LAYOUT_STEREO; - audio_codec_data->codec_context->cutoff = 0; /*automatic*/ + audio_codec_data->codec_context->cutoff = 0; /*automatic*/ audio_codec_data->codec_context->codec_id = audio_defaults->codec_id; - audio_codec_data->codec_context->codec_type = AVMEDIA_TYPE_AUDIO; + audio_codec_data->codec_context->codec_type = AVMEDIA_TYPE_AUDIO; int best_samprate = select_sample_rate(audio_codec_data->codec, encoder_ctx->audio_samprate); - if(best_samprate != encoder_ctx->audio_samprate) - { - fprintf(stderr, "ENCODER: audio codec doesn't support sample rate = %i (best is %i)\n", - encoder_ctx->audio_samprate, best_samprate); - encoder_ctx->audio_samprate = best_samprate; - } - - audio_codec_data->codec_context->time_base = (AVRational){1, encoder_ctx->audio_samprate}; - - /*check if codec supports sample format*/ - if (!encoder_check_audio_sample_fmt(audio_codec_data->codec, audio_defaults->sample_format)) - { - switch(audio_defaults->sample_format) - { - case AV_SAMPLE_FMT_S16: - if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_S16P)) - { - fprintf(stderr, "ENCODER: changing sample format (S16 -> S16P)\n"); - audio_defaults->sample_format = AV_SAMPLE_FMT_S16P; - } - else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_FLT)) - { - fprintf(stderr, "ENCODER: changing sample format (S16 -> FLT)\n"); - audio_defaults->sample_format = AV_SAMPLE_FMT_FLT; - } - else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_FLTP)) - { - fprintf(stderr, "ENCODER: changing sample format (S16 -> FLTP)\n"); - audio_defaults->sample_format = AV_SAMPLE_FMT_FLTP; - } - else - { - fprintf(stderr, "ENCODER: could not open audio codec: no supported sample format\n"); - free(audio_codec_data->codec_context); - free(audio_codec_data); - free(enc_audio_ctx); - encoder_ctx->enc_audio_ctx = NULL; - return NULL; - } - break; - - case AV_SAMPLE_FMT_FLT: - if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_S16)) - { - fprintf(stderr, "ENCODER: changing sample format (FLT -> S16)\n"); - audio_defaults->sample_format = AV_SAMPLE_FMT_S16; - } - else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_S16P)) - { - fprintf(stderr, "ENCODER: changing sample format (FLT -> S16P)\n"); - audio_defaults->sample_format = AV_SAMPLE_FMT_S16P; - } - else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_FLTP)) - { - fprintf(stderr, "ENCODER: changing sample format (FLT -> FLTP)\n"); - audio_defaults->sample_format = AV_SAMPLE_FMT_FLTP; - } - else - { - fprintf(stderr, "ENCODER: could not open audio codec: no supported sample format\n"); - free(audio_codec_data->codec_context); - free(audio_codec_data); - free(enc_audio_ctx); - encoder_ctx->enc_audio_ctx = NULL; - return NULL; - } - break; - - case AV_SAMPLE_FMT_FLTP: - if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_S16)) - { - fprintf(stderr, "ENCODER: changing sample format (FLTP -> S16)\n"); - audio_defaults->sample_format = AV_SAMPLE_FMT_S16; - } - else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_S16P)) - { - fprintf(stderr, "ENCODER: changing sample format (FLTP -> S16P)\n"); - audio_defaults->sample_format = AV_SAMPLE_FMT_S16P; - } - else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_FLT)) - { - fprintf(stderr, "ENCODER: changing sample format (FLTP -> FLT)\n"); - audio_defaults->sample_format = AV_SAMPLE_FMT_FLT; - } - else - { - fprintf(stderr, "ENCODER: could not open audio codec: no supported sample format\n"); - free(audio_codec_data->codec_context); - free(audio_codec_data); - free(enc_audio_ctx); - encoder_ctx->enc_audio_ctx = NULL; - return NULL; - } - break; - } - } - - audio_codec_data->codec_context->sample_fmt = audio_defaults->sample_format; - - /* open codec*/ + if (best_samprate != encoder_ctx->audio_samprate) { + fprintf(stderr, "ENCODER: audio codec doesn't support sample rate = %i (best is %i)\n", + encoder_ctx->audio_samprate, best_samprate); + encoder_ctx->audio_samprate = best_samprate; + } + + audio_codec_data->codec_context->time_base = (AVRational) {1, encoder_ctx->audio_samprate}; + + /*check if codec supports sample format*/ + if (!encoder_check_audio_sample_fmt(audio_codec_data->codec, audio_defaults->sample_format)) { + switch (audio_defaults->sample_format) { + case AV_SAMPLE_FMT_S16: + if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_S16P)) { + fprintf(stderr, "ENCODER: changing sample format (S16 -> S16P)\n"); + audio_defaults->sample_format = AV_SAMPLE_FMT_S16P; + } else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_FLT)) { + fprintf(stderr, "ENCODER: changing sample format (S16 -> FLT)\n"); + audio_defaults->sample_format = AV_SAMPLE_FMT_FLT; + } else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_FLTP)) { + fprintf(stderr, "ENCODER: changing sample format (S16 -> FLTP)\n"); + audio_defaults->sample_format = AV_SAMPLE_FMT_FLTP; + } else { + fprintf(stderr, "ENCODER: could not open audio codec: no supported sample format\n"); + free(audio_codec_data->codec_context); + free(audio_codec_data); + free(enc_audio_ctx); + encoder_ctx->enc_audio_ctx = NULL; + return NULL; + } + break; + + case AV_SAMPLE_FMT_FLT: + if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_S16)) { + fprintf(stderr, "ENCODER: changing sample format (FLT -> S16)\n"); + audio_defaults->sample_format = AV_SAMPLE_FMT_S16; + } else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_S16P)) { + fprintf(stderr, "ENCODER: changing sample format (FLT -> S16P)\n"); + audio_defaults->sample_format = AV_SAMPLE_FMT_S16P; + } else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_FLTP)) { + fprintf(stderr, "ENCODER: changing sample format (FLT -> FLTP)\n"); + audio_defaults->sample_format = AV_SAMPLE_FMT_FLTP; + } else { + fprintf(stderr, "ENCODER: could not open audio codec: no supported sample format\n"); + free(audio_codec_data->codec_context); + free(audio_codec_data); + free(enc_audio_ctx); + encoder_ctx->enc_audio_ctx = NULL; + return NULL; + } + break; + + case AV_SAMPLE_FMT_FLTP: + if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_S16)) { + fprintf(stderr, "ENCODER: changing sample format (FLTP -> S16)\n"); + audio_defaults->sample_format = AV_SAMPLE_FMT_S16; + } else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_S16P)) { + fprintf(stderr, "ENCODER: changing sample format (FLTP -> S16P)\n"); + audio_defaults->sample_format = AV_SAMPLE_FMT_S16P; + } else if (encoder_check_audio_sample_fmt(audio_codec_data->codec, AV_SAMPLE_FMT_FLT)) { + fprintf(stderr, "ENCODER: changing sample format (FLTP -> FLT)\n"); + audio_defaults->sample_format = AV_SAMPLE_FMT_FLT; + } else { + fprintf(stderr, "ENCODER: could not open audio codec: no supported sample format\n"); + free(audio_codec_data->codec_context); + free(audio_codec_data); + free(enc_audio_ctx); + encoder_ctx->enc_audio_ctx = NULL; + return NULL; + } + break; + } + } + + audio_codec_data->codec_context->sample_fmt = audio_defaults->sample_format; + + /* open codec*/ if (getLoadLibsInstance()->m_avcodec_open2( - audio_codec_data->codec_context, - audio_codec_data->codec, NULL) < 0) - { - fprintf(stderr, "ENCODER: could not open audio codec\n"); - free(audio_codec_data->codec_context); - free(audio_codec_data); - free(enc_audio_ctx); - encoder_ctx->enc_audio_ctx = NULL; - return NULL; - } - - /* the codec gives us the frame size, in samples */ - int frame_size = audio_codec_data->codec_context->frame_size; - if(frame_size <= 0) - { - frame_size = 1152; /*default value*/ - audio_codec_data->codec_context->frame_size = frame_size; - } - if(verbosity > 0) - printf("ENCODER: Audio frame size is %d frames for selected codec\n", frame_size); - - enc_audio_ctx->monotonic_pts = audio_defaults->monotonic_pts; - - /*alloc outbuf*/ - enc_audio_ctx->outbuf_size = 240000; - enc_audio_ctx->outbuf = calloc(enc_audio_ctx->outbuf_size, sizeof(uint8_t)); - if(enc_audio_ctx->outbuf == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_audio_init): %s\n", strerror(errno)); - exit(-1); - } + audio_codec_data->codec_context, + audio_codec_data->codec, NULL) < 0) { + fprintf(stderr, "ENCODER: could not open audio codec\n"); + free(audio_codec_data->codec_context); + free(audio_codec_data); + free(enc_audio_ctx); + encoder_ctx->enc_audio_ctx = NULL; + return NULL; + } + + /* the codec gives us the frame size, in samples */ + int frame_size = audio_codec_data->codec_context->frame_size; + if (frame_size <= 0) { + frame_size = 1152; /*default value*/ + audio_codec_data->codec_context->frame_size = frame_size; + } + if (verbosity > 0) + printf("ENCODER: Audio frame size is %d frames for selected codec\n", frame_size); + + enc_audio_ctx->monotonic_pts = audio_defaults->monotonic_pts; + + /*alloc outbuf*/ + enc_audio_ctx->outbuf_size = 240000; + enc_audio_ctx->outbuf = calloc(enc_audio_ctx->outbuf_size, sizeof(uint8_t)); + if (enc_audio_ctx->outbuf == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_audio_init): %s\n", strerror(errno)); + exit(-1); + } audio_codec_data->frame = getAvutil()->m_av_frame_alloc(); - if(audio_codec_data->frame == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_audio_init): %s\n", strerror(errno)); - exit(-1); - } + if (audio_codec_data->frame == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_audio_init): %s\n", strerror(errno)); + exit(-1); + } getAvutil()->m_av_frame_unref(audio_codec_data->frame); audio_codec_data->outpkt = getLoadLibsInstance()->m_av_packet_alloc(); - if(audio_codec_data->outpkt == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_audio_init): %s\n", strerror(errno)); - exit(-1); - } + if (audio_codec_data->outpkt == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_audio_init): %s\n", strerror(errno)); + exit(-1); + } - audio_codec_data->frame->nb_samples = frame_size; - audio_codec_data->frame->format = audio_defaults->sample_format; -audio_codec_data->frame->channels = audio_codec_data->codec_context->channels; - audio_codec_data->frame->channel_layout = audio_codec_data->codec_context->channel_layout; + audio_codec_data->frame->nb_samples = frame_size; + audio_codec_data->frame->format = audio_defaults->sample_format; + audio_codec_data->frame->channels = audio_codec_data->codec_context->channels; + audio_codec_data->frame->channel_layout = audio_codec_data->codec_context->channel_layout; - /*set codec data in encoder context*/ - enc_audio_ctx->codec_data = (void *) audio_codec_data; + /*set codec data in encoder context*/ + enc_audio_ctx->codec_data = (void *) audio_codec_data; - return (enc_audio_ctx); + return (enc_audio_ctx); #endif } @@ -950,17 +943,17 @@ audio_codec_data->frame->channels = audio_codec_data->codec_context->channels; */ int encoder_get_audio_frame_size(encoder_context_t *encoder_ctx) { - /*assertions*/ - assert(encoder_ctx); - if(encoder_ctx->enc_audio_ctx == NULL) - return -1; + /*assertions*/ + assert(encoder_ctx); + if (encoder_ctx->enc_audio_ctx == NULL) + return -1; - encoder_codec_data_t *audio_codec_data = (encoder_codec_data_t *) encoder_ctx->enc_audio_ctx->codec_data; + encoder_codec_data_t *audio_codec_data = (encoder_codec_data_t *) encoder_ctx->enc_audio_ctx->codec_data; - if(audio_codec_data == NULL) - return -1; + if (audio_codec_data == NULL) + return -1; - return audio_codec_data->codec_context->frame_size; + return audio_codec_data->codec_context->frame_size; } @@ -976,37 +969,36 @@ int encoder_get_audio_frame_size(encoder_context_t *encoder_ctx) */ int encoder_get_audio_sample_fmt(encoder_context_t *encoder_ctx) { - /*assertions*/ - assert(encoder_ctx); + /*assertions*/ + assert(encoder_ctx); - /*default*/ - int sample_type = GV_SAMPLE_TYPE_INT16; + /*default*/ + int sample_type = GV_SAMPLE_TYPE_INT16; - if(encoder_ctx->enc_audio_ctx == NULL) - return sample_type; + if (encoder_ctx->enc_audio_ctx == NULL) + return sample_type; - encoder_codec_data_t *audio_codec_data = (encoder_codec_data_t *) encoder_ctx->enc_audio_ctx->codec_data; + encoder_codec_data_t *audio_codec_data = (encoder_codec_data_t *) encoder_ctx->enc_audio_ctx->codec_data; - if(audio_codec_data == NULL) - return sample_type; + if (audio_codec_data == NULL) + return sample_type; - switch(audio_codec_data->codec_context->sample_fmt) - { - case AV_SAMPLE_FMT_FLTP: - sample_type = GV_SAMPLE_TYPE_FLOATP; - break; - case AV_SAMPLE_FMT_FLT: - sample_type = GV_SAMPLE_TYPE_FLOAT; - break; - case AV_SAMPLE_FMT_S16P: - sample_type = GV_SAMPLE_TYPE_INT16P; - break; - default: - sample_type = GV_SAMPLE_TYPE_INT16; - break; - } - - return sample_type; + switch (audio_codec_data->codec_context->sample_fmt) { + case AV_SAMPLE_FMT_FLTP: + sample_type = GV_SAMPLE_TYPE_FLOATP; + break; + case AV_SAMPLE_FMT_FLT: + sample_type = GV_SAMPLE_TYPE_FLOAT; + break; + case AV_SAMPLE_FMT_S16P: + sample_type = GV_SAMPLE_TYPE_INT16P; + break; + default: + sample_type = GV_SAMPLE_TYPE_INT16; + break; + } + + return sample_type; } /* @@ -1018,7 +1010,7 @@ int encoder_get_audio_sample_fmt(encoder_context_t *encoder_ctx) */ int encoder_get_max_audio_sample_fmt() { - return AV_SAMPLE_FMT_NB-1; + return AV_SAMPLE_FMT_NB - 1; } /* @@ -1037,56 +1029,53 @@ int encoder_get_max_audio_sample_fmt() */ double encoder_buff_scheduler(int mode, double thresh, double max_time) { - int diff_ind = 0; - double sched_time = 0; /*in milisec*/ - - __LOCK_MUTEX( __PMUTEX ); - /* try to balance buffer overrun in read/write operations */ - if(video_write_index >= video_read_index) - diff_ind = video_write_index - video_read_index; - else - diff_ind = (video_ring_buffer_size - video_read_index) + video_write_index; - __UNLOCK_MUTEX( __PMUTEX ); - - /*clip ring buffer threshold*/ - if(thresh < 0.2) - thresh = 0.2; /*20% full*/ - if(thresh > 0.9) - thresh = 0.9; /*90% full*/ - - int th = (int) lround((double) video_ring_buffer_size * thresh); - - if (diff_ind >= th) - { - switch(mode) - { - case ENCODER_SCHED_LIN: /*linear function*/ - sched_time = (double) (diff_ind - th) * (max_time/(video_ring_buffer_size - th)); - break; - - case ENCODER_SCHED_EXP: /*exponencial*/ - { - double exp = (double) log10(max_time)/log10(video_ring_buffer_size - th); - if(exp > 0) - sched_time = pow(diff_ind - th, exp); - else /*use linear function*/ - sched_time = (double) (diff_ind - th) * (max_time/(video_ring_buffer_size - th)); - break; - } - - } - } - - if(verbosity > 2) - printf("ENCODER: scheduler %.2f ms (index delta %i)\n", sched_time, diff_ind); - - /*clip*/ - if(sched_time > max_time) - sched_time = max_time; - if(sched_time < 0) - sched_time = 0; - - return (sched_time); + int diff_ind = 0; + double sched_time = 0; /*in milisec*/ + + __LOCK_MUTEX(__PMUTEX); + /* try to balance buffer overrun in read/write operations */ + if (video_write_index >= video_read_index) + diff_ind = video_write_index - video_read_index; + else + diff_ind = (video_ring_buffer_size - video_read_index) + video_write_index; + __UNLOCK_MUTEX(__PMUTEX); + + /*clip ring buffer threshold*/ + if (thresh < 0.2) + thresh = 0.2; /*20% full*/ + if (thresh > 0.9) + thresh = 0.9; /*90% full*/ + + int th = (int) lround((double) video_ring_buffer_size * thresh); + + if (diff_ind >= th) { + switch (mode) { + case ENCODER_SCHED_LIN: /*linear function*/ + sched_time = (double)(diff_ind - th) * (max_time / (video_ring_buffer_size - th)); + break; + + case ENCODER_SCHED_EXP: { /*exponencial*/ + double exp = (double) log10(max_time) / log10(video_ring_buffer_size - th); + if (exp > 0) + sched_time = pow(diff_ind - th, exp); + else /*use linear function*/ + sched_time = (double)(diff_ind - th) * (max_time / (video_ring_buffer_size - th)); + break; + } + + } + } + + if (verbosity > 2) + printf("ENCODER: scheduler %.2f ms (index delta %i)\n", sched_time, diff_ind); + + /*clip*/ + if (sched_time > max_time) + sched_time = max_time; + if (sched_time < 0) + sched_time = 0; + + return (sched_time); } /* @@ -1101,7 +1090,7 @@ double encoder_buff_scheduler(int mode, double thresh, double max_time) */ int encoder_get_valid_video_codecs() { - return valid_video_codecs; + return valid_video_codecs; } /* @@ -1116,7 +1105,7 @@ int encoder_get_valid_video_codecs() */ int encoder_get_valid_audio_codecs() { - return valid_audio_codecs; + return valid_audio_codecs; } /* @@ -1140,59 +1129,64 @@ int encoder_get_valid_audio_codecs() * returns: pointer to encoder context (NULL on error) */ encoder_context_t *encoder_init( - int input_format, - int video_codec_ind, - int audio_codec_ind, - int muxer_id, - int video_width, - int video_height, - int fps_num, - int fps_den, - int audio_channels, - int audio_samprate) + int input_format, + int video_codec_ind, + int audio_codec_ind, + int muxer_id, + int video_width, + int video_height, + int fps_num, + int fps_den, + int audio_channels, + int audio_samprate, + int use_pugx_code) { - encoder_context_t *encoder_ctx = calloc(1, sizeof(encoder_context_t)); + encoder_context_t *encoder_ctx = calloc(1, sizeof(encoder_context_t)); - if(encoder_ctx == NULL) - { - fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_get_context): %s\n", strerror(errno)); - exit(-1); - } + if (encoder_ctx == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (encoder_get_context): %s\n", strerror(errno)); + exit(-1); + } - encoder_ctx->input_format = input_format; + encoder_ctx->input_format = input_format; - encoder_ctx->video_codec_ind = video_codec_ind; - encoder_ctx->audio_codec_ind = audio_codec_ind; + encoder_ctx->video_codec_ind = video_codec_ind; + encoder_ctx->audio_codec_ind = audio_codec_ind; - encoder_ctx->muxer_id = muxer_id; + encoder_ctx->muxer_id = muxer_id; - encoder_ctx->video_width = video_width; - encoder_ctx->video_height = video_height; + encoder_ctx->video_width = video_width; + encoder_ctx->video_height = video_height; - encoder_ctx->fps_num = fps_num; - encoder_ctx->fps_den = fps_den; + encoder_ctx->fps_num = fps_num; + encoder_ctx->fps_den = fps_den; - encoder_ctx->audio_channels = audio_channels; - encoder_ctx->audio_samprate = audio_samprate; + encoder_ctx->audio_channels = audio_channels; + encoder_ctx->audio_samprate = audio_samprate; + + /******************* video **********************/ + encoder_video_init_vaapi(encoder_ctx); + if (HW_VAAPI_OK != is_vaapi) { + encoder_video_init(encoder_ctx, use_pugx_code); + //hw_vaapi ng + } - /******************* video **********************/ - encoder_video_init(encoder_ctx); - /******************* audio **********************/ - encoder_audio_init(encoder_ctx); + /******************* audio **********************/ + encoder_audio_init(encoder_ctx); - if(!encoder_ctx->enc_audio_ctx) - encoder_ctx->audio_channels = 0; /*no audio*/ + if (!encoder_ctx->enc_audio_ctx) + encoder_ctx->audio_channels = 0; /*no audio*/ - /****************** ring buffer *****************/ - encoder_alloc_video_ring_buffer( - video_width, - video_height, - fps_den, - fps_num, - video_codec_ind); + /****************** ring buffer *****************/ + encoder_alloc_video_ring_buffer( + video_width, + video_height, + fps_den, + fps_num, + video_codec_ind); - return encoder_ctx; + return encoder_ctx; } /* @@ -1211,53 +1205,49 @@ encoder_context_t *encoder_init( int encoder_add_video_frame(uint8_t *frame, int size, int64_t timestamp, int isKeyframe) { // cheese_print_log("encoder_add_video_frame"); - if(!video_ring_buffer) - return -1; + if (!video_ring_buffer) + return -1; - if (reference_pts == 0) - { - reference_pts = timestamp; /*first frame ts*/ - if(verbosity > 0) - printf("ENCODER: ref ts = %" PRId64 "\n", timestamp); - } + if (reference_pts == 0) { + reference_pts = timestamp; /*first frame ts*/ + if (verbosity > 0) + printf("ENCODER: ref ts = %" PRId64 "\n", timestamp); + } int64_t video_pause_timestamp = get_video_pause_timestamp(); - if(video_pause_timestamp != 0) - { + if (video_pause_timestamp != 0) { reference_pts += video_pause_timestamp; set_video_pause_timestamp(0); } int64_t pts = timestamp - reference_pts; - __LOCK_MUTEX( __PMUTEX ); - int flag = video_ring_buffer[video_write_index].flag; - __UNLOCK_MUTEX( __PMUTEX ); + __LOCK_MUTEX(__PMUTEX); + int flag = video_ring_buffer[video_write_index].flag; + __UNLOCK_MUTEX(__PMUTEX); - if(flag != VIDEO_BUFF_FREE) - { - fprintf(stderr, "ENCODER: video ring buffer full - dropping frame\n"); - return -1; - } + if (flag != VIDEO_BUFF_FREE) { + fprintf(stderr, "ENCODER: video ring buffer full - dropping frame\n"); + return -1; + } - /*clip*/ - if(size > video_frame_max_size) - { - fprintf(stderr, "ENCODER: frame (%i bytes) larger than buffer (%i bytes): clipping\n", - size, video_frame_max_size); - - size = video_frame_max_size; - } - memcpy(video_ring_buffer[video_write_index].frame, frame, size); - video_ring_buffer[video_write_index].frame_size = size; - video_ring_buffer[video_write_index].timestamp = pts; - video_ring_buffer[video_write_index].keyframe = isKeyframe; - - __LOCK_MUTEX( __PMUTEX ); - video_ring_buffer[video_write_index].flag = VIDEO_BUFF_USED; - NEXT_IND(video_write_index, video_ring_buffer_size); - __UNLOCK_MUTEX( __PMUTEX ); - - return 0; + /*clip*/ + if (size > video_frame_max_size) { + fprintf(stderr, "ENCODER: frame (%i bytes) larger than buffer (%i bytes): clipping\n", + size, video_frame_max_size); + + size = video_frame_max_size; + } + memcpy(video_ring_buffer[video_write_index].frame, frame, size); + video_ring_buffer[video_write_index].frame_size = size; + video_ring_buffer[video_write_index].timestamp = pts; + video_ring_buffer[video_write_index].keyframe = isKeyframe; + + __LOCK_MUTEX(__PMUTEX); + video_ring_buffer[video_write_index].flag = VIDEO_BUFF_USED; + NEXT_IND(video_write_index, video_ring_buffer_size); + __UNLOCK_MUTEX(__PMUTEX); + + return 0; } /* @@ -1272,44 +1262,45 @@ int encoder_add_video_frame(uint8_t *frame, int size, int64_t timestamp, int isK */ int encoder_process_next_video_buffer(encoder_context_t *encoder_ctx) { - /*assertions*/ - assert(encoder_ctx != NULL); - - __LOCK_MUTEX( __PMUTEX ); + /*assertions*/ + assert(encoder_ctx != NULL); - int flag = video_ring_buffer[video_read_index].flag; + __LOCK_MUTEX(__PMUTEX); - __UNLOCK_MUTEX ( __PMUTEX ); + int flag = video_ring_buffer[video_read_index].flag; - if(flag == VIDEO_BUFF_FREE) - return 1; /*all done*/ + __UNLOCK_MUTEX(__PMUTEX); - /*timestamp is zero indexed*/ - encoder_ctx->enc_video_ctx->pts = video_ring_buffer[video_read_index].timestamp; + if (flag == VIDEO_BUFF_FREE) + return 1; /*all done*/ - /*raw (direct input)*/ - if(encoder_ctx->video_codec_ind == 0) - { - /*outbuf_coded_size must already be set*/ - encoder_ctx->enc_video_ctx->outbuf_coded_size = video_ring_buffer[video_read_index].frame_size; - if(video_ring_buffer[video_read_index].keyframe) - encoder_ctx->enc_video_ctx->flags |= AV_PKT_FLAG_KEY; - } + /*timestamp is zero indexed*/ + encoder_ctx->enc_video_ctx->pts = video_ring_buffer[video_read_index].timestamp; - encoder_encode_video(encoder_ctx, video_ring_buffer[video_read_index].frame); + /*raw (direct input)*/ + if (encoder_ctx->video_codec_ind == 0) { + /*outbuf_coded_size must already be set*/ + encoder_ctx->enc_video_ctx->outbuf_coded_size = video_ring_buffer[video_read_index].frame_size; + if (video_ring_buffer[video_read_index].keyframe) + encoder_ctx->enc_video_ctx->flags |= AV_PKT_FLAG_KEY; + } + if (HW_VAAPI_OK == is_vaapi) + encoder_encode_video_vaapi(encoder_ctx, video_ring_buffer[video_read_index].frame); + else + encoder_encode_video(encoder_ctx, video_ring_buffer[video_read_index].frame); - /*mux the frame*/ - __LOCK_MUTEX( __PMUTEX ); + /*mux the frame*/ + __LOCK_MUTEX(__PMUTEX); - video_ring_buffer[video_read_index].flag = VIDEO_BUFF_FREE; - NEXT_IND(video_read_index, video_ring_buffer_size); + video_ring_buffer[video_read_index].flag = VIDEO_BUFF_FREE; + NEXT_IND(video_read_index, video_ring_buffer_size); - __UNLOCK_MUTEX ( __PMUTEX ); + __UNLOCK_MUTEX(__PMUTEX); - //encoder_write_video_data(encoder_ctx); + //encoder_write_video_data(encoder_ctx); - return 0; + return 0; } /* @@ -1324,55 +1315,56 @@ int encoder_process_next_video_buffer(encoder_context_t *encoder_ctx) */ int encoder_flush_video_buffer(encoder_context_t *encoder_ctx) { - /*assertions*/ - assert(encoder_ctx != NULL); + /*assertions*/ + assert(encoder_ctx != NULL); - __LOCK_MUTEX( __PMUTEX ); - int flag = video_ring_buffer[video_read_index].flag; - __UNLOCK_MUTEX ( __PMUTEX ); + __LOCK_MUTEX(__PMUTEX); + int flag = video_ring_buffer[video_read_index].flag; + __UNLOCK_MUTEX(__PMUTEX); - int buffer_count = video_ring_buffer_size; - int flushed_frame_counter = buffer_count; + int buffer_count = video_ring_buffer_size; + int flushed_frame_counter = buffer_count; - if(verbosity > 1) - printf("ENCODER: flushing video buffer with %i frames\n", buffer_count); + if (verbosity > 1) + printf("ENCODER: flushing video buffer with %i frames\n", buffer_count); - while(flag != VIDEO_BUFF_FREE && buffer_count > 0) - { - buffer_count--; + while (flag != VIDEO_BUFF_FREE && buffer_count > 0) { + buffer_count--; - encoder_process_next_video_buffer(encoder_ctx); + encoder_process_next_video_buffer(encoder_ctx); - /*get next buffer flag*/ - __LOCK_MUTEX( __PMUTEX ); - flag = video_ring_buffer[video_read_index].flag; - __UNLOCK_MUTEX ( __PMUTEX ); - } + /*get next buffer flag*/ + __LOCK_MUTEX(__PMUTEX); + flag = video_ring_buffer[video_read_index].flag; + __UNLOCK_MUTEX(__PMUTEX); + } - if(verbosity > 1) - printf("ENCODER: processed remaining %i video frames\n", flushed_frame_counter - buffer_count); + if (verbosity > 1) + printf("ENCODER: processed remaining %i video frames\n", flushed_frame_counter - buffer_count); - /*flush libav*/ - flushed_frame_counter = 0; - encoder_ctx->enc_video_ctx->flush_delayed_frames = 1; + /*flush libav*/ + flushed_frame_counter = 0; + encoder_ctx->enc_video_ctx->flush_delayed_frames = 1; - // while(!encoder_ctx->enc_video_ctx->flush_done) - // { - encoder_encode_video(encoder_ctx, NULL); - // encoder_write_video_data(encoder_ctx); - // flushed_frame_counter++; - // } + // while(!encoder_ctx->enc_video_ctx->flush_done) + // { + if (HW_VAAPI_OK == is_vaapi) + encoder_encode_video_vaapi(encoder_ctx, NULL); + else + encoder_encode_video(encoder_ctx, NULL); + // encoder_write_video_data(encoder_ctx); + // flushed_frame_counter++; + // } - if(verbosity > 1) - printf("ENCODER: flushed %i delayed video frames\n", flushed_frame_counter); + if (verbosity > 1) + printf("ENCODER: flushed %i delayed video frames\n", flushed_frame_counter); - if(!buffer_count) - { - fprintf(stderr, "ENCODER: (flush video buffer) max processed buffers reached\n"); - return -1; - } + if (!buffer_count) { + fprintf(stderr, "ENCODER: (flush video buffer) max processed buffers reached\n"); + return -1; + } - return 0; + return 0; } /* @@ -1387,24 +1379,24 @@ int encoder_flush_video_buffer(encoder_context_t *encoder_ctx) */ int encoder_flush_audio_buffer(encoder_context_t *encoder_ctx) { - /*assertions*/ - assert(encoder_ctx != NULL); + /*assertions*/ + assert(encoder_ctx != NULL); - /*flush libav*/ - int flushed_frame_counter = 0; - encoder_ctx->enc_audio_ctx->flush_delayed_frames = 1; + /*flush libav*/ + int flushed_frame_counter = 0; + encoder_ctx->enc_audio_ctx->flush_delayed_frames = 1; - // while(!encoder_ctx->enc_audio_ctx->flush_done) - // { - encoder_encode_audio(encoder_ctx, NULL); - // encoder_write_audio_data(encoder_ctx); - // flushed_frame_counter++; - // } + // while(!encoder_ctx->enc_audio_ctx->flush_done) + // { + encoder_encode_audio(encoder_ctx, NULL); + // encoder_write_audio_data(encoder_ctx); + // flushed_frame_counter++; + // } - if(verbosity > 1) - printf("ENCODER: flushed %i delayed audio frames\n", flushed_frame_counter); + if (verbosity > 1) + printf("ENCODER: flushed %i delayed audio frames\n", flushed_frame_counter); - return 0; + return 0; } /* @@ -1420,18 +1412,18 @@ int encoder_flush_audio_buffer(encoder_context_t *encoder_ctx) */ int encoder_process_audio_buffer(encoder_context_t *encoder_ctx, void *data) { - /*assertions*/ - assert(encoder_ctx != NULL); + /*assertions*/ + assert(encoder_ctx != NULL); - if(encoder_ctx->enc_audio_ctx == NULL || - encoder_ctx->audio_channels <= 0) - return -1; + if (encoder_ctx->enc_audio_ctx == NULL || + encoder_ctx->audio_channels <= 0) + return -1; - return encoder_encode_audio(encoder_ctx, data); + return encoder_encode_audio(encoder_ctx, data); - // int ret = encoder_write_audio_data(encoder_ctx); + // int ret = encoder_write_audio_data(encoder_ctx); - // return ret; + // return ret; } /* @@ -1446,37 +1438,34 @@ int encoder_process_audio_buffer(encoder_context_t *encoder_ctx, void *data) */ static int store_video_df_pts(encoder_video_context_t *enc_video_ctx) { - /*assertions*/ - assert(enc_video_ctx != NULL); + /*assertions*/ + assert(enc_video_ctx != NULL); - if(enc_video_ctx->write_df < 0) - enc_video_ctx->write_df = 0; - else - enc_video_ctx->write_df++; + if (enc_video_ctx->write_df < 0) + enc_video_ctx->write_df = 0; + else + enc_video_ctx->write_df++; - if(enc_video_ctx->write_df == enc_video_ctx->read_df) - { - fprintf(stderr, "ENCODER: Maximum of %i delayed video frames reached...\n", MAX_DELAYED_FRAMES); - fprintf(stderr, " write: %i read: %i\n", enc_video_ctx->write_df, enc_video_ctx->read_df); - return -1; - } + if (enc_video_ctx->write_df == enc_video_ctx->read_df) { + fprintf(stderr, "ENCODER: Maximum of %i delayed video frames reached...\n", MAX_DELAYED_FRAMES); + fprintf(stderr, " write: %i read: %i\n", enc_video_ctx->write_df, enc_video_ctx->read_df); + return -1; + } - if(enc_video_ctx->write_df >= MAX_DELAYED_FRAMES) - { - if(enc_video_ctx->read_df > 0) - enc_video_ctx->write_df = 0; //go to start - else - { - fprintf(stderr, "ENCODER: Maximum of %i delayed video frames reached...\n", MAX_DELAYED_FRAMES); - fprintf(stderr, " write: %i read: %i\n", enc_video_ctx->write_df, enc_video_ctx->read_df); - enc_video_ctx->write_df = MAX_DELAYED_FRAMES -1; - return -1; - } - } - - enc_video_ctx->delayed_pts[enc_video_ctx->write_df] = enc_video_ctx->pts; - - return enc_video_ctx->write_df; + if (enc_video_ctx->write_df >= MAX_DELAYED_FRAMES) { + if (enc_video_ctx->read_df > 0) + enc_video_ctx->write_df = 0; //go to start + else { + fprintf(stderr, "ENCODER: Maximum of %i delayed video frames reached...\n", MAX_DELAYED_FRAMES); + fprintf(stderr, " write: %i read: %i\n", enc_video_ctx->write_df, enc_video_ctx->read_df); + enc_video_ctx->write_df = MAX_DELAYED_FRAMES - 1; + return -1; + } + } + + enc_video_ctx->delayed_pts[enc_video_ctx->write_df] = enc_video_ctx->pts; + + return enc_video_ctx->write_df; } /* @@ -1491,96 +1480,87 @@ static int store_video_df_pts(encoder_video_context_t *enc_video_ctx) */ static int read_video_df_pts(encoder_video_context_t *enc_video_ctx) { - /*assertions*/ - assert(enc_video_ctx != NULL); - - //store the current frame pts - if(!enc_video_ctx->flush_delayed_frames) - store_video_df_pts(enc_video_ctx); - - if(enc_video_ctx->read_df < 0) - { - printf("ENCODER: video codec is using %i delayed frames\n", enc_video_ctx->write_df); - enc_video_ctx->read_df = 0; - } - else - enc_video_ctx->read_df++; - - if(enc_video_ctx->read_df >= MAX_DELAYED_FRAMES) - enc_video_ctx->read_df = 0; - - //read the delayed frame pts - enc_video_ctx->pts = enc_video_ctx->delayed_pts[enc_video_ctx->read_df]; - - if(enc_video_ctx->flush_delayed_frames && verbosity > 1) - printf("ENCODER: video codec flushing delayed frame %i ( pts: %" PRId64 " )\n", - enc_video_ctx->read_df, enc_video_ctx->pts); - - if(enc_video_ctx->read_df == enc_video_ctx->write_df) - { - printf("ENCODER: no more delayed video frames\n"); - if(enc_video_ctx->flush_delayed_frames) - enc_video_ctx->flush_done = 1; - enc_video_ctx->read_df = -1; - } + /*assertions*/ + assert(enc_video_ctx != NULL); + + //store the current frame pts + if (!enc_video_ctx->flush_delayed_frames) + store_video_df_pts(enc_video_ctx); + + if (enc_video_ctx->read_df < 0) { + printf("ENCODER: video codec is using %i delayed frames\n", enc_video_ctx->write_df); + enc_video_ctx->read_df = 0; + } else + enc_video_ctx->read_df++; + + if (enc_video_ctx->read_df >= MAX_DELAYED_FRAMES) + enc_video_ctx->read_df = 0; + + //read the delayed frame pts + enc_video_ctx->pts = enc_video_ctx->delayed_pts[enc_video_ctx->read_df]; + + if (enc_video_ctx->flush_delayed_frames && verbosity > 1) + printf("ENCODER: video codec flushing delayed frame %i ( pts: %" PRId64 " )\n", + enc_video_ctx->read_df, enc_video_ctx->pts); + + if (enc_video_ctx->read_df == enc_video_ctx->write_df) { + printf("ENCODER: no more delayed video frames\n"); + if (enc_video_ctx->flush_delayed_frames) + enc_video_ctx->flush_done = 1; + enc_video_ctx->read_df = -1; + } - return enc_video_ctx->read_df; + return enc_video_ctx->read_df; } static int libav_send_encode(AVCodecContext *avctx, AVFrame *frame) { - int ret; + int ret; if (!getLoadLibsInstance()->m_avcodec_is_open(avctx)) - fprintf(stderr, "ENCODER: codec not opened\n"); - if(!getLoadLibsInstance()->m_av_codec_is_encoder(avctx->codec)) - fprintf(stderr, "ENCODER: codec not an encoder\n"); - - if(frame) - { - - if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && frame->nb_samples != avctx->frame_size) - fprintf(stderr, "ENCODER: audio samples differ from frame size\n"); - if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && frame->channels <= 0) - { - fprintf(stderr, "ENCODER: no audio channels set in frame\n"); - frame->channels = avctx->channels; - } + fprintf(stderr, "ENCODER: codec not opened\n"); + if (!getLoadLibsInstance()->m_av_codec_is_encoder(avctx->codec)) + fprintf(stderr, "ENCODER: codec not an encoder\n"); + + if (frame) { + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && frame->nb_samples != avctx->frame_size) + fprintf(stderr, "ENCODER: audio samples differ from frame size\n"); + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && frame->channels <= 0) { + fprintf(stderr, "ENCODER: no audio channels set in frame\n"); + frame->channels = avctx->channels; + } ret = getLoadLibsInstance()->m_avcodec_send_frame(avctx, frame); - if (ret < 0) - { - // fprintf(stderr, "ENCODER: avcodec_send_frame error (%i): %s\n", ret, av_err2str(ret)); - return ret; //if (ret == AVERROR(EAGAIN)) //input buffer is full - } - } - else - { - //flush encode buffers + if (ret < 0) { + // fprintf(stderr, "ENCODER: avcodec_send_frame error (%i): %s\n", ret, av_err2str(ret)); + return ret; //if (ret == AVERROR(EAGAIN)) //input buffer is full + } + } else { + //flush encode buffers getLoadLibsInstance()->m_avcodec_send_frame(avctx, NULL); - } - + } + - return ret; + return ret; } -static int libav_get_encode(AVCodecContext *avctx, AVPacket *pkt, int* got_packet) +static int libav_get_encode(AVCodecContext *avctx, AVPacket *pkt, int *got_packet) { - int ret = 0; - *got_packet = 0; + int ret = 0; + *got_packet = 0; ret = getLoadLibsInstance()->m_avcodec_receive_packet(avctx, pkt); - if (!ret) - *got_packet = 1; + if (!ret) + *got_packet = 1; - return ret; + return ret; } // static int libav_encode(AVCodecContext *avctx, AVPacket *pkt, AVFrame *frame, int *got_packet) // { -// int ret; +// int ret; // *got_packet = 0; -// if(frame) +// if(frame) // { // ret = getLoadLibsInstance()->m_avcodec_send_frame(avctx, frame); // if (ret < 0) @@ -1592,9 +1572,9 @@ static int libav_get_encode(AVCodecContext *avctx, AVPacket *pkt, int* got_packe // sprintf(str,"avcode_receive_packet of ret=%d",ret); // //cheese_print_log(str); // if (!ret) -// *got_packet = 1; +// *got_packet = 1; // if (ret == AVERROR(EAGAIN)) //output buffer is empty -// return 0; +// return 0; // return ret; // } @@ -1612,159 +1592,145 @@ static int libav_get_encode(AVCodecContext *avctx, AVPacket *pkt, int* got_packe */ int encoder_encode_video(encoder_context_t *encoder_ctx, void *input_frame) { - /*assertions*/ - assert(encoder_ctx != NULL); + /*assertions*/ + assert(encoder_ctx != NULL); #if !LIBAVCODEC_VER_AT_LEAST(57, 16) - fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)\n"); - return 0; + fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)\n"); + return 0; #else - encoder_video_context_t *enc_video_ctx = encoder_ctx->enc_video_ctx; + encoder_video_context_t *enc_video_ctx = encoder_ctx->enc_video_ctx; - int outsize = 0; + int outsize = 0; - if(!enc_video_ctx) - { - if(verbosity > 1) - printf("ENCODER: video encoder not set\n"); - encoder_ctx->enc_video_ctx->outbuf_coded_size = outsize; - return outsize; - } + if (!enc_video_ctx) { + if (verbosity > 1) + printf("ENCODER: video encoder not set\n"); + encoder_ctx->enc_video_ctx->outbuf_coded_size = outsize; + return outsize; + } - /*raw - direct input no software encoding*/ - if(encoder_ctx->video_codec_ind == 0) - { - if(enc_video_ctx->flush_delayed_frames > 0) - { - enc_video_ctx->flush_done = 1; - encoder_ctx->enc_video_ctx->outbuf_coded_size = outsize; - return outsize; - } - if(input_frame == NULL) - { - encoder_ctx->enc_video_ctx->outbuf_coded_size = outsize; - return outsize; - } - /*outbuf_coded_size must already be set*/ - outsize = enc_video_ctx->outbuf_coded_size; + /*raw - direct input no software encoding*/ + if (encoder_ctx->video_codec_ind == 0) { + if (enc_video_ctx->flush_delayed_frames > 0) { + enc_video_ctx->flush_done = 1; + encoder_ctx->enc_video_ctx->outbuf_coded_size = outsize; + return outsize; + } + if (input_frame == NULL) { + encoder_ctx->enc_video_ctx->outbuf_coded_size = outsize; + return outsize; + } + /*outbuf_coded_size must already be set*/ + outsize = enc_video_ctx->outbuf_coded_size; char str[100]; - sprintf(str,"enc_video_ctx->outbuf_coded_size of outsize is %d\n",outsize); + sprintf(str, "enc_video_ctx->outbuf_coded_size of outsize is %d\n", outsize); //cheese_print_log(str); - if(outsize > enc_video_ctx->outbuf_size) - { - enc_video_ctx->outbuf_size = outsize; - if(enc_video_ctx->outbuf) - free(enc_video_ctx->outbuf); - enc_video_ctx->outbuf = calloc(enc_video_ctx->outbuf_size, sizeof(uint8_t)); - } - memcpy(enc_video_ctx->outbuf, input_frame, outsize); - enc_video_ctx->flags = 0; - /*enc_video_ctx->flags must be set*/ - enc_video_ctx->dts = AV_NOPTS_VALUE; - - if(last_video_pts == 0) - last_video_pts = enc_video_ctx->pts; - - enc_video_ctx->duration = enc_video_ctx->pts - last_video_pts; - last_video_pts = enc_video_ctx->pts; - return (outsize); - } - - encoder_codec_data_t *video_codec_data = (encoder_codec_data_t *) enc_video_ctx->codec_data; - - if(input_frame != NULL) - prepare_video_frame(video_codec_data, input_frame, encoder_ctx->video_width, encoder_ctx->video_height); - - if(!enc_video_ctx->monotonic_pts) //generate a real pts based on the frame timestamp - { - video_codec_data->frame->pts += ((enc_video_ctx->pts - last_video_pts)/1000) * 90; - printf("ENCODER: using non-monotonic pts (this can cause encoding to fail)\n"); - } - else /*generate a true monotonic pts based on the codec fps*/ - { - video_codec_data->frame->pts += - (video_codec_data->codec_context->time_base.num * 1000 / video_codec_data->codec_context->time_base.den) * 90; - } + if (outsize > enc_video_ctx->outbuf_size) { + enc_video_ctx->outbuf_size = outsize; + if (enc_video_ctx->outbuf) + free(enc_video_ctx->outbuf); + enc_video_ctx->outbuf = calloc(enc_video_ctx->outbuf_size, sizeof(uint8_t)); + } + memcpy(enc_video_ctx->outbuf, input_frame, outsize); + enc_video_ctx->flags = 0; + /*enc_video_ctx->flags must be set*/ + enc_video_ctx->dts = AV_NOPTS_VALUE; - if(enc_video_ctx->flush_delayed_frames) - { - if(!enc_video_ctx->flushed_buffers) - { + if (last_video_pts == 0) + last_video_pts = enc_video_ctx->pts; + + enc_video_ctx->duration = enc_video_ctx->pts - last_video_pts; + last_video_pts = enc_video_ctx->pts; + return (outsize); + } + + encoder_codec_data_t *video_codec_data = (encoder_codec_data_t *) enc_video_ctx->codec_data; + + if (input_frame != NULL) + prepare_video_frame(video_codec_data, input_frame, encoder_ctx->video_width, encoder_ctx->video_height); + + if (!enc_video_ctx->monotonic_pts) { //generate a real pts based on the frame timestamp + video_codec_data->frame->pts += ((enc_video_ctx->pts - last_video_pts) / 1000) * 90; + printf("ENCODER: using non-monotonic pts (this can cause encoding to fail)\n"); + } else { /*generate a true monotonic pts based on the codec fps*/ + video_codec_data->frame->pts += + (video_codec_data->codec_context->time_base.num * 1000 / video_codec_data->codec_context->time_base.den) * 90; + } + + if (enc_video_ctx->flush_delayed_frames) { + if (!enc_video_ctx->flushed_buffers) { getLoadLibsInstance()->m_avcodec_flush_buffers(video_codec_data->codec_context); - enc_video_ctx->flushed_buffers = 1; - } - } - - /* encode the video */ - AVPacket *pkt = video_codec_data->outpkt; - int got_packet = 0; - int ret = 0; + enc_video_ctx->flushed_buffers = 1; + } + } + + /* encode the video */ + AVPacket *pkt = video_codec_data->outpkt; + int got_packet = 0; + int ret = 0; //if(enc_video_ctx->outbuf_size < FF_MIN_BUFFER_SIZE) //{ - // av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n"); + // av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n"); // return -1; //} - ret = libav_send_encode( - video_codec_data->codec_context, - video_codec_data->frame); - - if(ret < 0) - { - fprintf(stderr, "ENCODER: Error encoding video frame: %i\n", ret); - return ret; - } + ret = libav_send_encode( + video_codec_data->codec_context, + video_codec_data->frame); - if(enc_video_ctx->flush_delayed_frames) - { - if(!enc_video_ctx->flushed_buffers) + if (ret < 0) { + fprintf(stderr, "ENCODER: Error encoding video frame: %i\n", ret); + return ret; + } + + if (enc_video_ctx->flush_delayed_frames) { + if (!enc_video_ctx->flushed_buffers) getLoadLibsInstance()->m_avcodec_flush_buffers(video_codec_data->codec_context); - - enc_video_ctx->flushed_buffers = 1; - } - while (libav_get_encode(video_codec_data->codec_context, pkt, &got_packet) >= 0) - { - //if(pkt.pts != AV_NOPTS_VALUE) - // printf("ENCODER: (video) pts:%" PRId64 " dts:%" PRId64 "\n", pkt.pts, pkt.dts); - //else - // printf("ENCODER: (video) no pts set\n"); - enc_video_ctx->dts = pkt->dts; - enc_video_ctx->flags = pkt->flags; - enc_video_ctx->duration = pkt->duration; - - if(pkt->size <= enc_video_ctx->outbuf_size) - memcpy(enc_video_ctx->outbuf, pkt->data, pkt->size); - else - fprintf(stderr, "video packet size is bigger than output buffer(%i>%i)\n",pkt->size, enc_video_ctx->outbuf_size); - - /* free any side data since we cannot return it */ - if (pkt->side_data_elems > 0) - { - int i; - for (i = 0; i < pkt->side_data_elems; i++) + enc_video_ctx->flushed_buffers = 1; + } + + while (libav_get_encode(video_codec_data->codec_context, pkt, &got_packet) >= 0) { + //if(pkt.pts != AV_NOPTS_VALUE) + // printf("ENCODER: (video) pts:%" PRId64 " dts:%" PRId64 "\n", pkt.pts, pkt.dts); + //else + // printf("ENCODER: (video) no pts set\n"); + enc_video_ctx->dts = pkt->dts; + enc_video_ctx->flags = pkt->flags; + enc_video_ctx->duration = pkt->duration; + + if (pkt->size <= enc_video_ctx->outbuf_size) + memcpy(enc_video_ctx->outbuf, pkt->data, pkt->size); + else + fprintf(stderr, "video packet size is bigger than output buffer(%i>%i)\n", pkt->size, enc_video_ctx->outbuf_size); + + /* free any side data since we cannot return it */ + if (pkt->side_data_elems > 0) { + int i; + for (i = 0; i < pkt->side_data_elems; i++) getAvutil()->m_av_free(pkt->side_data[i].data); getAvutil()->m_av_freep(&pkt->side_data); - pkt->side_data_elems = 0; - } - outsize = pkt->size; + pkt->side_data_elems = 0; + } + outsize = pkt->size; - getLoadLibsInstance()->m_av_packet_unref(pkt); - //} + getLoadLibsInstance()->m_av_packet_unref(pkt); + //} - if(enc_video_ctx->flush_delayed_frames && ((outsize == 0) || !got_packet)) - enc_video_ctx->flush_done = 1; - else if(outsize == 0 || !got_packet) //the frame was delayed - store_video_df_pts(enc_video_ctx); - else if(enc_video_ctx->write_df >= 0) //we have delayed frames - read_video_df_pts(enc_video_ctx); + if (enc_video_ctx->flush_delayed_frames && ((outsize == 0) || !got_packet)) + enc_video_ctx->flush_done = 1; + else if (outsize == 0 || !got_packet) //the frame was delayed + store_video_df_pts(enc_video_ctx); + else if (enc_video_ctx->write_df >= 0) //we have delayed frames + read_video_df_pts(enc_video_ctx); - last_video_pts = enc_video_ctx->pts; + last_video_pts = enc_video_ctx->pts; - encoder_ctx->enc_video_ctx->outbuf_coded_size = outsize; - encoder_write_video_data(encoder_ctx); - } - return (outsize); + encoder_ctx->enc_video_ctx->outbuf_coded_size = outsize; + encoder_write_video_data(encoder_ctx); + } + return (outsize); #endif } @@ -1781,20 +1747,20 @@ int encoder_encode_video(encoder_context_t *encoder_ctx, void *input_frame) */ int encoder_encode_audio(encoder_context_t *encoder_ctx, void *audio_data) { - /*assertions*/ - assert(encoder_ctx != NULL); + /*assertions*/ + assert(encoder_ctx != NULL); #if !LIBAVCODEC_VER_AT_LEAST(57, 16) - fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)\n"); - return outsize; + fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)\n"); + return outsize; #else - encoder_audio_context_t *enc_audio_ctx = encoder_ctx->enc_audio_ctx; + encoder_audio_context_t *enc_audio_ctx = encoder_ctx->enc_audio_ctx; int outsize = 0; if (!audio_data) { - fprintf(stderr, "ENCODER: audio_data is empty."); + fprintf(stderr, "ENCODER: audio_data is empty.\n"); return outsize; } @@ -1802,180 +1768,168 @@ int encoder_encode_audio(encoder_context_t *encoder_ctx, void *audio_data) { if(verbosity > 1) printf("ENCODER: audio encoder not set\n"); + return outsize; + } - return outsize; - } + encoder_codec_data_t *audio_codec_data = (encoder_codec_data_t *) enc_audio_ctx->codec_data; - encoder_codec_data_t *audio_codec_data = (encoder_codec_data_t *) enc_audio_ctx->codec_data; + /*PCM output: no need for encoding - save samples directly to outbuf*/ + if (audio_codec_data->codec_context->codec_id == AV_CODEC_ID_PCM_F32LE) { + if (enc_audio_ctx->flush_delayed_frames) { + /*since we are not encoding we don't have to flush the encoder buffers*/ + enc_audio_ctx->flushed_buffers = 1; + enc_audio_ctx->flush_done = 1; + } - /*PCM output: no need for encoding - save samples directly to outbuf*/ - if(audio_codec_data->codec_context->codec_id == AV_CODEC_ID_PCM_F32LE) - { - if(enc_audio_ctx->flush_delayed_frames) - { - /*since we are not encoding we don't have to flush the encoder buffers*/ - enc_audio_ctx->flushed_buffers = 1; - enc_audio_ctx->flush_done = 1; - } - - if (audio_data == NULL) - { - enc_audio_ctx->outbuf_coded_size = outsize; - return outsize; - } - - int align = 0; + if (audio_data == NULL) { + enc_audio_ctx->outbuf_coded_size = outsize; + return outsize; + } + + int align = 0; int buffer_size = getAvutil()->m_av_samples_get_buffer_size( - NULL, - audio_codec_data->codec_context->channels, - audio_codec_data->codec_context->frame_size, - audio_codec_data->codec_context->sample_fmt, - align); - - if(buffer_size <= 0) - { - fprintf(stderr, "ENCODER: (encoder_encode_audio) PCM av_samples_get_buffer_size error (%d): chan(%d) nb_samp(%d) samp_fmt(%d)\n", - buffer_size, - audio_codec_data->codec_context->channels, - audio_codec_data->codec_context->frame_size, - audio_codec_data->codec_context->sample_fmt); - - return outsize; - } - - memcpy(enc_audio_ctx->outbuf, audio_data, buffer_size); - enc_audio_ctx->duration = (audio_codec_data->codec_context->time_base.num*1000/audio_codec_data->codec_context->time_base.den) * 90; - enc_audio_ctx->pts += enc_audio_ctx->duration; - enc_audio_ctx->dts = enc_audio_ctx->pts; - enc_audio_ctx->flags = 0; - enc_audio_ctx->outbuf_coded_size = buffer_size; - - outsize = buffer_size; - return outsize; - } - - /* encode the audio */ - /* encode the video */ - AVPacket *pkt = audio_codec_data->outpkt; - int got_packet = 0; - int ret = 0; - - if(!enc_audio_ctx->flush_delayed_frames) - { - /*number of samples per channel*/ - audio_codec_data->frame->nb_samples = audio_codec_data->codec_context->frame_size; - audio_codec_data->frame->pts = enc_audio_ctx->pts; + NULL, + audio_codec_data->codec_context->channels, + audio_codec_data->codec_context->frame_size, + audio_codec_data->codec_context->sample_fmt, + align); + + if (buffer_size <= 0) { + fprintf(stderr, "ENCODER: (encoder_encode_audio) PCM av_samples_get_buffer_size error (%d): chan(%d) nb_samp(%d) samp_fmt(%d)\n", + buffer_size, + audio_codec_data->codec_context->channels, + audio_codec_data->codec_context->frame_size, + audio_codec_data->codec_context->sample_fmt); + + return outsize; + } - int align = 0; + memcpy(enc_audio_ctx->outbuf, audio_data, buffer_size); + enc_audio_ctx->duration = (audio_codec_data->codec_context->time_base.num * 1000 / audio_codec_data->codec_context->time_base.den) * 90; + enc_audio_ctx->pts += enc_audio_ctx->duration; + enc_audio_ctx->dts = enc_audio_ctx->pts; + enc_audio_ctx->flags = 0; + enc_audio_ctx->outbuf_coded_size = buffer_size; - int buffer_size = getAvutil()->m_av_samples_get_buffer_size( - NULL, - audio_codec_data->codec_context->channels, - audio_codec_data->frame->nb_samples, - audio_codec_data->codec_context->sample_fmt, - align); + outsize = buffer_size; + return outsize; + } - if(buffer_size <= 0) - { - fprintf(stderr, "ENCODER: (encoder_encode_audio) av_samples_get_buffer_size error (%d): chan(%d) nb_samp(%d) samp_fmt(%d)\n", - buffer_size, - audio_codec_data->codec_context->channels, - audio_codec_data->frame->nb_samples, - audio_codec_data->codec_context->sample_fmt); + /* encode the audio */ + /* encode the video */ + AVPacket *pkt = audio_codec_data->outpkt; + int got_packet = 0; + int ret = 0; - return outsize; - } + if (!enc_audio_ctx->flush_delayed_frames) { + /*number of samples per channel*/ + audio_codec_data->frame->nb_samples = audio_codec_data->codec_context->frame_size; + audio_codec_data->frame->pts = enc_audio_ctx->pts; + int align = 0; - /*set the data pointers in frame*/ + int buffer_size = getAvutil()->m_av_samples_get_buffer_size( + NULL, + audio_codec_data->codec_context->channels, + audio_codec_data->frame->nb_samples, + audio_codec_data->codec_context->sample_fmt, + align); + + if (buffer_size <= 0) { + fprintf(stderr, "ENCODER: (encoder_encode_audio) av_samples_get_buffer_size error (%d): chan(%d) nb_samp(%d) samp_fmt(%d)\n", + buffer_size, + audio_codec_data->codec_context->channels, + audio_codec_data->frame->nb_samples, + audio_codec_data->codec_context->sample_fmt); + + return outsize; + } + + + /*set the data pointers in frame*/ ret = getLoadLibsInstance()->m_avcodec_fill_audio_frame( - audio_codec_data->frame, - audio_codec_data->codec_context->channels, - audio_codec_data->codec_context->sample_fmt, - (const uint8_t *) audio_data, - buffer_size, - align); - - if(ret < 0) - { - fprintf(stderr, "ENCODER: (encoder_encode_audio) avcodec_fill_audio_frame error (%d): chan(%d) nb_samp(%d) samp_fmt(%d) buff(%d bytes)\n", - ret, - audio_codec_data->codec_context->channels, - audio_codec_data->frame->nb_samples, - audio_codec_data->codec_context->sample_fmt, - buffer_size); - - return outsize; - } - - if(audio_codec_data->frame->nb_samples != audio_codec_data->codec_context->frame_size) - { - fprintf(stderr, "ENCODER: audio frame->nb_samples(%i) != codec_context->frame_size(%i)", - audio_codec_data->frame->nb_samples, audio_codec_data->codec_context->frame_size); - } - if(!enc_audio_ctx->monotonic_pts) /*generate a real pts based on the frame timestamp*/ - audio_codec_data->frame->pts += ((enc_audio_ctx->pts - last_audio_pts)/1000) * 90; - else if (audio_codec_data->codec_context->time_base.den > 0) /*generate a true monotonic pts based on the codec fps*/ - audio_codec_data->frame->pts += - (audio_codec_data->codec_context->time_base.num*1000/audio_codec_data->codec_context->time_base.den) * 90; - else - { - fprintf(stderr, "ENCODER: (encoder_encode_audio) couldn't generate a monotonic ts: time_base.den(%d)\n", - audio_codec_data->codec_context->time_base.den); - } - } + audio_codec_data->frame, + audio_codec_data->codec_context->channels, + audio_codec_data->codec_context->sample_fmt, + (const uint8_t *) audio_data, + buffer_size, + align); + + if (ret < 0) { + fprintf(stderr, "ENCODER: (encoder_encode_audio) avcodec_fill_audio_frame error (%d): chan(%d) nb_samp(%d) samp_fmt(%d) buff(%d bytes)\n", + ret, + audio_codec_data->codec_context->channels, + audio_codec_data->frame->nb_samples, + audio_codec_data->codec_context->sample_fmt, + buffer_size); + + return outsize; + } + + if (audio_codec_data->frame->nb_samples != audio_codec_data->codec_context->frame_size) { + fprintf(stderr, "ENCODER: audio frame->nb_samples(%i) != codec_context->frame_size(%i)", + audio_codec_data->frame->nb_samples, audio_codec_data->codec_context->frame_size); + } + if (!enc_audio_ctx->monotonic_pts) /*generate a real pts based on the frame timestamp*/ + audio_codec_data->frame->pts += ((enc_audio_ctx->pts - last_audio_pts) / 1000) * 90; + else if (audio_codec_data->codec_context->time_base.den > 0) /*generate a true monotonic pts based on the codec fps*/ + audio_codec_data->frame->pts += + (audio_codec_data->codec_context->time_base.num * 1000 / audio_codec_data->codec_context->time_base.den) * 90; + else { + fprintf(stderr, "ENCODER: (encoder_encode_audio) couldn't generate a monotonic ts: time_base.den(%d)\n", + audio_codec_data->codec_context->time_base.den); + } + } ret = libav_send_encode( - audio_codec_data->codec_context, - audio_codec_data->frame); - if(!enc_audio_ctx->flushed_buffers) - { - if(audio_codec_data) + audio_codec_data->codec_context, + audio_codec_data->frame); + if (!enc_audio_ctx->flushed_buffers) { + if (audio_codec_data) getLoadLibsInstance()->m_avcodec_flush_buffers(audio_codec_data->codec_context); - enc_audio_ctx->flushed_buffers = 1; - } + enc_audio_ctx->flushed_buffers = 1; + } - while (libav_get_encode(audio_codec_data->codec_context, pkt, &got_packet) >= 0) - { - //if(pkt.pts != AV_NOPTS_VALUE) - // printf("ENCODER: (audio) pts:%" PRId64 " dts:%" PRId64 "\n", pkt.pts, pkt.dts); - //else - // printf("ENCODER: (audio) no pts set\n"); - - if(pkt->pts < 0) //avoid negative pts - pkt->pts = -pkt->pts; - enc_audio_ctx->pts = pkt->pts; - enc_audio_ctx->dts = pkt->dts; - enc_audio_ctx->flags = pkt->flags; - enc_audio_ctx->duration = pkt->duration; - - if(pkt->size <= enc_audio_ctx->outbuf_size) - memcpy(enc_audio_ctx->outbuf, pkt->data, pkt->size); - else - fprintf(stderr, "audio packet size is bigger than output buffer(%i>%i)\n",pkt->size, enc_audio_ctx->outbuf_size); - - /* free any side data since we cannot return it */ - //ff_packet_free_side_data(&pkt); - if (audio_codec_data->frame && - audio_codec_data->frame->extended_data != audio_codec_data->frame->data) + while (libav_get_encode(audio_codec_data->codec_context, pkt, &got_packet) >= 0) { + //if(pkt.pts != AV_NOPTS_VALUE) + // printf("ENCODER: (audio) pts:%" PRId64 " dts:%" PRId64 "\n", pkt.pts, pkt.dts); + //else + // printf("ENCODER: (audio) no pts set\n"); + + if (pkt->pts < 0) //avoid negative pts + pkt->pts = -pkt->pts; + enc_audio_ctx->pts = pkt->pts; + enc_audio_ctx->dts = pkt->dts; + enc_audio_ctx->flags = pkt->flags; + enc_audio_ctx->duration = pkt->duration; + + if (pkt->size <= enc_audio_ctx->outbuf_size) + memcpy(enc_audio_ctx->outbuf, pkt->data, pkt->size); + else + fprintf(stderr, "audio packet size is bigger than output buffer(%i>%i)\n", pkt->size, enc_audio_ctx->outbuf_size); + + /* free any side data since we cannot return it */ + //ff_packet_free_side_data(&pkt); + if (audio_codec_data->frame && + audio_codec_data->frame->extended_data != audio_codec_data->frame->data) getAvutil()->m_av_freep(audio_codec_data->frame->extended_data); - outsize = pkt->size; - + outsize = pkt->size; + getLoadLibsInstance()->m_av_packet_unref(pkt); - last_audio_pts = enc_audio_ctx->pts; + last_audio_pts = enc_audio_ctx->pts; - if(enc_audio_ctx->flush_delayed_frames && outsize == 0) - enc_audio_ctx->flush_done = 1; + if (enc_audio_ctx->flush_delayed_frames && outsize == 0) + enc_audio_ctx->flush_done = 1; - enc_audio_ctx->outbuf_coded_size = outsize; + enc_audio_ctx->outbuf_coded_size = outsize; - encoder_write_audio_data(encoder_ctx); - } - return (outsize); + encoder_write_audio_data(encoder_ctx); + } + return (outsize); #endif } @@ -1991,103 +1945,727 @@ int encoder_encode_audio(encoder_context_t *encoder_ctx, void *audio_data) */ void encoder_close(encoder_context_t *encoder_ctx) { - encoder_clean_video_ring_buffer(); + encoder_clean_video_ring_buffer(); - if(!encoder_ctx) - return; + if (!encoder_ctx) + return; - encoder_video_context_t *enc_video_ctx = encoder_ctx->enc_video_ctx; - encoder_audio_context_t *enc_audio_ctx = encoder_ctx->enc_audio_ctx; - encoder_codec_data_t *video_codec_data = NULL; - encoder_codec_data_t *audio_codec_data = NULL; + encoder_video_context_t *enc_video_ctx = encoder_ctx->enc_video_ctx; + encoder_audio_context_t *enc_audio_ctx = encoder_ctx->enc_audio_ctx; + encoder_codec_data_t *video_codec_data = NULL; + encoder_codec_data_t *audio_codec_data = NULL; - if(encoder_ctx->h264_pps) - free(encoder_ctx->h264_pps); + if (encoder_ctx->h264_pps) + free(encoder_ctx->h264_pps); - if(encoder_ctx->h264_sps) - free(encoder_ctx->h264_sps); + if (encoder_ctx->h264_sps) + free(encoder_ctx->h264_sps); - /*close video codec*/ - if(enc_video_ctx) - { + /*close video codec*/ + if (enc_video_ctx) { - video_codec_data = (encoder_codec_data_t *) enc_video_ctx->codec_data; - if(video_codec_data) - { - if(!(enc_video_ctx->flushed_buffers)) - { + video_codec_data = (encoder_codec_data_t *) enc_video_ctx->codec_data; + if (video_codec_data) { + if (!(enc_video_ctx->flushed_buffers)) { getLoadLibsInstance()->m_avcodec_flush_buffers(video_codec_data->codec_context); - enc_video_ctx->flushed_buffers = 1; - } + enc_video_ctx->flushed_buffers = 1; + } getLoadLibsInstance()->m_avcodec_close(video_codec_data->codec_context); - free(video_codec_data->codec_context); + free(video_codec_data->codec_context); getAvutil()->m_av_dict_free(&(video_codec_data->private_options)); - if(video_codec_data->frame) + if (video_codec_data->frame) getAvutil()->m_av_frame_free(&video_codec_data->frame); - if(video_codec_data->outpkt) + if (video_codec_data->outpkt) getLoadLibsInstance()->m_av_packet_free(&video_codec_data->outpkt); - free(video_codec_data); - } + free(video_codec_data); + } - if(enc_video_ctx->priv_data) - free(enc_video_ctx->priv_data); - if(enc_video_ctx->tmpbuf) - free(enc_video_ctx->tmpbuf); - if(enc_video_ctx->outbuf) - free(enc_video_ctx->outbuf); + if (enc_video_ctx->priv_data) + free(enc_video_ctx->priv_data); + if (enc_video_ctx->tmpbuf) + free(enc_video_ctx->tmpbuf); + if (enc_video_ctx->outbuf) + free(enc_video_ctx->outbuf); - free(enc_video_ctx); - } + free(enc_video_ctx); + } - /*close audio codec*/ - if(enc_audio_ctx) - { + /*close audio codec*/ + if (enc_audio_ctx) { //测试video时长是否正常 - printf("video_duration:%d",enc_audio_ctx->duration); - audio_codec_data = (encoder_codec_data_t *) enc_audio_ctx->codec_data; - if(audio_codec_data) - { + printf("video_duration:%d\n", enc_audio_ctx->duration); + audio_codec_data = (encoder_codec_data_t *) enc_audio_ctx->codec_data; + if (audio_codec_data) { getLoadLibsInstance()->m_avcodec_flush_buffers(audio_codec_data->codec_context); getLoadLibsInstance()->m_avcodec_close(audio_codec_data->codec_context); - free(audio_codec_data->codec_context); + free(audio_codec_data->codec_context); - if(audio_codec_data->frame) + if (audio_codec_data->frame) getAvutil()->m_av_frame_free(&audio_codec_data->frame); - if(audio_codec_data->outpkt) + if (audio_codec_data->outpkt) getLoadLibsInstance()->m_av_packet_free(&audio_codec_data->outpkt); - free(audio_codec_data); - } + free(audio_codec_data); + } - if(enc_audio_ctx->priv_data) - free(enc_audio_ctx->priv_data); - if(enc_audio_ctx->outbuf) - free(enc_audio_ctx->outbuf); + if (enc_audio_ctx->priv_data) + free(enc_audio_ctx->priv_data); + if (enc_audio_ctx->outbuf) + free(enc_audio_ctx->outbuf); - free(enc_audio_ctx); - } + free(enc_audio_ctx); + } - free(encoder_ctx); + free(encoder_ctx); - /*reset static data*/ + /*reset static data*/ set_video_pause_timestamp(0); set_video_timestamptmp(0); - last_video_pts = 0; - last_audio_pts = 0; - reference_pts = 0; + last_video_pts = 0; + last_audio_pts = 0; + reference_pts = 0; + + video_frame_max_size = 0; + + video_ring_buffer_size = 0; + video_ring_buffer = NULL; + video_read_index = 0; + video_write_index = 0; + video_scheduler = 0; + + if (HW_VAAPI_OK == is_vaapi) + vaapi_over(); +} + + + +// #define VAAPI_DEBUG 0 + +static AVBufferRef *hw_device_ctx = NULL; +AVFrame *swsframe = NULL; +struct SwsContext *swsContext = NULL; +AVFrame *hw_frame = NULL; +uint8_t *out_uuvv = NULL; + +void vaapi_over(void) +{ + getAvutil()->m_av_buffer_unref(&hw_device_ctx); + getAvutil()->m_av_freep(&swsframe->data[0]); + getLoadLibsInstance()->m_sws_freeContext(swsContext); + getAvutil()->m_av_frame_free(&swsframe); + free(out_uuvv); +} + +/* + * close and clean encoder context + * args: + * encoder_ctx - pointer to encoder context data + * + * asserts: + * none + * + * returns: none + */ +void encoder_video_close(encoder_video_context_t *enc_video_ctx) +{ + if (!enc_video_ctx) + return; + encoder_codec_data_t *video_codec_data = NULL; + + /*close video codec*/ + if (enc_video_ctx) { + + video_codec_data = (encoder_codec_data_t *) enc_video_ctx->codec_data; + if (video_codec_data) { + if (!(enc_video_ctx->flushed_buffers)) { + getLoadLibsInstance()->m_avcodec_flush_buffers(video_codec_data->codec_context); + enc_video_ctx->flushed_buffers = 1; + } + + getLoadLibsInstance()->m_avcodec_close(video_codec_data->codec_context); + free(video_codec_data->codec_context); + + getAvutil()->m_av_dict_free(&(video_codec_data->private_options)); + + if (video_codec_data->frame) + getAvutil()->m_av_frame_free(&video_codec_data->frame); + + if (video_codec_data->outpkt) + getLoadLibsInstance()->m_av_packet_free(&video_codec_data->outpkt); + + free(video_codec_data); + } + + if (enc_video_ctx->priv_data) + free(enc_video_ctx->priv_data); + if (enc_video_ctx->tmpbuf) + free(enc_video_ctx->tmpbuf); + if (enc_video_ctx->outbuf) + free(enc_video_ctx->outbuf); + + free(enc_video_ctx); + } +} + + +static char *vm_err22str(int errnum) +{ + char *errbuf = (char[AV_ERROR_MAX_STRING_SIZE]) {0}; + getAvutil()->m_av_strerror(errnum, errbuf, 64); + return errbuf; +} + + + +static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx, int width, int height) +{ + AVBufferRef *hw_frames_ref; + AVHWFramesContext *frames_ctx = NULL; + int err = 0; + + if (!(hw_frames_ref = getAvutil()->m_av_hwframe_ctx_alloc(hw_device_ctx))) { + fprintf(stderr, "Failed to create VAAPI frame context.\n"); + return -1; + } + frames_ctx = (AVHWFramesContext *)(hw_frames_ref->data); + frames_ctx->format = AV_PIX_FMT_VAAPI; + frames_ctx->sw_format = AV_PIX_FMT_NV12; // AV_PIX_FMT_YUV420P + frames_ctx->width = width; + frames_ctx->height = height; + frames_ctx->initial_pool_size = 20; + if ((err = getAvutil()->m_av_hwframe_ctx_init(hw_frames_ref)) < 0) { + fprintf(stderr, "Failed to initialize VAAPI frame context." + "Error code: %s\n", vm_err22str(err)); + getAvutil()->m_av_buffer_unref(&hw_frames_ref); + return err; + } + ctx->hw_frames_ctx = getAvutil()->m_av_buffer_ref(hw_frames_ref); + if (!ctx->hw_frames_ctx) + err = AVERROR(ENOMEM); + + getAvutil()->m_av_buffer_unref(&hw_frames_ref); + return err; +} + + + +/* + * video encoder initialization + * args: + * encoder_ctx - pointer to encoder context + * + * asserts: + * encoder_ctx is not null + * + * returns: pointer to encoder video context (NULL on none) + */ + +static encoder_video_context_t *encoder_video_init_vaapi(encoder_context_t *encoder_ctx) +{ + struct pci_device_iterator *iter; + struct pci_device *dev; + int ret; + is_vaapi = HW_VAAPI_OK; + ret = pci_system_init(); + if (ret != 0) { + fprintf(stderr, "Couldn't initialize PCI system\n"); + is_vaapi = HW_VAAPI_FAIL1; + return NULL; + } + iter = pci_slot_match_iterator_create(NULL); + + while (1) { + if ((dev = pci_device_next(iter)) == NULL) { + is_vaapi = HW_VAAPI_FAIL1; + fprintf(stderr, "no gpu card for vaapi\n"); + return NULL; + } + + if (0x03 == ((dev->device_class >> 16) & 0x0ff)) { + fprintf(stderr, " CLASS 0x%02x subclass 0x%02x prog-if_name 0x%02x REVISION 0x%02x\n", + (dev->device_class >> 16) & 0x0ff, + (dev->device_class >> 8) & 0x0ff, + (dev->device_class >> 0) & 0x0ff, + dev->revision); + fprintf(stderr, "bus 0x%04x cardnum 0x%02x function 0x%02x:" + " vendor 0x%04x device 0x%04x\n", + dev->bus, + dev->dev, + dev->func, + dev->vendor_id, + dev->device_id); + + if (0x8086 == dev->vendor_id) { // intel gpu support vaapi, vendor_id :0x8086 can find from file pci.ids + //Iris Xe Graphics don't suppot vaapi, so softening coding. + if (dev->device_id == 0xa7a0) { + is_vaapi = HW_VAAPI_FAIL1; + return NULL; + } + fprintf(stderr, "try this gpu card for vaapi\n"); + break; + } + } + } + pci_system_cleanup(); + + //assertions + assert(encoder_ctx != NULL); + +#if !LIBAVCODEC_VER_AT_LEAST(57,16) + fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)\n"); + return NULL; +#else + if (encoder_ctx->video_codec_ind < 0) { + if (verbosity > 0) + printf("ENCODER: no video codec set - using raw (direct input)\n"); + + encoder_ctx->video_codec_ind = 0; + } + + video_codec_t *video_defaults = encoder_get_video_codec_defaults(encoder_ctx->video_codec_ind); + if (!video_defaults) { + fprintf(stderr, "ENCODER: defaults for video codec index %i not found: using raw (direct input)\n", encoder_ctx->video_codec_ind); + is_vaapi = HW_VAAPI_FAIL1; + } + + encoder_video_context_t *enc_video_ctx = calloc(1, sizeof(encoder_video_context_t)); + if (enc_video_ctx == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (e_ncoder_video_init): %s\n", strerror(errno)); + is_vaapi = HW_VAAPI_FAIL2; + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + return NULL; + } + + /* make sure enc_video_ctx is set in encoder_ctx */ + encoder_ctx->enc_video_ctx = enc_video_ctx; + + if (encoder_ctx->video_codec_ind == 0) { + encoder_set_raw_video_input(encoder_ctx, video_defaults); + is_vaapi = HW_VAAPI_FAIL3 ; + return (enc_video_ctx); + } + + /* + * alloc the video codec data + */ + encoder_codec_data_t *video_codec_data = calloc(1, sizeof(encoder_codec_data_t)); + if (video_codec_data == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (e_ncoder_video_init): %s\n", strerror(errno)); + is_vaapi = HW_VAAPI_FAIL4; + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + return NULL; + } + + + int err = getAvutil()->m_av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, NULL, NULL, 0); + if (err < 0) { + fprintf(stderr, "Failed to create a VAAPI device. Error code: %s\n", vm_err22str(err)); + is_vaapi = HW_VAAPI_FAIL5; + + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + free(video_codec_data); + return NULL; + } +// video_defaults->codec_name = "h264_vaapi"; + video_codec_data->codec = getLoadLibsInstance()->m_avcodec_find_encoder_by_name("h264_vaapi"); (video_defaults->codec_name); + + if (!video_codec_data->codec) { + /*we will use raw data so free the codec data*/ + free(video_codec_data); + fprintf(stderr, "ENCODER: libav video codec (%i) not found - using raw input\n", video_defaults->codec_id); + is_vaapi = HW_VAAPI_FAIL6; + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + free(video_codec_data); + return NULL; + } + + video_codec_data->codec_context = getLoadLibsInstance()->m_avcodec_alloc_context3(video_codec_data->codec); + + getLoadLibsInstance()->m_avcodec_get_context_defaults3 && getLoadLibsInstance()->m_avcodec_get_context_defaults3( + video_codec_data->codec_context, + video_codec_data->codec); + + if (video_codec_data->codec_context == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (e_ncoder_video_init): %s\n", strerror(errno)); + is_vaapi = HW_VAAPI_FAIL7; + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + free(video_codec_data); + return NULL; + } + + /*set codec defaults*/ + // video_codec_data->codec_context->bit_rate = video_defaults->bit_rate; + video_codec_data->codec_context->width = encoder_ctx->video_width; + video_codec_data->codec_context->height = encoder_ctx->video_height; + + video_codec_data->codec_context->flags |= video_defaults->flags; + if (video_defaults->num_threads > 0) + video_codec_data->codec_context->thread_count = video_defaults->num_threads; + /* + * mb_decision: + * 0 (FF_MB_DECISION_SIMPLE) Use mbcmp (default). + * 1 (FF_MB_DECISION_BITS) Select the MB mode which needs the fewest bits (=vhq). + * 2 (FF_MB_DECISION_RD) Select the MB mode which has the best rate distortion. + */ + video_codec_data->codec_context->mb_decision = video_defaults->mb_decision; + /*use trellis quantization*/ + video_codec_data->codec_context->trellis = video_defaults->trellis; + + /*motion estimation method */ + if (video_defaults->codec_id == AV_CODEC_ID_H264 && video_defaults->me_method > 4) + video_defaults->me_method = X264_ME_HEX; + + getAvutil()->m_av_dict_set_int(&video_codec_data->private_options, "motion-est", video_defaults->me_method, 0); + getAvutil()->m_av_dict_set_int(&video_codec_data->private_options, "mpeg_quant", video_defaults->mpeg_quant, 0); + getAvutil()->m_av_dict_set_int(&video_codec_data->private_options, "mepre", video_defaults->pre_me, 0); + + + video_codec_data->codec_context->dia_size = video_defaults->dia; + video_codec_data->codec_context->pre_dia_size = video_defaults->pre_dia; + + video_codec_data->codec_context->me_pre_cmp = video_defaults->me_pre_cmp; + video_codec_data->codec_context->me_cmp = video_defaults->me_cmp; + video_codec_data->codec_context->me_sub_cmp = video_defaults->me_sub_cmp; + video_codec_data->codec_context->me_subpel_quality = video_defaults->subq; //NEW + video_codec_data->codec_context->refs = video_defaults->framerefs; //NEW + video_codec_data->codec_context->last_predictor_count = video_defaults->last_pred; + + + video_codec_data->codec_context->qmin = video_defaults->qmin; // best detail allowed - worst compression + video_codec_data->codec_context->qmax = video_defaults->qmax; // worst detail allowed - best compression + video_codec_data->codec_context->max_qdiff = video_defaults->max_qdiff; + video_codec_data->codec_context->max_b_frames = video_defaults->max_b_frames; + + video_codec_data->codec_context->qcompress = video_defaults->qcompress; + video_codec_data->codec_context->qblur = video_defaults->qblur; + video_codec_data->codec_context->strict_std_compliance = FF_COMPLIANCE_NORMAL; + video_codec_data->codec_context->codec_id = video_defaults->codec_id; + + video_codec_data->codec_context->codec_type = AVMEDIA_TYPE_VIDEO; + +// video_codec_data->codec_context->pix_fmt = video_defaults->pix_fmt; //only yuv420p available for mpeg + video_codec_data->codec_context->pix_fmt = AV_PIX_FMT_VAAPI; + if (video_defaults->fps) + video_codec_data->codec_context->time_base = (AVRational) {1, video_defaults->fps}; //use codec properties fps + else if (encoder_ctx->fps_den >= 5) + video_codec_data->codec_context->time_base = (AVRational) {encoder_ctx->fps_num, encoder_ctx->fps_den}; //default fps (for gspca this is 1/1) + else + video_codec_data->codec_context->time_base = (AVRational) {1, 15}; //fallback to 15 fps (e.g gspca) + + + if (video_defaults->gop_size > 0) { + video_codec_data->codec_context->gop_size = video_defaults->gop_size; + } else { + video_codec_data->codec_context->gop_size = video_codec_data->codec_context->time_base.den; + } + switch (video_defaults->codec_id) { + case AV_CODEC_ID_H264: { + video_codec_data->codec_context->me_range = 16; + //av_dict_set(&video_codec_data->private_options, "rc_lookahead", "1", 0); + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "crf", "23", 0); + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "preset", "ultrafast", 0); + getAvutil()->m_av_dict_set(&video_codec_data->private_options, "tune", "zerolatency", 0); + } + break; + case AV_CODEC_ID_HEVC: + case AV_CODEC_ID_VP8: { + is_vaapi = HW_VAAPI_FAIL20; + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + free(video_codec_data); + return NULL; + } + break; + default: { + is_vaapi = HW_VAAPI_FAIL21; + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + free(video_codec_data); + return NULL; + } + break; + } + + ret = 0; + /* set hw_frames_ctx for encoder's AVCodecContext */ + if ((ret = set_hwframe_ctx(video_codec_data->codec_context, hw_device_ctx, video_codec_data->codec_context->width, video_codec_data->codec_context->height)) < 0) { + fprintf(stderr, "Failed to set hwframe context.\n"); + is_vaapi = HW_VAAPI_FAIL8; + getAvutil()->m_av_buffer_unref(&hw_device_ctx); + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + free(video_codec_data); + return NULL; + } + + + /* open codec*/ + if ((ret = getLoadLibsInstance()->m_avcodec_open2(video_codec_data->codec_context,video_codec_data->codec,&video_codec_data->private_options)) < 0){ + fprintf(stderr, "ENCODER: could not open video codec (%s): %i - using raw input\n", video_defaults->codec_name, ret); + free(video_codec_data->codec_context); + video_codec_data->codec_context = NULL; + video_codec_data->codec = 0; + /*we will use raw data so free the codec data*/ + free(video_codec_data); + video_defaults = encoder_get_video_codec_defaults(0); + encoder_set_raw_video_input(encoder_ctx, video_defaults); + + //alloc outbuf + if(enc_video_ctx->outbuf_size <= 0) + enc_video_ctx->outbuf_size = 240000;//1792 + if(enc_video_ctx->outbuf != NULL) + free(enc_video_ctx->outbuf); + is_vaapi = HW_VAAPI_FAIL9; + getAvutil()->m_av_buffer_unref(&hw_device_ctx); + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + free(video_codec_data); + return NULL; + } + + video_codec_data->frame = getAvutil()->m_av_frame_alloc(); + + if (video_codec_data->frame == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (e_ncoder_video_init): %s\n", strerror(errno)); + is_vaapi = HW_VAAPI_FAIL10; + getAvutil()->m_av_buffer_unref(&hw_device_ctx); + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + free(video_codec_data); + return NULL; + } + video_codec_data->frame->pts = 0; + + video_codec_data->outpkt = getLoadLibsInstance()->m_av_packet_alloc(); + + if (video_codec_data->outpkt == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (e_ncoder_video_init): %s\n", strerror(errno)); + is_vaapi = HW_VAAPI_FAIL11; + getAvutil()->m_av_buffer_unref(&hw_device_ctx); + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + free(video_codec_data); + return NULL; + } + + /*set the codec data in codec context*/ + enc_video_ctx->codec_data = (void *) video_codec_data; + enc_video_ctx->tmpbuf = NULL; //no need to temp buffer input already in yu12 (yuv420p) + enc_video_ctx->monotonic_pts = video_defaults->monotonic_pts; + + //alloc outbuf + enc_video_ctx->outbuf_size = (encoder_ctx->video_width * encoder_ctx->video_height) / 2; + if (enc_video_ctx->outbuf_size <= 0) + enc_video_ctx->outbuf_size = 240000;//1792 + if (enc_video_ctx->outbuf != NULL) + free(enc_video_ctx->outbuf); + enc_video_ctx->outbuf = calloc(enc_video_ctx->outbuf_size, sizeof(uint8_t)); + if (enc_video_ctx->outbuf == NULL) { + fprintf(stderr, "ENCODER: FATAL memory allocation failure (e_ncoder_video_init): %s\n", strerror(errno)); + is_vaapi = HW_VAAPI_FAIL12; + getAvutil()->m_av_buffer_unref(&hw_device_ctx); + fprintf(stderr, "FAIL to encoder_video_init_vaapi:%d.\n", is_vaapi); + free(video_codec_data); + return NULL; + } + + enc_video_ctx->read_df = -1; + enc_video_ctx->write_df = -1; + + enc_video_ctx->flushed_buffers = 0; + enc_video_ctx->flush_delayed_frames = 0; + enc_video_ctx->flush_done = 0; + + is_vaapi = HW_VAAPI_OK; + swsframe = getAvutil()->m_av_frame_alloc(); + out_uuvv = (uint8_t *)malloc(encoder_ctx->video_width * encoder_ctx->video_height / 2); + fprintf(stderr, "Success to encoder_video_init_vaapi.\n"); + return (enc_video_ctx); +#endif +} + +/* + * encode video frame vaapi + * args: + * encoder_ctx - pointer to encoder context + * input_frame - pointer to frame data + * + * asserts: + * encoder_ctx is not null + * + * returns: encoded buffer size + */ + +int encoder_encode_video_vaapi(encoder_context_t *encoder_ctx, void *input_frame) +{ + /*assertions*/ + assert(encoder_ctx != NULL); + +#if !LIBAVCODEC_VER_AT_LEAST(57, 16) + fprintf(stderr, "ENCODER: Error - libavcodec version not supported (minimum 57.16)\n"); + return 0; +#else + + encoder_video_context_t *enc_video_ctx = encoder_ctx->enc_video_ctx; + + int outsize = 0; + + if (!enc_video_ctx) { + if (verbosity > 1) + printf("ENCODER: video encoder not set\n"); + encoder_ctx->enc_video_ctx->outbuf_coded_size = outsize; + return outsize; + } + + /*raw - direct input no software encoding*/ + if (encoder_ctx->video_codec_ind == 0) { + fprintf(stderr, "Error code: encoder_ctx->video_codec_ind == 0 \n"); + return (outsize); + } + + encoder_codec_data_t *video_codec_data = (encoder_codec_data_t *) enc_video_ctx->codec_data; + + if (input_frame != NULL) { + // // prepare_video_frame_nv12 + // /*assertions*/ + assert(video_codec_data); + assert(input_frame); + int width = encoder_ctx->video_width; + int height = encoder_ctx->video_height; + int size = width * height; + /* by ffmpeg way + // int linesize[4]; + // // swsframe = getAvutil()->m_av_frame_alloc(); + + // swsContext = getLoadLibsInstance()->m_sws_getContext(width, height, (enum AVPixelFormat)video_codec_data->frame->format, \ + // width, height, AV_PIX_FMT_NV12, SWS_BILINEAR, NULL, NULL, NULL); + // getAvutil()->m_av_image_alloc(swsframe->data , linesize, width, height, AV_PIX_FMT_NV12, 16); //AV_PIX_FMT_YUYV422 AV_PIX_FMT_NV12 + // getLoadLibsInstance()->m_sws_scale(swsContext, video_codec_data->frame->data, video_codec_data->frame->linesize, 0, height, swsframe->data, linesize); + + // video_codec_data->frame->linesize[2] = 0; + // video_codec_data->frame->linesize[0] = width; + // video_codec_data->frame->linesize[1] = width ; + // video_codec_data->frame->width = width; + // video_codec_data->frame->height = height; + // video_codec_data->frame->format = AV_PIX_FMT_NV12; //AV_PIX_FMT_YUV420P; + // video_codec_data->frame->data[0] = input_frame; //Y + // video_codec_data->frame->data[1] = swsframe->data[1]; //Uv + */ + + uint8_t *uv = out_uuvv; + uint8_t *iu = input_frame + size; + uint8_t *iv = input_frame + size + size / 4; + for (int hh = 0; hh < height; hh++) { + for (int ww = 0; ww < width / 4; ww++) { + *uv++ = *iu++; + *uv++ = *iv++; +// fprintf(stderr, "--hh--%d,--ww--%d\n",hh,ww); + } + } + + video_codec_data->frame->format = AV_PIX_FMT_NV12; //AV_PIX_FMT_YUV420P; + video_codec_data->frame->width = width; + video_codec_data->frame->height = height; + + video_codec_data->frame->data[0] = input_frame; //Y + video_codec_data->frame->data[1] = out_uuvv; //Uv + + video_codec_data->frame->linesize[0] = width; + video_codec_data->frame->linesize[1] = width ; + video_codec_data->frame->linesize[2] = 0; + } + + if (!enc_video_ctx->monotonic_pts) { //generate a real pts based on the frame timestamp + video_codec_data->frame->pts += ((enc_video_ctx->pts - last_video_pts) / 1000) * 90; + printf("ENCODER: using non-monotonic pts (this can cause encoding to fail)\n"); + } else { /*generate a true monotonic pts based on the codec fps*/ + video_codec_data->frame->pts += + (video_codec_data->codec_context->time_base.num * 1000 / video_codec_data->codec_context->time_base.den) * 90; + } + + if (enc_video_ctx->flush_delayed_frames) { + if (!enc_video_ctx->flushed_buffers) { + getLoadLibsInstance()->m_avcodec_flush_buffers(video_codec_data->codec_context); + enc_video_ctx->flushed_buffers = 1; + } + } - video_frame_max_size = 0; + int err = 0; - video_ring_buffer_size = 0; - video_ring_buffer = NULL; - video_read_index = 0; - video_write_index = 0; - video_scheduler = 0; + if (!(hw_frame = getAvutil()->m_av_frame_alloc())) + err = AVERROR(ENOMEM); + + if ((getAvutil()->m_av_hwframe_get_buffer(video_codec_data->codec_context->hw_frames_ctx, hw_frame, 0)) < 0) { + fprintf(stderr, "Error code: av_hwframe_get_buffer.\n"); + + } + if (!hw_frame->hw_frames_ctx) { + err = AVERROR(ENOMEM); + fprintf(stderr, "Error code: hw_frame->hw_frames_ctx.\n"); + } + + if ((err = getAvutil()->m_av_hwframe_transfer_data(hw_frame, video_codec_data->frame, 0)) < 0) { + // if (( err = getAvutil()->m_av_hwframe_transfer_data(hw_frame, swsframe, 0)) < 0) { + fprintf(stderr, "Error while transferring frame data to surface." + "Error code: %s.\n", vm_err22str(err)); + } + + /* encode the video */ + AVPacket *pkt = video_codec_data->outpkt; + int got_packet = 0; + int ret = 0; + + ret = libav_send_encode(video_codec_data->codec_context, hw_frame); + + if (ret < 0) { + fprintf(stderr, "ENCODER: Error encoding video frame: %i\n", ret); + return ret; + } + + if (enc_video_ctx->flush_delayed_frames) { + if (!enc_video_ctx->flushed_buffers) + getLoadLibsInstance()->m_avcodec_flush_buffers(video_codec_data->codec_context); + + enc_video_ctx->flushed_buffers = 1; + } + + while (libav_get_encode(video_codec_data->codec_context, pkt, &got_packet) >= 0) { + + enc_video_ctx->dts = pkt->dts; + enc_video_ctx->flags = pkt->flags; + enc_video_ctx->duration = pkt->duration; + + if (pkt->size <= enc_video_ctx->outbuf_size) + memcpy(enc_video_ctx->outbuf, pkt->data, pkt->size); + else + fprintf(stderr, "video packet size is bigger than output buffer(%i>%i)\n", pkt->size, enc_video_ctx->outbuf_size); + + /* free any side data since we cannot return it */ + if (pkt->side_data_elems > 0) { + int i; + for (i = 0; i < pkt->side_data_elems; i++) + getAvutil()->m_av_free(pkt->side_data[i].data); + getAvutil()->m_av_freep(&pkt->side_data); + pkt->side_data_elems = 0; + } + outsize = pkt->size; + + getLoadLibsInstance()->m_av_packet_unref(pkt); + + if (enc_video_ctx->flush_delayed_frames && ((outsize == 0) || !got_packet)) + enc_video_ctx->flush_done = 1; + else if (outsize == 0 || !got_packet) //the frame was delayed + store_video_df_pts(enc_video_ctx); + else if (enc_video_ctx->write_df >= 0) //we have delayed frames + read_video_df_pts(enc_video_ctx); + + last_video_pts = enc_video_ctx->pts; + + encoder_ctx->enc_video_ctx->outbuf_coded_size = outsize; + encoder_write_video_data(encoder_ctx); + } + getAvutil()->m_av_frame_free(&hw_frame); + return (outsize); +#endif } diff --git a/libcam/libcam_encoder/gviewencoder.h b/libcam/libcam_encoder/gviewencoder.h index 47038c68..714b33b3 100644 --- a/libcam/libcam_encoder/gviewencoder.h +++ b/libcam/libcam_encoder/gviewencoder.h @@ -331,7 +331,8 @@ encoder_context_t *encoder_init( int fps_num, int fps_den, int audio_channels, - int audio_samprate); + int audio_samprate, + int use_pugx_code); /* * initialization of the file muxer diff --git a/libcam/libcam_encoder/mp4.c b/libcam/libcam_encoder/mp4.c index 495cf196..f4ad0696 100644 --- a/libcam/libcam_encoder/mp4.c +++ b/libcam/libcam_encoder/mp4.c @@ -1,7 +1,23 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ %YEAR% Uniontech Software Technology Co.,Ltd. +* +* Author: shicetu +* hujianbo +* Maintainer: shicetu +* hujianbo +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "mp4.h" #include diff --git a/libcam/libcam_encoder/mp4.h b/libcam/libcam_encoder/mp4.h index d6025243..22584d4b 100644 --- a/libcam/libcam_encoder/mp4.h +++ b/libcam/libcam_encoder/mp4.h @@ -1,7 +1,23 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ %YEAR% Uniontech Software Technology Co.,Ltd. +* +* Author: shicetu +* hujianbo +* Maintainer: shicetu +* hujianbo +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef MP4_H #define MP4_H diff --git a/libcam/libcam_encoder/video_codecs.c b/libcam/libcam_encoder/video_codecs.c index 348d1b79..59112a7b 100644 --- a/libcam/libcam_encoder/video_codecs.c +++ b/libcam/libcam_encoder/video_codecs.c @@ -387,7 +387,7 @@ static video_codec_t listSupCodecs[] = .trellis = 0, .me_method = X264_ME_HEX, .mpeg_quant = 1, - .max_b_frames = 16, + .max_b_frames = 4, .num_threads = 4, #if LIBAVCODEC_VER_AT_LEAST(54,01) .flags = CODEC_FLAG2_INTRA_REFRESH diff --git a/libcam/libcam_v4l2core/jpeg_decoder.c b/libcam/libcam_v4l2core/jpeg_decoder.c index c32e696c..072b9616 100644 --- a/libcam/libcam_v4l2core/jpeg_decoder.c +++ b/libcam/libcam_v4l2core/jpeg_decoder.c @@ -1415,6 +1415,7 @@ int jpeg_init_decoder(int width, int height) #if LIBAVCODEC_VER_AT_LEAST(53,6) codec_data->context = getLoadLibsInstance()->m_avcodec_alloc_context3(codec_data->codec); + getLoadLibsInstance()->m_avcodec_get_context_defaults3 && getLoadLibsInstance()->m_avcodec_get_context_defaults3 (codec_data->context, codec_data->codec); #else codec_data->context = getLoadLibsInstance()->m_avcodec_alloc_context(); getLoadLibsInstance()->m_avcodec_get_context_defaults(codec_data->context); diff --git a/libcam/libcam_v4l2core/uvc_h264.c b/libcam/libcam_v4l2core/uvc_h264.c index d0f182cc..bfad6840 100644 --- a/libcam/libcam_v4l2core/uvc_h264.c +++ b/libcam/libcam_v4l2core/uvc_h264.c @@ -1006,6 +1006,7 @@ int h264_init_decoder(int width, int height) #if LIBAVCODEC_VER_AT_LEAST(53,6) h264_ctx->context = getLoadLibsInstance()->m_avcodec_alloc_context3(h264_ctx->codec); + getLoadLibsInstance()->m_avcodec_get_context_defaults3 (h264_ctx->context, h264_ctx->codec); #else h264_ctx->context = getLoadLibsInstance()->m_avcodec_alloc_context(); getLoadLibsInstance()->m_avcodec_get_context_defaults(h264_ctx->context); diff --git a/linglong.yaml b/linglong.yaml new file mode 100644 index 00000000..b4d4a86d --- /dev/null +++ b/linglong.yaml @@ -0,0 +1,67 @@ +package: + id: org.deepin.camera + name: "deepin-camera" + version: 1.4.0 + kind: app + description: | + camera for deepin os. + +variables: + extra_args: | + -DVERSION=${VERSION} + +runtime: + id: org.deepin.Runtime + version: 23.0.0 + +#libxtst ffmpeg vlc +depends: + - id: ffmpeg + version: 4.1.8 + - id: "udisks2-qt5" + version: 5.0.3 + - id: qtdbusextended + version: 0.0.3 + type: runtime + - id: ffmpegthumbnailer + version: 2.1.1 + - id: "gstreamer1.0" + version: 1.14.6 + - id: "gst-plugins-base1.0" + version: 1.14.5 + type: runtime + - id: "gst-plugins-bad1.0" + version: 1.14.4.2 + type: runtime + - id: "image-editor" + version: 1.0.9 + - id: libusb-1.0 + version: 1.0.24 + - id: portaudio19 + version: 19.6.0 + type: runtime + - id: v4l-utils + version: 1.22.1 + type: runtime + - id: icu + version: 63.1 + type: runtime + - id: xcb-util + version: 0.3.8.1 + type: runtime + +source: + kind: local + url: "http://gerrit.uniontech.com/deepin-camera" + version: develop/snipe + commit: I08d14ec62ac8221581c0cea64f5fc0ae5ad09add + patch: patches/remove-absolute-path-from-cmake-file.patch +build: + kind: manual + manual: + configure: | + mkdir build + cd build + cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} ${extra_args} .. + make -j6 + make -j install diff --git a/patches/remove-absolute-path-from-cmake-file.patch b/patches/remove-absolute-path-from-cmake-file.patch new file mode 100644 index 00000000..adfe5a46 --- /dev/null +++ b/patches/remove-absolute-path-from-cmake-file.patch @@ -0,0 +1,170 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c14914a..835a298 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.0) + + project(deepin-camera VERSION 1.0.0) + ++include_directories( ${CMAKE_INSTALL_PREFIX}/include) + add_subdirectory(src) + + if (CMAKE_BUILD_TYPE STREQUAL "Debug") +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index ae2a68b..7d089e3 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -11,6 +11,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) + project(deepin-camera VERSION 1.0.0) + set(CMD_NAME deepin-camera) + set(TARGET_NAME deepin-camera) ++include_directories( ${CMAKE_INSTALL_PREFIX}/include) ++include_directories( ${CMAKE_INSTALL_PREFIX}/include/libavcodec) + #option (__mips__ "Use UNITTEST" ON) + + # cube文件目录,libvisualresult在打包时,会自动将cube文件安装到share目录下 +@@ -58,8 +60,8 @@ set(PROJECT_INCLUDE + ./src/qtsingleapplication + ./src/accessibility + ./src/accessible +- /usr/include +- /usr/include/libusb-1.0 ++ ${CMAKE_INSTALL_PREFIX}/include ++ ${CMAKE_INSTALL_PREFIX}/include/libusb-1.0 + ) + + # 设置Qt模块 +@@ -96,8 +98,11 @@ pkg_check_modules(3rd_lib REQUIRED + pciaccess + # libv4l2 + # libudev +-# libusb-1.0 +-# libavcodec ++ libusb-1.0 ++ libavcodec ++ libimageviewer ++ libffmpegthumbnailer ++ portaudio-2.0 + # libavutil + # libavformat + # libswscale +@@ -145,34 +150,34 @@ target_link_libraries(${TARGET_NAME} ${3rd_lib_LIBRARIES} + qt5_use_modules(${TARGET_NAME} ${QtModule}) + + #application +-install(TARGETS ${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) ++install(TARGETS ${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) + + #desk desktop + install(FILES ${PROJECT_SOURCE_DIR}/deepin-camera.desktop +- DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) ++ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) + + #table desktop + install(FILES ${PROJECT_SOURCE_DIR}/table/deepin-camera.desktop +- DESTINATION ${CMAKE_INSTALL_DATADIR}/due-shell/shortcuts) ++ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/due-shell/shortcuts) + + #icons + install(FILES ${PROJECT_SOURCE_DIR}/assets/deepin-camera.svg +- DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps) ++ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps) + + #table_icons +-install(DIRECTORY ${PROJECT_SOURCE_DIR}/assets/panel/Icons DESTINATION ${CMAKE_INSTALL_DATADIR}/due-shell/shortcuts) ++install(DIRECTORY ${PROJECT_SOURCE_DIR}/assets/panel/Icons DESTINATION ${CMAKE_INSTALL_PREFIX}/share/due-shell/shortcuts) + + #manual +-install(DIRECTORY ${PROJECT_SOURCE_DIR}/assets/deepin-camera DESTINATION ${CMAKE_INSTALL_DATADIR}/deepin-manual/manual-assets/application/) ++install(DIRECTORY ${PROJECT_SOURCE_DIR}/assets/deepin-camera DESTINATION ${CMAKE_INSTALL_PREFIX}/share/deepin-manual/manual-assets/application/) + + #debus_service +-install(FILES ${PROJECT_SOURCE_DIR}/com.deepin.Camera.service DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services) ++install(FILES ${PROJECT_SOURCE_DIR}/com.deepin.Camera.service DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dbus-1/services) + + ##translations +-#install(FILES ${PROJECT_SOURCE_DIR}/translations/*.qm DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_SOURCE_DIR}/translations) ++#install(FILES ${PROJECT_SOURCE_DIR}/translations/*.qm DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_SOURCE_DIR}/translations) + + #translations +-set(APPSHAREDIR ${CMAKE_INSTALL_DATADIR}/${TARGET_NAME}) ++set(APPSHAREDIR ${CMAKE_INSTALL_PREFIX}/share/${TARGET_NAME}) + install(DIRECTORY ${PROJECT_SOURCE_DIR}/translations + DESTINATION ${APPSHAREDIR} + FILES_MATCHING PATTERN "*.qm") +diff --git a/src/com.deepin.Camera.service b/src/com.deepin.Camera.service +index bcc39d0..114a477 100644 +--- a/src/com.deepin.Camera.service ++++ b/src/com.deepin.Camera.service +@@ -1,4 +1,4 @@ +-$ cat /usr/share/dbus-1/services/com.deepin.Camera.service ++#$ cat ${CMAKE_INSTALL_PREFIX}/share/dbus-1/services/com.deepin.Camera.service + [D-BUS Service] + Name=com.deepin.Camera +-Exec=/usr/bin/qdbus --literal com.deepin.SessionManager /com/deepin/StartManager com.deepin.StartManager.Launch /usr/share/applications/deepin-camera.desktop ++Exec=/usr/bin/ll-cli run org.deepin.camera --exec deepin-camera +diff --git a/src/src/mainwindow.cpp b/src/src/mainwindow.cpp +index de1ceb6..6da4b9e 100644 +--- a/src/src/mainwindow.cpp ++++ b/src/src/mainwindow.cpp +@@ -785,18 +785,31 @@ void CMainWindow::slotPopupSettingsDialog() + QString CMainWindow::libPath(const QString &strlib) + { + QDir dir; +- QString path = QLibraryInfo::location(QLibraryInfo::LibrariesPath); +- dir.setPath(path); +- QStringList list = dir.entryList(QStringList() << (strlib + "*"), QDir::NoDotAndDotDot | QDir::Files); //filter name with strlib +- +- if (list.contains(strlib)) +- return strlib; +- +- list.sort(); +- if (list.size() > 0) +- return list.last(); +- +- return ""; ++ QStringList environment = QProcess::systemEnvironment(); ++ QString str, t_str; ++ foreach (str, environment) { ++ if (str.startsWith("LD_LIBRARY_PATH=")) { ++ t_str = str; ++ break; ++ } ++ } ++ if (t_str.isEmpty()) { ++ return QString(); ++ } ++ qDebug() << "lib:"< $@ - bzip2 -9 $^ - -%.pp: %.te - make -f ${SHARE}/selinux/devel/Makefile $@ - -clean: - rm -f *~ *.tc *.pp *.pp.bz2 - rm -rf tmp *.tar.gz diff --git a/selinux/deepin-camera.fc b/selinux/deepin-camera.fc deleted file mode 100644 index b4a00002..00000000 --- a/selinux/deepin-camera.fc +++ /dev/null @@ -1,6 +0,0 @@ -# myapp executable will have: -# label: system_u:object_r:myapp_exec_t -# MLS sensitivity: s0 -# MCS categories: - -/usr/bin/deepin-camera -- gen_context(system_u:object_r:deepin_camera_exec_t,s0) diff --git a/selinux/deepin-camera.if b/selinux/deepin-camera.if deleted file mode 100644 index ddd0e8c7..00000000 --- a/selinux/deepin-camera.if +++ /dev/null @@ -1,58 +0,0 @@ -## policy for deepin_camera - -######################################## -## -## Execute deepin_camera_exec_t in the deepin_camera domain. -## -## -## -## Domain allowed to transition. -## -## -# -interface(`deepin_camera_domtrans',` - gen_require(` - type deepin_camera_t, deepin_camera_exec_t; - ') - - corecmd_search_bin($1) - domtrans_pattern($1, deepin_camera_exec_t, deepin_camera_t) -') - -###################################### -## -## Execute deepin_camera in the caller domain. -## -## -## -## Domain allowed access. -## -## -# -interface(`deepin_camera_exec',` - gen_require(` - type deepin_camera_exec_t; - ') - - corecmd_search_bin($1) - can_exec($1, deepin_camera_exec_t) -') - -######################################## -## -## Read deepin_camera log files. -## -## -## -## Domain allowed to read the log files. -## -## -# -interface(`deepin_camera_read_log',` - gen_require(` - type deepin_camera_log_t; - ') - - logging_search_logs($1) - allow $1 deepin_camera_log_t:file read_file_perms; -') diff --git a/selinux/deepin-camera.pp.bz2 b/selinux/deepin-camera.pp.bz2 deleted file mode 100644 index 1ed9da8b..00000000 Binary files a/selinux/deepin-camera.pp.bz2 and /dev/null differ diff --git a/selinux/deepin-camera.te b/selinux/deepin-camera.te deleted file mode 100644 index 72eee687..00000000 --- a/selinux/deepin-camera.te +++ /dev/null @@ -1,87 +0,0 @@ -policy_module(deepin-camera, 1.0.0) - -######################################## -# -# Declarations -# - -type deepin_camera_t; -type deepin_camera_exec_t; -init_daemon_domain(deepin_camera_t, deepin_camera_exec_t) -userdom_user_application_domain(deepin_camera_t,deepin_camera_exec_t) -#domain_role_change_exemption(deepin_camera_t) -#domain_system_change_exemption(deepin_camera_t) -#domain_interactive_fd(deepin_camera_t) -#role deepin_camera_roles types deepin_camera_t; - -##域切换 -unprivuser_domtrans_to(deepin_camera_t, deepin_camera_exec_t) -sysadm_domtrans_to(deepin_camera_t, deepin_camera_exec_t) -secadm_domtrans_to(deepin_camera_t, deepin_camera_exec_t) -auditadm_domtrans_to(deepin_camera_t, deepin_camera_exec_t) -unconfined_domain(deepin_camera_t) - -require { - type initrc_t; - type user_dbusd_t; - type xdm_t; - type tmpfs_t; - type pulseaudio_t; - type user_t; - type systemd_logind_t; - type system_dbusd_t; - type sysadm_t; - type secadm_t; - type v4l_device_t; - type NetworkManager_t; - class chr_file { getattr ioctl map open read write }; - class process { noatsecure rlimitinh siginh getattr signull }; - class capability sys_ptrace; - class file {getattr open read write }; - class dir { getattr open read search setattr write }; - class lnk_file { getattr read }; - class fd use; - class dbus { acquire_svc send_msg }; - type alsa_t; -} - - -domain_use_interactive_fds(deepin_camera_t) -files_read_etc_files(deepin_camera_t) -miscfiles_read_localization(deepin_camera_t) - - -#domain_auto_transition_pattern(sysadm_t,deepin_camera_exec_t,deepin_camera_t) -allow deepin_camera_t v4l_device_t:chr_file { getattr ioctl map open read write }; -allow deepin_camera_t user_dbusd_t:dbus { acquire_svc send_msg }; -allow deepin_camera_t user_t:dbus send_msg; - - -allow NetworkManager_t deepin_camera_t:dbus send_msg; - -allow sysadm_t deepin_camera_t:fd use; -allow sysadm_t deepin_camera_t:process { noatsecure siginh }; -allow sysadm_t deepin_camera_t:dbus send_msg; -#allow system_dbusd_t alsa_t:process { noatsecure rlimitinh siginh }; -#allow system_dbusd_t self:capability sys_ptrace; -allow systemd_logind_t deepin_camera_t:dbus send_msg; - -allow secadm_t deepin_camera_t:dbus send_msg; -allow secadm_t deepin_camera_t:dir { getattr search }; -allow secadm_t deepin_camera_t:file { getattr open read }; -allow secadm_t deepin_camera_t:process { noatsecure siginh signull }; - - -allow pulseaudio_t deepin_camera_t:fd use; -allow user_t deepin_camera_t:dir { getattr search }; -allow user_t deepin_camera_t:file { getattr open read }; -allow user_t deepin_camera_t:lnk_file { getattr read }; -allow user_t deepin_camera_t:process { noatsecure siginh getattr }; -allow user_t deepin_camera_t:dbus send_msg; - -#allow user_t xdm_t:file { noatsecure siginh }; -xserver_read_xdm_state(domain) - -allow system_dbusd_t deepin_camera_t:dbus send_msg; - -allow initrc_t deepin_camera_t:dbus send_msg; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 031bbe14..e3b66cde 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# +# SPDX-License-Identifier: GPL-3.0-or-later + cmake_minimum_required(VERSION 3.0) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -7,22 +11,29 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) project(deepin-camera VERSION 1.0.0) set(CMD_NAME deepin-camera) set(TARGET_NAME deepin-camera) +find_package(DWayland) +find_package(KF5Wayland) +if (NOT DWayland_FOUND) + if (${KF5Wayland_VERSION} VERSION_GREATER 5.54.1) + option(USE_DEEPIN_WAYLAND "option for wayland support" ON) + endif() +else() + option(USE_DEEPIN_WAYLAND "option for wayland support" ON) +endif() #option (__mips__ "Use UNITTEST" ON) # cube文件目录,libvisualresult在打包时,会自动将cube文件安装到share目录下 set(LUT_DIR "/usr/share/libimagevisualresult/filter_cube") add_definitions(-DLUT_DIR="${LUT_DIR}") -#add_definitions(-D__mips__) -if(EXISTS /etc/os-version) - execute_process(COMMAND cat /etc/os-version COMMAND grep MinorVersion COMMAND grep -o \\-\\?[0-9]\\+ OUTPUT_VARIABLE osversion) - message(${osversion}) - if(NOT (${osversion} LESS 1050)) - add_definitions(-DKF5_WAYLAND_FLAGE_ON) - endif() -else() - message("/etc/os-version is not exist") - add_definitions(-DKF5_WAYLAND_FLAGE_ON) +# 判断系统环境 +#file(STRINGS "/etc/os-version" MAJOR_STR REGEX "MajorVersion") +execute_process(COMMAND cat /etc/os-version OUTPUT_VARIABLE OS_INFO_STR) +string(REGEX MATCHALL "MajorVersion=[0-9]+" MAJOR_STR "${OS_INFO_STR}") +string(REGEX MATCH "[0-9]+" MAJOR_VERSION "${MAJOR_STR}") +if (MAJOR_VERSION MATCHES "23") + message("--------------------- OS_BUILD_V23 on") + add_definitions(-DOS_BUILD_V23) endif() include(GNUInstallDirs) @@ -30,6 +41,10 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX /usr) endif () +if (USE_DEEPIN_WAYLAND) + add_definitions("-DUSE_DEEPIN_WAYLAND") +endif() + # 加速编译优化参数 if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64") SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O3 -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -Wl,--as-needed -fPIE") @@ -69,6 +84,17 @@ set(QtModule Core Gui Widgets DBus Concurrent LinguistTools Multimedia PrintSupp find_package(Qt5 REQUIRED ${QtModule}) find_package(PkgConfig REQUIRED) +include(FindPkgConfig) +if (USE_DEEPIN_WAYLAND) + if (DWayland_FOUND) + message("DWayland founded.") + add_definitions(-DDWAYLAND) + elseif(KF5Wayland_FOUND) + message("KF5Wayland founded.") + add_definitions(-DKF5WAYLAND) + endif() +endif() + file (GLOB_RECURSE CXXSOURCES ./src/*.cpp ./*.cpp @@ -93,6 +119,7 @@ file (GLOB_RECURSE RESOURCES ${PROJECT_SOURCE_DIR}/assets/assets.qrc) pkg_check_modules(3rd_lib REQUIRED dtkwidget dtkcore gobject-2.0 + pciaccess # libv4l2 # libudev # libusb-1.0 @@ -129,6 +156,14 @@ endif () # 设置不删除生成的文件夹内容文件 set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) +if (USE_DEEPIN_WAYLAND) + if (DWayland_FOUND) + set(LIBS DWaylandClient DWaylandServer) + else() + message("KF5 environment") + set(LIBS KF5::WaylandClient KF5::WaylandServer) + endif() +endif() add_executable( ${TARGET_NAME} ${CXXSOURCES} ${CSOURCES} ${RESOURCES} ${QM} ) @@ -138,10 +173,10 @@ target_link_libraries(${TARGET_NAME} ${3rd_lib_LIBRARIES} pthread dl imagevisualresult - KF5WaylandClient + ${LIBS} ) -include_directories("/usr/include/KF5") +include_directories("/usr/include") # 将工程与Qt模块链接起来 qt5_use_modules(${TARGET_NAME} ${QtModule}) @@ -170,8 +205,24 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/assets/deepin-camera DESTINATION ${CMAKE #debus_service install(FILES ${PROJECT_SOURCE_DIR}/com.deepin.Camera.service DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services) +# Install camera config file. +install(FILES assets/camera.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/share/deepin-camera) + +##translations +#install(FILES ${PROJECT_SOURCE_DIR}/translations/*.qm DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_SOURCE_DIR}/translations) + #translations set(APPSHAREDIR ${CMAKE_INSTALL_DATADIR}/${TARGET_NAME}) install(DIRECTORY ${PROJECT_SOURCE_DIR}/translations DESTINATION ${APPSHAREDIR} FILES_MATCHING PATTERN "*.qm") + +#hw机型增加DConfig配置 +set(APPID org.deepin.camera) +set(configFile ${PROJECT_SOURCE_DIR}/assets/org.deepin.camera.encode.json) +if (DEFINED DSG_DATA_DIR) + message("-- DConfig is supported by DTK") + dconfig_meta_files(APPID ${APPID} FILES ${configFile}) +else() + install(FILES ${configFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/dsg/configs/org.deepin.camera/) +endif() diff --git a/src/assets/camera.conf b/src/assets/camera.conf new file mode 100644 index 00000000..a441422d --- /dev/null +++ b/src/assets/camera.conf @@ -0,0 +1,2 @@ +[General] +LowPerformanceBoard=600F,NZ275D,GWMNDA1GL1,CCA-W23-D20A diff --git a/src/assets/deepin-camera/camera/common/delay.png b/src/assets/deepin-camera/camera/common/delay.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/common/exposure.png b/src/assets/deepin-camera/camera/common/exposure.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/common/filter.png b/src/assets/deepin-camera/camera/common/filter.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/common/flashlight.png b/src/assets/deepin-camera/camera/common/flashlight.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/common/fold.png b/src/assets/deepin-camera/camera/common/fold.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/common/more.png b/src/assets/deepin-camera/camera/common/more.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/common/photograph.png b/src/assets/deepin-camera/camera/common/photograph.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/common/record.png b/src/assets/deepin-camera/camera/common/record.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/common/switch.png b/src/assets/deepin-camera/camera/common/switch.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/en_US/camera.md b/src/assets/deepin-camera/camera/en_US/camera.md index e89a7521..91ad6f56 100644 --- a/src/assets/deepin-camera/camera/en_US/camera.md +++ b/src/assets/deepin-camera/camera/en_US/camera.md @@ -127,4 +127,4 @@ There are three window themes, namely Light Theme, Dark Theme, and System Theme. ### Exit 1. Click ![icon_menu](../common/icon_menu.svg) on the Camera interface. -2. Click **Exit** to exit Camera. \ No newline at end of file +2. Click **Exit** to exit Camera. diff --git a/src/assets/deepin-camera/camera/zh_CN/fig/d_output_settings.png b/src/assets/deepin-camera/camera/zh_CN/fig/d_output_settings.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/zh_CN/fig/d_settings.png b/src/assets/deepin-camera/camera/zh_CN/fig/d_settings.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/zh_CN/fig/right_menu.png b/src/assets/deepin-camera/camera/zh_CN/fig/right_menu.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/zh_HK/fig/d_output_settings.png b/src/assets/deepin-camera/camera/zh_HK/fig/d_output_settings.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/zh_HK/fig/d_settings.png b/src/assets/deepin-camera/camera/zh_HK/fig/d_settings.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/zh_HK/fig/right_menu.png b/src/assets/deepin-camera/camera/zh_HK/fig/right_menu.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/zh_TW/fig/d_outputsettings.png b/src/assets/deepin-camera/camera/zh_TW/fig/d_outputsettings.png old mode 100644 new mode 100755 diff --git a/src/assets/deepin-camera/camera/zh_TW/fig/d_settings.png b/src/assets/deepin-camera/camera/zh_TW/fig/d_settings.png old mode 100644 new mode 100755 diff --git a/src/assets/images/icons/light/switch_camera.svg b/src/assets/images/icons/light/switch_camera.svg index 68b8e526..55542568 100644 --- a/src/assets/images/icons/light/switch_camera.svg +++ b/src/assets/images/icons/light/switch_camera.svg @@ -1,9 +1,25 @@ - - 切换摄像头 - - - - + + -mockplus- + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/assets/images/icons/light/switch_camera_press.svg b/src/assets/images/icons/light/switch_camera_press.svg index 2e3a71d5..9704c7f4 100644 --- a/src/assets/images/icons/light/switch_camera_press.svg +++ b/src/assets/images/icons/light/switch_camera_press.svg @@ -1,7 +1 @@ - - - 切换摄像头-press - - - - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/org.deepin.camera.encode.json b/src/assets/org.deepin.camera.encode.json new file mode 100644 index 00000000..64bad69a --- /dev/null +++ b/src/assets/org.deepin.camera.encode.json @@ -0,0 +1,16 @@ +{ + "magic": "dsg.config.meta", + "version": "1.0", + "contents": { + "mp4EncodeMode": { + "value": -1, + "serial": 0, + "flags": ["global"], + "name": "pugx mp4 code mode", + "name[zh_CN]": "特殊编码模式", + "description": "pugx mp4 code mode", + "permissions": "readwrite", + "visibility": "private" + } + } +} \ No newline at end of file diff --git a/src/assets/resource/panel_settings.json b/src/assets/resource/panel_settings.json index 840c6c36..ad800144 100644 --- a/src/assets/resource/panel_settings.json +++ b/src/assets/resource/panel_settings.json @@ -184,7 +184,7 @@ "options": [ { "key": "resolution", - "name": "Resolution:", + "name": "Maximum resolution:", "type":"combobox", "default": " " } diff --git a/src/assets/resource/settings.json b/src/assets/resource/settings.json index 5c14c9ff..90d8354b 100644 --- a/src/assets/resource/settings.json +++ b/src/assets/resource/settings.json @@ -182,7 +182,7 @@ "options": [ { "key": "resolution", - "name": "Resolution:", + "name": "Maximum resolution:", "type":"combobox", "default": " " } diff --git a/src/main.cpp b/src/main.cpp index cafbfd56..5fc4984f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,9 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later -extern "C" -{ +extern "C" { #include "camview.h" } #include "mainwindow.h" @@ -13,8 +12,11 @@ extern "C" #include "acobjectlist.h" #include "dbus_adpator.h" -extern "C" -{ +#ifdef DTKCORE_CLASS_DConfigFile +#include +#endif + +extern "C" { #include } @@ -38,32 +40,6 @@ extern "C" DWIDGET_USE_NAMESPACE - - -static bool runSingleInstance() -{ - QString userName = QDir::homePath().section("/", -1, -1); - std::string path = ("/home/" + userName + "/.cache/deepin/deepin-camera/").toStdString(); - QDir tdir(path.c_str()); - if (!tdir.exists()) { - tdir.mkpath(path.c_str()); - } - - path += "single"; - int fd = open(path.c_str(), O_WRONLY | O_CREAT, 0644); - int flock = lockf(fd, F_TLOCK, 0); - - if (fd == -1) { - qInfo() << strerror(errno); - return false; - } - if (flock == -1) { - qInfo() << strerror(errno); - return false; - } - return true; -} - //判断是否采用wayland显示服务器 static bool CheckWayland() { @@ -80,11 +56,11 @@ static bool CheckWayland() static bool CheckFFmpegEnv() { QDir dir; - QString path = QLibraryInfo::location(QLibraryInfo::LibrariesPath); + QString path = QLibraryInfo::location(QLibraryInfo::LibrariesPath); dir.setPath(path); QStringList list = dir.entryList(QStringList() << (QString("libavcodec") + "*"), QDir::NoDotAndDotDot | QDir::Files); QString libName = nullptr; - QRegExp re("libavcodec.so.*"); //Sometimes libavcodec.so may not exist, so find it through regular expression. + QRegExp re("libavcodec.so.*"); //Sometimes libavcodec.so may not exist, so find it through regular expression. for (int i = 0; i < list.count(); i++) { if (re.exactMatch(list[i])) { libName = list[i]; @@ -93,9 +69,9 @@ static bool CheckFFmpegEnv() } if (libName != nullptr) { - QLibrary libavcodec; //检查编码器是否存在 + QLibrary libavcodec; //检查编码器是否存在 libavcodec.setFileName(libName); - qDebug() << "Whether the libavcodec is loaded successfully: "<< libavcodec.load(); + qDebug() << "Whether the libavcodec is loaded successfully: " << libavcodec.load(); typedef AVCodec *(*p_avcodec_find_encoder)(enum AVCodecID id); p_avcodec_find_encoder m_avcodec_find_encoder = nullptr; m_avcodec_find_encoder = reinterpret_cast(libavcodec.resolve("avcodec_find_encoder")); @@ -119,6 +95,9 @@ static bool CheckFFmpegEnv() int main(int argc, char *argv[]) { + // Task 326583 不参与合成器崩溃重连 + unsetenv("QT_WAYLAND_RECONNECT"); + QAccessible::installFactory(accessibleFactory); bool bWayland = CheckWayland(); bool bFFmpegEnv = CheckFFmpegEnv(); @@ -142,6 +121,42 @@ int main(int argc, char *argv[]) format.setRenderableType(QSurfaceFormat::OpenGLES); format.setDefaultFormat(format); set_wayland_status(1); + + int mp4Encode = -1; +#ifdef DTKCORE_CLASS_DConfigFile + //需要查询是否对PGUX设置MP4编码缓存特殊处理 + DConfig *dconfig = DConfig::create("org.deepin.camera", "org.deepin.camera.encode"); + if (dconfig && dconfig->isValid() && dconfig->keyList().contains("mp4EncodeMode")) { + mp4Encode = dconfig->value("mp4EncodeMode").toInt(); + set_pugx_status(mp4Encode); + } +#endif + qInfo() << "mp4EncodeMode value is:" << get_pugx_status(); + if (mp4Encode == -1) { + //判断是否是pgux + QStringList options; + options << QString(QStringLiteral("-c")); + options << QString(QStringLiteral("dmidecode -s system-product-name|awk '{print $NF}'")); + QProcess process; + process.start(QString(QStringLiteral("bash")), options); + process.waitForFinished(); + process.waitForReadyRead(); + QByteArray tempArray = process.readAllStandardOutput(); + char *charTemp = tempArray.data(); + QString str_output = QString(QLatin1String(charTemp)); + process.close(); + + if (str_output.contains("PGUX", Qt::CaseInsensitive)) { + mp4Encode = 1; + qDebug() << "this is PGUX"; + } else { + mp4Encode = 0; + } + qInfo() << "process find mp4EncodeMode value is:" << get_pugx_status(); + } + + set_pugx_status(mp4Encode); + qInfo() << "last mp4EncodeMode value is:" << get_pugx_status(); } QTime time; @@ -151,7 +166,7 @@ int main(int argc, char *argv[]) qDebug() << QString("initFilters cost %1 ms").arg(time.elapsed()); CApplication a(argc, argv); -// gst_init(&argc, &argv); + //gst_init(&argc, &argv); qApp->setObjectName("deepin-camera"); #ifndef __mips__ @@ -187,7 +202,7 @@ int main(int argc, char *argv[]) DApplicationSettings saveTheme; - if (!runSingleInstance()) { + if (!qApp->setSingleInstance("deepin-camera")) { qDebug() << "another deepin camera instance has started"; QDBusInterface iface("com.deepin.camera", QDir::separator(), "com.deepin.camera"); if (iface.isValid()) { diff --git a/src/src/LPF_V4L2.c b/src/src/LPF_V4L2.c index 94252382..a91fd419 100644 --- a/src/src/LPF_V4L2.c +++ b/src/src/LPF_V4L2.c @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/LPF_V4L2.h b/src/src/LPF_V4L2.h index 34bd2026..4aaabb4f 100644 --- a/src/src/LPF_V4L2.h +++ b/src/src/LPF_V4L2.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/Settings.cpp b/src/src/Settings.cpp index 3d753730..cd6d58ed 100644 --- a/src/src/Settings.cpp +++ b/src/src/Settings.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -8,6 +8,7 @@ #include "gviewv4l2core.h" #include "capplication.h" #include "camera.h" +#include "globalutils.h" #include #include @@ -48,14 +49,19 @@ void Settings::init() QStringList videoFormatList; if (DataManager::instance()->encodeEnv() == FFmpeg_Env) { if (DataManager::instance()->encExists()) { - videoFormatList << tr("mp4") << tr("webm"); + GlobalUtils::loadCameraConf(); + if (!GlobalUtils::isLowPerformanceBoard()) { + videoFormatList << tr("mp4") << tr("webm"); + } else { + videoFormatList << tr("webm") << tr("mp4"); + } + } else { videoFormatList << tr("webm"); m_settings->setOption("outsetting.outformat.vidformat", 0); } - } else { - videoFormatList << tr("webm"); + videoFormatList << "webm"; m_settings->setOption("outsetting.outformat.vidformat", 0); } m_settings->option("outsetting.outformat.vidformat")->setData("items", videoFormatList); diff --git a/src/src/Settings.h b/src/src/Settings.h index 33b8d896..584e09c7 100644 --- a/src/src/Settings.h +++ b/src/src/Settings.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/accessibility/ac-deepin-camera-define.h b/src/src/accessibility/ac-deepin-camera-define.h index add4f747..be1f1114 100644 --- a/src/src/accessibility/ac-deepin-camera-define.h +++ b/src/src/accessibility/ac-deepin-camera-define.h @@ -1,5 +1,5 @@ -// Copyright (C) 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 UOS Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/accessibility/acobjectlist.h b/src/src/accessibility/acobjectlist.h index d2ba99a1..13cebcf9 100644 --- a/src/src/accessibility/acobjectlist.h +++ b/src/src/accessibility/acobjectlist.h @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 UOS Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/accessible/accessiblefunctions.h b/src/src/accessible/accessiblefunctions.h index 9bff8b0f..545d0a2f 100644 --- a/src/src/accessible/accessiblefunctions.h +++ b/src/src/accessible/accessiblefunctions.h @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/accessible/accessiblelist.h b/src/src/accessible/accessiblelist.h index 113887f2..2907d48d 100644 --- a/src/src/accessible/accessiblelist.h +++ b/src/src/accessible/accessiblelist.h @@ -1,7 +1,8 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 UOS Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later + #ifndef DDE_FILE_MANAGER_ACCESSIBLE_LIST_H #define DDE_FILE_MANAGER_ACCESSIBLE_LIST_H diff --git a/src/src/audioprocessingthread.cpp b/src/src/audioprocessingthread.cpp index b2be9f28..64041f19 100644 --- a/src/src/audioprocessingthread.cpp +++ b/src/src/audioprocessingthread.cpp @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/audioprocessingthread.h b/src/src/audioprocessingthread.h index 68ced1d9..eb9ce5ca 100644 --- a/src/src/audioprocessingthread.h +++ b/src/src/audioprocessingthread.h @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/basepub/datamanager.cpp b/src/src/basepub/datamanager.cpp index 502dba0f..4fbbd3c6 100644 --- a/src/src/basepub/datamanager.cpp +++ b/src/src/basepub/datamanager.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/basepub/datamanager.h b/src/src/basepub/datamanager.h index 082f30b2..e2c6c16d 100644 --- a/src/src/basepub/datamanager.h +++ b/src/src/basepub/datamanager.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/basepub/load_libs.c b/src/src/basepub/load_libs.c index 8aad7c6a..34559c9b 100644 --- a/src/src/basepub/load_libs.c +++ b/src/src/basepub/load_libs.c @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -51,6 +51,8 @@ static LoadLibs *newClass(void) PrintError(); pLibs->m_avcodec_free_context = (uos_avcodec_free_context)dlsym(handle,"avcodec_free_context"); PrintError(); + pLibs->m_avcodec_get_context_defaults3 = (uos_avcodec_get_context_defaults3)dlsym(handle, "avcodec_get_context_defaults3"); + PrintError(); #else pLibs->m_avcodec_alloc_context = (uos_avcodec_alloc_context)dlsym(handle, "avcodec_alloc_context"); PrintError(); @@ -170,6 +172,12 @@ static LoadLibs *newClass(void) pLibs->m_sws_freeContext = (uos_sws_freeContext)dlsym(handle4, "sws_freeContext"); PrintError(); +//----vaapi---- + pLibs->m_sws_getContext = (uos_sws_getContext)dlsym(handle4, "sws_getContext"); //libswscale/swscale.h + PrintError(); + pLibs->m_sws_scale = (uos_sws_scale)dlsym(handle4, "sws_scale"); //libswscale/swscale.h + PrintError(); + assert(pLibs != NULL); return pLibs; } @@ -336,7 +344,26 @@ static LoadAvutil *newAvutil(void) PrintError(); Avutil->m_av_image_get_buffer_size = (uos_av_image_get_buffer_size)dlsym(handle5, "av_image_get_buffer_size"); PrintError(); - +//----vaapi---- + Avutil->m_av_hwdevice_ctx_create = (uos_av_hwdevice_ctx_create)dlsym(handle5, "av_hwdevice_ctx_create"); //libavutil/hwcontext.h + PrintError(); + Avutil->m_av_hwframe_ctx_alloc = (uos_av_hwframe_ctx_alloc)dlsym(handle5, "av_hwframe_ctx_alloc"); //libavutil/hwcontext.h + PrintError(); + Avutil->m_av_hwframe_get_buffer = (uos_av_hwframe_get_buffer)dlsym(handle5, "av_hwframe_get_buffer"); //libavutil/hwcontext.h + PrintError(); + Avutil->m_av_frame_get_buffer = (uos_av_frame_get_buffer)dlsym(handle5, "av_frame_get_buffer"); //libavutil/hwcontext.h + PrintError(); + Avutil->m_av_hwframe_ctx_init = (uos_av_hwframe_ctx_init)dlsym(handle5, "av_hwframe_ctx_init"); //libavutil/hwcontext.h + PrintError(); + Avutil->m_av_hwframe_transfer_data = (uos_av_hwframe_transfer_data)dlsym(handle5, "av_hwframe_transfer_data"); //libavutil/hwcontext.h + PrintError(); + Avutil->m_av_buffer_unref = (uos_av_buffer_unref)dlsym(handle5, "av_buffer_unref"); + PrintError(); + Avutil->m_av_buffer_ref = (uos_av_buffer_ref)dlsym(handle5, "av_buffer_ref"); + PrintError(); + Avutil->m_av_image_alloc = (uos_av_image_alloc)dlsym(handle5, "av_image_alloc"); + PrintError(); + assert(Avutil != NULL); return Avutil; } diff --git a/src/src/basepub/load_libs.h b/src/src/basepub/load_libs.h index d51b1630..e890a841 100644 --- a/src/src/basepub/load_libs.h +++ b/src/src/basepub/load_libs.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -27,6 +27,8 @@ typedef AVCodec *(*uos_avcodec_find_encoder_by_name)(const char *name); typedef AVCodecContext *(*uos_avcodec_alloc_context)(const AVCodec *codec); typedef void (*uos_avcodec_free_context)(AVCodecContext **avctx); typedef AVCodecContext *(*uos_avcodec_alloc_context3)(const AVCodec *codec); +//int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); +typedef int (*uos_avcodec_get_context_defaults3)(AVCodecContext *s, const AVCodec *codec); //int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); typedef int (*uos_avcodec_open2)(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); //void avcodec_flush_buffers(AVCodecContext *avctx); @@ -76,6 +78,25 @@ typedef void (*uos_swr_free)(struct SwrContext **s); typedef void (*uos_sws_freeContext)(struct SwsContext *swsContext); typedef int (*uos_avcodec_is_open)(AVCodecContext *s); typedef int (*uos_av_codec_is_encoder)( AVCodec *codec); + //----VAAPI------ +typedef int (*uos_av_hwdevice_ctx_create)(AVBufferRef **device_ctx, enum AVHWDeviceType type, const char *device, AVDictionary *opts, int flags); +typedef AVBufferRef *(*uos_av_hwframe_ctx_alloc)( AVBufferRef *device_ctx ); //AVBufferRef *av_hwframe_ctx_alloc(AVBufferRef *device_ctx); +typedef int (*uos_av_hwframe_get_buffer)( AVBufferRef *hwframe_ctx, AVFrame *frame, int flags ); +typedef int (*uos_av_frame_get_buffer)( AVFrame *frame, int align ); +typedef int (*uos_av_hwframe_ctx_init)( AVBufferRef *ref); +typedef int (*uos_av_hwframe_transfer_data)( AVFrame *dst, const AVFrame *src, int flags ); +typedef int (*uos_av_buffer_unref)( AVBufferRef **buf); +typedef AVBufferRef *(*uos_av_buffer_ref)( AVBufferRef *buf); //AVBufferRef *av_buffer_ref(AVBufferRef *buf); +typedef int (*uos_av_image_alloc)( uint8_t *pointers[4], int linesizes[4],int w, int h, enum AVPixelFormat pix_fmt, int align); +typedef struct SwsContext *(*uos_sws_getContext)( int srcW, int srcH, enum AVPixelFormat srcFormat,\ + int dstW, int dstH, enum AVPixelFormat dstFormat,\ + int flags, SwsFilter *srcFilter,\ + SwsFilter *dstFilter, const double *param); +typedef int (*uos_sws_scale)( struct SwsContext *c, const uint8_t *const srcSlice[],\ + const int srcStride[], int srcSliceY, int srcSliceH,\ + uint8_t *const dst[], const int dstStride[]); + //----VAAPI------ + typedef struct _LoadLibNames { char *chAvcodec; char *chFfmpegthumbnailer; @@ -98,6 +119,7 @@ typedef struct _LoadLibs { uos_avcodec_alloc_context m_avcodec_alloc_context; uos_avcodec_free_context m_avcodec_free_context; uos_avcodec_alloc_context3 m_avcodec_alloc_context3; + uos_avcodec_get_context_defaults3 m_avcodec_get_context_defaults3; uos_avcodec_open2 m_avcodec_open2; uos_avcodec_flush_buffers m_avcodec_flush_buffers; uos_avcodec_close m_avcodec_close; @@ -117,6 +139,11 @@ typedef struct _LoadLibs { uos_av_codec_is_encoder m_av_codec_is_encoder; uos_avcodec_is_open m_avcodec_is_open; + + uos_sws_getContext m_sws_getContext; + uos_sws_scale m_sws_scale; + //----VAAPI------ + uos_video_thumbnailer m_video_thumbnailer; uos_video_thumbnailer_destroy m_video_thumbnailer_destroy; uos_video_thumbnailer_create_image_data m_video_thumbnailer_create_image_data; @@ -228,6 +255,16 @@ typedef struct _LoadAvutil { uos_av_samples_get_buffer_size m_av_samples_get_buffer_size; uos_av_get_media_type_string m_av_get_media_type_string;// uos_av_image_get_buffer_size m_av_image_get_buffer_size; + //----VAAPI------ + uos_av_hwdevice_ctx_create m_av_hwdevice_ctx_create; + uos_av_hwframe_ctx_alloc m_av_hwframe_ctx_alloc; + uos_av_hwframe_get_buffer m_av_hwframe_get_buffer; + uos_av_frame_get_buffer m_av_frame_get_buffer; + uos_av_hwframe_ctx_init m_av_hwframe_ctx_init; + uos_av_hwframe_transfer_data m_av_hwframe_transfer_data; + uos_av_buffer_unref m_av_buffer_unref; + uos_av_buffer_ref m_av_buffer_ref; + uos_av_image_alloc m_av_image_alloc; } LoadAvutil; LoadAvutil *getAvutil(); diff --git a/src/src/camera.cpp b/src/src/camera.cpp index c86f88f4..5883e717 100755 --- a/src/src/camera.cpp +++ b/src/src/camera.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/camera.h b/src/src/camera.h index 14ba6be7..145d2cb8 100644 --- a/src/src/camera.h +++ b/src/src/camera.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/capplication.cpp b/src/src/capplication.cpp index 85f0c369..67177bd3 100644 --- a/src/src/capplication.cpp +++ b/src/src/capplication.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/capplication.h b/src/src/capplication.h index de9e48a1..f6115a33 100644 --- a/src/src/capplication.h +++ b/src/src/capplication.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/circlepushbutton.cpp b/src/src/circlepushbutton.cpp index fafb9411..cf147489 100644 --- a/src/src/circlepushbutton.cpp +++ b/src/src/circlepushbutton.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/circlepushbutton.h b/src/src/circlepushbutton.h index 695a3d61..08acfb23 100644 --- a/src/src/circlepushbutton.h +++ b/src/src/circlepushbutton.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/closedialog.cpp b/src/src/closedialog.cpp index 43e84d61..f2e5a88f 100644 --- a/src/src/closedialog.cpp +++ b/src/src/closedialog.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/closedialog.h b/src/src/closedialog.h index f621ba29..a7125191 100644 --- a/src/src/closedialog.h +++ b/src/src/closedialog.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/devnummonitor.cpp b/src/src/devnummonitor.cpp index 42e7aeac..a6757894 100644 --- a/src/src/devnummonitor.cpp +++ b/src/src/devnummonitor.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/devnummonitor.h b/src/src/devnummonitor.h index 4ec269d8..1176ffbc 100644 --- a/src/src/devnummonitor.h +++ b/src/src/devnummonitor.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/eventlogutils.cpp b/src/src/eventlogutils.cpp index fd0b408a..cccf2ecf 100644 --- a/src/src/eventlogutils.cpp +++ b/src/src/eventlogutils.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/eventlogutils.h b/src/src/eventlogutils.h index 1d31d8d1..f2d2e7d6 100644 --- a/src/src/eventlogutils.h +++ b/src/src/eventlogutils.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/exposureslider.cpp b/src/src/exposureslider.cpp index 27432c26..dc443962 100644 --- a/src/src/exposureslider.cpp +++ b/src/src/exposureslider.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/exposureslider.h b/src/src/exposureslider.h index df2784bb..5c26b43a 100644 --- a/src/src/exposureslider.h +++ b/src/src/exposureslider.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/filterpreviewbutton.cpp b/src/src/filterpreviewbutton.cpp index 58082b4d..8dae1b30 100644 --- a/src/src/filterpreviewbutton.cpp +++ b/src/src/filterpreviewbutton.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/filterpreviewbutton.h b/src/src/filterpreviewbutton.h index c559c29d..8b4cfbe7 100644 --- a/src/src/filterpreviewbutton.h +++ b/src/src/filterpreviewbutton.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/globalutils.cpp b/src/src/globalutils.cpp new file mode 100644 index 00000000..24aa7390 --- /dev/null +++ b/src/src/globalutils.cpp @@ -0,0 +1,89 @@ +// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "globalutils.h" + +#include +#include +#include +#include +#include + +// 相机配置文件 +const QString CAMERA_CONF_PATH = "/usr/share/deepin-camera/camera.conf"; +#define LOW_PERFORMANCE_BOARD "LowPerformanceBoard" + +QStringList GlobalUtils::m_LowPerformanceBoards = QStringList(); + +struct DMIInfo { + QString biosManufacturer; + QString biosVersion; + QString biosRelease; + QString productName; + QString serialNumber; + QString Manufacturer; + QString version; + QString sysProductName; + QString Family; + QString sysSerialNumber; + QString sysUUID; +}; +Q_DECLARE_METATYPE(DMIInfo) + +// Marshall the MyStructure data into a D-Bus argument +QDBusArgument &operator<<(QDBusArgument &argument, const DMIInfo &mystruct) +{ + argument.beginStructure(); + argument << mystruct.biosManufacturer << mystruct.biosVersion << mystruct.biosRelease << mystruct.productName + << mystruct.serialNumber << mystruct.Manufacturer << mystruct.version << mystruct.sysProductName + << mystruct.Family << mystruct.sysSerialNumber << mystruct.sysUUID; + argument.endStructure(); + return argument; +} + +// Retrieve the MyStructure data from the D-Bus argument +const QDBusArgument &operator>>(const QDBusArgument &argument, DMIInfo &mystruct) +{ + argument.beginStructure(); + argument >> mystruct.biosManufacturer >> mystruct.biosVersion >> mystruct.biosRelease >> mystruct.productName + >> mystruct.serialNumber >> mystruct.Manufacturer >> mystruct.version >> mystruct.sysProductName + >> mystruct.Family >> mystruct.sysSerialNumber >> mystruct.sysUUID; + argument.endStructure(); + return argument; +} + +bool GlobalUtils::isLowPerformanceBoard() +{ + qDBusRegisterMetaType(); + QDBusInterface *monitorInterface = new QDBusInterface("com.deepin.system.SystemInfo", "/com/deepin/system/SystemInfo", "org.freedesktop.DBus.Properties", QDBusConnection::systemBus()); + if (!monitorInterface->isValid()) + return false; + + DMIInfo dmiInfo; + QDBusReply replay = monitorInterface->call("Get", "com.deepin.system.SystemInfo", "DMIInfo"); + + replay.value().variant().value() >> dmiInfo; + + qDebug() << __func__ << "dmiInfo.productName: " << dmiInfo.productName; + + // BXC 600F/NZ2750、CC GWMNDA1GL1等主板不能满足mp4封装的性能要求,因此需要特殊适配 + for (auto board : m_LowPerformanceBoards) { + if (dmiInfo.productName.contains(board)) + return true; + } + + return false; +} + +void GlobalUtils::loadCameraConf() +{ + QSettings conf(CAMERA_CONF_PATH, QSettings::IniFormat); + QVariant value = conf.value(LOW_PERFORMANCE_BOARD); + if (value.isValid()) { + m_LowPerformanceBoards = value.toStringList(); + } else { + m_LowPerformanceBoards = QStringList(); + } +} diff --git a/src/src/globalutils.h b/src/src/globalutils.h new file mode 100644 index 00000000..51e021d4 --- /dev/null +++ b/src/src/globalutils.h @@ -0,0 +1,24 @@ +// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef GLOBALUTILS_H +#define GLOBALUTILS_H + +#include + +class GlobalUtils +{ +public: + // 判断是否为低性能主板 + static bool isLowPerformanceBoard(); + + // 加载相机配置 + static void loadCameraConf(); + +private: + static QStringList m_LowPerformanceBoards; +}; + +#endif // GLOBALUTILS_H diff --git a/src/src/gridline.cpp b/src/src/gridline.cpp index 9d13ecb5..8ada2257 100644 --- a/src/src/gridline.cpp +++ b/src/src/gridline.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/gridline.h b/src/src/gridline.h index fde1993b..def3dcb4 100644 --- a/src/src/gridline.h +++ b/src/src/gridline.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/gstvideowriter.cpp b/src/src/gstvideowriter.cpp index f8e47bfb..c96c8b01 100644 --- a/src/src/gstvideowriter.cpp +++ b/src/src/gstvideowriter.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/gstvideowriter.h b/src/src/gstvideowriter.h index a23622bf..89a03de3 100644 --- a/src/src/gstvideowriter.h +++ b/src/src/gstvideowriter.h @@ -1,5 +1,5 @@ // Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/imageitem.cpp b/src/src/imageitem.cpp index e0b95a1e..a47da7f6 100644 --- a/src/src/imageitem.cpp +++ b/src/src/imageitem.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -215,11 +215,15 @@ void ImageItem::paintEvent(QPaintEvent *event) painter.drawPath(inside); } +static bool mouseDblClick = false; void ImageItem::mousePressEvent(QMouseEvent *event) { - if (event->type() == QEvent::MouseButtonDblClick) + if (event->type() == QEvent::MouseButtonDblClick) { + mouseDblClick = true; return; //不响应双击事件 + } + mouseDblClick = false; DLabel::mousePressEvent(event); } @@ -232,8 +236,9 @@ void ImageItem::mouseMoveEvent(QMouseEvent *event) void ImageItem::mouseReleaseEvent(QMouseEvent *event) { - if (event->type() == QEvent::MouseButtonDblClick) + if (event->type() == QEvent::MouseButtonDblClick || mouseDblClick) { return; //不响应双击事件 + } if (!rect().contains(event->pos())) return; @@ -281,7 +286,8 @@ void ImageItem::onOpenFolder() //这里不能直接使用strFolder调replace函数 m_path.replace(0, 1, QDir::homePath()); } - Dtk::Widget::DDesktopServices::showFolder(m_path); + QString path = QFileInfo(m_path).absolutePath(); + Dtk::Widget::DDesktopServices::showFolder(path); qDebug() << "Click the right mouse or press the shortcut to open the folder"; } @@ -311,33 +317,71 @@ void ImageItem::initShortcut() void ImageItem::openFile() { QFileInfo fileInfo(m_path); - QString program; + QString program("dde-file-manager"); //dbus调用失败,通过文管打开 QStringList arguments; if (m_path.isEmpty()) { return; } + + bool ret = false; + QProcess *myProcess = new QProcess(this); + +#ifdef OS_BUILD_V23 + //玲珑环境下无法通过QProcess方式打开应用,通过DBus打开 if (fileInfo.suffix() == "jpg") { - program = "deepin-image-viewer"; //用看图打开 - arguments << m_path; - qDebug() << "Open it with deepin-image-viewer"; + //用看图打开 + QDBusMessage message = QDBusMessage::createMethodCall("com.deepin.imageViewer", + "/", + "com.deepin.imageViewer", + "openImageFile"); + message << m_path; + QDBusMessage retMessage = QDBusConnection::sessionBus().call(message); + + if (retMessage.type() != QDBusMessage::ErrorMessage) { + ret = true; + qDebug() << "[dbus] Open it with deepin-image-viewer"; + } else { + qWarning() << retMessage.errorMessage(); + } } else { - program = "deepin-movie"; //用影院打开 - arguments << m_path; - qDebug() << "Open it with deepin-movie"; + //用影院打开 + QDBusMessage message = QDBusMessage::createMethodCall("com.deepin.movie", + "/", + "com.deepin.movie", + "openFile"); + message << m_path; + QDBusMessage retMessage = QDBusConnection::sessionBus().call(message); + + if (retMessage.type() != QDBusMessage::ErrorMessage) { + ret = true; + qDebug() << "[dbus] Open it with deepin-movie"; + } else { + qWarning() << retMessage.errorMessage(); + } } - +#else + if (fileInfo.suffix() == "jpg") { + program = "deepin-image-viewer"; //用看图打开 + arguments << m_path; + qDebug() << "[process] Open it with deepin-image-viewer"; + } else { + program = "deepin-movie"; //用影院打开 + arguments << m_path; + qDebug() << "[process] Open it with deepin-movie"; + } + ret = myProcess->startDetached(program, arguments); +#endif qInfo() << m_path; - QProcess *myProcess = new QProcess(this); - bool bOK = myProcess->startDetached(program, arguments); + if (CamApp->isPanelEnvironment()) CamApp->getMainWindow()->showMinimized(); - if (!bOK) { //打开失败,调用文管选择“打开方式”窗口 + if (!ret) { //打开失败,调用文管选择“打开方式”窗口 qWarning() << "QProcess startDetached error"; arguments.clear(); program = "dde-file-manager"; arguments << "-o" << m_path; - bOK = myProcess->startDetached(program, arguments); + ret = myProcess->startDetached(program, arguments); } } diff --git a/src/src/imageitem.h b/src/src/imageitem.h index b49e996a..ba892c99 100644 --- a/src/src/imageitem.h +++ b/src/src/imageitem.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/mainwindow.cpp b/src/src/mainwindow.cpp index c5e329d7..57cba718 100644 --- a/src/src/mainwindow.cpp +++ b/src/src/mainwindow.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -17,6 +17,7 @@ #include "camera.h" #include "eventlogutils.h" #include "config.h" +#include "globalutils.h" #include #include @@ -1889,9 +1890,15 @@ void CMainWindow::initConnection() //控制中心更改了本地时间,及时更新当前时间 //避免时间往前切换过后,需要点击两次才能结束录制 +#ifdef OS_BUILD_V23 + QDBusConnection::sessionBus().connect("org.deepin.daemon.Timedate1", "/org/deepin/daemon/Timedate1", + "org.deepin.daemon.Timedate1", "TimeUpdate", this, + SLOT(onLocalTimeChanged())); +#else QDBusConnection::sessionBus().connect("com.deepin.daemon.Timedate", "/com/deepin/daemon/Timedate", "com.deepin.daemon.Timedate", "TimeUpdate", this, SLOT(onLocalTimeChanged())); +#endif QDBusConnection::systemBus().connect("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForSleep", this, SLOT(stopCancelContinuousRecording(bool))); diff --git a/src/src/mainwindow.h b/src/src/mainwindow.h index 55679add..d76d46a3 100644 --- a/src/src/mainwindow.h +++ b/src/src/mainwindow.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/majorimageprocessingthread.cpp b/src/src/majorimageprocessingthread.cpp index dfff61fa..1aef0dc3 100644 --- a/src/src/majorimageprocessingthread.cpp +++ b/src/src/majorimageprocessingthread.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -14,6 +14,8 @@ extern "C" { #include #include #include +#include +DCORE_USE_NAMESPACE MajorImageProcessingThread::MajorImageProcessingThread():m_bHorizontalMirror(false) { @@ -250,6 +252,9 @@ void MajorImageProcessingThread::run() #if defined(_loongarch) || defined(__loongarch__) || defined(__loongarch64) || defined (__mips__) bUseRgb = true; #endif + if(DSysInfo::majorVersion() == "23") { + bUseRgb = true; + } if (get_wayland_status()) bUseRgb = true; @@ -377,7 +382,7 @@ void MajorImageProcessingThread::run() } QImage* imgTmp = nullptr; - if (m_rgbPtr && bUseRgb) + if (m_rgbPtr) imgTmp = new QImage(m_rgbPtr, m_frame->width, m_frame->height, QImage::Format_RGB888); /*拍照*/ diff --git a/src/src/majorimageprocessingthread.h b/src/src/majorimageprocessingthread.h index efde634d..109df561 100644 --- a/src/src/majorimageprocessingthread.h +++ b/src/src/majorimageprocessingthread.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/photorecordbtn.cpp b/src/src/photorecordbtn.cpp index 0ad43ef0..6fc05968 100644 --- a/src/src/photorecordbtn.cpp +++ b/src/src/photorecordbtn.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/photorecordbtn.h b/src/src/photorecordbtn.h index 15e73fae..26a18f49 100644 --- a/src/src/photorecordbtn.h +++ b/src/src/photorecordbtn.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/previewopenglwidget.cpp b/src/src/previewopenglwidget.cpp index 5babc01f..40b5c239 100644 --- a/src/src/previewopenglwidget.cpp +++ b/src/src/previewopenglwidget.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/previewopenglwidget.h b/src/src/previewopenglwidget.h index 2b23490a..1fb0789b 100644 --- a/src/src/previewopenglwidget.h +++ b/src/src/previewopenglwidget.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/qtsingleapplication/qtsingleapplication.cpp b/src/src/qtsingleapplication/qtsingleapplication.cpp index a6bb4ae2..1a5eca95 100644 --- a/src/src/qtsingleapplication/qtsingleapplication.cpp +++ b/src/src/qtsingleapplication/qtsingleapplication.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/qtsingleapplication/qtsingleapplication.h b/src/src/qtsingleapplication/qtsingleapplication.h index 2a3d3859..3026abe3 100644 --- a/src/src/qtsingleapplication/qtsingleapplication.h +++ b/src/src/qtsingleapplication/qtsingleapplication.h @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/rollingbox.cpp b/src/src/rollingbox.cpp index 55b4a540..62107ec3 100644 --- a/src/src/rollingbox.cpp +++ b/src/src/rollingbox.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/rollingbox.h b/src/src/rollingbox.h index d96268a8..3e381e95 100644 --- a/src/src/rollingbox.h +++ b/src/src/rollingbox.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/settings_translation.cpp b/src/src/settings_translation.cpp index 3f516322..b9966687 100644 --- a/src/src/settings_translation.cpp +++ b/src/src/settings_translation.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -29,5 +29,5 @@ void GenerateSettingTranslate() auto outsetting_10pcs = QObject::tr("10 pcs"); auto outsetting_none = QObject::tr("None"); auto outsetting_resolutionsettingName = QObject::tr("Resolution settings"); - auto outsetting_resolutionsetting_resolutionName = QObject::tr("Resolution:"); + auto outsetting_resolutionsetting_resolutionName = QObject::tr("Maximum resolution:"); } diff --git a/src/src/shortcut.cpp b/src/src/shortcut.cpp index 1e761e0d..162754a6 100755 --- a/src/src/shortcut.cpp +++ b/src/src/shortcut.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 ~ 2018 Deepin Technology Co., Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/shortcut.h b/src/src/shortcut.h index a689f5ca..ec250985 100755 --- a/src/src/shortcut.h +++ b/src/src/shortcut.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 ~ 2018 Deepin Technology Co., Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/switchcamerabtn.cpp b/src/src/switchcamerabtn.cpp index 3de74811..e9da48c8 100644 --- a/src/src/switchcamerabtn.cpp +++ b/src/src/switchcamerabtn.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -55,18 +55,15 @@ void SwitchCameraBtn::paintEvent(QPaintEvent *event) painter.setPen(Qt::NoPen); painter.setBrush(QBrush(QColor(0,0,0,100))); painter.drawEllipse(rect3); - } - else{ + } else { painter.setPen(Qt::NoPen); painter.setBrush(QBrush(QColor(0,0,0,100))); painter.drawEllipse(rect); } - if (m_bPressed) - { + if (m_bPressed) { m_pressedSvg->render(&painter); - } - else { + } else { m_normalSvg->render(&painter); } } diff --git a/src/src/switchcamerabtn.h b/src/src/switchcamerabtn.h index d69d8ea3..5af9e1d4 100644 --- a/src/src/switchcamerabtn.h +++ b/src/src/switchcamerabtn.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/takephotosettingareawidget.cpp b/src/src/takephotosettingareawidget.cpp index 3ebdcc6f..3297e8b5 100644 --- a/src/src/takephotosettingareawidget.cpp +++ b/src/src/takephotosettingareawidget.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/takephotosettingareawidget.h b/src/src/takephotosettingareawidget.h index 97cf47d3..cc72ae76 100644 --- a/src/src/takephotosettingareawidget.h +++ b/src/src/takephotosettingareawidget.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/titlebar.cpp b/src/src/titlebar.cpp index 8790c6ee..36404c13 100644 --- a/src/src/titlebar.cpp +++ b/src/src/titlebar.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -28,7 +28,6 @@ Titlebar::Titlebar(QWidget *parent) : DBlurEffectWidget(parent), d_ptr(new Title Q_D(Titlebar); setAttribute(Qt::WA_TranslucentBackground, true); - //setFocusPolicy(Qt::NoFocus); QHBoxLayout *layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); @@ -40,12 +39,6 @@ Titlebar::Titlebar(QWidget *parent) : DBlurEffectWidget(parent), d_ptr(new Title d->m_titlebar->setBlurBackground(false); layout->addWidget(d->m_titlebar); -// d->m_shadowEffect = new QGraphicsDropShadowEffect(this); -// d->m_shadowEffect->setOffset(d->offsetX, d->offsetY); -// d->m_shadowEffect->setBlurRadius(d->offsetY); -// d->m_shadowEffect->setColor(d->darkEffectColor); -// this->setGraphicsEffect(d->m_shadowEffect); - connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &Titlebar::slotThemeTypeChanged); } diff --git a/src/src/titlebar.h b/src/src/titlebar.h index 9102e477..9144a680 100644 --- a/src/src/titlebar.h +++ b/src/src/titlebar.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/videosurface.cpp b/src/src/videosurface.cpp index 0b432b0d..0ed9c762 100644 --- a/src/src/videosurface.cpp +++ b/src/src/videosurface.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/videosurface.h b/src/src/videosurface.h index 7fc84231..dc5f6b0b 100644 --- a/src/src/videosurface.h +++ b/src/src/videosurface.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/src/videowidget.cpp b/src/src/videowidget.cpp old mode 100755 new mode 100644 index 37ff56af..490c34f9 --- a/src/src/videowidget.cpp +++ b/src/src/videowidget.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -12,8 +12,10 @@ #include "camera.h" #include "eventlogutils.h" #include "config.h" +#include "globalutils.h" #include +#include #include #include @@ -214,9 +216,15 @@ videowidget::videowidget(DWidget *parent) // 默认不显示网格线 setGridType(Grid_None); - if (dc::Settings::get().getOption("outsetting.outformat.vidformat").toInt() || - DataManager::instance()->encodeEnv() != FFmpeg_Env || !DataManager::instance()->encExists()) + if (DataManager::instance()->encodeEnv() != FFmpeg_Env || !DataManager::instance()->encExists() || GlobalUtils::isLowPerformanceBoard()) { m_videoFormat = "webm"; + } + if (dc::Settings::get().getOption("outsetting.outformat.vidformat").toInt()) { + if (!GlobalUtils::isLowPerformanceBoard()) + m_videoFormat = "webm"; + else + m_videoFormat = "mp4"; + } } //延迟加载 @@ -433,6 +441,13 @@ void videowidget::ReceiveOpenGLstatus(bool result) void videowidget::ReceiveMajorImage(QImage *image, int result) { + // 若窗口高度改变,需要刷新整个窗口,防止上一帧图像出现在其它区域 + static int height = this->height(); + if (height != this->height()) { + update(); + height = this->height(); + } + if (!image->isNull()) { switch (result) { case 0: //Success @@ -452,9 +467,8 @@ void videowidget::ReceiveMajorImage(QImage *image, int result) if (m_openglwidget && m_openglwidget->isVisible()) m_openglwidget->hide(); { - // OpenGL窗口等比例缩放画面 - int widgetwidth = width(); - int widgetheight = height(); + int widgetwidth = this->width(); + int widgetheight = this->height(); if ((image->width() * 100 / image->height()) > (widgetwidth * 100 / widgetheight)) { QImage img = image->scaled(widgetwidth, widgetwidth * image->height() / image->width(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); m_framePixmap = QPixmap::fromImage(img); @@ -671,7 +685,7 @@ void videowidget::showCountdown() m_savePicFolder = strDefaultPath; } - QString strFileName = "UOS_" + QDateTime::currentDateTime().toString("yyyyMMddHHmmss") + "_" + QString::number(m_nFileID) + ".jpg"; + QString strFileName = getSaveFilePrefix() + QDateTime::currentDateTime().toString("yyyyMMddHHmmss") + "_" + QString::number(m_nFileID) + ".jpg"; emit filename(strFileName); m_imgPrcThread->m_strPath = m_savePicFolder + QDir::separator() + strFileName; m_imgPrcThread->m_bTake = true; //保存图片标志 @@ -1103,6 +1117,17 @@ int videowidget::switchCamera(const char *device, const char *devName) return ret; } +QString videowidget::getSaveFilePrefix() +{ + QString filePrefix = "Camera_"; + if (DSysInfo::deepinType() == DSysInfo::DeepinProfessional) { + filePrefix = "UOS_"; + } else if (DSysInfo::deepinType() == DSysInfo::DeepinDesktop) { + filePrefix = "DEEPIN_"; + } + return filePrefix; +} + void videowidget::onTakePic(bool bTrue) { g_Enum_Camera_State = PICTRUE; @@ -1260,7 +1285,7 @@ void videowidget::startTakeVideo() } else { if (DataManager::instance()->getdevStatus() == CAM_CANUSE) { qDebug() << "start takeVideo"; - DataManager::instance()->getstrFileName() = "UOS_" + QDateTime::currentDateTime().toString("yyyyMMddHHmmss") + "_" + DataManager::instance()->getstrFileName() = getSaveFilePrefix() + QDateTime::currentDateTime().toString("yyyyMMddHHmmss") + "_" + QString::number(m_nFileID) + "." + m_videoFormat; emit filename(DataManager::instance()->getstrFileName()); m_nFileID ++; @@ -1326,7 +1351,7 @@ void videowidget::startCaptureVideo() } else { if (DataManager::instance()->getdevStatus() == CAM_CANUSE) { qDebug() << "start Gstreamer takeVideo"; - DataManager::instance()->getstrFileName() = "UOS_" + QDateTime::currentDateTime().toString("yyyyMMddHHmmss") + "_" + QString::number(m_nFileID); + DataManager::instance()->getstrFileName() = getSaveFilePrefix() + QDateTime::currentDateTime().toString("yyyyMMddHHmmss") + "_" + QString::number(m_nFileID); emit filename(DataManager::instance()->getstrFileName()); m_nFileID ++; diff --git a/src/src/videowidget.h b/src/src/videowidget.h index 72458e4a..d769086c 100644 --- a/src/src/videowidget.h +++ b/src/src/videowidget.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -414,6 +414,11 @@ private slots: */ int switchCamera(const char *device, const char *devName); + /** + * @brief getSaveFilePrefix + * @return UOS_ 专业版 DEEPIN_ 社区版 CAMERA_ 其他 + */ + QString getSaveFilePrefix(); public: MajorImageProcessingThread *m_imgPrcThread; AudioProcessingThread *m_audPrcThread; diff --git a/src/src/windowstatethread.cpp b/src/src/windowstatethread.cpp index 6afb9f25..83d12670 100644 --- a/src/src/windowstatethread.cpp +++ b/src/src/windowstatethread.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -13,7 +13,7 @@ windowStateThread::windowStateThread(bool isWayland, QObject *parent /*= nullptr : QThread (parent) { setObjectName("windowStateThread"); -#ifdef KF5_WAYLAND_FLAGE_ON +#ifdef USE_DEEPIN_WAYLAND if (isWayland) { qInfo() << __FUNCTION__ << __LINE__ << "KF5_WAYLAND_FLAGE_ON is open!!"; //wayland自动识别窗口 @@ -38,10 +38,11 @@ windowStateThread::windowStateThread(bool isWayland, QObject *parent /*= nullptr windowStateThread::~windowStateThread() { -#ifdef KF5_WAYLAND_FLAGE_ON - m_connectionThread->quit(); - m_connectionThread->wait(); - m_connectionThreadObject->deleteLater(); +#ifdef USE_DEEPIN_WAYLAND + if (m_connectionThread != nullptr) { + m_connectionThread->terminate(); + m_connectionThread->wait(); + } #endif } @@ -100,7 +101,7 @@ QList windowStateThread::workspaceWindows() const return windowList; } -#ifdef KF5_WAYLAND_FLAGE_ON +#ifdef USE_DEEPIN_WAYLAND void windowStateThread::setupRegistry(Registry *registry) { connect(registry, &Registry::compositorAnnounced, this, diff --git a/src/src/windowstatethread.h b/src/src/windowstatethread.h index 33fe624c..bef73992 100644 --- a/src/src/windowstatethread.h +++ b/src/src/windowstatethread.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -13,14 +13,24 @@ #include #include -#ifdef KF5_WAYLAND_FLAGE_ON +#ifdef USE_DEEPIN_WAYLAND +#ifdef DWAYLAND +#include +#include +#include +#include +#else #include #include #include #include -using namespace KWayland::Client; #endif +using namespace KWayland::Client; +#endif // USE_DEEPIN_WAYLAND + +DGUI_USE_NAMESPACE + class windowStateThread : public QThread { Q_OBJECT @@ -35,7 +45,7 @@ class windowStateThread : public QThread void someWindowFullScreen(); private: -#ifdef KF5_WAYLAND_FLAGE_ON +#ifdef USE_DEEPIN_WAYLAND /** * @brief wayland获取屏幕窗口信息的安装注册函数 * @param registry @@ -50,9 +60,9 @@ class windowStateThread : public QThread #endif private: -#ifdef KF5_WAYLAND_FLAGE_ON +#ifdef USE_DEEPIN_WAYLAND // 获取wayland窗口信息相关。 wayland获取窗口的方法对于x11有很大的区别 - QThread *m_connectionThread; + QThread *m_connectionThread = nullptr; EventQueue *m_eventQueue = nullptr; ConnectionThread *m_connectionThreadObject; Compositor *m_compositor = nullptr; diff --git a/src/translations/deepin-camera_ar.ts b/src/translations/deepin-camera_ar.ts index 4dde3609..0adede3e 100644 --- a/src/translations/deepin-camera_ar.ts +++ b/src/translations/deepin-camera_ar.ts @@ -154,7 +154,7 @@ Resolution: - الدِّقَّة: + الدِّقَّة: Photos: @@ -188,6 +188,10 @@ 2*2 lines + + Maximum resolution: + + Shortcut @@ -257,14 +261,6 @@ None لا أحد - - mp4 - - - - webm - - filterPreviewButton diff --git a/src/translations/deepin-camera_az.ts b/src/translations/deepin-camera_az.ts index 6b4ba6df..f9c14115 100644 --- a/src/translations/deepin-camera_az.ts +++ b/src/translations/deepin-camera_az.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Təsvir imkanları: + Təsvir imkanları: Photos: @@ -176,15 +178,19 @@ Gridlines - Tor xətləri + 1*1 lines - 1*1 xətlər + 2*2 lines - 2*2 xətlər + + + + Maximum resolution: + @@ -337,4 +343,4 @@ Çəkimi saxlamaq - \ No newline at end of file + diff --git a/src/translations/deepin-camera_bo.ts b/src/translations/deepin-camera_bo.ts index 947e58e8..29f79ae8 100644 --- a/src/translations/deepin-camera_bo.ts +++ b/src/translations/deepin-camera_bo.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - འབྱེད་ཕྱོད། + འབྱེད་ཕྱོད། Photos: @@ -176,15 +178,19 @@ Gridlines - རི་མོའི་མཚོན་ཆ་བཀོད་སྒྲིག་དྲ་བ། + 1*1 lines - + 2*2 lines - + + + + Maximum resolution: + @@ -337,4 +343,4 @@ ཕབ་ལེན་བྱེད་མཚམས་འཇོག་པ། - \ No newline at end of file + diff --git a/src/translations/deepin-camera_ca.ts b/src/translations/deepin-camera_ca.ts index 6b6a53d0..52a4efd3 100644 --- a/src/translations/deepin-camera_ca.ts +++ b/src/translations/deepin-camera_ca.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Resolució: + Resolució: Photos: @@ -176,15 +178,19 @@ Gridlines - Línies de la graella + 1*1 lines - 1*1 + 2*2 lines - 2*2 + + + + Maximum resolution: + @@ -337,4 +343,4 @@ Interromp la gravació - \ No newline at end of file + diff --git a/src/translations/deepin-camera_cs.ts b/src/translations/deepin-camera_cs.ts index 3ff3fba5..85d4c148 100644 --- a/src/translations/deepin-camera_cs.ts +++ b/src/translations/deepin-camera_cs.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Rozlišení: + Rozlišení: Photos: @@ -176,15 +178,19 @@ Gridlines - Čáry mřížky + 1*1 lines - 1 ⨉ 1 čára + 2*2 lines - 2 ⨉ 2 čáry + + + + Maximum resolution: + @@ -260,35 +266,35 @@ filterPreviewButton Normal - Normální + Vivid - Živé + Warm - Teplé + Cold - Studené + Retro - Retro + Film - Film + Gray - Šedé + B&W - ČB + @@ -315,11 +321,11 @@ Filters - Filtry + Exposure - Expozice + @@ -337,4 +343,4 @@ Zastavit zaznamenávání - \ No newline at end of file + diff --git a/src/translations/deepin-camera_de.ts b/src/translations/deepin-camera_de.ts index dba37078..c5a19748 100644 --- a/src/translations/deepin-camera_de.ts +++ b/src/translations/deepin-camera_de.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Auflösung: + Auflösung: Photos: @@ -176,15 +178,19 @@ Gridlines - Gitternetzlinien + 1*1 lines - 1*1 Linien + 2*2 lines - 2*2 Linien + + + + Maximum resolution: + @@ -337,4 +343,4 @@ Aufnahme stoppen - \ No newline at end of file + diff --git a/src/translations/deepin-camera_el.ts b/src/translations/deepin-camera_el.ts index 09bb1f16..76746b52 100644 --- a/src/translations/deepin-camera_el.ts +++ b/src/translations/deepin-camera_el.ts @@ -154,7 +154,7 @@ Resolution: - Ανάλυση: + Ανάλυση: Photos: @@ -188,6 +188,10 @@ 2*2 lines + + Maximum resolution: + + Shortcut @@ -257,14 +261,6 @@ None Κανένα - - mp4 - - - - webm - - filterPreviewButton diff --git a/src/translations/deepin-camera_en_US.ts b/src/translations/deepin-camera_en_US.ts index 1bf1a6e1..d057cc65 100644 --- a/src/translations/deepin-camera_en_US.ts +++ b/src/translations/deepin-camera_en_US.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Resolution: + Resolution: Photos: @@ -186,6 +188,10 @@ 2*2 lines 2*2 lines + + Maximum resolution: + Maximum resolution: + Shortcut @@ -337,4 +343,4 @@ Stop recording - \ No newline at end of file + diff --git a/src/translations/deepin-camera_es.ts b/src/translations/deepin-camera_es.ts index c1a3086d..8d526e2c 100644 --- a/src/translations/deepin-camera_es.ts +++ b/src/translations/deepin-camera_es.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Resolución: + Resolución: Photos: @@ -172,19 +174,23 @@ Flashlight - Flash + Linterna Gridlines - Líneas de cuadrícula + 1*1 lines - líneas 1*1 + 2*2 lines - líneas 2*2 + + + + Maximum resolution: + @@ -337,4 +343,4 @@ Detener grabación - \ No newline at end of file + diff --git a/src/translations/deepin-camera_fi.ts b/src/translations/deepin-camera_fi.ts index bd79ff22..3bcf1a23 100644 --- a/src/translations/deepin-camera_fi.ts +++ b/src/translations/deepin-camera_fi.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Tarkkuus: + Tarkkuus: Photos: @@ -176,15 +178,19 @@ Gridlines - Ruudukkoviivat + 1*1 lines - 1*1 viivaa + 2*2 lines - 2*2 viivaa + + + + Maximum resolution: + @@ -337,4 +343,4 @@ Lopeta tallennus - \ No newline at end of file + diff --git a/src/translations/deepin-camera_fr.ts b/src/translations/deepin-camera_fr.ts index 6566e0bc..acf79b83 100644 --- a/src/translations/deepin-camera_fr.ts +++ b/src/translations/deepin-camera_fr.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -19,15 +21,15 @@ Photo - Photo + Video - Vidéo + Switch Cameras - Changer de caméra + @@ -152,7 +154,7 @@ Resolution: - Résolution : + Résolution : Photos: @@ -168,23 +170,27 @@ Mirror mode - Mode miroir + Flashlight - Lampe de poche + Gridlines - Lignes de grille + 1*1 lines - 1*1 lignes + 2*2 lines - 2*2 lignes + + + + Maximum resolution: + @@ -260,54 +266,54 @@ filterPreviewButton Normal - Normal + Vivid - Vif + Warm - Chaud + Cold - Froid + Retro - Rétro + Film - Film + Gray - Gris + B&W - N&B + takePhotoSettingAreaWidget Flashlight - Lampe de poche + On - On + Off - Off + Delay capture - Retarder la capture + None @@ -315,11 +321,11 @@ Filters - Filtres + Exposure - Exposition + @@ -337,4 +343,4 @@ Arrêter l'enregistrement - \ No newline at end of file + diff --git a/src/translations/deepin-camera_hi_IN.ts b/src/translations/deepin-camera_hi_IN.ts index c1d711af..5d8c77ac 100644 --- a/src/translations/deepin-camera_hi_IN.ts +++ b/src/translations/deepin-camera_hi_IN.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - रेजोलुशन : + रेजोलुशन : Photos: @@ -176,15 +178,19 @@ Gridlines - + 1*1 lines - + 2*2 lines - + + + + Maximum resolution: + @@ -260,35 +266,35 @@ filterPreviewButton Normal - + Vivid - + Warm - + Cold - + Retro - + Film - + Gray - + B&W - + @@ -315,11 +321,11 @@ Filters - + Exposure - + @@ -337,4 +343,4 @@ रिकॉर्डिंग बंद करें - \ No newline at end of file + diff --git a/src/translations/deepin-camera_hr.ts b/src/translations/deepin-camera_hr.ts index 6c25d6d2..d072c4a7 100644 --- a/src/translations/deepin-camera_hr.ts +++ b/src/translations/deepin-camera_hr.ts @@ -154,7 +154,7 @@ Resolution: - Razlučivost: + Razlučivost: Photos: @@ -188,6 +188,10 @@ 2*2 lines + + Maximum resolution: + + Shortcut @@ -257,14 +261,6 @@ None NIjedan - - mp4 - - - - webm - - filterPreviewButton diff --git a/src/translations/deepin-camera_hu.ts b/src/translations/deepin-camera_hu.ts index 25daac20..559ccb19 100644 --- a/src/translations/deepin-camera_hu.ts +++ b/src/translations/deepin-camera_hu.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Felbontás: + Felbontás: Photos: @@ -186,6 +188,10 @@ 2*2 lines 2*2 sor + + Maximum resolution: + + Shortcut @@ -337,4 +343,4 @@ Rögzítés megállítása - \ No newline at end of file + diff --git a/src/translations/deepin-camera_it.ts b/src/translations/deepin-camera_it.ts index 5e276980..7d29a70e 100644 --- a/src/translations/deepin-camera_it.ts +++ b/src/translations/deepin-camera_it.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -153,7 +155,7 @@ Localizzazione italiana a cura di Massimo A. Carofano. Resolution: - Risoluzione: + Risoluzione: Photos: @@ -177,15 +179,19 @@ Localizzazione italiana a cura di Massimo A. Carofano. Gridlines - Linee della griglia + 1*1 lines - Griglia 1*1 linee + 2*2 lines - Griglia 2*2 linee + + + + Maximum resolution: + @@ -338,4 +344,4 @@ Localizzazione italiana a cura di Massimo A. Carofano. Interrompi video - \ No newline at end of file + diff --git a/src/translations/deepin-camera_ms.ts b/src/translations/deepin-camera_ms.ts index 59b48776..a239d12b 100644 --- a/src/translations/deepin-camera_ms.ts +++ b/src/translations/deepin-camera_ms.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Resolusi: + Resolusi: Photos: @@ -176,15 +178,19 @@ Gridlines - Garisan grid + 1*1 lines - Garisan 1*1 + 2*2 lines - Garisan 2*2 + + + + Maximum resolution: + @@ -260,35 +266,35 @@ filterPreviewButton Normal - Biasa + Vivid - Terang + Warm - Panas + Cold - Sejuk + Retro - Retro + Film - Filem + Gray - Kelabu + B&W - H&P + @@ -315,11 +321,11 @@ Filters - Penapis + Exposure - Dedahan + @@ -337,4 +343,4 @@ Henti rakaman - \ No newline at end of file + diff --git a/src/translations/deepin-camera_nl.ts b/src/translations/deepin-camera_nl.ts index ec18e3da..2b1e9040 100644 --- a/src/translations/deepin-camera_nl.ts +++ b/src/translations/deepin-camera_nl.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Resolutie: + Resolutie: Photos: @@ -176,15 +178,19 @@ Gridlines - Rooster tonen + 1*1 lines - 1x1 + 2*2 lines - 2x2 + + + + Maximum resolution: + @@ -337,4 +343,4 @@ Opname stoppen - \ No newline at end of file + diff --git a/src/translations/deepin-camera_pl.ts b/src/translations/deepin-camera_pl.ts index 9fb301ca..e04e19d7 100644 --- a/src/translations/deepin-camera_pl.ts +++ b/src/translations/deepin-camera_pl.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -7,7 +9,7 @@ Open folder - Otwórz katalog + Otwórz folder Settings @@ -53,7 +55,7 @@ Open folder - Otwórz katalog + Otwórz folder Print @@ -64,7 +66,7 @@ QObject You don't have permission to operate this folder - Nie posiadasz uprawnień do wykonywania działań na tym katalogu + Nie masz uprawnień do operowania na tym folderze Close @@ -72,11 +74,11 @@ Invalid folder - Nieprawidłowy katalog + Nieprawidłowy folder Open folder - Otwórz katalog + Otwórz folder Settings @@ -88,7 +90,7 @@ File location - Położenie pliku + Lokalizacja pliku Shoot @@ -104,7 +106,7 @@ Output - Wyjście + Wynik Output format @@ -152,7 +154,7 @@ Resolution: - Rozdzielczość: + Rozdzielczość: Photos: @@ -176,15 +178,19 @@ Gridlines - Linie siatki + 1*1 lines - 1*1 linii + 2*2 lines - 2*2 linii + + + + Maximum resolution: + @@ -307,7 +313,7 @@ Delay capture - Opóźnienie przechwytywania + Opóźnij migawkę None @@ -319,22 +325,22 @@ Exposure - Wystawienie + Odsłonięcie videowidget No webcam found - Nie odnaleziono kamery internetowej + Nie znaleziono kamery internetowej The webcam is in use - Kamera internetowa jest już w użyciu + Kamera internetowa jest używana Stop recording Zatrzymaj nagrywanie - \ No newline at end of file + diff --git a/src/translations/deepin-camera_pt.ts b/src/translations/deepin-camera_pt.ts index 06c601ab..9453ed53 100644 --- a/src/translations/deepin-camera_pt.ts +++ b/src/translations/deepin-camera_pt.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Resolução: + Resolução: Photos: @@ -176,15 +178,19 @@ Gridlines - Linhas de grelha + 1*1 lines - Linhas 1*1 + 2*2 lines - Linhas 2*2 + + + + Maximum resolution: + @@ -337,4 +343,4 @@ Parar de gravar - \ No newline at end of file + diff --git a/src/translations/deepin-camera_pt_BR.ts b/src/translations/deepin-camera_pt_BR.ts index 2efb50e9..22295d6d 100644 --- a/src/translations/deepin-camera_pt_BR.ts +++ b/src/translations/deepin-camera_pt_BR.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Resolução: + Resolução: Photos: @@ -176,15 +178,19 @@ Gridlines - Linhas de grade + 1*1 lines - Linhas 1*1 + 2*2 lines - Linhas 2*2 + + + + Maximum resolution: + @@ -260,35 +266,35 @@ filterPreviewButton Normal - Normal + Vivid - Vívido + Warm - Quente + Cold - Frio + Retro - Retro + Film - Cinema + Gray - Cinzento + B&W - P&B + @@ -315,11 +321,11 @@ Filters - Filtros + Exposure - Exposição + @@ -337,4 +343,4 @@ Interromper a gravação - \ No newline at end of file + diff --git a/src/translations/deepin-camera_ro.ts b/src/translations/deepin-camera_ro.ts index 27e7fa6d..f24e8a8e 100644 --- a/src/translations/deepin-camera_ro.ts +++ b/src/translations/deepin-camera_ro.ts @@ -154,7 +154,7 @@ Resolution: - Rezoluție: + Rezoluție: Photos: @@ -188,6 +188,10 @@ 2*2 lines + + Maximum resolution: + + Shortcut @@ -257,14 +261,6 @@ None Nimic - - mp4 - - - - webm - - filterPreviewButton diff --git a/src/translations/deepin-camera_ru.ts b/src/translations/deepin-camera_ru.ts index a537e13b..2808d4a7 100644 --- a/src/translations/deepin-camera_ru.ts +++ b/src/translations/deepin-camera_ru.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -19,15 +21,15 @@ Photo - Фото + Video - Видео + Switch Cameras - Переключить камеру + @@ -152,7 +154,7 @@ Resolution: - Разрешение: + Разрешение: Photos: @@ -168,23 +170,27 @@ Mirror mode - Зеркальный режим + Flashlight - Фонарик + Gridlines - Линии сетки + 1*1 lines - + 2*2 lines - + + + + Maximum resolution: + @@ -260,54 +266,54 @@ filterPreviewButton Normal - Обычный + Vivid - Яркий + Warm - Теплый + Cold - Холодный + Retro - Ретро + Film - Пленка + Gray - Серый + B&W - Черно-белый + takePhotoSettingAreaWidget Flashlight - Фонарик + On - Вкл + Off - Выкл + Delay capture - Задержка снимка + None @@ -315,11 +321,11 @@ Filters - Фильтры + Exposure - Выдержка + @@ -337,4 +343,4 @@ Остановить видеозапись - \ No newline at end of file + diff --git a/src/translations/deepin-camera_sl.ts b/src/translations/deepin-camera_sl.ts index 326a9464..e7519cfb 100644 --- a/src/translations/deepin-camera_sl.ts +++ b/src/translations/deepin-camera_sl.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Ločljivost + Ločljivost Photos: @@ -176,15 +178,19 @@ Gridlines - + 1*1 lines - + 2*2 lines - + + + + Maximum resolution: + @@ -260,35 +266,35 @@ filterPreviewButton Normal - + Vivid - + Warm - + Cold - + Retro - + Film - + Gray - + B&W - + @@ -315,11 +321,11 @@ Filters - + Exposure - + @@ -337,4 +343,4 @@ Zaustavi snemanje - \ No newline at end of file + diff --git a/src/translations/deepin-camera_sq.ts b/src/translations/deepin-camera_sq.ts index 55f921f4..f59425cc 100644 --- a/src/translations/deepin-camera_sq.ts +++ b/src/translations/deepin-camera_sq.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Qartësi: + Qartësi: Photos: @@ -176,15 +178,19 @@ Gridlines - Vija rrjete + 1*1 lines - Vija 1*1 + 2*2 lines - Vija 2*2 + + + + Maximum resolution: + @@ -337,4 +343,4 @@ Resht së regjistruari - \ No newline at end of file + diff --git a/src/translations/deepin-camera_sr.ts b/src/translations/deepin-camera_sr.ts index 9018eb33..0aa1750d 100644 --- a/src/translations/deepin-camera_sr.ts +++ b/src/translations/deepin-camera_sr.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Резолуција: + Резолуција: Photos: @@ -176,15 +178,19 @@ Gridlines - + 1*1 lines - + 2*2 lines - + + + + Maximum resolution: + @@ -260,35 +266,35 @@ filterPreviewButton Normal - + Vivid - + Warm - + Cold - + Retro - + Film - + Gray - + B&W - + @@ -315,11 +321,11 @@ Filters - + Exposure - + @@ -337,4 +343,4 @@ Заустави снимање - \ No newline at end of file + diff --git a/src/translations/deepin-camera_tr.ts b/src/translations/deepin-camera_tr.ts index 4cf6265d..a7131ec2 100644 --- a/src/translations/deepin-camera_tr.ts +++ b/src/translations/deepin-camera_tr.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Çözünürlük: + Çözünürlük: Photos: @@ -176,15 +178,19 @@ Gridlines - Kılavuz çizgileri + 1*1 lines - 1*1 satır + 2*2 lines - 2*2 satır + + + + Maximum resolution: + @@ -337,4 +343,4 @@ Kaydı durdur - \ No newline at end of file + diff --git a/src/translations/deepin-camera_ug.ts b/src/translations/deepin-camera_ug.ts index 7bfc7271..b5324eed 100644 --- a/src/translations/deepin-camera_ug.ts +++ b/src/translations/deepin-camera_ug.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - ئېنىقلىقى: + ئېنىقلىقى: Photos: @@ -176,15 +178,19 @@ Gridlines - بەدىئىي تۈزۈلمە تور + 1*1 lines - 1*1 لىك تور + 2*2 lines - 2*2 لىك تور + + + + Maximum resolution: + @@ -337,4 +343,4 @@ ئېلىشنى توختىتىش - \ No newline at end of file + diff --git a/src/translations/deepin-camera_uk.ts b/src/translations/deepin-camera_uk.ts index 50bd6acf..655b7f97 100644 --- a/src/translations/deepin-camera_uk.ts +++ b/src/translations/deepin-camera_uk.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - Роздільна здатність: + Роздільна здатність: Photos: @@ -176,15 +178,19 @@ Gridlines - Лінії сітки + 1*1 lines - Лінії 1*1 + 2*2 lines - Лінії 2*2 + + + + Maximum resolution: + @@ -337,4 +343,4 @@ Зупинити записування - \ No newline at end of file + diff --git a/src/translations/deepin-camera_zh_CN.ts b/src/translations/deepin-camera_zh_CN.ts index cd4258e4..fde6e9a7 100644 --- a/src/translations/deepin-camera_zh_CN.ts +++ b/src/translations/deepin-camera_zh_CN.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - 分辨率: + 分辨率: Photos: @@ -186,6 +188,10 @@ 2*2 lines 井字网格 + + Maximum resolution: + 最大分辨率: + Shortcut @@ -337,4 +343,4 @@ 结束录制 - \ No newline at end of file + diff --git a/src/translations/deepin-camera_zh_HK.ts b/src/translations/deepin-camera_zh_HK.ts index 66069483..e7ff7208 100644 --- a/src/translations/deepin-camera_zh_HK.ts +++ b/src/translations/deepin-camera_zh_HK.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - 解像度: + 解像度: Photos: @@ -186,6 +188,10 @@ 2*2 lines 井字網格 + + Maximum resolution: + + Shortcut @@ -337,4 +343,4 @@ 結束錄製 - \ No newline at end of file + diff --git a/src/translations/deepin-camera_zh_TW.ts b/src/translations/deepin-camera_zh_TW.ts index e3b05146..e16eeb86 100644 --- a/src/translations/deepin-camera_zh_TW.ts +++ b/src/translations/deepin-camera_zh_TW.ts @@ -1,4 +1,6 @@ - + + + CMainWindow @@ -152,7 +154,7 @@ Resolution: - 解析度: + 解析度: Photos: @@ -186,6 +188,10 @@ 2*2 lines 井字網格 + + Maximum resolution: + + Shortcut @@ -337,4 +343,4 @@ 結束錄製 - \ No newline at end of file + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 82a1c725..91f91e69 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,3 @@ -# SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -# -# SPDX-License-Identifier: GPL-3.0-or-later # 设置工程名字 project(deepin-camera-test VERSION 1.0.0) @@ -87,6 +84,7 @@ add_executable( ${TARGET_NAME} ${CXXSOURCES} ${CSOURCES} ${RESOURCES} pkg_check_modules(3rd_lib REQUIRED dtkgui dtkwidget gstreamer-1.0 gstreamer-app-1.0 + pciaccess # libv4l2 # libudev # libusb-1.0 @@ -114,12 +112,8 @@ target_link_libraries(${PROJECT_NAME} ${3rd_lib_LIBRARIES} # z imagevisualresult - KF5WaylandClient ) -include_directories("/usr/include/KF5") - - # 将工程与Qt模块链接起来 qt5_use_modules(${PROJECT_NAME} ${QtModule}) diff --git a/tests/CameraTest.cpp b/tests/CameraTest.cpp index d57821f6..27b09d65 100644 --- a/tests/CameraTest.cpp +++ b/tests/CameraTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "CameraTest.h" #include "src/Settings.h" diff --git a/tests/CameraTest.h b/tests/CameraTest.h index bfc44033..f30639fd 100644 --- a/tests/CameraTest.h +++ b/tests/CameraTest.h @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _DEV_NUM_TEST_H #define _DEV_NUM_TEST_H diff --git a/tests/ClosedialogTest.cpp b/tests/ClosedialogTest.cpp index 7f3cb7ef..65a042e7 100644 --- a/tests/ClosedialogTest.cpp +++ b/tests/ClosedialogTest.cpp @@ -1,7 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - #include #include diff --git a/tests/ClosedialogTest.h b/tests/ClosedialogTest.h index 7b6b7380..4c26271f 100644 --- a/tests/ClosedialogTest.h +++ b/tests/ClosedialogTest.h @@ -1,7 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - #ifndef VIDEOWIDGETTEST_H #define VIDEOWIDGETTEST_H diff --git a/tests/DevNumTest.cpp b/tests/DevNumTest.cpp index e69b1ef4..ee220189 100644 --- a/tests/DevNumTest.cpp +++ b/tests/DevNumTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "DevNumTest.h" #include "src/mainwindow.h" diff --git a/tests/DevNumTest.h b/tests/DevNumTest.h index c9dd3f2e..4f800c8f 100644 --- a/tests/DevNumTest.h +++ b/tests/DevNumTest.h @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _DEV_NUM_TEST_H #define _DEV_NUM_TEST_H diff --git a/tests/GStreamerTest.cpp b/tests/GStreamerTest.cpp index 8317fcc3..b5cbac22 100644 --- a/tests/GStreamerTest.cpp +++ b/tests/GStreamerTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. +* +* Author: houchengqiu +* Maintainer: houchengqiu +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "GStreamerTest.h" #include "src/Settings.h" diff --git a/tests/GStreamerTest.h b/tests/GStreamerTest.h index ad0c4e2c..a03944b0 100644 --- a/tests/GStreamerTest.h +++ b/tests/GStreamerTest.h @@ -1,7 +1,21 @@ -// Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. +* +* Author: houchengqiu +* Maintainer: houchengqiu +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _DEV_NUM_TEST_H #define _DEV_NUM_TEST_H diff --git a/tests/ImageItemTest.cpp b/tests/ImageItemTest.cpp index 6c2c7224..4df03dff 100644 --- a/tests/ImageItemTest.cpp +++ b/tests/ImageItemTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "ImageItemTest.h" #include "src/mainwindow.h" diff --git a/tests/ImageItemTest.h b/tests/ImageItemTest.h index 78874871..324b82b0 100644 --- a/tests/ImageItemTest.h +++ b/tests/ImageItemTest.h @@ -1,7 +1,22 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + #ifndef _IMAGE_ITEM_TEST_H #define _IMAGE_ITEM_TEST_H diff --git a/tests/MainwindowTest.cpp b/tests/MainwindowTest.cpp index 94994580..e5f6d788 100644 --- a/tests/MainwindowTest.cpp +++ b/tests/MainwindowTest.cpp @@ -1,7 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - #include "src/mainwindow.h" #include "src/imageitem.h" #include "src/switchcamerabtn.h" diff --git a/tests/MainwindowTest.h b/tests/MainwindowTest.h index b45bad3f..140e37aa 100644 --- a/tests/MainwindowTest.h +++ b/tests/MainwindowTest.h @@ -1,7 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - #ifndef MAINWINDOWTEST_H #define MAINWINDOWTEST_H diff --git a/tests/MajorImageProcessingThreadTest.cpp b/tests/MajorImageProcessingThreadTest.cpp index 4834b363..bd3d7a2e 100644 --- a/tests/MajorImageProcessingThreadTest.cpp +++ b/tests/MajorImageProcessingThreadTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "MajorImageProcessingThreadTest.h" #include "src/majorimageprocessingthread.h" diff --git a/tests/MajorImageProcessingThreadTest.h b/tests/MajorImageProcessingThreadTest.h index c962e18c..172283d7 100644 --- a/tests/MajorImageProcessingThreadTest.h +++ b/tests/MajorImageProcessingThreadTest.h @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _MAJOR_IMAGE_PROCESSING_THREAD_TEST_H #define _MAJOR_IMAGE_PROCESSING_THREAD_TEST_H diff --git a/tests/PhotoRecordBtnTest.cpp b/tests/PhotoRecordBtnTest.cpp index 752caba1..3cdaf69a 100644 --- a/tests/PhotoRecordBtnTest.cpp +++ b/tests/PhotoRecordBtnTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "PhotoRecordBtnTest.h" #include "src/photorecordbtn.h" diff --git a/tests/PhotoRecordBtnTest.h b/tests/PhotoRecordBtnTest.h index 34eff3e6..0b7a6002 100644 --- a/tests/PhotoRecordBtnTest.h +++ b/tests/PhotoRecordBtnTest.h @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _PHOTO_RECORD_BTN_TEST_H #define _PHOTO_RECORD_BTN_TEST_H diff --git a/tests/PreviewOpenglWidgetTest.cpp b/tests/PreviewOpenglWidgetTest.cpp index dd3f1781..52041ad0 100644 --- a/tests/PreviewOpenglWidgetTest.cpp +++ b/tests/PreviewOpenglWidgetTest.cpp @@ -1,6 +1,20 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "PreviewOpenglWidgetTest.h" diff --git a/tests/PreviewOpenglWidgetTest.h b/tests/PreviewOpenglWidgetTest.h index 353098a9..32902a45 100644 --- a/tests/PreviewOpenglWidgetTest.h +++ b/tests/PreviewOpenglWidgetTest.h @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _PREVIEW_OPENGL_WIDGET_TEST_H #define _PREVIEW_OPENGL_WIDGET_TEST_H diff --git a/tests/RollingBoxTest.cpp b/tests/RollingBoxTest.cpp index dc7f5a5d..258829dc 100644 --- a/tests/RollingBoxTest.cpp +++ b/tests/RollingBoxTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "RollingBoxTest.h" #include "src/rollingbox.h" diff --git a/tests/RollingBoxTest.h b/tests/RollingBoxTest.h index c3ee389b..0a30e255 100644 --- a/tests/RollingBoxTest.h +++ b/tests/RollingBoxTest.h @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _ROLLING_BOX_TEST_H #define _ROLLING_BOX_TEST_H diff --git a/tests/SettingTest.cpp b/tests/SettingTest.cpp index 20f91b04..93e05351 100644 --- a/tests/SettingTest.cpp +++ b/tests/SettingTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "SettingTest.h" #include "src/Settings.h" diff --git a/tests/SettingTest.h b/tests/SettingTest.h index af3cac41..f30a2cfa 100644 --- a/tests/SettingTest.h +++ b/tests/SettingTest.h @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _SEETING_TEST_H #define _SEETING_TEST_H diff --git a/tests/TakePhotoSettingTest.cpp b/tests/TakePhotoSettingTest.cpp index 8c25c8c2..b26ef742 100644 --- a/tests/TakePhotoSettingTest.cpp +++ b/tests/TakePhotoSettingTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: tanlang +* Maintainer: tanlang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "TakePhotoSettingTest.h" #include "src/capplication.h" diff --git a/tests/TakePhotoSettingTest.h b/tests/TakePhotoSettingTest.h index e6940eb6..0a5a6905 100644 --- a/tests/TakePhotoSettingTest.h +++ b/tests/TakePhotoSettingTest.h @@ -1,8 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: tanlang +* Maintainer: tanlang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _TAKE_PHOTO_SETTING_TEST_H #define _TAKE_PHOTO_SETTING_TEST_H diff --git a/tests/VideoWidgetTest.cpp b/tests/VideoWidgetTest.cpp index dadd7d20..238dcc98 100644 --- a/tests/VideoWidgetTest.cpp +++ b/tests/VideoWidgetTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "VideoWidgetTest.h" #include "src/videowidget.h" diff --git a/tests/VideoWidgetTest.h b/tests/VideoWidgetTest.h index 43adb86e..17be100b 100644 --- a/tests/VideoWidgetTest.h +++ b/tests/VideoWidgetTest.h @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _VIDEO_WIDGET_TEST_H #define _VIDEO_WIDGET_TEST_H diff --git a/tests/main.cpp b/tests/main.cpp index fa4ebd3b..99987062 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,7 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - #include "src/mainwindow.h" #include "src/capplication.h" #include "stub_function.h" diff --git a/tests/stub/addr_any.h b/tests/stub/addr_any.h index 7d086d45..a153f348 100644 --- a/tests/stub/addr_any.h +++ b/tests/stub/addr_any.h @@ -1,7 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - #ifndef __ADDR_ANY_H__ #define __ADDR_ANY_H__ diff --git a/tests/stub/addr_pri.h b/tests/stub/addr_pri.h index 08b7edb7..9174bb0c 100755 --- a/tests/stub/addr_pri.h +++ b/tests/stub/addr_pri.h @@ -1,7 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - #ifndef __ADDR_PRI_H__ #define __ADDR_PRI_H__ diff --git a/tests/stub/catch.hpp b/tests/stub/catch.hpp index 46dddce0..94e20c21 100644 --- a/tests/stub/catch.hpp +++ b/tests/stub/catch.hpp @@ -1,8 +1,13 @@ -// Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - +/* + * Catch v2.13.1 + * Generated: 2020-09-07 12:12:38.090364 + * ---------------------------------------------------------- + * This file has been merged from multiple headers. Please don't edit it directly + * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ #ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED #define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED // start catch.hpp diff --git a/tests/stub/elfio.hpp b/tests/stub/elfio.hpp index b45da856..dd5c9aec 100644 --- a/tests/stub/elfio.hpp +++ b/tests/stub/elfio.hpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later /*** Start of inlined file: elfio_dump.hpp ***/ #ifndef ELFIO_DUMP_HPP diff --git a/tests/stub/stub.h b/tests/stub/stub.h index 366b34dc..a39ac805 100644 --- a/tests/stub/stub.h +++ b/tests/stub/stub.h @@ -1,7 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - #ifndef __STUB_H__ #define __STUB_H__ diff --git a/tests/stub/stub_function.cpp b/tests/stub/stub_function.cpp index 7b200bec..b0da250e 100644 --- a/tests/stub/stub_function.cpp +++ b/tests/stub/stub_function.cpp @@ -1,7 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - #include "stub_function.h" #include "stub.h" extern "C" diff --git a/tests/stub/stub_function.h b/tests/stub/stub_function.h index 9e0fa4ab..208e9494 100644 --- a/tests/stub/stub_function.h +++ b/tests/stub/stub_function.h @@ -1,7 +1,3 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - #ifndef STUB_FUNCTION_H #define STUB_FUNCTION_H diff --git a/tests/test-prj-running.sh b/tests/test-prj-running.sh index 11370de6..df99b949 100755 --- a/tests/test-prj-running.sh +++ b/tests/test-prj-running.sh @@ -1,7 +1,3 @@ -# SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -# -# SPDX-License-Identifier: GPL-3.0-or-later - remove_cache(){ export DISPLAY=":0" export QT_QPA_PLATFORM= diff --git a/tests/windowStateTest.cpp b/tests/windowStateTest.cpp index 55ee6c7d..0f2453e3 100644 --- a/tests/windowStateTest.cpp +++ b/tests/windowStateTest.cpp @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include "windowStateTest.h" #include "src/capplication.h" diff --git a/tests/windowStateTest.h b/tests/windowStateTest.h index b1c9c1e8..ecfa0c0e 100644 --- a/tests/windowStateTest.h +++ b/tests/windowStateTest.h @@ -1,7 +1,21 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later +/* +* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +* +* Author: wuzhigang +* Maintainer: wuzhigang +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #ifndef _WINDOWN_STATE_TEST_H #define _WINDOWN_STATE_TEST_H