Commit 15d640b8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

probe: infrastructure for run-time features probing

parent dccd9472
/*****************************************************************************
* vlc_probe.h: service probing interface
*****************************************************************************
* Copyright (C) 2009 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 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.
*****************************************************************************/
#ifndef VLC_PROBE_H
# define VLC_PROBE_H 1
# include <stdlib.h>
/**
* \file
* This file defines functions and structures to run-time probe VLC extensions
*/
# ifdef __cplusplus
extern "C" {
# endif
VLC_EXPORT(void *, vlc_probe, (vlc_object_t *, const char *,
size_t *restrict));
#define vlc_probe(obj, cap, pcount) \
vlc_probe(VLC_OBJECT(obj), cap, pcount)
struct vlc_probe_t
{
VLC_COMMON_MEMBERS
void *list;
size_t count;
};
typedef struct vlc_probe_t vlc_probe_t;
static inline int vlc_probe_add(vlc_probe_t *obj, const void *data,
size_t len)
{
char *tab = (char *)realloc (obj->list, (obj->count + 1) * len);
if (unlikely(tab == NULL))
return VLC_ENOMEM;
memcpy(tab + (obj->count * len), data, len);
obj->list = tab;
obj->count++;
return VLC_SUCCESS;
}
# define VLC_PROBE_CONTINUE VLC_EGENERIC
# define VLC_PROBE_STOP VLC_SUCCESS
# ifdef __cplusplus
}
# endif
#endif
......@@ -88,6 +88,7 @@ pluginsinclude_HEADERS = \
../include/vlc_picture_pool.h \
../include/vlc_playlist.h \
../include/vlc_plugin.h \
../include/vlc_probe.h \
../include/vlc_rand.h \
../include/vlc_services_discovery.h \
../include/vlc_sql.h \
......@@ -402,6 +403,7 @@ SOURCES_libvlc_common = \
text/iso_lang.c \
text/iso-639_def.h \
misc/md5.c \
misc/probe.c \
misc/rand.c \
misc/mtime.c \
misc/block.c \
......
/*****************************************************************************
* probe.c : run-time service listing
*****************************************************************************
* Copyright © 2009 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 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_probe.h>
#include "libvlc.h"
#undef vlc_probe
void *vlc_probe (vlc_object_t *obj,
const char *capability, size_t *restrict pcount)
{
vlc_probe_t *probe = vlc_custom_create (obj, sizeof(*probe),
VLC_OBJECT_GENERIC, "probe");
if (unlikely(probe == NULL))
{
*pcount = 0;
return NULL;
}
probe->list = NULL;
probe->count = 0;
module_t *mod = module_need (probe, capability, NULL, false);
if (mod != NULL)
module_unneed (probe, mod);
void *ret = probe->list;
*pcount = probe->count;
vlc_object_release (probe);
return ret;
}
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