Commit 346a3ebe authored by Laurent Aimar's avatar Laurent Aimar

Clean up vlm script parsing and introduce new API.

parent dabdeb40
......@@ -425,8 +425,6 @@ typedef struct osd_menu_state_t osd_menu_state_t;
/* VLM */
typedef struct vlm_t vlm_t;
typedef struct vlm_message_t vlm_message_t;
typedef struct vlm_media_t vlm_media_t;
typedef struct vlm_schedule_t vlm_schedule_t;
/* divers */
typedef struct vlc_meta_t vlc_meta_t;
......
......@@ -35,6 +35,106 @@ extern "C" {
#include <vlc_input.h>
/* VLM media */
typedef struct
{
int64_t id;
vlc_bool_t b_enabled;
/* */
char *psz_name;
/* */
int i_input;
char **ppsz_input;
int i_option;
char **ppsz_option;
char *psz_output;
/* */
vlc_bool_t b_vod;
struct
{
vlc_bool_t b_loop;
} broadcast;
struct
{
char *psz_mux;
} vod;
} vlm_media_t;
/* VLM media instance */
typedef struct
{
char *psz_name;
int64_t i_time;
int64_t i_length;
double d_position;
vlc_bool_t b_paused;
int i_rate; // normal is INPUT_RATE_DEFAULT
} vlm_media_instance_t;
#if 0
typedef struct
{
} vlm_schedule_t
#endif
/* VLM control query */
enum vlm_query_e
{
/* --- Media control */
/* Get all medias */
VLM_GET_MEDIAS, /* arg1=vlm_media_t ***, int *pi_media */
/* Delete all medias */
VLM_CLEAR_MEDIAS, /* no arg */
/* Add a new media */
VLM_ADD_MEDIA, /* arg1=vlm_media_t* arg2=int64_t *p_id res=can fail */
/* Delete an existing media */
VLM_DEL_MEDIA, /* arg1=int64_t id */
/* Change properties of an existing media (all fields but id and b_vod) */
VLM_CHANGE_MEDIA, /* arg1=vlm_media_t* res=can fail */
/* Get 1 media by it's ID */
VLM_GET_MEDIA, /* arg1=int64_t id arg2=vlm_media_t ** */
/* Get media ID from its name */
VLM_GET_MEDIA_ID, /* arg1=const char *psz_name arg2=int64_t* */
/* Media instance control XXX VOD control are for internal use only */
/* Get all media instances */
VLM_GET_MEDIA_INSTANCES, /* arg1=int64_t id arg2=vlm_media_instance_t *** arg3=int *pi_instance */
/* Delete all media instances */
VLM_CLEAR_MEDIA_INSTANCES, /* arg1=int64_t id */
/* Control broadcast instance */
VLM_START_MEDIA_BROADCAST_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index res=can fail */
/* Control VOD instance */
VLM_START_MEDIA_VOD_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name, int i_input_index char *psz_vod_output res=can fail */
/* Stop an instance */
VLM_STOP_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */
/* Pause an instance */
VLM_PAUSE_MEDIA_INSTANCE, /* arg1=int64_t id, arg2=const char *psz_instance_name res=can fail */
/* Get instance position time (in microsecond) */
VLM_GET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t * */
/* Set instance position time (in microsecond) */
VLM_SET_MEDIA_INSTANCE_TIME, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=int64_t */
/* Get instance position ([0.0 .. 1.0]) */
VLM_GET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double * */
/* Set instance position ([0.0 .. 1.0]) */
VLM_SET_MEDIA_INSTANCE_POSITION, /* arg1=int64_t id, arg2=const char *psz_instance_name arg3=double */
/* Schedule control */
VLM_CLEAR_SCHEDULES, /* no arg */
/* TODO: missing schedule control */
/* */
};
/* VLM specific - structures and functions */
/* ok, here is the structure of a vlm_message:
......@@ -55,11 +155,127 @@ struct vlm_message_t
VLC_EXPORT( vlm_t *, __vlm_New, ( vlc_object_t * ) );
VLC_EXPORT( void, vlm_Delete, ( vlm_t * ) );
VLC_EXPORT( int, vlm_ExecuteCommand, ( vlm_t *, const char *, vlm_message_t ** ) );
VLC_EXPORT( int, vlm_Control, ( vlm_t *p_vlm, int i_query, ... ) );
VLC_EXPORT( vlm_message_t *, vlm_MessageNew, ( const char *, const char *, ... ) );
VLC_EXPORT( vlm_message_t *, vlm_MessageAdd, ( vlm_message_t *, vlm_message_t * ) );
VLC_EXPORT( void, vlm_MessageDelete, ( vlm_message_t * ) );
/* media helpers */
static inline void vlm_media_Init( vlm_media_t *p_media )
{
memset( p_media, 0, sizeof(vlm_media_t) );
p_media->id = 0; // invalid id
p_media->psz_name = NULL;
TAB_INIT( p_media->i_input, p_media->ppsz_input );
TAB_INIT( p_media->i_option, p_media->ppsz_option );
p_media->psz_output = NULL;
p_media->b_vod = VLC_FALSE;
p_media->vod.psz_mux = NULL;
p_media->broadcast.b_loop = VLC_FALSE;
}
static inline void vlm_media_Copy( vlm_media_t *p_dst, vlm_media_t *p_src )
{
int i;
memset( p_dst, 0, sizeof(vlm_media_t) );
p_dst->id = p_src->id;
p_dst->b_enabled = p_src->b_enabled;
if( p_src->psz_name )
p_dst->psz_name = strdup( p_src->psz_name );
for( i = 0; i < p_src->i_input; i++ )
TAB_APPEND( p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) );
for( i = 0; i < p_src->i_option; i++ )
TAB_APPEND( p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) );
if( p_src->psz_output )
p_dst->psz_output = strdup( p_src->psz_output );
p_dst->b_vod = p_src->b_vod;
if( p_src->b_vod )
{
if( p_src->vod.psz_mux )
p_dst->vod.psz_mux = strdup( p_src->vod.psz_mux );
}
else
{
p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
}
}
static inline void vlm_media_Clean( vlm_media_t *p_media )
{
int i;
if( p_media->psz_name )
free( p_media->psz_name );
for( i = 0; i < p_media->i_input; i++ )
free( p_media->ppsz_input[i]) ;
TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
for( i = 0; i < p_media->i_option; i++ )
free( p_media->ppsz_option[i]) ;
TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
if( p_media->psz_output )
free( p_media->psz_output );
if( p_media->b_vod )
{
if( p_media->vod.psz_mux )
free( p_media->vod.psz_mux );
}
}
static inline vlm_media_t *vlm_media_New(void)
{
vlm_media_t *p_media = malloc( sizeof(vlm_media_t) );
if( p_media )
vlm_media_Init( p_media );
return p_media;
}
static inline void vlm_media_Delete( vlm_media_t *p_media )
{
vlm_media_Clean( p_media );
free( p_media );
}
static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
{
vlm_media_t *p_dst = vlm_media_New();
if( p_dst )
vlm_media_Copy( p_dst, p_src );
return p_dst;
}
/* media instance helpers */
static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
{
memset( p_instance, 0, sizeof(vlm_media_instance_t) );
p_instance->psz_name = NULL;
p_instance->i_time = 0;
p_instance->i_length = 0;
p_instance->d_position = 0.0;
p_instance->b_paused = VLC_FALSE;
p_instance->i_rate = INPUT_RATE_DEFAULT;
}
static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
{
if( p_instance->psz_name )
free( p_instance->psz_name );
}
static inline vlm_media_instance_t *vlm_media_instance_New(void)
{
vlm_media_instance_t *p_instance = malloc( sizeof(vlm_media_instance_t) );
if( p_instance )
vlm_media_instance_Init( p_instance );
return p_instance;
}
static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
{
vlm_media_instance_Clean( p_instance );
free( p_instance );
}
#ifdef __cpluplus
}
#endif
......
This diff is collapsed.
......@@ -26,14 +26,7 @@
#include <vlc_vlm.h>
enum
{
VOD_TYPE = 0,
BROADCAST_TYPE,
SCHEDULE_TYPE,
};
/* Private */
typedef struct
{
/* instance name */
......@@ -48,40 +41,25 @@ typedef struct
input_thread_t *p_input;
sout_instance_t *p_sout;
} vlm_media_instance_t;
struct vlm_media_t
{
vlc_bool_t b_enabled;
int i_type;
/* name "media" is reserved */
char *psz_name;
input_item_t item;
/* "playlist" */
int i_input;
char **input;
} vlm_media_instance_sys_t;
int i_option;
char **option;
char *psz_output;
/* only for broadcast */
vlc_bool_t b_loop;
typedef struct
{
vlm_media_t cfg;
/* only for vod */
vod_media_t *vod_media;
char *psz_vod_output;
char *psz_mux;
struct
{
input_item_t item;
vod_media_t *p_media;
} vod;
/* actual input instances */
int i_instance;
vlm_media_instance_t **instance;
};
int i_instance;
vlm_media_instance_sys_t **instance;
} vlm_media_sys_t;
struct vlm_schedule_t
typedef struct
{
/* names "schedule" is reserved */
char *psz_name;
......@@ -98,7 +76,7 @@ struct vlm_schedule_t
/* number of times you have to repeat
i_repeat < 0 : endless repeat */
int i_repeat;
};
} vlm_schedule_sys_t;
struct vlm_t
......@@ -107,14 +85,20 @@ struct vlm_t
vlc_mutex_t lock;
int i_media;
vlm_media_t **media;
/* */
int64_t i_id;
/* Vod server (used by media) */
int i_vod;
vod_t *vod;
vod_t *p_vod;
/* Media list */
int i_media;
vlm_media_sys_t **media;
/* Schedule list */
int i_schedule;
vlm_schedule_t **schedule;
vlm_schedule_sys_t **schedule;
};
#endif
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