From: "Jan Ekström" <jeebjp@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH v2] avformat/mpegts: set data broadcast streams as such
Date: Mon, 11 Apr 2022 13:50:31 +0300
Message-ID: <20220411105031.7924-1-jeebjp@gmail.com> (raw)
From: Jan Ekström <jan.ekstrom@24i.com>
Additionally, they should not be probed, as this is essentially
various types of binary data.
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
libavformat/mpegts.c | 53 +++++++++++++++++++++
tests/fate/mpegts.mak | 3 ++
tests/ref/fate/mpegts-probe-sdt-data-stream | 14 ++++++
3 files changed, 70 insertions(+)
create mode 100644 tests/ref/fate/mpegts-probe-sdt-data-stream
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 49f7735123..d41f7fc8bd 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2516,6 +2516,13 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
}
}
p = desc_list_end;
+
+ if (!ts->pkt && (stream_type >= 0x80 && stream_type <= 0xFF) &&
+ st->codecpar->codec_id == AV_CODEC_ID_NONE)
+ // if we are reading headers, and still have a user private stream
+ // with no proper codec set, do not stop reading at PMT. Data
+ // streams are marked within SDT.
+ ts->stop_parse = 0;
}
if (!ts->pids[pcr_pid])
@@ -2699,6 +2706,7 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
if (val < 0)
return;
for (;;) {
+ struct Program *program = NULL;
sid = get16(&p, p_end);
if (sid < 0)
break;
@@ -2712,6 +2720,15 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
desc_list_end = p + desc_list_len;
if (desc_list_end > p_end)
break;
+
+ program = get_program(ts, sid);
+
+ if (!ts->pkt && program && program->pmt_found)
+ // if during header reading we have already received a PMT for
+ // this program and now have received an SDT for it, stop further
+ // reading at this point.
+ ts->stop_parse = 2;
+
for (;;) {
desc_tag = get8(&p, desc_list_end);
if (desc_tag < 0)
@@ -2744,6 +2761,42 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
av_free(name);
av_free(provider_name);
break;
+ case 0x64: /* ETSI data broadcast descriptor; EN 300 468 6.2.11 */
+ if (desc_len < 3)
+ // length of the always available header part, up to and
+ // including the component_tag field.
+ break;
+
+ {
+ AVStream *st = NULL;
+ FFStream *sti = NULL;
+
+ int data_broadcast_id = get16(&p, desc_end); // TS 101 162
+ int component_tag = get8(&p, desc_end);
+ if (!component_tag)
+ // no stream mapping according to component_tag
+ break;
+
+ av_log(ts->stream, AV_LOG_TRACE,
+ "data broadcast id: %d, component tag: %d\n",
+ data_broadcast_id, component_tag);
+
+ if (!program)
+ break;
+
+ st = find_matching_stream(ts, 0, sid, component_tag + 1, 0,
+ program);
+ if (!st)
+ break;
+
+ sti = ffstream(st);
+
+ st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+ st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA;
+ sti->request_probe = sti->need_parsing = 0;
+ sti->need_context_update = 1;
+ break;
+ }
default:
break;
}
diff --git a/tests/fate/mpegts.mak b/tests/fate/mpegts.mak
index bbcbfc47b2..ae21ee87d0 100644
--- a/tests/fate/mpegts.mak
+++ b/tests/fate/mpegts.mak
@@ -19,6 +19,9 @@ FATE_MPEGTS_PROBE-$(call DEMDEC, MPEGTS) += fate-mpegts-probe-pmt-merge
fate-mpegts-probe-pmt-merge: SRC = $(TARGET_SAMPLES)/mpegts/pmtchange.ts
fate-mpegts-probe-pmt-merge: CMD = run $(PROBE_CODEC_NAME_COMMAND) -merge_pmt_versions 1 -i "$(SRC)"
+FATE_MPEGTS_PROBE-$(call DEMDEC, MPEGTS, MP2) += fate-mpegts-probe-sdt-data-stream
+fate-mpegts-probe-sdt-data-stream: SRC = $(TARGET_SAMPLES)/mpegts/mpegts_sdt_data_stream.ts
+fate-mpegts-probe-sdt-data-stream: CMD = run $(PROBE_CODEC_NAME_COMMAND) -i "$(SRC)"
FATE_SAMPLES_FFPROBE += $(FATE_MPEGTS_PROBE-yes)
diff --git a/tests/ref/fate/mpegts-probe-sdt-data-stream b/tests/ref/fate/mpegts-probe-sdt-data-stream
new file mode 100644
index 0000000000..0b8e90962f
--- /dev/null
+++ b/tests/ref/fate/mpegts-probe-sdt-data-stream
@@ -0,0 +1,14 @@
+[PROGRAM]
+[STREAM]
+codec_name=mp2
+[/STREAM]
+[STREAM]
+codec_name=bin_data
+[/STREAM]
+[/PROGRAM]
+[STREAM]
+codec_name=mp2
+[/STREAM]
+[STREAM]
+codec_name=bin_data
+[/STREAM]
--
2.35.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-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2022-04-11 10:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-11 10:50 Jan Ekström [this message]
2022-04-11 13:31 ` Jan Ekström
2022-04-14 6:59 ` Jan Ekström
2022-04-19 0:00 ` Marton Balint
2022-04-19 10:13 ` Jan Ekström
2022-04-19 14:08 ` Jan Ekström
2022-04-19 20:06 ` Marton Balint
2022-04-25 10:36 ` Jan Ekström
2022-04-25 11:33 ` Jan Ekström
2022-04-25 12:19 ` Jan Ekström
2022-04-25 14:45 ` Jan Ekström
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220411105031.7924-1-jeebjp@gmail.com \
--to=jeebjp@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git