fix build error of kylin-recorder

This commit is contained in:
peijiankang 2024-03-29 17:22:55 +08:00
parent 7671f8faf0
commit bca95315d2
2 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,63 @@
From f30bed9e983be7aa406349db351442bb33b2c5f1 Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Fri, 29 Mar 2024 17:21:37 +0800
Subject: [PATCH] fix build error of kylin-recorder
---
src/ffutil.cpp | 4 ++++
src/ffutil.h | 9 ++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/ffutil.cpp b/src/ffutil.cpp
index f824db5..2b0cd77 100644
--- a/src/ffutil.cpp
+++ b/src/ffutil.cpp
@@ -17,14 +17,18 @@ extern "C"
FFUtil::FFUtil(QObject *parent) : QObject(parent)
{
+#if !AVFORMAT_STATIC_REGISTER
av_register_all();
+#endif
}
int FFUtil::getDuration(QString path)
{
int64_t duration = 0;
+#if !AVFORMAT_STATIC_REGISTER
av_register_all();
+#endif
AVFormatContext *pFormatCtx = avformat_alloc_context();
avformat_open_input(&pFormatCtx, path.toStdString().c_str(), NULL, NULL);
diff --git a/src/ffutil.h b/src/ffutil.h
index 65461a5..12473a8 100644
--- a/src/ffutil.h
+++ b/src/ffutil.h
@@ -3,6 +3,13 @@
#include <QObject>
+#define QTAV_USE_FFMPEG(MODULE) (MODULE##_VERSION_MICRO >= 100)
+#define QTAV_USE_LIBAV(MODULE) !QTAV_USE_FFMPEG(MODULE)
+#define FFMPEG_MODULE_CHECK(MODULE, MAJOR, MINOR, MICRO) \
+ (QTAV_USE_FFMPEG(MODULE) && MODULE##_VERSION_INT >= AV_VERSION_INT(MAJOR, MINOR, MICRO))
+
+#define AVFORMAT_STATIC_REGISTER FFMPEG_MODULE_CHECK(LIBAVFORMAT, 58, 9, 100)
+
struct AVCodec;
struct AVCodecContext;
struct AVFormatContext;
@@ -32,7 +39,7 @@ private:
AVOutputFormat *pOutputFormat = nullptr;
AVFormatContext *pFormatCtx = nullptr;
AVCodecContext *pCodecCtx = nullptr;
- AVCodec *pCodec = nullptr;
+ const AVCodec *pCodec = nullptr;
int audioStream;
int audioDuration;
--
2.25.1

View File

@ -1,11 +1,12 @@
Name: kylin-recorder
Version: 1.3.0
Release: 4
Release: 5
Summary: kylin-recorder
License: GPL-3.0-or-later
URL: https://github.com/UbuntuKylin/kylin-recorder
Source0: %{name}-%{version}.tar.gz
Patch01: 0001-add-user-guide-for-kylin-recorder.patch
Patch02: 0002-fix-build-error-of-kylin-recorder.patch
BuildRequires: qt5-qtbase-devel
BuildRequires: qt5-qtscript-devel
@ -40,6 +41,7 @@ kylin-recording
%prep
%setup -q
%patch01 -p1
%patch02 -p1
%build
@ -66,6 +68,9 @@ popd
%{_datadir}/kylin-user-guide/data/guide/kylin-recorder
%changelog
* Fri Mar 29 2024 peijiankang <peijiankang@kylinos.cn> - 1.3.0-5
- add 0002-fix-build-error-of-kylin-recorder.patch
* Wed Mar 22 2023 peijiankang <peijiankang@kylinos.cn> - 1.3.0-4
- fix user-guide for kylin-recorder in English