Skip to content

Commit

Permalink
Add FFmpeg 7.0 support (#182)
Browse files Browse the repository at this point in the history
* Add ffmpeg 7.0 support

* Use FFmpeg 7.0 as default and update readme.md how to switch to FFmpeg 6.1
  • Loading branch information
tszumski authored Sep 2, 2024
1 parent 9c25694 commit dde0aae
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 3 deletions.
87 changes: 87 additions & 0 deletions ffmpeg-plugin/7.0/0001-Enable-FFmpeg-support-in-MCM.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
From 0b5b445454655f3bbe326fef865a418a2de03f08 Mon Sep 17 00:00:00 2001
From: Tomasz Szumski <[email protected]>
Date: Thu, 29 Aug 2024 09:12:42 +0200
Subject: [PATCH] Enable FFmpeg support in MCM

---
configure | 9 +++++++++
libavdevice/Makefile | 5 +++++
libavdevice/alldevices.c | 5 +++++
3 files changed, 19 insertions(+)

diff --git a/configure b/configure
index bde796d03a..f9eb340f7a 100755
--- a/configure
+++ b/configure
@@ -290,6 +290,7 @@ External library support:
--enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]
--enable-libvorbis enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
+ --enable-mcm enable Media Communications Mesh library [no]
--enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no]
--enable-libwebp enable WebP encoding via libwebp [no]
--enable-libx264 enable H.264 encoding via x264 [no]
@@ -1903,6 +1904,7 @@ EXTERNAL_LIBRARY_LIST="
jni
ladspa
lcms2
+ mcm
libaom
libaribcaption
libass
@@ -3665,6 +3667,11 @@ xwma_demuxer_select="riffdec"
android_camera_indev_deps="android camera2ndk mediandk pthreads"
alsa_indev_deps="alsa"
alsa_outdev_deps="alsa"
+mcm_indev_deps="libmcm_dp"
+mcm_outdev_deps="libmcm_dp"
+mcm_audio_indev_deps="libmcm_dp"
+mcm_audio_outdev_deps="libmcm_dp"
+mcm_audio_pcm16_outdev_deps="libmcm_dp"
avfoundation_indev_deps="avfoundation corevideo coremedia pthreads"
avfoundation_indev_suggest="coregraphics applicationservices"
avfoundation_indev_extralibs="-framework Foundation"
@@ -6834,6 +6841,8 @@ enabled libaribb24 && { check_pkg_config libaribb24 "aribb24 > 1.0.3" "ar
enabled libaribcaption && require_pkg_config libaribcaption "libaribcaption >= 1.1.1" "aribcaption/aribcaption.h" aribcc_context_alloc
enabled lv2 && require_pkg_config lv2 lilv-0 "lilv/lilv.h" lilv_world_new
enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
+enabled mcm && { check_pkg_config libmcm_dp "libmcm_dp >= 24.00" mcm_dp.h mcm_dequeue_buffer ||
+ die "ERROR: libmcm_dp must be installed and version must be >= 24.00"; }
enabled libass && require_pkg_config libass "libass >= 0.11.0" ass/ass.h ass_library_init
enabled libbluray && require_pkg_config libbluray libbluray libbluray/bluray.h bd_open
enabled libbs2b && require_pkg_config libbs2b libbs2b bs2b.h bs2b_open
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index c30449201d..62bda757c3 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -20,6 +20,11 @@ OBJS-$(CONFIG_AUDIOTOOLBOX_OUTDEV) += audiotoolbox.o
OBJS-$(CONFIG_AVFOUNDATION_INDEV) += avfoundation.o
OBJS-$(CONFIG_BKTR_INDEV) += bktr.o
OBJS-$(CONFIG_CACA_OUTDEV) += caca.o
+OBJS-$(CONFIG_MCM_INDEV) += mcm_video_rx.o mcm_common.o
+OBJS-$(CONFIG_MCM_OUTDEV) += mcm_video_tx.o mcm_common.o
+OBJS-$(CONFIG_MCM_AUDIO_INDEV) += mcm_audio_rx.o mcm_common.o
+OBJS-$(CONFIG_MCM_AUDIO_OUTDEV) += mcm_audio_tx.o mcm_common.o
+OBJS-$(CONFIG_MCM_AUDIO_PCM16_OUTDEV) += mcm_audio_tx.o mcm_common.o
OBJS-$(CONFIG_DECKLINK_OUTDEV) += decklink_enc.o decklink_enc_c.o decklink_common.o
OBJS-$(CONFIG_DECKLINK_INDEV) += decklink_dec.o decklink_dec_c.o decklink_common.o
OBJS-$(CONFIG_DSHOW_INDEV) += dshow_crossbar.o dshow.o dshow_enummediatypes.o \
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 9b9a9146c7..a95f68850c 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -29,6 +29,11 @@ FF_VISIBILITY_PUSH_HIDDEN
/* devices */
extern const FFInputFormat ff_alsa_demuxer;
extern const FFOutputFormat ff_alsa_muxer;
+extern const FFInputFormat ff_mcm_demuxer;
+extern const FFOutputFormat ff_mcm_muxer;
+extern const FFInputFormat ff_mcm_audio_demuxer;
+extern const FFOutputFormat ff_mcm_audio_muxer;
+extern const FFOutputFormat ff_mcm_audio_pcm16_muxer;
extern const FFInputFormat ff_android_camera_demuxer;
extern const FFOutputFormat ff_audiotoolbox_muxer;
extern const FFInputFormat ff_avfoundation_demuxer;
--
2.45.1.windows.1

3 changes: 2 additions & 1 deletion ffmpeg-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ Install dependencies and build MCM as described in the top level README.md, para

### Build flow

1. Clone the FFmpeg repository and apply MCM patches
1. Clone the FFmpeg repository (Release 7.0 by default) and apply MCM patches

```bash
./clone-and-patch-ffmpeg.sh
```
**Note:** For FFmpeg Release 6.1, replace `7.0` with `6.1` in the above cloning script

2. Run the FFmpeg configuration tool

Expand Down
4 changes: 2 additions & 2 deletions ffmpeg-plugin/clone-and-patch-ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")"
BUILD_DIR="${BUILD_DIR:-${SCRIPT_DIR}/build}"
. "${SCRIPT_DIR}/../common.sh"

# Default to latest 6.1
FFMPEG_VER="${FFMPEG_VER:-6.1}"
# Default to latest 7.0
FFMPEG_VER="${FFMPEG_VER:-7.0}"

rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
Expand Down
16 changes: 16 additions & 0 deletions ffmpeg-plugin/mcm_audio_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include "libavformat/internal.h"
#include "libavdevice/mcm_common.h"
#include <mcm_dp.h>
#ifdef MCM_FFMPEG_7_0
#include "libavformat/demux.h"
#endif /* MCM_FFMPEG_7_0 */

typedef struct McmAudioDemuxerContext {
const AVClass *class; /**< Class for private options. */
Expand Down Expand Up @@ -166,6 +169,18 @@ static const AVClass mcm_audio_demuxer_class = {
.category = AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT,
};

#ifdef MCM_FFMPEG_7_0
FFInputFormat ff_mcm_audio_demuxer = {
.p.name = "mcm_audio",
.p.long_name = NULL_IF_CONFIG_SMALL("Media Communications Mesh audio"),
.priv_data_size = sizeof(McmAudioDemuxerContext),
.read_header = mcm_audio_read_header,
.read_packet = mcm_audio_read_packet,
.read_close = mcm_audio_read_close,
.p.flags = AVFMT_NOFILE,
.p.priv_class = &mcm_audio_demuxer_class,
};
#else /* MCM_FFMPEG_7_0 */
AVInputFormat ff_mcm_audio_demuxer = {
.name = "mcm_audio",
.long_name = NULL_IF_CONFIG_SMALL("Media Communications Mesh audio"),
Expand All @@ -176,3 +191,4 @@ AVInputFormat ff_mcm_audio_demuxer = {
.flags = AVFMT_NOFILE,
.priv_class = &mcm_audio_demuxer_class,
};
#endif /* MCM_FFMPEG_7_0 */
6 changes: 6 additions & 0 deletions ffmpeg-plugin/mcm_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ extern "C" {

#include "libavformat/avformat.h"
#include <mcm_dp.h>
#include "libavdevice/version.h"
#if LIBAVDEVICE_VERSION_MAJOR <= 60
#define MCM_FFMPEG_6_1
#else /* LIBAVDEVICE_VERSION_MAJOR <= 60 */
#define MCM_FFMPEG_7_0
#endif /* LIBAVDEVICE_VERSION_MAJOR <= 60 */

int mcm_parse_conn_param(AVFormatContext* avctx, mcm_conn_param *param,
transfer_type type, char *ip_addr, char *port,
Expand Down
18 changes: 18 additions & 0 deletions ffmpeg-plugin/mcm_video_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include "libavformat/internal.h"
#include "libavdevice/mcm_common.h"
#include <mcm_dp.h>
#ifdef MCM_FFMPEG_7_0
#include "libavformat/demux.h"
#endif /* MCM_FFMPEG_7_0 */

typedef struct McmVideoDemuxerContext {
const AVClass *class; /**< Class for private options. */
Expand Down Expand Up @@ -210,6 +213,20 @@ static const AVClass mcm_video_demuxer_class = {
.category = AV_CLASS_CATEGORY_DEVICE_INPUT,
};

#ifdef MCM_FFMPEG_7_0
FFInputFormat ff_mcm_demuxer = {
.p.name = "mcm",
.p.long_name = NULL_IF_CONFIG_SMALL("Media Communications Mesh video"),
.priv_data_size = sizeof(McmVideoDemuxerContext),
.read_header = mcm_video_read_header,
.read_packet = mcm_video_read_packet,
.read_close = mcm_video_read_close,
.p.flags = AVFMT_NOFILE,
.p.extensions = "mcm",
.raw_codec_id = AV_CODEC_ID_RAWVIDEO,
.p.priv_class = &mcm_video_demuxer_class,
};
#else /* MCM_FFMPEG_7_0 */
AVInputFormat ff_mcm_demuxer = {
.name = "mcm",
.long_name = NULL_IF_CONFIG_SMALL("Media Communications Mesh video"),
Expand All @@ -222,3 +239,4 @@ AVInputFormat ff_mcm_demuxer = {
.raw_codec_id = AV_CODEC_ID_RAWVIDEO,
.priv_class = &mcm_video_demuxer_class,
};
#endif /* MCM_FFMPEG_7_0 */

0 comments on commit dde0aae

Please sign in to comment.