[FFmpeg-devel] [PATCH v2] lavf/libsrt: nonblock enabling correction

2020-01-16 Thread Anthony Delannoy

As requested I negate the value inside the function instead of using directly
the input.

Regards,
Anthony Delannoy

___
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 v2] lavf/libsrt: nonblock enabling correction

2020-01-16 Thread Anthony Delannoy
As written in https://github.com/Haivision/srt/blob/v1.4.1/docs/API.md,
the nonblock mode is activated if SRTO_SNDSYN and SRTO_RCVSYN, for
sending and receiving respectively, are set to 0.
---
 libavformat/libsrt.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 16975b6d94..6e230c254b 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -152,12 +152,21 @@ static int libsrt_neterrno(URLContext *h)
 return AVERROR_UNKNOWN;
 }
 
+/*
+ * SRT functions can also work in blocking and non-blocking mode, for which
+ * there are two separate options for sending and receiving: SRTO_SNDSYN and
+ * SRTO_RCVSYN.
+ * Setting SRTO_{SND,RCV}SYN options to 1 enable blocking mode, setting them
+ * to 0 enable non-blocking mode.
+ */
 static int libsrt_socket_nonblock(int socket, int enable)
 {
-int ret = srt_setsockopt(socket, 0, SRTO_SNDSYN, , sizeof(enable));
+int ret, blocking = enable ? 0 : 1;
+
+ret = srt_setsockopt(socket, 0, SRTO_SNDSYN, , sizeof(blocking));
 if (ret < 0)
 return ret;
-return srt_setsockopt(socket, 0, SRTO_RCVSYN, , sizeof(enable));
+return srt_setsockopt(socket, 0, SRTO_RCVSYN, , sizeof(blocking));
 }
 
 static int libsrt_network_wait_fd(URLContext *h, int eid, int fd, int write)
-- 
2.24.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] lavf/libsrt: nonblock enabling correction

2020-01-15 Thread Anthony Delannoy
As written in https://github.com/Haivision/srt/blob/v1.4.1/docs/API.md,
the nonblock mode is activated if SRTO_SNDSYN and SRTO_RCVSYN, for
sending and receiving respectively, are set to 0.
---
 libavformat/libsrt.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 16975b6d94..60b1dd8e9c 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -152,12 +152,12 @@ static int libsrt_neterrno(URLContext *h)
 return AVERROR_UNKNOWN;
 }
 
-static int libsrt_socket_nonblock(int socket, int enable)
+static int libsrt_socket_nonblock(int socket, int disable)
 {
-int ret = srt_setsockopt(socket, 0, SRTO_SNDSYN, , sizeof(enable));
+int ret = srt_setsockopt(socket, 0, SRTO_SNDSYN, , 
sizeof(disable));
 if (ret < 0)
 return ret;
-return srt_setsockopt(socket, 0, SRTO_RCVSYN, , sizeof(enable));
+return srt_setsockopt(socket, 0, SRTO_RCVSYN, , sizeof(disable));
 }
 
 static int libsrt_network_wait_fd(URLContext *h, int eid, int fd, int write)
