[vlc-commits] noseek: demux filter to disable seeking

Rémi Denis-Courmont git at videolan.org
Sat Jul 8 15:35:17 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jul  8 16:26:02 2017 +0300| [dca9e7a3243e7de66f6003c9d7f5a6b55968d47a] | committer: Rémi Denis-Courmont

noseek: demux filter to disable seeking

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dca9e7a3243e7de66f6003c9d7f5a6b55968d47a
---

 NEWS                          |  1 +
 modules/MODULES_LIST          |  1 +
 modules/demux/Makefile.am     |  2 ++
 modules/demux/filter/noseek.c | 84 +++++++++++++++++++++++++++++++++++++++++++
 po/POTFILES.in                |  1 +
 5 files changed, 89 insertions(+)

diff --git a/NEWS b/NEWS
index 27bc0fa8f4..c61a2b2a0d 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 5c9e96bd18..353df9f1a7 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 5a3a84b691..b267c7d20d 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 0000000000..ab72fe8595
--- /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 bf284db391..d5e49253ad 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



More information about the vlc-commits mailing list