summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--as2-platform-dji-osdk.spec15
-rw-r--r--ffmpeg5-compat.patch101
2 files changed, 114 insertions, 2 deletions
diff --git a/as2-platform-dji-osdk.spec b/as2-platform-dji-osdk.spec
index a51bae7..aff0442 100644
--- a/as2-platform-dji-osdk.spec
+++ b/as2-platform-dji-osdk.spec
@@ -4,12 +4,13 @@
Name: ros-%{ros_distro}-%{RosPkgName}
Version: 1.1.0
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: Package to communicate DJI OSDK with Aerostack2 framework
License: BSD-3-Clause
URL: https://github.com/aerostack2/as2_platform_dji_osdk/tree/main
Source0: %{RosPkgName}-%{src_version}.tar.gz
Source1: Onboard-SDK-master.tar.gz
+Patch0: ffmpeg5-compat.patch
%global debug_package %{nil}
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
@@ -52,8 +53,11 @@ Provides: %{name}-runtime = %{version}-%{release}
Package to communicate DJI OSDK with Aerostack2 framework
%prep
-%autosetup -n %{RosPkgName}-%{src_version}
+%autosetup -n %{RosPkgName}-%{src_version} -N
tar xzf %{SOURCE1} -C %{_builddir}
+cd %{_builddir}/Onboard-SDK-master
+patch -p1 < %{PATCH0}
+cd -
%build
[ -f /opt/ros/%{ros_distro}/setup.sh ] && source /opt/ros/%{ros_distro}/setup.sh || true
@@ -83,6 +87,13 @@ make install DESTDIR=%{buildroot}
/opt/ros/%{ros_distro}
%changelog
+* Sat Oct 10 2026 ai-importer <ai-importer@openeuler.org> - 1.1.0-3
+- Add ffmpeg5-compat.patch for FFmpeg 5.x API compatibility
+- Replace removed APIs: avcodec_register_all, avcodec_decode_video2,
+ avpicture_get_size/fill, av_free_packet, AVPicture, AVCodec const
+- Use avcodec_send_packet/avcodec_receive_frame, av_image_*,
+ av_packet_unref, avcodec_free_context, av_frame_free
+
* Sat Oct 10 2026 ai-importer <ai-importer@openeuler.org> - 1.1.0-2
- Bundle DJI Onboard-SDK as Source1 to avoid network git clone in COPR
- Add ffmpeg-devel BuildRequires for advanced-sensing component
diff --git a/ffmpeg5-compat.patch b/ffmpeg5-compat.patch
new file mode 100644
index 0000000..b8c57ca
--- /dev/null
+++ b/ffmpeg5-compat.patch
@@ -0,0 +1,101 @@
+--- a/osdk-core/advanced-sensing/camera_stream/src/dji_camera_stream_decoder.hpp
++++ b/osdk-core/advanced-sensing/camera_stream/src/dji_camera_stream_decoder.hpp
+@@ -13,6 +13,7 @@
+ extern "C"{
+ #include <libavcodec/avcodec.h>
+ #include <libavformat/avformat.h>
++#include <libavutil/imgutils.h>
+ #include <libswscale/swscale.h>
+ }
+
+@@ -52,7 +53,7 @@
+
+ pthread_mutex_t decodemutex;
+ AVCodecContext* pCodecCtx;
+- AVCodec* pCodec;
++ const AVCodec* pCodec;
+ AVCodecParserContext* pCodecParserCtx;
+ SwsContext* pSwsCtx;
+
+--- a/osdk-core/advanced-sensing/camera_stream/src/dji_camera_stream_decoder.cpp
++++ b/osdk-core/advanced-sensing/camera_stream/src/dji_camera_stream_decoder.cpp
+@@ -67,7 +67,6 @@
+ return true;
+ }
+
+- avcodec_register_all();
+ pCodecCtx = avcodec_alloc_context3(NULL);
+ if (!pCodecCtx)
+ {
+@@ -130,7 +129,7 @@
+
+ if (NULL != pFrameYUV)
+ {
+- av_free(pFrameYUV);
++ av_frame_free(&pFrameYUV);
+ pFrameYUV = NULL;
+ }
+
+@@ -140,16 +139,10 @@
+ pCodecParserCtx = NULL;
+ }
+
+- if (NULL != pCodec)
+- {
+- avcodec_close(pCodecCtx);
+- pCodec = NULL;
+- }
+-
+ if (NULL != pCodecCtx)
+ {
+- av_free(pCodecCtx);
+- pCodecCtx = NULL;
++ avcodec_free_context(&pCodecCtx);
++ pCodec = NULL;
+ }
+
+ if (NULL != rgbBuf )
+@@ -160,7 +153,7 @@
+
+ if (NULL != pFrameRGB)
+ {
+- av_free(pFrameRGB);
++ av_frame_free(&pFrameRGB);
+ pFrameRGB = NULL;
+ }
+
+@@ -219,7 +212,12 @@
+ if (pkt.size > 0)
+ {
+ int gotPicture = 0;
+- avcodec_decode_video2(pCodecCtx, pFrameYUV, &gotPicture, &pkt);
++ int ret = avcodec_send_packet(pCodecCtx, &pkt);
++ if (ret >= 0)
++ {
++ ret = avcodec_receive_frame(pCodecCtx, pFrameYUV);
++ gotPicture = (ret == 0) ? 1 : 0;
++ }
+
+ if (!gotPicture)
+ {
+@@ -241,9 +239,9 @@
+
+ if(NULL == rgbBuf)
+ {
+- bufSize = avpicture_get_size(AV_PIX_FMT_RGB24, w, h);
++ bufSize = av_image_get_buffer_size(AV_PIX_FMT_RGB24, w, h, 1);
+ rgbBuf = (uint8_t*) av_malloc(bufSize);
+- avpicture_fill((AVPicture*)pFrameRGB, rgbBuf, AV_PIX_FMT_RGB24, w, h);
++ av_image_fill_arrays(pFrameRGB->data, pFrameRGB->linesize, rgbBuf, AV_PIX_FMT_RGB24, w, h, 1);
+ }
+
+ if(NULL != pSwsCtx && NULL != rgbBuf)
+@@ -261,7 +259,7 @@
+ }
+ }
+ pthread_mutex_unlock(&decodemutex);
+- av_free_packet(&pkt);
++ av_packet_unref(&pkt);
+ }
+
+ bool DJICameraStreamDecoder::registerCallback(CameraImageCallback f, void *param)