@@ -235,7 +235,7 @@ static int libsrt_listen(int eid, int fd, const struct 
sockaddr *addr, socklen_t
 ret = srt_accept(fd, NULL, NULL);
 if (ret < 0)
 return libsrt_neterrno(h);
-if (libsrt_socket_nonblock(ret, 1) < 0)
+if (libsrt_socket_nonblock(ret, 0) < 0)
 av_log(h, AV_LOG_DEBUG, "libsrt_socket_nonblock failed\n");
 
 return ret;
@@ -245,7 +245,7 @@ static int libsrt_listen_connect(int eid, int fd, const 
struct sockaddr *addr, s
 {
 int ret;
 
-if (libsrt_socket_nonblock(fd, 1) < 0)
+if (libsrt_socket_nonblock(fd, 0) < 0)
 av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
 
 while ((ret = srt_connect(fd, addr, addrlen))) {
-- 
2.24.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] lavf/libsrt: Fix typo

2020-01-06 Thread Anthony Delannoy
---
 libavformat/libsrt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index a727b1c3e4..16975b6d94 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -337,9 +337,9 @@ static int libsrt_set_options_pre(URLContext *h, int fd)
 (s->kmrefreshrate >= 0 && libsrt_setsockopt(h, fd, SRTO_KMREFRESHRATE, 
"SRTO_KMREFRESHRATE", >kmrefreshrate, sizeof(s->kmrefreshrate)) < 0) ||
 (s->kmpreannounce >= 0 && libsrt_setsockopt(h, fd, SRTO_KMPREANNOUNCE, 
"SRTO_KMPREANNOUNCE", >kmpreannounce, sizeof(s->kmpreannounce)) < 0) ||
 #endif
-(s->mss >= 0 && libsrt_setsockopt(h, fd, SRTO_MSS, "SRTO_MMS", 
>mss, sizeof(s->mss)) < 0) ||
+(s->mss >= 0 && libsrt_setsockopt(h, fd, SRTO_MSS, "SRTO_MSS", 
>mss, sizeof(s->mss)) < 0) ||
 (s->ffs >= 0 && libsrt_setsockopt(h, fd, SRTO_FC, "SRTO_FC", >ffs, 
sizeof(s->ffs)) < 0) ||
-(s->ipttl >= 0 && libsrt_setsockopt(h, fd, SRTO_IPTTL, "SRTO_UPTTL", 
>ipttl, sizeof(s->ipttl)) < 0) ||
+(s->ipttl >= 0 && libsrt_setsockopt(h, fd, SRTO_IPTTL, "SRTO_IPTTL", 
>ipttl, sizeof(s->ipttl)) < 0) ||
 (s->iptos >= 0 && libsrt_setsockopt(h, fd, SRTO_IPTOS, "SRTO_IPTOS", 
>iptos, sizeof(s->iptos)) < 0) ||
 (s->latency >= 0 && libsrt_setsockopt(h, fd, SRTO_LATENCY, 
"SRTO_LATENCY", , sizeof(latency)) < 0) ||
 (s->rcvlatency >= 0 && libsrt_setsockopt(h, fd, SRTO_RCVLATENCY, 
"SRTO_RCVLATENCY", , sizeof(rcvlatency)) < 0) ||
-- 
2.24.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".

Re: [FFmpeg-devel] [PATCH 3/3] avformat/mpegts: add support for non-standard NIT pid

2019-10-13 Thread Anthony Delannoy
Ping
-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma 
brièveté.
___
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 2/3] avformat/mpegts: add support for NIT extraction

2019-10-03 Thread Anthony Delannoy
---
 libavformat/mpegts.c | 45 +++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 587ed33327..5a3e71d9ab 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -169,7 +169,7 @@ struct MpegTSContext {
 MpegTSFilter *pids[NB_PID_MAX];
 int current_pid;
 
-AVStream *epg_stream;
+AVStream *epg_stream, *nit_stream;
 };
 
 #define MPEGTS_OPTIONS \
@@ -2426,6 +2426,46 @@ out:
 av_free(mp4_descr[i].dec_config_descr);
 }
 
+static void nit_cb(MpegTSFilter *filter, const uint8_t *section, int 
section_len)
+{
+MpegTSContext *ts = filter->u.section_filter.opaque;
+const uint8_t *p, *p_end;
+SectionHeader h1, *h = 
+
+if (!ts->nit_stream) {
+ts->nit_stream = avformat_new_stream(ts->stream, NULL);
+if (!ts->nit_stream)
+return;
+ts->nit_stream->id = NIT_PID;
+ts->nit_stream->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+ts->nit_stream->codecpar->codec_id = AV_CODEC_ID_NIT;
+}
+
+if (ts->nit_stream->discard == AVDISCARD_ALL)
+return;
+
+p_end = section + section_len - 4;
+p = section;
+
+if (parse_section_header(h, , p_end) < 0)
+return;
+if (h->tid != NIT_TID && h->tid != ONIT_TID)
+return;
+
+av_log(ts->stream, AV_LOG_TRACE, "NIT: tid received = %.02x\n", h->tid);
+
+/**
+ * In case we receive a packet before mpegts context is fully
+ * initialized.
+ */
+if (!ts->pkt)
+return;
+
+new_data_packet(section, section_len, ts->pkt);
+ts->pkt->stream_index = ts->nit_stream->index;
+ts->stop_parse = 1;
+}
+
 static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int 
section_len)
 {
 MpegTSContext *ts = filter->u.section_filter.opaque;
@@ -2468,6 +2508,7 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 
 if (sid == 0x) {
 /* NIT info */
+// XXX for now we only use default NIT_PID
 } else {
 MpegTSFilter *fil = ts->pids[pmt_pid];
 program = av_new_program(ts->stream, sid);
@@ -3043,6 +3084,7 @@ static int mpegts_read_header(AVFormatContext *s)
 mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
 mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
 mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);
+mpegts_open_section_filter(ts, NIT_PID, nit_cb, ts, 1);
 
 handle_packets(ts, probesize / ts->raw_packet_size);
 /* if could not find service, enable auto_guess */
@@ -3301,6 +3343,7 @@ MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext 
*s)
 mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
 mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
 mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);
