[vlc-devel] [PATCH] stream_filter: added ADF stream filter (Fixes #17501)

Tristan Matthews tmatth at videolan.org
Tue Oct 25 01:47:02 CEST 2016


So the issue with my initial stream filter attempt was that I wasn't probing in Open(), seems to work fine now.

---
 NEWS                              |  1 +
 modules/MODULES_LIST              |  1 +
 modules/stream_filter/Makefile.am |  3 ++
 modules/stream_filter/adf.c       | 84 +++++++++++++++++++++++++++++++++++++++
 po/POTFILES.in                    |  1 +
 5 files changed, 90 insertions(+)
 create mode 100644 modules/stream_filter/adf.c

diff --git a/NEWS b/NEWS
index 50ad866..5fa0cf6 100644
--- a/NEWS
+++ b/NEWS
@@ -115,6 +115,7 @@ Demuxers:
  * Fix Quicktime Mp4 inside MKV and unpacketized VC1
 
 Stream filter:
+ * Added ADF stream filter
  * Added ARIB STD-B25 TS streams decoder
  * Added stream prebuffering plugin
  * Removed HTTP Live streaming stream filter
diff --git a/modules/MODULES_LIST b/modules/MODULES_LIST
index 8fc8f97..e7685a3 100644
--- a/modules/MODULES_LIST
+++ b/modules/MODULES_LIST
@@ -24,6 +24,7 @@ $Id$
  * adaptive: Unified adaptive streaming module (DASH/HLS)
  * addonsfsstorage: Local storage extensions repository
  * addonsvorepository: Videolan extensions repository
+ * adf: ADF stream_filter module
  * adjust: Contrast/Hue/saturation/Brightness adjust module
  * adpcm: ADPCM audio decoder
  * adummy: dummy audio output
diff --git a/modules/stream_filter/Makefile.am b/modules/stream_filter/Makefile.am
index cd25583..e8026e4 100644
--- a/modules/stream_filter/Makefile.am
+++ b/modules/stream_filter/Makefile.am
@@ -49,3 +49,6 @@ libaccesstweaks_plugin_la_CFLAGS = $(AM_CFLAGS)
 libaccesstweaks_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(stream_filterdir)'
 stream_filter_LTLIBRARIES += $(LTLIBaccesstweaks)
 EXTRA_LTLIBRARIES += libaccesstweaks_plugin.la
+
+libadf_plugin_la_SOURCES = stream_filter/adf.c
+stream_filter_LTLIBRARIES += libadf_plugin.la
diff --git a/modules/stream_filter/adf.c b/modules/stream_filter/adf.c
new file mode 100644
index 0000000..db28740
--- /dev/null
+++ b/modules/stream_filter/adf.c
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * adf.c ADF stream filter
+ *****************************************************************************
+ * Copyright (C) 2016 VideoLAN Authors
+ *
+ * Author: Tristan Matthews <tmatth at videolan.org>
+ * Based on record.c by: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
+ *
+ * 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.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_stream.h>
+
+static int Open( vlc_object_t * );
+
+vlc_module_begin()
+    set_shortname( "adf" )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_STREAM_FILTER )
+    set_capability( "stream_filter", 30 )
+    set_description( N_( "ADF stream filter" ) )
+    set_callbacks( Open, NULL )
+vlc_module_end()
+
+static int Control( stream_t *p_stream, int i_query, va_list args )
+{
+    return vlc_stream_vaControl( p_stream->p_source, i_query, args );
+}
+
+static ssize_t Read( stream_t *s, void *buffer, size_t i_read )
+{
+    const ssize_t i_ret = vlc_stream_Read( s->p_source, buffer, i_read );
+    if( i_ret < 1 || !buffer ) return i_ret;
+
+    uint8_t *p_buffer = buffer;
+    static const uint8_t ADF_XOR_MASK = 34;
+    for( ssize_t i = 0; i < i_ret; ++i )
+        p_buffer[i] ^= ADF_XOR_MASK;
+    return i_ret;
+}
+
+static int Seek( stream_t *s, uint64_t offset )
+{
+    return vlc_stream_Seek( s->p_source, offset );
+}
+
+static int Open( vlc_object_t *p_object )
+{
+    stream_t *p_stream = (stream_t *)p_object;
+
+    const uint8_t *peek;
+    if( vlc_stream_Peek( p_stream->p_source, &peek, 4 ) < 4 )
+        return VLC_EGENERIC;
+    /* Probe for XOR'd ID3 tag. */
+    if( memcmp( peek, "\x6B\x66\x11\x21", 4 ) )
+        return VLC_EGENERIC;
+
+    p_stream->pf_read = Read;
+    p_stream->pf_seek = Seek;
+    p_stream->pf_control = Control;
+
+    return VLC_SUCCESS;
+}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e7bd933..754a5f5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1029,6 +1029,7 @@ modules/services_discovery/udev.c
 modules/services_discovery/upnp.cpp
 modules/services_discovery/windrive.c
 modules/services_discovery/xcb_apps.c
+modules/stream_filter/adf.c
 modules/stream_filter/aribcam.c
 modules/stream_filter/cache_block.c
 modules/stream_filter/cache_read.c
-- 
2.9.3



More information about the vlc-devel mailing list