Skip to content

Commit

Permalink
fix kmre-window
Browse files Browse the repository at this point in the history
  • Loading branch information
sukanka committed Sep 8, 2024
1 parent c496c94 commit 36b3d8f
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 8 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ Some packages are not included.

### specific
- `kmre-image-data`: lacks `kmre-container-image.tar` which is not included in [the repo](https://gitee.com/openkylin/kylin-kmre-image-data), also, there is `kmre-image-data-x64` but their `kmre.conf` is the same, only `kmre-container-image.tar` differs, so there is no needed to package them separately.

- `kmre-window` : cannot be built with `ffmpeg-7.0`, a similar issue is at [OpenBoard](https://github.com/OpenBoard-org/OpenBoard/issues/1002), we should add a patch for it.
99 changes: 99 additions & 0 deletions kmre-window/0001-fix-ffmpeg7.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
From 22b1c5467b5ae9637da611af223922965c9048d1 Mon Sep 17 00:00:00 2001
From: sukanka <[email protected]>
Date: Sun, 8 Sep 2024 21:03:03 +0800
Subject: [PATCH] fix ffmpeg7.0


24 5 window/record/AV/Output/AudioEncoder.cpp
7 2 window/record/AV/Output/Synchronizer.cpp

diff --git a/window/record/AV/Output/AudioEncoder.cpp b/window/record/AV/Output/AudioEncoder.cpp
index 576dd93..e52a4de 100644
--- a/window/record/AV/Output/AudioEncoder.cpp
+++ b/window/record/AV/Output/AudioEncoder.cpp
@@ -67,7 +67,12 @@ AVSampleFormat AudioEncoder::GetSampleFormat() {
}

unsigned int AudioEncoder::GetChannels() {
- return GetCodecContext()->channels;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 3, 100)
+ return GetCodecContext()->channels;
+#else
+ return GetCodecContext()->ch_layout.nb_channels;
+#endif
+
}

unsigned int AudioEncoder::GetSampleRate() {
@@ -104,8 +109,15 @@ void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context
}

codec_context->bit_rate = bit_rate;
- codec_context->channels = channels;
- codec_context->channel_layout = (channels == 1)? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 3, 100)
+ codec_context->channels = channels;
+ codec_context->channel_layout =
+ (channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
+#else
+ codec_context->ch_layout.nb_channels = channels;
+ codec_context->ch_layout.u.mask = (channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
+#endif
+
codec_context->sample_rate = sample_rate;
codec_context->time_base.num = 1;
codec_context->time_base.den = sample_rate;
@@ -137,7 +149,7 @@ void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context
continue;
if(!AVCodecSupportsSampleFormat(codec, SUPPORTED_SAMPLE_FORMATS[i].m_format))
continue;
- syslog(LOG_INFO, "[AudioEncoder::PrepareStream] Using sample format %s.",
+ syslog(LOG_INFO, "[AudioEncoder::PrepareStream] Using sample format %s.",
SUPPORTED_SAMPLE_FORMATS[i].m_name.toStdString().c_str());
codec_context->sample_fmt = SUPPORTED_SAMPLE_FORMATS[i].m_format;
break;
@@ -156,7 +168,14 @@ bool AudioEncoder::EncodeFrame(AVFrameWrapper* frame) {
assert((unsigned int) frame->GetFrame()->nb_samples == GetFrameSize());
#endif
#if SSR_USE_AVFRAME_CHANNELS
- assert(frame->GetFrame()->channels == GetCodecContext()->channels);
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 3, 100)
+ assert(frame->GetFrame()->channels ==
+ GetCodecContext()->channels);
+#else
+ assert(frame->GetFrame()->ch_layout.nb_channels ==
+ GetCodecContext()->ch_layout.nb_channels);
+#endif
+
#endif
#if SSR_USE_AVFRAME_SAMPLE_RATE
assert(frame->GetFrame()->sample_rate == GetCodecContext()->sample_rate);
diff --git a/window/record/AV/Output/Synchronizer.cpp b/window/record/AV/Output/Synchronizer.cpp
index 38daa49..ca76b45 100644
--- a/window/record/AV/Output/Synchronizer.cpp
+++ b/window/record/AV/Output/Synchronizer.cpp
@@ -176,7 +176,12 @@ static std::unique_ptr<AVFrameWrapper> CreateAudioFrame(unsigned int channels, u
frame->GetFrame()->nb_samples = samples;
#endif
#if SSR_USE_AVFRAME_CHANNELS
- frame->GetFrame()->channels = channels;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 3, 100)
+ frame->GetFrame()->channels = channels;
+#else
+ frame->GetFrame()->ch_layout.nb_channels = channels;
+#endif
+
#endif
#if SSR_USE_AVFRAME_SAMPLE_RATE
frame->GetFrame()->sample_rate = sample_rate;
@@ -858,7 +863,7 @@ void Synchronizer::SynchronizerThread() {
usleep(20000);
}
syslog(LOG_INFO, "[Synchronizer::SynchronizerThread] Synchronizer thread stopped.");
-
+
} catch(const std::exception& e) {
m_error_occurred = true;
syslog(LOG_ERR, "[Synchronizer::SynchronizerThread] Exception '%s' in synchronizer thread.", e.what());
--
2.46.0
21 changes: 15 additions & 6 deletions kmre-window/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,34 @@ license=('GPL3')
url='https://gitee.com/openkylin/kylin-kmre-window'
groups=(kmre)
depends=(gsettings-qt)
source=(git+${url}.git)
sha512sums=('SKIP')
source=(git+${url}.git
0001-fix-ffmpeg7.0.patch
)
sha512sums=('SKIP'
'eb0ea19ffd128b0cfd499b4c38d2ff7c5f8eb03d52c744886237e59f6681d8f9d8f046406870e1466738e1bb78d80d66a16d9f682ef8e5a3b0c73e4eecbc391e')
depends=(
qt5-{base,svg,webengine,x11extras,wayland}
qt5-{base,webengine,x11extras,wayland,multimedia}
gsettings-qt
speexdsp
kwayland5
kmre-display-control
libxinerama
protobuf
dconf
abseil-cpp

)
makedepends=(
git lsb-release
qt5-{multimedia,tools}
qt5-tools
boost
protobuf
speexdsp
patch
libepoxy
)

prepare() {
cd ${srcdir}/kylin-${pkgname}
patch --strip=1 --ignore-whitespace <../0001-fix-ffmpeg7.0.patch
sed -i '/dpkg-buildflags/d' */*.pro
sed -i window/display/displaybackend/display_control.cpp \
-e 's|"display_control_api_functions.h"|<DisplayControl/display_control_api_functions.h>|'
Expand Down

0 comments on commit 36b3d8f

Please sign in to comment.