+mpegts_open_section_filter(ts, NIT_PID, nit_cb, ts, 1);
 
 return ts;
 }
-- 
2.23.0

___
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 1/3] avcodec: add NIT codec id

2019-10-03 Thread Anthony Delannoy
hi,

here the first version of NIT table extraction from DVB stream.
Patch 2/3 only open default NIT pid whereas patch 3/3 read PAT table
to open even non-standard NIT pid.

Anthony Delannoy

---
 libavcodec/avcodec.h| 1 +
 libavcodec/codec_desc.c | 6 ++
 libavcodec/version.h| 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index bcb931f0dd..92969ced83 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -691,6 +691,7 @@ enum AVCodecID {

 AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of 
program stream.
 AV_CODEC_ID_EPG,
+AV_CODEC_ID_NIT,
 AV_CODEC_ID_BINTEXT= 0x18800,
 AV_CODEC_ID_XBIN,
 AV_CODEC_ID_IDF,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0602ecb1b5..624befae91 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3203,6 +3203,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .name  = "epg",
 .long_name = NULL_IF_CONFIG_SMALL("Electronic Program Guide"),
 },
+{
+.id= AV_CODEC_ID_NIT,
+.type  = AVMEDIA_TYPE_DATA,
+.name  = "nit",
+.long_name = NULL_IF_CONFIG_SMALL("Network Information Table"),
+},
 {
 .id= AV_CODEC_ID_BINTEXT,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 04b210371e..64e23659f4 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"

 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR  59
+#define LIBAVCODEC_VERSION_MINOR  60
 #define LIBAVCODEC_VERSION_MICRO 101

 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
--
2.23.0
___
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 3/3] avformat/mpegts: add support for non-standard NIT pid

2019-10-03 Thread Anthony Delannoy
---
 libavformat/mpegts.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 5a3e71d9ab..02da272325 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -169,6 +169,7 @@ struct MpegTSContext {
 MpegTSFilter *pids[NB_PID_MAX];
 int current_pid;
 
+int nit_pid;
 AVStream *epg_stream, *nit_stream;
 };
 
@@ -2432,15 +2433,6 @@ static void nit_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 const uint8_t *p, *p_end;
 SectionHeader h1, *h = 
 
-if (!ts->nit_stream) {
-ts->nit_stream = avformat_new_stream(ts->stream, NULL);
-if (!ts->nit_stream)
-return;
-ts->nit_stream->id = NIT_PID;
-ts->nit_stream->codecpar->codec_type = AVMEDIA_TYPE_DATA;
-ts->nit_stream->codecpar->codec_id = AV_CODEC_ID_NIT;
-}
-
 if (ts->nit_stream->discard == AVDISCARD_ALL)
 return;
 
