Commit 0ef201d8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

accesstweaks: automatically probe

accesstweaks no longer needs to be explicitly added to stream filters.
It is now enabled implicitly with --no-seek, --no-fastseek and/or
 --no-stream-size.
parent bf51e088
......@@ -31,22 +31,21 @@
#include <assert.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)
set_capability ("stream_filter", 1)
/* Developers only module, no translation please */
set_description ("Access controls tweaking")
set_callbacks (Open, Close)
set_callbacks(Open, NULL)
add_bool ("seek", true, "forces result of the CAN_SEEK control", NULL, false)
add_bool("seek", true, "Expose seeking capability", NULL, false)
change_volatile ()
add_bool ("fastseek", true, "forces result of the CAN_FASTSEEK control", NULL, false)
add_bool("fastseek", true, "Expose fast-seeking capability", NULL, false)
change_volatile ()
add_bool("stream-size", true, "expose stream size if known", NULL, false)
add_bool("stream-size", true, "Expose stream size if known", NULL, false)
change_volatile()
add_shortcut("tweaks")
vlc_module_end ()
......@@ -108,24 +107,43 @@ static int Seek( stream_t *s, uint64_t offset )
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) );
stream_sys_t *p_sys = vlc_obj_malloc(p_object, 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" );
uint64_t size;
bool b;
bool used = false;
p_sys->b_seek = var_InheritBool(p_stream, "seek");
p_sys->b_size = var_InheritBool(p_stream, "stream-size");
if (!p_sys->b_seek)
{
if (vlc_stream_Control(p_stream->p_source, STREAM_CAN_SEEK, &b) == 0)
used = b;
p_sys->b_fastseek = false;
}
else
{
p_sys->b_fastseek = var_InheritBool(p_stream, "fastseek");
if (!p_sys->b_fastseek
&& vlc_stream_Control(p_stream->p_source, STREAM_CAN_FASTSEEK,
&b) == 0)
used = b;
}
if (!p_sys->b_size && vlc_stream_GetSize(p_stream->p_source, &size) == 0)
used = true;
if (!used) /* Nothing to do: skip this filter */
return VLC_EGENERIC;
p_stream->p_sys = p_sys;
p_stream->pf_read = Read;
p_stream->pf_seek = p_sys->b_seek ? Seek : NULL;
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 );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment