stream_filter: add ADF stream filter (Fixes #17501)
authorTristan Matthews <tmatth@videolan.org>
Mon, 24 Oct 2016 22:10:11 +0000 (18:10 -0400)
committerTristan Matthews <tmatth@videolan.org>
Tue, 25 Oct 2016 12:44:37 +0000 (08:44 -0400)
NEWS
modules/MODULES_LIST
modules/stream_filter/Makefile.am
modules/stream_filter/adf.c [new file with mode: 0644]
po/POTFILES.in

diff --git a/NEWS b/NEWS
index 50ad866..5fa0cf6 100644 (file)
--- 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
index 8fc8f97..e7685a3 100644 (file)
@@ -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
index cd25583..e8026e4 100644 (file)
@@ -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 (file)
index 0000000..d3e2476
--- /dev/null
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * adf.c ADF stream filter
+ *****************************************************************************
+ * Copyright (C) 2016 VideoLAN Authors
+ *
+ * Author: Tristan Matthews <tmatth@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, 3 ) < 3 )
+        return VLC_EGENERIC;
+
+    /* Probe for XOR'd ID3 tag. */
+    if( memcmp( peek, "\x6B\x66\x11", 3 ) )
+        return VLC_EGENERIC;
+
+    p_stream->pf_read = Read;
+    p_stream->pf_seek = Seek;
+    p_stream->pf_control = Control;
+
+    return VLC_SUCCESS;
+}
index e7bd933..754a5f5 100644 (file)
@@ -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