diff --git a/NEWS b/NEWS index 27bc0fa8f4698f6dd384a5496c208b73df167f92..c61a2b2a0d90b078cea25be5d6ec7d33438fb11b 100644 --- a/NEWS +++ b/NEWS @@ -140,6 +140,7 @@ Stream filter: Demux filter: * Added a demuxer filter chain to filter or intercept control commands and demuxing + * Added a demuxer filter to block seeking (--demux-filter noseek) Audio output: * Complete rewrite of the AudioTrack Android module, it is now the default diff --git a/modules/MODULES_LIST b/modules/MODULES_LIST index 5c9e96bd183660730adf44eaa0bb87a6371cb873..353df9f1a7e377564b70abee26584e1e3c6d7714 100644 --- a/modules/MODULES_LIST +++ b/modules/MODULES_LIST @@ -262,6 +262,7 @@ $Id$ * nfs: NFS access module using libnfs * normvol: a audio filter for volume normalization * notify: notifications using libnotify + * noseek: seek prevention demuxing filter * nsc: decoder for Microsoft proprietary NSC descriptors * nsspeechsynthesizer: Text to speech subtitles renderer * nsv: NullSoft Video demuxer diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am index 5a3a84b691e94de6057061b8e3ba0e66f40b1b0d..b267c7d20d5ae7c7e7b311893b172b20abcaf045 100644 --- a/modules/demux/Makefile.am +++ b/modules/demux/Makefile.am @@ -464,3 +464,5 @@ libadaptive_plugin_la_LIBADD += $(GCRYPT_LIBS) endif demux_LTLIBRARIES += libadaptive_plugin.la +libnoseek_plugin_la_SOURCES = demux/filter/noseek.c +demux_LTLIBRARIES += libnoseek_plugin.la diff --git a/modules/demux/filter/noseek.c b/modules/demux/filter/noseek.c new file mode 100644 index 0000000000000000000000000000000000000000..ab72fe85958d784f91f1e120388cdd471c5a54ee --- /dev/null +++ b/modules/demux/filter/noseek.c @@ -0,0 +1,84 @@ +/***************************************************************************** + * noseek.c: + ***************************************************************************** + * Copyright (C) 2017 Rémi Denis-Courmont + * + * 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. + *****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <vlc_common.h> +#include <vlc_plugin.h> +#include <vlc_demux.h> + +static int Demux(demux_t *demux) +{ + return demux_Demux(demux->p_next); +} + +static int Control(demux_t *demux, int query, va_list args) +{ + switch (query) + { + case DEMUX_CAN_SEEK: + *va_arg(args, bool *) = false; + break; + + case DEMUX_SET_POSITION: + case DEMUX_SET_TIME: + case DEMUX_GET_TITLE_INFO: + return VLC_EGENERIC; + + case DEMUX_TEST_AND_CLEAR_FLAGS: + { + unsigned *restrict pf = va_arg(args, unsigned *); + + if (demux_Control(demux->p_next, DEMUX_TEST_AND_CLEAR_FLAGS, pf)) + { + unsigned update = demux->info.i_update & *pf; + demux->info.i_update &= ~*pf; + *pf = update; + } + *pf &= ~(INPUT_UPDATE_TITLE|INPUT_UPDATE_SEEKPOINT| + INPUT_UPDATE_TITLE_LIST); + break; + } + + default: + return demux_vaControl(demux->p_next, query, args); + } + + return VLC_SUCCESS; +} + +static int Open(vlc_object_t *obj) +{ + demux_t *demux = (demux_t *)obj; + + demux->pf_demux = Demux; + demux->pf_control = Control; + return VLC_SUCCESS; +} + +vlc_module_begin () + set_description(N_("Seek prevention demux filter")) + set_category(CAT_INPUT) + set_subcategory(SUBCAT_INPUT_STREAM_FILTER) + set_capability("demux_filter", 0) + set_callbacks(Open, NULL) +vlc_module_end() diff --git a/po/POTFILES.in b/po/POTFILES.in index bf284db391d9af0c438c279d65ef2fe3b11912c7..d5e49253ade3cfe85490c6a79fc299214d92f449 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -444,6 +444,7 @@ modules/demux/caf.c modules/demux/cdg.c modules/demux/demuxdump.c modules/demux/dirac.c +modules/demux/filter/noseek.c modules/demux/flac.c modules/demux/gme.c modules/demux/image.c