[vlc-commits] add controls tweaking modules

Francois Cartegnie git at videolan.org
Fri Aug 28 17:51:45 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jul 17 21:14:15 2015 +0200| [e305b509dc6ff26fa7bac0020d700ac0eda725dd] | committer: Francois Cartegnie

add controls tweaking modules

Because we have too many access/demux misbehaving with
seekable and non seekable cases, some developers only
options could be really useful.

module built only using invisible configure option
--enable-devtools

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

 configure.ac                         |    7 +++
 modules/MODULES_LIST                 |    1 +
 modules/stream_filter/Makefile.am    |    6 ++
 modules/stream_filter/accesstweaks.c |  115 ++++++++++++++++++++++++++++++++++
 4 files changed, 129 insertions(+)

diff --git a/configure.ac b/configure.ac
index d38f8e8..3ec70c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3970,6 +3970,13 @@ AS_IF([test "${enable_taglib}" != "no"], [
     AC_MSG_WARN([${TAGLIB_PKG_ERRORS}.])])
 ])
 
+dnl
+dnl  Developers helper modules (should be hidden from configure help)
+dnl
+AC_ARG_ENABLE(devtools, [], [], [enable_devtools="no"])
+AS_IF([test "${enable_devtools}" != "no"], [
+  VLC_ADD_PLUGIN([accesstweaks])
+])
 
 dnl
 dnl update checking system
diff --git a/modules/MODULES_LIST b/modules/MODULES_LIST
index 4595acd..deb1a77 100644
--- a/modules/MODULES_LIST
+++ b/modules/MODULES_LIST
@@ -22,6 +22,7 @@ $Id$
  * access_output_udp: UDP Network access_output module
  * access_realrtsp: Real RTSP access
  * access_wasapi: WASAPI audio input
+ * accesstweaks: access control tweaking module (dev tool)
  * adaptative: Unified adaptative streaming module (DASH/HLS)
  * addonsfsstorage: Local storage extensions repository
  * addonsvorepository: Videolan extensions repository
diff --git a/modules/stream_filter/Makefile.am b/modules/stream_filter/Makefile.am
index 9b90d60..8480620 100644
--- a/modules/stream_filter/Makefile.am
+++ b/modules/stream_filter/Makefile.am
@@ -42,3 +42,9 @@ libaribcam_plugin_la_LDFLAGS = $(AM_LDFLAGS) $(ARIBB25_LDFLAGS) -rpath '$(stream
 libaribcam_plugin_la_LIBADD = $(ARIBB25_LIBS)
 stream_filter_LTLIBRARIES += $(LTLIBaribcam)
 EXTRA_LTLIBRARIES += libaribcam_plugin.la
+
+libaccesstweaks_plugin_la_SOURCES = stream_filter/accesstweaks.c
+libaccesstweaks_plugin_la_CFLAGS = $(AM_CFLAGS)
+libaccesstweaks_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(stream_filterdir)'
+stream_filter_LTLIBRARIES += $(LTLIBaccesstweaks)
+EXTRA_LTLIBRARIES += libaccesstweaks_plugin.la
diff --git a/modules/stream_filter/accesstweaks.c b/modules/stream_filter/accesstweaks.c
new file mode 100644
index 0000000..ce51f95
--- /dev/null
+++ b/modules/stream_filter/accesstweaks.c
@@ -0,0 +1,115 @@
+/*****************************************************************************
+ * accesstweaks.c Access controls tweaking stream filter
+ *****************************************************************************
+ * Copyright (C) 2015 VideoLAN Authors
+ *
+ * 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 *);
+static void Close(vlc_object_t *);
+
+vlc_module_begin ()
+    set_shortname("accesstweaks")
+    set_category (CAT_INPUT)
+    set_subcategory (SUBCAT_INPUT_STREAM_FILTER)
+    set_capability ("stream_filter", 0)
+    /* Developers only module, no translation please */
+    set_description ("Access controls tweaking")
+    set_callbacks (Open, Close)
+
+    add_bool ("seek", true, "forces result of the CAN_SEEK control", NULL, false)
+        change_volatile ()
+    add_bool ("fastseek", true, "forces result of the CAN_FASTSEEK control", NULL, false)
+        change_volatile ()
+    add_shortcut("tweaks")
+vlc_module_end ()
+
+struct stream_sys_t
+{
+    bool b_seek;
+    bool b_fastseek;
+};
+
+/**
+ *
+ */
+static int Control( stream_t *p_stream, int i_query, va_list args )
+{
+    stream_sys_t *p_sys = p_stream->p_sys;
+
+    switch( i_query )
+    {
+    case STREAM_CAN_FASTSEEK:
+        if( !p_sys->b_fastseek || !p_sys->b_seek )
+        {
+            *((bool*)va_arg( args, bool* )) = false;
+            return VLC_SUCCESS;
+        }
+        break;
+    case STREAM_CAN_SEEK:
+    case STREAM_SET_POSITION:
+        if( !p_sys->b_seek )
+        {
+            *((bool*)va_arg( args, bool* )) = false;
+            return VLC_SUCCESS;
+        }
+        break;
+
+    default:
+        break;
+    }
+
+    return stream_vaControl( p_stream->p_source, i_query, args );
+}
+
+static ssize_t Read( stream_t *s, void *buffer, size_t i_read )
+{
+    return stream_Read( s->p_source, buffer, i_read );
+}
+
+static int Open( vlc_object_t *p_object )
+{
+    stream_t *p_stream = (stream_t *) p_object;
+
+    stream_sys_t *p_sys = p_stream->p_sys = malloc( sizeof(*p_sys) );
+    if (unlikely(p_sys == NULL))
+        return VLC_ENOMEM;
+
+    p_sys->b_seek = var_InheritBool( p_stream, "seek" );
+    p_sys->b_fastseek = var_InheritBool( p_stream, "fastseek" );
+
+    p_stream->pf_read = Read;
+    p_stream->pf_control = Control;
+
+    return VLC_SUCCESS;
+}
+
+static void Close ( vlc_object_t *p_object )
+{
+    stream_t *p_stream = (stream_t *)p_object;
+    free( p_stream->p_sys );
+}



More information about the vlc-commits mailing list