@@ -2508,7 +2500,25 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 
 if (sid == 0x) {
 /* NIT info */
-// XXX for now we only use default NIT_PID
+if (!ts->nit_stream) {
+ts->nit_pid = pmt_pid;
+
+if (ts->nit_pid != NIT_PID)
+av_log(ts->stream, AV_LOG_WARNING,
+   "Using non-standard PID %i for NIT table.\n", 
pmt_pid);
+
+if (ts->pids[ts->nit_pid])
+mpegts_close_filter(ts, ts->pids[ts->nit_pid]);
+
+mpegts_open_section_filter(ts, ts->nit_pid, nit_cb, ts, 1);
+
+ts->nit_stream = avformat_new_stream(ts->stream, NULL);
+if (!ts->nit_stream)
+return;
+ts->nit_stream->id = ts->nit_pid;
+ts->nit_stream->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+ts->nit_stream->codecpar->codec_id = AV_CODEC_ID_NIT;
+}
 } else {
 MpegTSFilter *fil = ts->pids[pmt_pid];
 program = av_new_program(ts->stream, sid);
@@ -3084,7 +3094,6 @@ static int mpegts_read_header(AVFormatContext *s)
 mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
 mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
 mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);
-mpegts_open_section_filter(ts, NIT_PID, nit_cb, ts, 1);
 
 handle_packets(ts, probesize / ts->raw_packet_size);
 /* if could not find service, enable auto_guess */
@@ -3343,7 +3352,6 @@ MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext 
*s)
 mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
 mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
 mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);
-mpegts_open_section_filter(ts, NIT_PID, nit_cb, ts, 1);
 
 return ts;
 }
-- 
2.23.0

___
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] DVB EPG decoder

2019-09-11 Thread Anthony Delannoy
> > But I'd like to see data decoder in the future to use more easily
> > EPG/NIT/BAT etc tables.
> > Will it be possible? With modifications if it needs to be?
>
> I don't see how, as it does not fit into the concept of the libav*
> libraries. I feel this belongs to a separate library.

A new libavdata library for data handling ?

> In case of a scrambled EIT (which I have never seen myself in the wild) you'd
> print this at every packet. You should either remove the warning, or check if
> this is the first time (e.g. by checking if the EPG stream was just created).

> You should remove this, there are tons of captures where EIT PID is
> intentionally filtered, we should not spam the user.

I made both of this log print on AV_LOG_TRACE level, I rather keep
them here if i need them.


> Not needed, as context is zero initialized.

I deleted the unnecessary init.

Anthony Delannoy
From 4fe946f525a9409321ea2bc4f78a74857b9ee2b0 Mon Sep 17 00:00:00 2001
From: Anthony Delannoy 
Date: Fri, 26 Jul 2019 11:41:00 +0200
Subject: [PATCH 1/3] avformat/mpegts: add all pids & tids

---
 libavformat/mpegts.h | 74 
 1 file changed, 68 insertions(+), 6 deletions(-)

diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 272e2be4f7..560c319ef1 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -30,17 +30,79 @@
 #define TS_MAX_PACKET_SIZE 204
 
 #define NB_PID_MAX 8192
+#define USUAL_SECTION_SIZE 1024 /* except EIT which is limited to 4096 */
 #define MAX_SECTION_SIZE 4096
 
 /* pids */
-#define PAT_PID 0x
-#define SDT_PID 0x0011
+#define PAT_PID 0x /* Program Association Table */
+#define CAT_PID 0x0001 /* Conditional Access Table */
+#define TSDT_PID0x0002 /* Transport Stream Description Table */
+#define IPMP_PID0x0003
+/* PID from 0x0004 to 0x000F are reserved */
+#define NIT_PID 0x0010 /* Network Information Table */
+#define SDT_PID 0x0011 /* Service Description Table */
+#define BAT_PID SDT_PID /* Bouquet Association Table */
+#define EIT_PID 0x0012 /* Event Information Table */
+#define RST_PID 0x0013 /* Running Status Table */
+#define TDT_PID 0x0014 /* Time and Date Table */
+#define TOT_PID TDT_PID
+#define NET_SYNC_PID0x0015
+#define RNT_PID 0x0016 /* RAR Notification Table */
+/* PID from 0x0017 to 0x001B are reserved for future use */
+/* PID value 0x001C allocated to link-local inband signalling shall not be
+ * used on any broadcast signals. It shall only be used between devices in a
+ * controlled environment. */
+#define LINK_LOCAL_PID  0x001C
+#define MEASUREMENT_PID 0x001D
+#define DIT_PID 0x001E /* Discontinuity Information Table */
+#define SIT_PID 0x001F /* Selection Information Table */
+/* PID from 0x0020 to 0x1FFA may be assigned as needed to PMT, elementary
+ * streams and other data tables */
+/* PID 0x1FFB is used by DigiCipher 2/ATSC MGT metadata */
+/* PID from 0x1FFC to 0x1FFE may be assigned as needed to PMT, elementary
+ * streams and other data tables */
+#define NULL_PID0x1FFF /* Null packet (used for fixed bandwidth padding) */
 
 /* table ids */
