[FFmpeg-devel] [PATCH v2] avformat: add MMTP parser and MMT/TLV demuxer

2023-04-28 Thread SuperFashi
v0 -> v1: Refactor using GetByteContext; Fix compile error.

This patch adds an MPEG Media Transport Protocol (MMTP) parser, as defined in 
ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV) demuxer, as 
defined in ARIB STD-B32. Currently, it supports HEVC, AAC LATM, and ARIB-TTML 
demuxing.

Since MMTP is designed to transmit over IP, there is no size information within 
each MMTP packet, and there is no filesystem format defined alongside the 
protocol. One industrial solution is a simple container format using 
type–length–value packets, which is defined in ARIB STD-B32.

Another known container format for MMTP is using packet capture (pcap) files 
which records network packets. This patch does not include the demuxer for this 
container format.

Signed-off-by: SuperFashi 
---
 Changelog|1 +
 doc/demuxers.texi|4 +
 libavformat/Makefile |1 +
 libavformat/allformats.c |1 +
 libavformat/mmtp.c   | 1375 ++
 libavformat/mmtp.h   |   61 ++
 libavformat/mmttlv.c |  324 +
 libavformat/version.h|2 +-
 8 files changed, 1768 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/mmtp.c
 create mode 100644 libavformat/mmtp.h
 create mode 100644 libavformat/mmttlv.c

diff --git a/Changelog b/Changelog
index b6f6682904..2483fdd547 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ version :
 - Playdate video decoder and demuxer
 - Extend VAAPI support for libva-win32 on Windows
 - afireqsrc audio source filter
+- MMTP parser and MMT/TLV demuxer
 
 version 6.0:
 - Radiance HDR image support
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 2d33b47a56..56aab251b2 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -689,6 +689,10 @@ Set the sample rate for libopenmpt to output.
 Range is from 1000 to INT_MAX. The value default is 48000.
 @end table
 
