From 21bb83f3ae595e66a1cd6b6fcb46d0cf5f30656c Mon Sep 17 00:00:00 2001 From: Tristan Matthews Date: Mon, 24 Oct 2016 18:10:11 -0400 Subject: [PATCH] stream_filter: add ADF stream filter (Fixes #17501) --- NEWS | 1 + modules/MODULES_LIST | 1 + modules/stream_filter/Makefile.am | 3 ++ modules/stream_filter/adf.c | 85 +++++++++++++++++++++++++++++++ po/POTFILES.in | 1 + 5 files changed, 91 insertions(+) create mode 100644 modules/stream_filter/adf.c diff --git a/NEWS b/NEWS index 50ad8669d6..5fa0cf6498 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 8fc8f979f0..e7685a3167 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 cd25583cfd..e8026e46ca 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 0000000000..d3e2476b80 --- /dev/null +++ b/modules/stream_filter/adf.c @@ -0,0 +1,85 @@ +/***************************************************************************** + * adf.c ADF stream filter + ***************************************************************************** + * Copyright (C) 2016 VideoLAN Authors + * + * Author: Tristan Matthews + * Based on record.c by: Laurent Aimar + * + * 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 +#include +#include + +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; +} diff --git a/po/POTFILES.in b/po/POTFILES.in index e7bd933cc1..754a5f5e94 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