-#define PAT_TID   0x00
-#define PMT_TID   0x02
-#define M4OD_TID  0x05
-#define SDT_TID   0x42
+#define PAT_TID 0x00 /* Program Association section */
+#define CAT_TID 0x01 /* Conditional Access section */
+#define PMT_TID 0x02 /* Program Map section */
+#define TSDT_TID0x03 /* Transport Stream Description section */
+/* TID from 0x04 to 0x3F are reserved */
+#define M4OD_TID0x05
+#define NIT_TID 0x40 /* Network Information section - actual network */
+#define ONIT_TID0x41 /* Network Information section - other network */
+#define SDT_TID 0x42 /* Service Description section - actual TS */
+/* TID from 0x43 to 0x45 are reserved for future use */
+#define OSDT_TID0x46 /* Service Descrition section - other TS */
+/* TID from 0x47 to 0x49 are reserved for future use */
+#define BAT_TID 0x4A /* Bouquet Association section */
+#define UNT_TID 0x4B /* Update Notification Table section */
+#define DFI_TID 0x4C /* Downloadable Font Info section */
+/* TID 0x4D is reserved for future use */
+#define EIT_TID 0x4E /* Event Information section - actual TS */
+#define OEIT_TID0x4F /* Event Information section - other TS */
+#define EITS_START_TID  0x50 /* Event Information section schedule - actual TS */
+#define EITS_END_TID0x5F /* Event Information section schedule - actual TS */
+#define OEITS_START_TID 0x60 /* Event Information section schedule - other TS */
+#define OEITS_END_TID   0x6F /* Event Information section schedule - other TS */
+#define TDT_TID 0x70 /* Time Date section */
+#define RST_TID 0x71 /* Running Status section */
+#define ST_

Re: [FFmpeg-devel] [PATCH] DVB EPG decoder

2019-09-04 Thread Anthony Delannoy
Hi

I'm still interested to have those three commits merged (update in attachments).

But I'd like to see data decoder in the future to use more easily
EPG/NIT/BAT etc tables.
Will it be possible? With modifications if it needs to be?

Anthony Delannoy