+@section mmttlv
+
+Demuxer for MMT protocol over TLV packets (MMT/TLV), as defined in ARIB 
STD-B32.
+
 @section mov/mp4/3gp
 
 Demuxer for Quicktime File Format & ISO/IEC Base Media File Format (ISO/IEC 
14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
diff --git a/libavformat/Makefile b/libavformat/Makefile
index f8ad7c6a11..e32d6e71a3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -354,6 +354,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o 
riffdec.o
 OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
 OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
 OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
+OBJS-$(CONFIG_MMTTLV_DEMUXER)+= mmtp.o mmttlv.o
 OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index efdb34e29d..d5f4f5680e 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -270,6 +270,7 @@ extern const AVInputFormat  ff_mlv_demuxer;
 extern const AVInputFormat  ff_mm_demuxer;
 extern const AVInputFormat  ff_mmf_demuxer;
 extern const FFOutputFormat ff_mmf_muxer;
+extern const AVInputFormat  ff_mmttlv_demuxer;
 extern const AVInputFormat  ff_mods_demuxer;
 extern const AVInputFormat  ff_moflex_demuxer;
 extern const AVInputFormat  ff_mov_demuxer;
diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
new file mode 100644
index 00..a2f98e39f6
--- /dev/null
+++ b/libavformat/mmtp.c
@@ -0,0 +1,1375 @@
+/*
+ * MPEG Media Transport Protocol (MMTP) parser, as defined in ISO/IEC 23008-1.
+ * Copyright (c) 2023 SuperFashi
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "libavutil/mem.h"
+#include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
+#include "libavcodec/bytestream.h"
+#include "network.h"
+#include "mmtp.h"
+#include "internal.h"
+#include "demux.h"
+
+#include 
+
+#define AVERROR_INVALIDDATA (abort(), 0)
+
+#define ENSURE_BS_LEFT(bs, size) if (bytestream2_get_bytes_left(bs) < (size)) 
return AVERROR_INVALIDDATA
+
+struct MMTGeneralLocationInfo {
+uint8_t location_type;
+union {
+struct {
+ 

[FFmpeg-devel] [PATCH v4] avformat: add MMTP parser and MMT/TLV demuxer

2023-04-28 Thread SuperFashi
v1 -> v2: Refactor using GetByteContext; Fix compile error.
v2 -> v3: Remove debug statement.
v3 -> v4: Squash commits (sorry, first time git patch user :(

This patch adds an MPEG Media Transport Protocol (MMTP) parser, as defined in 
ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV) demuxer, as 
defined in ARIB STD-B32. Currently, it supports HEVC, AAC LATM, and ARIB-TTML 
demuxing.

Since MMTP is designed to transmit over IP, there is no size information within 
each MMTP packet, and there is no filesystem format defined alongside the 
protocol. One industrial solution is a simple container format using 
type–length–value packets, which is defined in ARIB STD-B32.

Another known container format for MMTP is using packet capture (pcap) files 
which records network packets. This patch does not include the demuxer for this 
container format.

Signed-off-by: SuperFashi 
---
 Changelog|1 +
 doc/demuxers.texi|4 +
 libavformat/Makefile |1 +
 libavformat/allformats.c |1 +
 libavformat/mmtp.c   | 1372 ++
 libavformat/mmtp.h   |   61 ++
 libavformat/mmttlv.c |  324 +
 libavformat/version.h|2 +-
 8 files changed, 1765 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/mmtp.c
 create mode 100644 libavformat/mmtp.h
 create mode 100644 libavformat/mmttlv.c

diff --git a/Changelog b/Changelog
index b6f6682904..2483fdd547 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ version :
 - Playdate video decoder and demuxer
 - Extend VAAPI support for libva-win32 on Windows
 - afireqsrc audio source filter
+- MMTP parser and MMT/TLV demuxer
 
 version 6.0:
 - Radiance HDR image support
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 2d33b47a56..56aab251b2 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -689,6 +689,10 @@ Set the sample rate for libopenmpt to output.
 Range is from 1000 to INT_MAX. The value default is 48000.
 @end table
 
+@section mmttlv
+
+Demuxer for MMT protocol over TLV packets (MMT/TLV), as defined in ARIB 
STD-B32.
+
 @section mov/mp4/3gp
 
 Demuxer for Quicktime File Format & ISO/IEC Base Media File Format (ISO/IEC 
14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
diff --git a/libavformat/Makefile b/libavformat/Makefile
index f8ad7c6a11..e32d6e71a3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -354,6 +354,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o 
riffdec.o
 OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
 OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
 OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
+OBJS-$(CONFIG_MMTTLV_DEMUXER)+= mmtp.o mmttlv.o
 OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index efdb34e29d..d5f4f5680e 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -270,6 +270,7 @@ extern const AVInputFormat  ff_mlv_demuxer;
 extern const AVInputFormat  ff_mm_demuxer;
 extern const AVInputFormat  ff_mmf_demuxer;
 extern const FFOutputFormat ff_mmf_muxer;
+extern const AVInputFormat  ff_mmttlv_demuxer;
 extern const AVInputFormat  ff_mods_demuxer;
 extern const AVInputFormat  ff_moflex_demuxer;
 extern const AVInputFormat  ff_mov_demuxer;
diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
new file mode 100644
index 00..ba1fcab281
--- /dev/null
+++ b/libavformat/mmtp.c
@@ -0,0 +1,1372 @@
+/*
+ * MPEG Media Transport Protocol (MMTP) parser, as defined in ISO/IEC 23008-1.
+ * Copyright (c) 2023 SuperFashi
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "libavutil/mem.h"
+#include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
+#include "libavcodec/bytestream.h"
+#include "network.h"
+#include "mmtp.h"
+#include "internal.h"
+#include "demux.h"
+
+#include 
+
+#define ENSURE_BS_LEFT(bs, size) if (bytestream2_get_bytes_left(bs) < (size)) 
return AVERROR_INVALIDDATA
+
+struct MMTGeneralLocationI

[FFmpeg-devel] [PATCH v3] avformat: add MMTP parser and MMT/TLV demuxer

2023-04-28 Thread SuperFashi
v0 -> v1: Refactor using GetByteContext; Fix compile error.
v1 -> v2: Remove debug statement.

This patch adds an MPEG Media Transport Protocol (MMTP) parser, as defined in 
ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV) demuxer, as 
defined in ARIB STD-B32. Currently, it supports HEVC, AAC LATM, and ARIB-TTML 
demuxing.

Since MMTP is designed to transmit over IP, there is no size information within 
each MMTP packet, and there is no filesystem format defined alongside the 
protocol. One industrial solution is a simple container format using 
type–length–value packets, which is defined in ARIB STD-B32.

Another known container format for MMTP is using packet capture (pcap) files 
which records network packets. This patch does not include the demuxer for this 
container format.

Signed-off-by: SuperFashi 
---
 libavformat/mmtp.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
index a2f98e39f6..ba1fcab281 100644
--- a/libavformat/mmtp.c
+++ b/libavformat/mmtp.c
@@ -29,8 +29,6 @@
 
 #include 
 
-#define AVERROR_INVALIDDATA (abort(), 0)
-
 #define ENSURE_BS_LEFT(bs, size) if (bytestream2_get_bytes_left(bs) < (size)) 
return AVERROR_INVALIDDATA
 
 struct MMTGeneralLocationInfo {
@@ -115,7 +113,6 @@ static inline int parse_mmt_general_location_info(struct 
MMTGeneralLocationInfo
 return 0;
 }
 
-
 struct Streams {
 AVStream *stream;
 
@@ -155,7 +152,7 @@ struct MMTPContext {
 AVFormatContext *s;
 AVPacket*pkt;
 uint16_tcurrent_pid;
-bool is_rap;
+boolis_rap;
 };
 
 static inline struct Streams *find_current_stream(struct MMTPContext *ctx) {
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] avformat: add MMTP parser and MMT/TLV demuxer

2023-04-28 Thread SuperFashi
This patch adds an MPEG Media Transport Protocol (MMTP) parser, as defined in 
ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV) demuxer, as 
defined in ARIB STD-B32. Currently, it supports hevc, aac (loas), and arib-ttml 
demuxing.

Since MMTP is designed to transmit over IP, there is no size information within 
each MMTP packet, and there is no filesystem format defined alongside the 
protocol. One of the solution is a simple container format using 
type–length–value packets, which is defined in ARIB STD-B32.

Another known container format for MMTP is using packet capture (pcap) files 
which records network packets. This patch does not include the demuxer for this 
container format.

Signed-off-by: SuperFashi 
---
 Changelog|1 +
 doc/demuxers.texi|4 +
 libavformat/Makefile |1 +
 libavformat/allformats.c |1 +
 libavformat/mmtp.c   | 1169 ++
 libavformat/mmtp.h   |   61 ++
 libavformat/mmttlv.c |  324 +++
 libavformat/version.h|2 +-
 8 files changed, 1562 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/mmtp.c
 create mode 100644 libavformat/mmtp.h
 create mode 100644 libavformat/mmttlv.c

diff --git a/Changelog b/Changelog
index b6f6682904..2483fdd547 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ version :
 - Playdate video decoder and demuxer
 - Extend VAAPI support for libva-win32 on Windows
 - afireqsrc audio source filter
+- MMTP parser and MMT/TLV demuxer
 
 version 6.0:
 - Radiance HDR image support
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 2d33b47a56..56aab251b2 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -689,6 +689,10 @@ Set the sample rate for libopenmpt to output.
 Range is from 1000 to INT_MAX. The value default is 48000.
 @end table
 
+@section mmttlv
+
+Demuxer for MMT protocol over TLV packets (MMT/TLV), as defined in ARIB 
STD-B32.
+
 @section mov/mp4/3gp
 
 Demuxer for Quicktime File Format & ISO/IEC Base Media File Format (ISO/IEC 
14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
diff --git a/libavformat/Makefile b/libavformat/Makefile
index f8ad7c6a11..e32d6e71a3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -354,6 +354,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o 
riffdec.o
 OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
 OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
 OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
+OBJS-$(CONFIG_MMTTLV_DEMUXER)+= mmtp.o mmttlv.o
 OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index efdb34e29d..d5f4f5680e 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -270,6 +270,7 @@ extern const AVInputFormat  ff_mlv_demuxer;
 extern const AVInputFormat  ff_mm_demuxer;
 extern const AVInputFormat  ff_mmf_demuxer;
 extern const FFOutputFormat ff_mmf_muxer;
+extern const AVInputFormat  ff_mmttlv_demuxer;
 extern const AVInputFormat  ff_mods_demuxer;
 extern const AVInputFormat  ff_moflex_demuxer;
 extern const AVInputFormat  ff_mov_demuxer;
diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
new file mode 100644
index 00..cb40b822fb
--- /dev/null
+++ b/libavformat/mmtp.c
@@ -0,0 +1,1169 @@
+/*
+ * MPEG Media Transport Protocol (MMTP) parser, as defined in ISO/IEC 23008-1.
+ * Copyright (c) 2023 SuperFashi
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "libavutil/mem.h"
+#include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
+#include "network.h"
+#include "mmtp.h"
+#include "internal.h"
+#include "demux.h"
+
+#include 
+
+#define LIMIT_READ(consume, block) \
+if (size < (consume)) return AVERROR_INVALIDDATA; \
+block; \
+buf += (consume); \
+size -= (consume);
+
+#define MUST_CONSUME(consume) \
+av_assert1((consume) <= size); \
+buf += (consume); \
+size -= (consume);
+
+struct MMTGeneralLocationInfo {
+uint8_t location_type;

Re: [FFmpeg-devel] [PATCH v2] avformat: add MMTP parser and MMT/TLV demuxer

2023-04-29 Thread SuperFashi
Please see new version.

On Sat, Apr 29, 2023 at 20:38 Jean-Baptiste Kempf  wrote:

> On Sat, 29 Apr 2023, at 07:44, SuperFashi wrote:
> > +#define AVERROR_INVALIDDATA (abort(), 0)
>
> Why are you aborting?
>
> --
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v4] avformat: add MMTP parser and MMT/TLV demuxer

2023-04-29 Thread SuperFashi
Thanks. Is there anything else that does not fit codebase tradition? Please
point everything out so I could send a new patch.

On Sun, Apr 30, 2023 at 3:06 AM Michael Niedermayer 
wrote:

> On Sat, Apr 29, 2023 at 02:53:06PM +0900, SuperFashi wrote:
> > v1 -> v2: Refactor using GetByteContext; Fix compile error.
> > v2 -> v3: Remove debug statement.
> > v3 -> v4: Squash commits (sorry, first time git patch user :(
> >
> > This patch adds an MPEG Media Transport Protocol (MMTP) parser, as
> defined in ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV)
> demuxer, as defined in ARIB STD-B32. Currently, it supports HEVC, AAC LATM,
> and ARIB-TTML demuxing.
> >
> > Since MMTP is designed to transmit over IP, there is no size information
> within each MMTP packet, and there is no filesystem format defined
> alongside the protocol. One industrial solution is a simple container
> format using type–length–value packets, which is defined in ARIB STD-B32.
> >
> > Another known container format for MMTP is using packet capture (pcap)
> files which records network packets. This patch does not include the
> demuxer for this container format.
> >
> > Signed-off-by: SuperFashi 
> > ---
> >  Changelog|1 +
> >  doc/demuxers.texi|4 +
> >  libavformat/Makefile |1 +
> >  libavformat/allformats.c |1 +
> >  libavformat/mmtp.c   | 1372 ++
> >  libavformat/mmtp.h   |   61 ++
> >  libavformat/mmttlv.c |  324 +
> >  libavformat/version.h|2 +-
> >  8 files changed, 1765 insertions(+), 1 deletion(-)
> >  create mode 100644 libavformat/mmtp.c
> >  create mode 100644 libavformat/mmtp.h
> >  create mode 100644 libavformat/mmttlv.c
> >
> > diff --git a/Changelog b/Changelog
> > index b6f6682904..2483fdd547 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -6,6 +6,7 @@ version :
> >  - Playdate video decoder and demuxer
> >  - Extend VAAPI support for libva-win32 on Windows
> >  - afireqsrc audio source filter
> > +- MMTP parser and MMT/TLV demuxer
> >
> >  version 6.0:
> >  - Radiance HDR image support
> > diff --git a/doc/demuxers.texi b/doc/demuxers.texi
> > index 2d33b47a56..56aab251b2 100644
> > --- a/doc/demuxers.texi
> > +++ b/doc/demuxers.texi
> > @@ -689,6 +689,10 @@ Set the sample rate for libopenmpt to output.
> >  Range is from 1000 to INT_MAX. The value default is 48000.
> >  @end table
> >
> > +@section mmttlv
> > +
> > +Demuxer for MMT protocol over TLV packets (MMT/TLV), as defined in ARIB
> STD-B32.
> > +
> >  @section mov/mp4/3gp
> >
> >  Demuxer for Quicktime File Format & ISO/IEC Base Media File Format
> (ISO/IEC 14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
> > diff --git a/libavformat/Makefile b/libavformat/Makefile
> > index f8ad7c6a11..e32d6e71a3 100644
> > --- a/libavformat/Makefile
> > +++ b/libavformat/Makefile
> > @@ -354,6 +354,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o
> riffdec.o
> >  OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
> >  OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
> >  OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
> > +OBJS-$(CONFIG_MMTTLV_DEMUXER)+= mmtp.o mmttlv.o
> >  OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
> >  OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
> >  OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o
> \
> > diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> > index efdb34e29d..d5f4f5680e 100644
> > --- a/libavformat/allformats.c
> > +++ b/libavformat/allformats.c
> > @@ -270,6 +270,7 @@ extern const AVInputFormat  ff_mlv_demuxer;
> >  extern const AVInputFormat  ff_mm_demuxer;
> >  extern const AVInputFormat  ff_mmf_demuxer;
> >  extern const FFOutputFormat ff_mmf_muxer;
> > +extern const AVInputFormat  ff_mmttlv_demuxer;
> >  extern const AVInputFormat  ff_mods_demuxer;
> >  extern const AVInputFormat  ff_moflex_demuxer;
> >  extern const AVInputFormat  ff_mov_demuxer;
> > diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
> > new file mode 100644
> > index 00..ba1fcab281
> > --- /dev/null
> > +++ b/libavformat/mmtp.c
> > @@ -0,0 +1,1372 @@
> > +/*
> > + * MPEG Media Transport Protocol (MMTP) parser, as defined in ISO/IEC
> 23008-1.
> > + * Copyright (c) 2023 SuperFashi
> > + *
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg is f

Re: [FFmpeg-devel] [PATCH v4] avformat: add MMTP parser and MMT/TLV demuxer

2023-04-30 Thread SuperFashi
Thanks for the feedback. I thought across libraries meant across different
muxers/demuxers. In which case, is there any naming scheme for functions
that are only used within lavf? Can i just remove the avpriv_ prefix?

For inline, my habit is to add it when there’s only one place that uses it.
I can remove it.

I will make changes to other parts.

On Mon, May 1, 2023 at 00:14 Anton Khirnov  wrote:

> Quoting SuperFashi (2023-04-30 05:32:46)
> > Thanks. Is there anything else that does not fit codebase tradition?
> Please
> > point everything out so I could send a new patch.
>
> Some quick notes:
> * why are there avpriv_ functions when everything you do is libavformat?
>   avpriv is for sharing functions across libraries
> * header order (first system, then ours, sort each of those
>   alphabetically)
> * opening brace for function declarations should be on its own line
> * very long lines everywhere; we have a soft limit of 80 characters (can
>   be exceeded where really needed, but should be done sparingly)
>   if your code needs more then it's a sign that you have too much
>   indentation or your names are too long
> * inline specifiers all over the place, I think modern compilers largely
>   ignore them; even if they didn't it's better to leave such decisions
>   to compilers in most cases
>
> --
> Anton Khirnov
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v5] avformat: add MMTP parser and MMT/TLV demuxer

2023-05-01 Thread SuperFashi
v1 -> v2: Refactor using GetByteContext; Fix compile error.
v2 -> v3: Remove debug statement.
v3 -> v4: Squash commits
v4 -> v5: Improve portability; Cosmetic changes.

This patch adds an MPEG Media Transport Protocol (MMTP) parser, as defined in 
ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV) demuxer, as 
defined in ARIB STD-B32. Currently, it supports HEVC, AAC LATM, and ARIB-TTML 
demuxing.

Since MMTP is designed to transmit over IP, there is no size information within 
each MMTP packet, and there is no on-disk format defined alongside the 
protocol. One industrial solution is a simple container format using 
type–length–value packets, which is defined in ARIB STD-B32.

Another known container format for MMTP is using packet capture (pcap) files 
which records network packets. This patch does not include the demuxer for this 
container format.

Signed-off-by: SuperFashi 
---
 Changelog|1 +
 doc/demuxers.texi|4 +
 libavformat/Makefile |1 +
 libavformat/allformats.c |1 +
 libavformat/mmtp.c   | 1528 ++
 libavformat/mmtp.h   |   64 ++
 libavformat/mmttlv.c |  334 +
 libavformat/version.h|2 +-
 8 files changed, 1934 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/mmtp.c
 create mode 100644 libavformat/mmtp.h
 create mode 100644 libavformat/mmttlv.c

diff --git a/Changelog b/Changelog
index 4901ef6ad7..594c445ea2 100644
--- a/Changelog
+++ b/Changelog
@@ -7,6 +7,7 @@ version :
 - Extend VAAPI support for libva-win32 on Windows
 - afireqsrc audio source filter
 - arls filter
+- MMTP parser and MMT/TLV demuxer
 
 version 6.0:
 - Radiance HDR image support
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 2d33b47a56..56aab251b2 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -689,6 +689,10 @@ Set the sample rate for libopenmpt to output.
 Range is from 1000 to INT_MAX. The value default is 48000.
 @end table
 
+@section mmttlv
+
+Demuxer for MMT protocol over TLV packets (MMT/TLV), as defined in ARIB 
STD-B32.
+
 @section mov/mp4/3gp
 
 Demuxer for Quicktime File Format & ISO/IEC Base Media File Format (ISO/IEC 
14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
diff --git a/libavformat/Makefile b/libavformat/Makefile
index f8ad7c6a11..e32d6e71a3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -354,6 +354,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o 
riffdec.o
 OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
 OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
 OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
+OBJS-$(CONFIG_MMTTLV_DEMUXER)+= mmtp.o mmttlv.o
 OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index efdb34e29d..d5f4f5680e 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -270,6 +270,7 @@ extern const AVInputFormat  ff_mlv_demuxer;
 extern const AVInputFormat  ff_mm_demuxer;
 extern const AVInputFormat  ff_mmf_demuxer;
 extern const FFOutputFormat ff_mmf_muxer;
+extern const AVInputFormat  ff_mmttlv_demuxer;
 extern const AVInputFormat  ff_mods_demuxer;
 extern const AVInputFormat  ff_moflex_demuxer;
 extern const AVInputFormat  ff_mov_demuxer;
diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
new file mode 100644
index 00..c6eebbff38
--- /dev/null
+++ b/libavformat/mmtp.c
@@ -0,0 +1,1528 @@
+/*
+ * MPEG Media Transport Protocol (MMTP) parser, as defined in ISO/IEC 23008-1.
+ * Copyright (c) 2023 SuperFashi
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavcodec/bytestream.h"
+#include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
+#include "demux.h"
+#include "internal.h"
+#include "mmtp.h"
+#include "network.h"
+
+struct MMTGeneralLocationInfo {
+uint8_t location_type;
+union {
+struct {
+uint16_t packet_id;
+} type0;
+ 

Re: [FFmpeg-devel] [PATCH v5] avformat: add MMTP parser and MMT/TLV demuxer

2023-05-02 Thread SuperFashi
I can remove the NULL checks, sure.

I could change L289 in mmttlv.c to a freep and reset the priv_data. Other
places have no need to change.

On Tue, May 2, 2023 at 9:58 PM Paul B Mahol  wrote:

> Use av_freep(), non need to check for NULL before av_freep() / av_free()
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v6] avformat: add MMTP parser and MMT/TLV demuxer

2023-05-03 Thread SuperFashi
v1 -> v2: Refactor using GetByteContext; Fix compile error.
v2 -> v3: Remove debug statement.
v3 -> v4: Squash commits.
v4 -> v5: Improve portability; Cosmetic changes.
v5 -> v6: remove unnecessary NULL checks.

This patch adds an MPEG Media Transport Protocol (MMTP) parser, as defined in 
ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV) demuxer, as 
defined in ARIB STD-B32. Currently, it supports HEVC, AAC LATM, and ARIB-TTML 
demuxing.

Since MMTP is designed to transmit over IP, there is no size information within 
each MMTP packet, and there is no on-disk format defined alongside the 
protocol. One industrial solution is a simple container format using 
type–length–value packets, which is defined in ARIB STD-B32.

Another known container format for MMTP is using packet capture (pcap) files 
which records network packets. This patch does not include the demuxer for this 
container format.

Signed-off-by: SuperFashi 
---
 Changelog|1 +
 doc/demuxers.texi|4 +
 libavformat/Makefile |1 +
 libavformat/allformats.c |1 +
 libavformat/mmtp.c   | 1525 ++
 libavformat/mmtp.h   |   64 ++
 libavformat/mmttlv.c |  335 +
 libavformat/version.h|2 +-
 8 files changed, 1932 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/mmtp.c
 create mode 100644 libavformat/mmtp.h
 create mode 100644 libavformat/mmttlv.c

diff --git a/Changelog b/Changelog
index 4901ef6ad7..594c445ea2 100644
--- a/Changelog
+++ b/Changelog
@@ -7,6 +7,7 @@ version :
 - Extend VAAPI support for libva-win32 on Windows
 - afireqsrc audio source filter
 - arls filter
+- MMTP parser and MMT/TLV demuxer
 
 version 6.0:
 - Radiance HDR image support
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 2d33b47a56..56aab251b2 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -689,6 +689,10 @@ Set the sample rate for libopenmpt to output.
 Range is from 1000 to INT_MAX. The value default is 48000.
 @end table
 
+@section mmttlv
+
+Demuxer for MMT protocol over TLV packets (MMT/TLV), as defined in ARIB 
STD-B32.
+
 @section mov/mp4/3gp
 
 Demuxer for Quicktime File Format & ISO/IEC Base Media File Format (ISO/IEC 
14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
diff --git a/libavformat/Makefile b/libavformat/Makefile
index f8ad7c6a11..e32d6e71a3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -354,6 +354,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o 
riffdec.o
 OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
 OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
 OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
+OBJS-$(CONFIG_MMTTLV_DEMUXER)+= mmtp.o mmttlv.o
 OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index efdb34e29d..d5f4f5680e 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -270,6 +270,7 @@ extern const AVInputFormat  ff_mlv_demuxer;
 extern const AVInputFormat  ff_mm_demuxer;
 extern const AVInputFormat  ff_mmf_demuxer;
 extern const FFOutputFormat ff_mmf_muxer;
+extern const AVInputFormat  ff_mmttlv_demuxer;
 extern const AVInputFormat  ff_mods_demuxer;
 extern const AVInputFormat  ff_moflex_demuxer;
 extern const AVInputFormat  ff_mov_demuxer;
diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
new file mode 100644
index 00..6f002cc827
--- /dev/null
+++ b/libavformat/mmtp.c
@@ -0,0 +1,1525 @@
+/*
+ * MPEG Media Transport Protocol (MMTP) parser, as defined in ISO/IEC 23008-1.
+ * Copyright (c) 2023 SuperFashi
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavcodec/bytestream.h"
+#include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
+#include "demux.h"
+#include "internal.h"
+#include "mmtp.h"
+#include "network.h"
+
+struct MMTGeneralLocationInfo {
+uint8_t location_type;
+union {
+struct {
+  

Re: [FFmpeg-devel] [PATCH v6] avformat: add MMTP parser and MMT/TLV demuxer

2023-05-17 Thread SuperFashi
Bumping this, thx.

On Wed, May 3, 2023 at 22:02 SuperFashi  wrote:

> v1 -> v2: Refactor using GetByteContext; Fix compile error.
> v2 -> v3: Remove debug statement.
> v3 -> v4: Squash commits.
> v4 -> v5: Improve portability; Cosmetic changes.
> v5 -> v6: remove unnecessary NULL checks.
>
> This patch adds an MPEG Media Transport Protocol (MMTP) parser, as defined
> in ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV) demuxer,
> as defined in ARIB STD-B32. Currently, it supports HEVC, AAC LATM, and
> ARIB-TTML demuxing.
>
> Since MMTP is designed to transmit over IP, there is no size information
> within each MMTP packet, and there is no on-disk format defined alongside
> the protocol. One industrial solution is a simple container format using
> type–length–value packets, which is defined in ARIB STD-B32.
>
> Another known container format for MMTP is using packet capture (pcap)
> files which records network packets. This patch does not include the
> demuxer for this container format.
>
> Signed-off-by: SuperFashi 
> ---
>  Changelog|1 +
>  doc/demuxers.texi|4 +
>  libavformat/Makefile |1 +
>  libavformat/allformats.c |1 +
>  libavformat/mmtp.c   | 1525 ++
>  libavformat/mmtp.h   |   64 ++
>  libavformat/mmttlv.c |  335 +
>  libavformat/version.h|2 +-
>  8 files changed, 1932 insertions(+), 1 deletion(-)
>  create mode 100644 libavformat/mmtp.c
>  create mode 100644 libavformat/mmtp.h
>  create mode 100644 libavformat/mmttlv.c
>
> diff --git a/Changelog b/Changelog
> index 4901ef6ad7..594c445ea2 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -7,6 +7,7 @@ version :
>  - Extend VAAPI support for libva-win32 on Windows
>  - afireqsrc audio source filter
>  - arls filter
> +- MMTP parser and MMT/TLV demuxer
>
>  version 6.0:
>  - Radiance HDR image support
> diff --git a/doc/demuxers.texi b/doc/demuxers.texi
> index 2d33b47a56..56aab251b2 100644
> --- a/doc/demuxers.texi
> +++ b/doc/demuxers.texi
> @@ -689,6 +689,10 @@ Set the sample rate for libopenmpt to output.
>  Range is from 1000 to INT_MAX. The value default is 48000.
>  @end table
>
> +@section mmttlv
> +
> +Demuxer for MMT protocol over TLV packets (MMT/TLV), as defined in ARIB
> STD-B32.
> +
>  @section mov/mp4/3gp
>
>  Demuxer for Quicktime File Format & ISO/IEC Base Media File Format
> (ISO/IEC 14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index f8ad7c6a11..e32d6e71a3 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -354,6 +354,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o
> riffdec.o
>  OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
>  OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
>  OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
> +OBJS-$(CONFIG_MMTTLV_DEMUXER)+= mmtp.o mmttlv.o
>  OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
>  OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
>  OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index efdb34e29d..d5f4f5680e 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -270,6 +270,7 @@ extern const AVInputFormat  ff_mlv_demuxer;
>  extern const AVInputFormat  ff_mm_demuxer;
>  extern const AVInputFormat  ff_mmf_demuxer;
>  extern const FFOutputFormat ff_mmf_muxer;
> +extern const AVInputFormat  ff_mmttlv_demuxer;
>  extern const AVInputFormat  ff_mods_demuxer;
>  extern const AVInputFormat  ff_moflex_demuxer;
>  extern const AVInputFormat  ff_mov_demuxer;
> diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
> new file mode 100644
> index 00..6f002cc827
> --- /dev/null
> +++ b/libavformat/mmtp.c
> @@ -0,0 +1,1525 @@
> +/*
> + * MPEG Media Transport Protocol (MMTP) parser, as defined in ISO/IEC
> 23008-1.
> + * Copyright (c) 2023 SuperFashi
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a c

Re: [FFmpeg-devel] [PATCH] avformat: add MMTP parser and MMT/TLV demuxer

2023-11-18 Thread SuperFashi
Hi, is there anything I could do to push this forward?

On Sun, Nov 12, 2023 at 19:02 SuperFashi  wrote:

> This patch adds an MPEG Media Transport Protocol (MMTP) parser, as defined
> in ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV) demuxer,
> as defined in ARIB STD-B32. Currently, it supports HEVC, AAC LATM, and
> ARIB-TTML demuxing.
>
> Since MMTP is designed to transmit over IP, there is no size information
> within each MMTP packet, and there is no on-disk format defined alongside
> the protocol. One industrial solution is a simple container format using
> type–length–value packets, which is defined in ARIB STD-B32.
>
> Another known container format for MMTP is using packet capture (pcap)
> files which records network packets. This patch does not include the
> demuxer for this container format.
>
> Signed-off-by: SuperFashi 
> ---
>  Changelog|1 +
>  doc/demuxers.texi|4 +
>  libavformat/Makefile |1 +
>  libavformat/allformats.c |1 +
>  libavformat/mmtp.c   | 1688 ++
>  libavformat/mmtp.h   |   64 ++
>  libavformat/mmttlv.c |  335 
>  libavformat/version.h|2 +-
>  8 files changed, 2095 insertions(+), 1 deletion(-)
>  create mode 100644 libavformat/mmtp.c
>  create mode 100644 libavformat/mmtp.h
>  create mode 100644 libavformat/mmttlv.c
>
> diff --git a/Changelog b/Changelog
> index ca38546262..05118fe1e4 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
>
>  version :
>  - LEAD MCMP decoder
> +- MMTP parser and MMT/TLV demuxer
>
>  version 6.1:
>  - libaribcaption decoder
> diff --git a/doc/demuxers.texi b/doc/demuxers.texi
> index ca1563abb0..69634c09da 100644
> --- a/doc/demuxers.texi
> +++ b/doc/demuxers.texi
> @@ -689,6 +689,10 @@ Set the sample rate for libopenmpt to output.
>  Range is from 1000 to INT_MAX. The value default is 48000.
>  @end table
>
> +@section mmttlv
> +
> +Demuxer for MMT protocol over TLV packets (MMT/TLV), as defined in ARIB
> STD-B32.
> +
>  @section mov/mp4/3gp
>
>  Demuxer for Quicktime File Format & ISO/IEC Base Media File Format
> (ISO/IEC 14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 329055ccfd..a4320e4193 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -359,6 +359,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o
> riffdec.o
>  OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
>  OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
>  OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
> +OBJS-$(CONFIG_MMTTLV_DEMUXER)+= mmtp.o mmttlv.o
>  OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
>  OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
>  OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index d4b505a5a3..afe8bbb1ec 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -275,6 +275,7 @@ extern const AVInputFormat  ff_mlv_demuxer;
>  extern const AVInputFormat  ff_mm_demuxer;
>  extern const AVInputFormat  ff_mmf_demuxer;
>  extern const FFOutputFormat ff_mmf_muxer;
> +extern const AVInputFormat  ff_mmttlv_demuxer;
>  extern const AVInputFormat  ff_mods_demuxer;
>  extern const AVInputFormat  ff_moflex_demuxer;
>  extern const AVInputFormat  ff_mov_demuxer;
> diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
> new file mode 100644
> index 00..5dc45ef309
> --- /dev/null
> +++ b/libavformat/mmtp.c
> @@ -0,0 +1,1688 @@
> +/*
> + * MPEG Media Transport Protocol (MMTP) parser, as defined in ISO/IEC
> 23008-1.
> + * Copyright (c) 2023 SuperFashi
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +#include 
> +
> +#include 

[FFmpeg-devel] [PATCH] avformat: add MMTP parser and MMT/TLV demuxer

2023-11-12 Thread SuperFashi
This patch adds an MPEG Media Transport Protocol (MMTP) parser, as defined in 
ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV) demuxer, as 
defined in ARIB STD-B32. Currently, it supports HEVC, AAC LATM, and ARIB-TTML 
demuxing.

Since MMTP is designed to transmit over IP, there is no size information within 
each MMTP packet, and there is no on-disk format defined alongside the 
protocol. One industrial solution is a simple container format using 
type–length–value packets, which is defined in ARIB STD-B32.

Another known container format for MMTP is using packet capture (pcap) files 
which records network packets. This patch does not include the demuxer for this 
container format.

Signed-off-by: SuperFashi 
---
 Changelog|1 +
 doc/demuxers.texi|4 +
 libavformat/Makefile |1 +
 libavformat/allformats.c |1 +
 libavformat/mmtp.c   | 1688 ++
 libavformat/mmtp.h   |   64 ++
 libavformat/mmttlv.c |  335 
 libavformat/version.h|2 +-
 8 files changed, 2095 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/mmtp.c
 create mode 100644 libavformat/mmtp.h
 create mode 100644 libavformat/mmttlv.c

diff --git a/Changelog b/Changelog
index ca38546262..05118fe1e4 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
 
 version :
 - LEAD MCMP decoder
+- MMTP parser and MMT/TLV demuxer
 
 version 6.1:
 - libaribcaption decoder
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index ca1563abb0..69634c09da 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -689,6 +689,10 @@ Set the sample rate for libopenmpt to output.
 Range is from 1000 to INT_MAX. The value default is 48000.
 @end table
 
+@section mmttlv
+
+Demuxer for MMT protocol over TLV packets (MMT/TLV), as defined in ARIB 
STD-B32.
+
 @section mov/mp4/3gp
 
 Demuxer for Quicktime File Format & ISO/IEC Base Media File Format (ISO/IEC 
14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 329055ccfd..a4320e4193 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -359,6 +359,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o 
riffdec.o
 OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
 OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
 OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
+OBJS-$(CONFIG_MMTTLV_DEMUXER)+= mmtp.o mmttlv.o
 OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d4b505a5a3..afe8bbb1ec 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -275,6 +275,7 @@ extern const AVInputFormat  ff_mlv_demuxer;
 extern const AVInputFormat  ff_mm_demuxer;
 extern const AVInputFormat  ff_mmf_demuxer;
 extern const FFOutputFormat ff_mmf_muxer;
+extern const AVInputFormat  ff_mmttlv_demuxer;
 extern const AVInputFormat  ff_mods_demuxer;
 extern const AVInputFormat  ff_moflex_demuxer;
 extern const AVInputFormat  ff_mov_demuxer;
diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
new file mode 100644
index 00..5dc45ef309
--- /dev/null
+++ b/libavformat/mmtp.c
@@ -0,0 +1,1688 @@
+/*
+ * MPEG Media Transport Protocol (MMTP) parser, as defined in ISO/IEC 23008-1.
+ * Copyright (c) 2023 SuperFashi
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavcodec/bytestream.h"
+#include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
+#include "demux.h"
+#include "internal.h"
+#include "mmtp.h"
+#include "network.h"
+
+struct MMTGeneralLocationInfo {
+uint8_t location_type;
+union {
+struct {
+uint16_t packet_id;
+} type0;
+struct {
+struct in_addr ipv4_src_addr;
+struct in_addr ipv4_dst_addr;
+uint16_t   dst_port;
+uint16_t   packet_id;
+} type1;
+struct {
+