#define FPS_LONGTEXT N_(\
"Frame rate of a video elementary stream")
+#define COOKIE_TEXT N_("Callback cookie string")
+#define COOKIE_LONGTEXT N_(\
+ "Text identifier for the callback functions")
+
#define DATA_TEXT N_("Callback data")
#define DATA_LONGTEXT N_(\
"Data for the get and release functions")
change_volatile()
add_string ("imem-release", "0", NULL, RELEASE_TEXT, RELEASE_LONGTEXT, true)
change_volatile()
+ add_string ("imem-cookie", NULL, NULL, COOKIE_TEXT, COOKIE_LONGTEXT, true)
+ change_volatile()
add_string ("imem-data", "0", NULL, DATA_TEXT, DATA_LONGTEXT, true)
change_volatile()
*
* TODO define flags
*/
-typedef int (*imem_get_t)(void *data,
+typedef int (*imem_get_t)(void *data, const char *cookie,
int64_t *dts, int64_t *pts, unsigned *flags,
size_t *, void **);
-typedef void (*imem_release_t)(void *data, size_t, void *);
+typedef void (*imem_release_t)(void *data, const char *cookie, size_t, void *);
/*****************************************************************************
* Local prototypes
struct {
imem_get_t get;
imem_release_t release;
- void *data;
+ void *data;
+ char *cookie;
} source;
es_out_id_t *es;
tmp = var_CreateGetString(demux, "imem-data");
if (tmp)
- sys->source.data = (void*)(intptr_t)strtoll(tmp, NULL, 0);
+ sys->source.data = (void *)(uintptr_t)strtoull(tmp, NULL, 0);
free(tmp);
/* Now we can parse the MRL (get/release must not be parsed to avoid
if (*demux->psz_path)
ParseMRL(demux);
- msg_Dbg(demux, "Using get(%p) release(%p) and data(%p)",
- sys->source.get, sys->source.release, sys->source.data);
+ /* Now we can parse the MRL (get/release must not be parsed to avoid
+ * security risks) */
+ if (*demux->psz_path)
+ ParseMRL(demux);
+
+ sys->source.cookie = var_InheritString(demux, "imem-cookie");
+
+ msg_Dbg(demux, "Using get(%p), release(%p), data(%p), cookie(%s)",
+ sys->source.get, sys->source.release, sys->source.data,
+ sys->source.cookie ? sys->source.cookie : "(null)");
/* ES format */
es_format_t fmt;
es_format_Clean(&fmt);
if (!sys->es) {
+ free(sys->source.data);
free(sys);
return VLC_EGENERIC;
}
static void Close(vlc_object_t *object)
{
demux_t *demux = (demux_t *)object;
+ demux_sys_t *sys = demux->p_sys;
- free(demux->p_sys);
+ free(sys->source.cookie);
+ free(sys);
}
/**
size_t buffer_size;
void *buffer;
- if (sys->source.get(sys->source.data, &dts, &pts, &flags, &buffer_size, &buffer))
+ if (sys->source.get(sys->source.data, sys->source.cookie,
+ &dts, &pts, &flags, &buffer_size, &buffer))
return 0;
if (dts < 0)
sys->dts = dts;
- sys->source.release(sys->source.data, buffer_size, buffer);
+ sys->source.release(sys->source.data, sys->source.cookie,
+ buffer_size, buffer);
}
sys->deadline = VLC_TS_INVALID;
return 1;
{ "channels", VLC_VAR_INTEGER },
{ "width", VLC_VAR_INTEGER },
{ "height", VLC_VAR_INTEGER },
- { "data", VLC_VAR_STRING },
+ { "cookie", VLC_VAR_STRING },
{ "codec", VLC_VAR_STRING },
{ "language", VLC_VAR_STRING },
{ "dar", VLC_VAR_STRING },