Le mar. 3 sept. 2019 à 23:39, Marton Balint  a écrit :
>
> Hi,
>
> I am not sure if you are interested getting only patch 1, 2 and 3
> merged, but if you are, then here are my comments for patch 3.
>
> > From 025ec8e8d607d02f2e5b4021783ab8f3b42d0bc1 Mon Sep 17 00:00:00 2001
> > From: Anthony Delannoy 
> > Date: Wed, 21 Aug 2019 11:46:56 +0200
> > Subject: [PATCH 03/10] lavf/mpegts: EPG extraction from mpegts
> >
> > ---
> >  libavformat/mpegts.c | 67 ++--
> >  1 file changed, 65 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > index 47d8d5f877..03c1753ac7 100644
> > --- a/libavformat/mpegts.c
> > +++ b/libavformat/mpegts.c
> > @@ -2489,13 +2489,57 @@ static void pat_cb(MpegTSFilter *filter, const 
> > uint8_t *section, int section_len
> >  }
> >  }
> >
> > +static void eit_cb(MpegTSFilter *filter, const uint8_t *section, int 
> > section_len)
> > +{
> > +MpegTSContext *ts = filter->u.section_filter.opaque;
> > +MpegTSSectionFilter *tssf = >u.section_filter;
> > +const uint8_t *p, *p_end;
> > +SectionHeader h1, *h = 
> > +int idx;
> > +AVProgram *prg;
>
> Maybe you can check if AVStream->discard == DISCARD_ALL for the EIT stream and
> skip the packet if the stream is discarded.
>
> > +
> > +p_end = section + section_len - 4;
> > +p = section;
> > +
> > +if (parse_section_header(h, , p_end) < 0)
> > +return;
> > +if (h->tid < EIT_TID || h->tid > OEITS_END_TID)
> > +return;
>
> > +if (ts->skip_changes)
> > +return;
> > +if (skip_identical(h, tssf))
> > +return;
>
> I don't think these last two checks (skip changes and skip identical) makes
> much sense here, just remove them.
>
> > +
> > +idx = ff_find_stream_index(ts->stream, filter->pid);
> > +if (idx < 0)
> > +return;
>
> Instead of finding the stream each time, you should simply add an AVStream
> *epg_stream to MpegTsContext, set it where you create the stream, and use that
> always.
>
> > +
> > +/**
> > + * In case we receive an EPG packet before mpegts context is fully
> > + * initialized.
> > + */
> > +if (!ts->pkt)
> > +return;
> > +
> > +new_data_packet(section, section_len, ts->pkt);
> > +ts->pkt->stream_index = idx;
>
> > +prg = av_find_program_from_stream(ts->stream, NULL, idx);
> > +if (prg && prg->pcr_pid != -1 && prg->discard != AVDISCARD_ALL) {
> > +MpegTSFilter *f = ts->pids[prg->pcr_pid];
> > +if (f && f->last_pcr != -1)
> > +ts->pkt->pts = ts->pkt->dts = f->last_pcr/300;
> > +}
>
> This program based logic is no longer needed since EIT is not added to 
> programs.
>
> > +ts->stop_parse = 1;
> > +}
> > +
> >  static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int 
> > section_len)
> >  {
> >  MpegTSContext *ts = filter->u.section_filter.opaque;
> >  MpegTSSectionFilter *tssf = >u.section_filter;
> >  SectionHeader h1, *h = 
> >  const uint8_t *p, *p_end, *desc_list_end, *desc_end;
> > -int onid, val, sid, desc_list_len, desc_tag, desc_len, service_type;
> > +int onid, val, sid, desc_list_len, desc_tag, desc_len, service_type,
> > +eit_sched, eit_pres_following;
> >  char *name, *provider_name;
> >
> >  av_log(ts->stream, AV_LOG_TRACE, "SDT:\n");
> > @@ -2525,6 +2569,24 @@ static void sdt_cb(MpegTSFilter *filter, const 
> > uint8_t *section, int section_len
> >  val = get8(, p_end);
> >  if (val < 0)
> >  break;
> > +eit_sched = (val >> 1) & 0x1;
> > +eit_pres_following = val & 0x1;
> > +
> > +if (eit_sched | eit_pres_following) {
> > +int idx = ff_find_stream_index(ts->stream, EIT_PID);
> > +AVStream *st = (idx >= 0) ? ts->stream->streams[EIT_PID] : 
> > NULL;
>
> I guess ts->stream->streams[EIT_PID] wa

[FFmpeg-devel] [PATCH] avformat/mpegts: check end of init before treating SCTE data

2019-09-03 Thread Anthony Delannoy
Hi

On some DVB stream ffprobe segfaulted, it was because of SCTE-35 data
packet reception
before the end of MpegTSContext initialization.

On this patch I check for `ts->pkt` availability before trying to
generate a new SCTE data
packet.

Anthony Delannoy
From 6dd92519ce5f7c85ca35c7227d35ff49fa6de3ef Mon Sep 17 00:00:00 2001
From: Anthony Delannoy 
Date: Tue, 3 Sep 2019 17:54:24 +0200
Subject: [PATCH] avformat/mpegts: Check if ready on SCTE reception

On some DVB stream SCTE-35 data packet are available before the end of
MpegTSContext initialization. We have to check if it is the case to
avoid a SEGFAULT.
---
 libavformat/mpegts.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 58902527c5..0415ceea02 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1725,6 +1725,13 @@ static void scte_data_cb(MpegTSFilter *filter, const uint8_t *section,
 if (idx < 0)
 return;
 
+/**
+ * In case we receive an SCTE-35 packet before mpegts context is fully
+ * initialized.
+ */
+if (!ts->pkt)
+return;
+
 new_data_packet(section, section_len, ts->pkt);
 ts->pkt->stream_index = idx;
 prg = av_find_program_from_stream(ts->stream, NULL, idx);
-- 
2.23.0

___
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] DVB EPG decoder

2019-08-26 Thread Anthony Delannoy
Okay, thanks

I will patch that

Le sam. 24 août 2019 à 20:09, Marton Balint  a écrit :
>
>
> On Fri, 23 Aug 2019, Anthony Delannoy wrote:
>
> >> I think we should only merge the part of this patchset which makes the EIT
> >> available as a data stream. Parsing the whole EIT or dumping the data as
> >> ASCII is not libavcodec's or libavutil's job.
> >
> > The EPG decoder does not change the table's data, it just store them
> > and it happens to
> > contains text sometimes.
> > Some utilites functions I made in libavutil/dvb can convert those raw
> > data in text
> > description(s) for certain descriptors.
> >
> >> Also there is no such concept in libavcodec as a data decoder, if 
> >> something happens to
> >> work with avcodec_send_packet/avcodec_receive_frame that is mostly luck I
> >> believe.
> >
> > avcodec_send_packet and avcodec_receive_frame both call
> > AVCodec::receive_frame if it is
> > implemented. That's why my implementation of the EPG decoder does
> > contain this function.
> >
> > For now my test scripts consists to:
> > ```
> > 99 if (st->codecpar->codec_id != AV_CODEC_ID_EPG)
> > 100 goto free_pkt;
> > 101
> > 102 ret = avcodec_send_packet(dec_ctx, );
> > ...
> > 112 while (1) {
> > 113 ret = avcodec_receive_frame(dec_ctx, frame);
> > 114 if (ret < 0)
> > 115 break;
> > 116
> > 117 for (int i = 0; i < frame->nb_side_data; i++) {
> > 118 AVFrameSideData *sd = frame->side_data[i];
> > 119 if (sd && sd->type == AV_FRAME_DATA_EPG_TABLE) {
> > 120 EPGTable *table = sd->data;
> > 121 av_epg_show_table(table, AV_LOG_WARNING);
> > 122 }
> > 123 }
> > 124 av_frame_unref(frame);
> > 125 }
> > 126
> > 127 free_pkt:
> > 128 av_packet_unref();
> > ```
> > It works as intended and permits to decode EPGTable without issues, I
> > tried on multiple channels.
> >
> > I wanted to permit the table decoding and not just an EPG data stream
> > to permit easy reading
> > and in the future easy modification before encoding EPG back.
> >
> >> I am also not sure if we should add the EIT PID to all programs, that
> >> would mess up the direct relation between a PMT and an AVProgram, and we
> >> probably don't want that. So I'd rather see the EIT data stream as a
> >> standalone PID separate from the programs.
> >
> > I'm not an expert but I think each service/program contains a PMT
> > table and all others. So one
> > EPG stream (if available) for each service.
> > That's what I understood from the ETSI EN 300 468 V1.16.1
>
> The EPG stream is a single stream in the whole TS, it is on a single PID.
> The PMTs do not reference the EIT PID, therefore we should not make the
> EPG stream part of the programs, even if the EPG stream can contain the
> schedule of the programs.
>
> Regards,
> Marton
> ___
> 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] DVB EPG decoder

2019-08-23 Thread Anthony Delannoy
> I think we should only merge the part of this patchset which makes the EIT
> available as a data stream. Parsing the whole EIT or dumping the data as
> ASCII is not libavcodec's or libavutil's job.

The EPG decoder does not change the table's data, it just store them
and it happens to
contains text sometimes.
Some utilites functions I made in libavutil/dvb can convert those raw
data in text
description(s) for certain descriptors.

> Also there is no such concept in libavcodec as a data decoder, if something 
> happens to
> work with avcodec_send_packet/avcodec_receive_frame that is mostly luck I
> believe.

avcodec_send_packet and avcodec_receive_frame both call
AVCodec::receive_frame if it is
implemented. That's why my implementation of the EPG decoder does
contain this function.

For now my test scripts consists to:
```
 99 if (st->codecpar->codec_id != AV_CODEC_ID_EPG)
100 goto free_pkt;
101
102 ret = avcodec_send_packet(dec_ctx, );
...
112 while (1) {
113 ret = avcodec_receive_frame(dec_ctx, frame);
114 if (ret < 0)
115 break;
116
117 for (int i = 0; i < frame->nb_side_data; i++) {
118 AVFrameSideData *sd = frame->side_data[i];
119 if (sd && sd->type == AV_FRAME_DATA_EPG_TABLE) {
120 EPGTable *table = sd->data;
121 av_epg_show_table(table, AV_LOG_WARNING);
122 }
123 }
124 av_frame_unref(frame);
125 }
126
127 free_pkt:
128 av_packet_unref();
```
It works as intended and permits to decode EPGTable without issues, I
tried on multiple channels.

I wanted to permit the table decoding and not just an EPG data stream
to permit easy reading
and in the future easy modification before encoding EPG back.

> I am also not sure if we should add the EIT PID to all programs, that
> would mess up the direct relation between a PMT and an AVProgram, and we
> probably don't want that. So I'd rather see the EIT data stream as a
> standalone PID separate from the programs.

I'm not an expert but I think each service/program contains a PMT
table and all others. So one
EPG stream (if available) for each service.
That's what I understood from the ETSI EN 300 468 V1.16.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".

Re: [FFmpeg-devel] MpegTS contribution question

2019-08-09 Thread Anthony Delannoy
For now I'm just reading and storing EPG data, once this part is done I'd
like to do what you said.
But first we will have to think of an easy way to change/insert descriptors
inside a specific table.

Thanks for your response :)

Le jeu. 8 août 2019 à 17:57, Phil Burr  a écrit :

> Hello Anthony,
>
> I'm not really the best to answer your questions, as I'm also a fairly new
> contributor (my patches seem to be languishing due to a lack of feedback
> and a lack of time on my part pushing the issue).  I've been working on
> getting support into mpegts for ATSC compliant descriptors of which EIT
> tables are a glaring omission in large part due to the amount of work
> needed to support them.  So to say the least, I'm excited about your
> patches!  I'll take a look at your patches but one thing I would like to
> know if you've considered, is whether or not your code supports modifying
> the EIT tables, ie updating tables_version when the tables are modified?
>
> Thanks,
> Phil
>
> On Thu, Aug 8, 2019 at 4:13 AM Anthony Delannoy  >
> wrote:
>
> > Hi,
> >
> > I'm currently doing my first contribution to ffmpeg by adding EPG support
> > in the mpegts format.
> > For now, i succeeded to add support for EIT table and majority of its
> > descriptors and can read/export EPG
> > events in a .csv file.
> > But I don't know on how to organize it now. Do I make a new codec for epg
> > and a data stream? Do I keep those
> > information « hidden » and present them only in metadatas plus functions
> > api to export them?
> >
> > For those who wants to see where I am at:
> > https://github.com/spnngl/FFmpeg/tree/epg2
> >
> > Some remarks:
> >   * For now I use linked list to store EPG events but I may change for
> > something simpler.
> >   * I made separate descriptors code to be able to use it on others
> tables
> > later. I want to add NIT table
> >   support and maybe others if i succeed to finish EPG.
> >   * EPG/descriptors files are all in libavformat for now, they need to be
> > moved
> >
> > Thanks
> > ___
> > 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 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] MpegTS contribution question

2019-08-08 Thread Anthony Delannoy
Hi,

I'm currently doing my first contribution to ffmpeg by adding EPG support
in the mpegts format.
For now, i succeeded to add support for EIT table and majority of its
descriptors and can read/export EPG
events in a .csv file.
But I don't know on how to organize it now. Do I make a new codec for epg
and a data stream? Do I keep those
information « hidden » and present them only in metadatas plus functions
api to export them?

For those who wants to see where I am at:
https://github.com/spnngl/FFmpeg/tree/epg2

Some remarks:
  * For now I use linked list to store EPG events but I may change for
something simpler.
  * I made separate descriptors code to be able to use it on others tables
later. I want to add NIT table
  support and maybe others if i succeed to finish EPG.
  * EPG/descriptors files are all in libavformat for now, they need to be
moved

Thanks
___
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".