!39 fix build error of kylin-video about ffmpeg-6.1

From: @peijiankang 
Reviewed-by: @dou33 
Signed-off-by: @dou33
This commit is contained in:
openeuler-ci-bot 2024-04-16 05:54:29 +00:00 committed by Gitee
commit c95f22fedd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 134 additions and 2 deletions

View File

@ -0,0 +1,127 @@
From d54bfd1df31ef73d8e18f2603cf7bbcf5354d344 Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Mon, 8 Apr 2024 14:42:03 +0800
Subject: [PATCH] fix build error of kylin-video about ffmpeg-6.1
---
src/core/ffutil.cpp | 2 ++
src/core/ffutil.h | 10 ++++++++-
src/core/mpvcore.cpp | 53 ++++++++++++++++++++++----------------------
3 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/src/core/ffutil.cpp b/src/core/ffutil.cpp
index 5297a31..9549b14 100644
--- a/src/core/ffutil.cpp
+++ b/src/core/ffutil.cpp
@@ -21,7 +21,9 @@ extern "C"
FFUtil::FFUtil(QObject *parent) : QObject(parent)
{
+#if !AVFORMAT_STATIC_REGISTER
av_register_all();
+#endif
m_videoTbr = new VideoThumbnailer;
m_videoTbr->setThumbnailSize(176);
pFormatCtx = nullptr;
diff --git a/src/core/ffutil.h b/src/core/ffutil.h
index cf3de29..4b4754c 100644
--- a/src/core/ffutil.h
+++ b/src/core/ffutil.h
@@ -4,6 +4,14 @@
#include <QObject>
#include <libffmpegthumbnailer/videothumbnailer.h>
+
+#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)
+
using namespace ffmpegthumbnailer;
struct AVCodec;
@@ -26,7 +34,7 @@ private:
VideoThumbnailer *m_videoTbr;
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
- AVCodec *pCodec;
+ const AVCodec *pCodec;
int videoStream;
int videoDuration;
diff --git a/src/core/mpvcore.cpp b/src/core/mpvcore.cpp
index 378db64..60dec98 100644
--- a/src/core/mpvcore.cpp
+++ b/src/core/mpvcore.cpp
@@ -1577,6 +1577,7 @@ bool MpvCore::event(QEvent *event)
Play();
ShowText("");
// 不要 break 有莫名其妙的问题,待查
+ //case MPV_EVENT_UNPAUSE:
case MPV_EVENT_UNPAUSE:
KyInfo() << "[mpv event] MPV_EVENT_UNPAUSE";
// 防止重复设置状态
@@ -1627,32 +1628,32 @@ bool MpvCore::event(QEvent *event)
// mpv_event_log_message *message = static_cast<mpv_event_log_message*>(event->data);
break;
}
- case MPV_EVENT_TRACK_SWITCHED:
- KyInfo() << "[mpv event] MPV_EVENT_TRACK_SWITCHED";
- // 轨道id改变
- mpv_get_property(m_mpvHandle, "sid", MPV_FORMAT_INT64, &sid);
- if (sid > m_stracks)
- sid = 0;
-
- g_core_signal->notifySubId(sid);
- if(sid != m_sid && sid >= 0)
- {
- m_sid = sid;
- if (sid == 0) {
- ShowText(tr("subtitle : ").append("no"));
- }
- // 字幕改变
- for(Mpv::Track tck : m_fileInfo.stracks)
- if(tck.id == sid)
- ShowText(tr("subtitle : ").append(tck.title));
- }
- mpv_get_property(m_mpvHandle, "aid", MPV_FORMAT_INT64, &aid);
- g_core_signal->notifyAudioId(aid);
- mpv_get_property(m_mpvHandle, "vid", MPV_FORMAT_INT64, &vid);
- g_core_signal->notifyVideoId(vid);
- m_vid = vid;
- m_aid = aid;
- break;
+// case MPV_EVENT_TRACK_SWITCHED:
+// KyInfo() << "[mpv event] MPV_EVENT_TRACK_SWITCHED";
+// // 轨道id改变
+// mpv_get_property(m_mpvHandle, "sid", MPV_FORMAT_INT64, &sid);
+// if (sid > m_stracks)
+// sid = 0;
+//
+// g_core_signal->notifySubId(sid);
+// if(sid != m_sid && sid >= 0)
+// {
+// m_sid = sid;
+// if (sid == 0) {
+// ShowText(tr("subtitle : ").append("no"));
+// }
+// // 字幕改变
+// for(Mpv::Track tck : m_fileInfo.stracks)
+// if(tck.id == sid)
+// ShowText(tr("subtitle : ").append(tck.title));
+// }
+// mpv_get_property(m_mpvHandle, "aid", MPV_FORMAT_INT64, &aid);
+// g_core_signal->notifyAudioId(aid);
+// mpv_get_property(m_mpvHandle, "vid", MPV_FORMAT_INT64, &vid);
+// g_core_signal->notifyVideoId(vid);
+// m_vid = vid;
+// m_aid = aid;
+// break;
default: // unhandled events
break;
}
--
2.43.0

View File

@ -1,12 +1,13 @@
Name: kylin-video
Version: 3.1.4
Release: 3
Release: 4
Summary: A powerful video player
License: GPL-2.0+
URL: https://gitee.com/openkylin/kylin-video
Source0: kylin-video-3.1.4.tar.gz
Patch01: 0001-fix-compile-error-of-kylin-video.patch
Patch01: 0001-fix-compile-error-of-kylin-video.patch
Patch02: 0002-Repair-the-user-guide-does-not-work.patch
Patch03: 0003-fix-build-error-of-kylin-video-about-ffmpeg-6.1.patch
BuildRequires: ffmpeg-devel
BuildRequires: libcrystalhd-devel
@ -41,6 +42,7 @@ It supports both x86 and ARM platform, and supports most of the audio and video
%setup -q
%patch01 -p1
%patch02 -p1
%patch03 -p1
%build
mkdir qmake-build
@ -63,6 +65,9 @@ popd
%changelog
* Wed Apr 10 2024 peijiankang <peijiankang@kylinos.cn> - 3.1.4-4
- add 0003-fix-build-error-of-kylin-video-about-ffmpeg-6.1.patch
* Mon Mar 06 2023 peijiankang <peijiankang@kylinos.cn> - 3.1.4-3
- Repair the user guide does not work