[vlc-devel] [PATCH] demux: ts: add wrapper for b25 stream filter

Francois Cartegnie fcvlcdev at free.fr
Tue Aug 25 15:22:58 CEST 2020


Can you try this one ?


---
 modules/demux/Makefile.am             |  1 +
 modules/demux/mpeg/ts.c               |  7 ++-
 modules/demux/mpeg/ts.h               |  5 +-
 modules/demux/mpeg/ts_psi.c           | 15 ++++--
 modules/demux/mpeg/ts_streamwrapper.h | 70 +++++++++++++++++++++++++++
 5 files changed, 88 insertions(+), 10 deletions(-)
 create mode 100644 modules/demux/mpeg/ts_streamwrapper.h

diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index 0f58860624..9bb30a715f 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -273,6 +273,7 @@ libts_plugin_la_SOURCES = demux/mpeg/ts.c demux/mpeg/ts.h \
         demux/mpeg/ts_hotfixes.c demux/mpeg/ts_hotfixes.h \
         demux/mpeg/ts_strings.h demux/mpeg/ts_streams_private.h \
         demux/mpeg/ts_pes.c demux/mpeg/ts_pes.h \
+        demux/mpeg/ts_streamwrapper.h \
         demux/mpeg/pes.h \
         demux/mpeg/timestamps.h \
 	demux/mpeg/ts_descriptions.h \
diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index bee529720d..8a98e3c6a3 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -392,7 +392,6 @@ static int Open( vlc_object_t *p_this )
 
     p_sys->vdr = vdr;
 
-    p_sys->arib.b25stream = NULL;
     p_sys->stream = p_demux->s;
 
     p_sys->b_broken_charset = false;
@@ -576,10 +575,10 @@ static void Close( vlc_object_t *p_this )
         arib_instance_destroy( p_sys->arib.p_instance );
 #endif
 
-    if ( p_sys->arib.b25stream )
+    if ( p_sys->stream != p_demux->s ) /* B25 wrapper in use */
     {
-        p_sys->arib.b25stream->s = NULL; /* don't chain kill demuxer's source */
-        vlc_stream_Delete( p_sys->arib.b25stream );
+        vlc_stream_Delete( p_sys->stream );
+        p_sys->stream = p_demux->s;
     }
 
     /* Release all non default pids */
diff --git a/modules/demux/mpeg/ts.h b/modules/demux/mpeg/ts.h
index 613a03ebcc..1d869181ff 100644
--- a/modules/demux/mpeg/ts.h
+++ b/modules/demux/mpeg/ts.h
@@ -76,13 +76,12 @@ struct demux_sys_t
 
     ts_standards_e standard;
 
+#ifdef HAVE_ARIBB24
     struct
     {
-#ifdef HAVE_ARIBB24
         arib_instance_t *p_instance;
-#endif
-        stream_t     *b25stream;
     } arib;
+#endif
 
     /* All pid */
     ts_pid_list_t pids;
diff --git a/modules/demux/mpeg/ts_psi.c b/modules/demux/mpeg/ts_psi.c
index dbdec34529..10cd2eb758 100644
--- a/modules/demux/mpeg/ts_psi.c
+++ b/modules/demux/mpeg/ts_psi.c
@@ -57,6 +57,7 @@
 #include "ts_descriptions.h"
 
 #include "../../access/dtv/en50221_capmt.h"
+#include "ts_streamwrapper.h"
 
 #include <assert.h>
 
@@ -2070,10 +2071,18 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
                                     (void *)p_en ) != VLC_SUCCESS )
             {
                 en50221_capmt_Delete( p_en );
-                if ( p_sys->standard == TS_STANDARD_ARIB && !p_sys->arib.b25stream )
+                if ( p_sys->standard == TS_STANDARD_ARIB && p_sys->stream == p_demux->s )
                 {
-                    p_sys->arib.b25stream = vlc_stream_FilterNew( p_demux->s, "aribcam" );
-                    p_sys->stream = ( p_sys->arib.b25stream ) ? p_sys->arib.b25stream : p_demux->s;
+                    stream_t *wrapper = ts_stream_wrapper_New( p_demux->s );
+                    if( wrapper )
+                    {
+                        p_sys->stream = vlc_stream_FilterNew( wrapper, "aribcam" );
+                        if( !p_sys->stream )
+                        {
+                            vlc_stream_Delete( wrapper );
+                            p_sys->stream = p_demux->s;
+                        }
+                    }
                 }
             }
         }
diff --git a/modules/demux/mpeg/ts_streamwrapper.h b/modules/demux/mpeg/ts_streamwrapper.h
new file mode 100644
index 0000000000..f57e8bccb1
--- /dev/null
+++ b/modules/demux/mpeg/ts_streamwrapper.h
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * ts_streamwrapper.c: Stream filter source wrapper
+ *****************************************************************************
+ * Copyright (C) 2020 VideoLabs, VLC authors and VideoLAN
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+#include <vlc_stream.h>
+
+static int ts_stream_wrapper_Control(stream_t *s, int i_query, va_list va)
+{
+    stream_t *demuxstream = s->p_sys;
+    return demuxstream->pf_control(demuxstream, i_query, va);
+}
+
+static ssize_t ts_stream_wrapper_Read(stream_t *s, void *buf, size_t len)
+{
+    stream_t *demuxstream = s->p_sys;
+    return demuxstream->pf_read(demuxstream, buf, len);
+}
+
+static block_t * ts_stream_wrapper_ReadBlock(stream_t *s, bool *eof)
+{
+    stream_t *demuxstream = s->p_sys;
+    return demuxstream->pf_block(demuxstream, eof);
+}
+
+static int ts_stream_wrapper_Seek(stream_t *s, uint64_t pos)
+{
+    stream_t *demuxstream = s->p_sys;
+    return demuxstream->pf_seek(demuxstream, pos);
+}
+
+static void ts_stream_wrapper_Destroy(stream_t *s)
+{
+    VLC_UNUSED(s);
+}
+
+static stream_t * ts_stream_wrapper_New(stream_t *demuxstream)
+{
+    stream_t *s = vlc_stream_CommonNew(VLC_OBJECT(demuxstream),
+                                       ts_stream_wrapper_Destroy);
+    assert(s);
+    if(s)
+    {
+        s->p_sys = demuxstream;
+        s->s = s;
+        if(demuxstream->pf_read)
+            s->pf_read = ts_stream_wrapper_Read;
+        if(demuxstream->pf_control)
+            s->pf_control = ts_stream_wrapper_Control;
+        if(demuxstream->pf_seek)
+            s->pf_seek = ts_stream_wrapper_Seek;
+        if(demuxstream->pf_block)
+            s->pf_block = ts_stream_wrapper_ReadBlock;
+    }
+    return s;
+}
-- 
2.25.4



More information about the vlc-devel mailing list