/*****************************************************************************
* Preamble
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <vlc/vlc.h>
#include <stdio.h>
#include <ctype.h> /* tolower() */
#include <assert.h>
+#include <vlc_vlm.h>
+
#ifdef ENABLE_VLM
+#ifndef WIN32
+# include <sys/time.h> /* gettimeofday() */
+#endif
#ifdef HAVE_TIME_H
# include <time.h> /* ctime() */
#include <vlc_input.h>
#include "input_internal.h"
#include <vlc_stream.h>
-#include <vlc_vlm.h>
#include "vlm_internal.h"
#include <vlc_vod.h>
#include <vlc_charset.h>
#include <vlc_sout.h>
#include "../stream_output/stream_output.h"
+#include "../libvlc.h"
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
+
+/* ugly kludge to avoid "null format string" warnings,
+ * even if we handle NULL format string in vlm_MessageNew() */
+static const char *vlm_NULL = NULL;
+
+static void vlm_Destructor( vlm_t *p_vlm );
+
/* */
static int vlm_ControlInternal( vlm_t *, int, ... );
/* */
static vlm_message_t *vlm_Show( vlm_t *, vlm_media_sys_t *, vlm_schedule_sys_t *, const char * );
-static vlm_message_t *vlm_Help( vlm_t *, char * );
static vlm_schedule_sys_t *vlm_ScheduleSearch( vlm_t *, const char * );
static int Manage( vlc_object_t * );
static vlm_schedule_sys_t *vlm_ScheduleNew( vlm_t *vlm, const char *psz_name );
-static void vlm_ScheduleDelete( vlm_t *vlm, vlm_schedule_sys_t *sched, const char *psz_name );
+static void vlm_ScheduleDelete( vlm_t *vlm, vlm_schedule_sys_t *sched );
static int vlm_ScheduleSetup( vlm_schedule_sys_t *schedule, const char *psz_cmd,
const char *psz_value );
vlc_value_t lockval;
vlm_t *p_vlm = NULL;
char *psz_vlmconf;
+ static const char vlm_object_name[] = "vlm daemon";
/* Avoid multiple creation */
if( var_Create( p_this->p_libvlc, "vlm_mutex", VLC_VAR_MUTEX ) ||
msg_Dbg( p_this, "creating VLM" );
- p_vlm = vlc_object_create( p_this, VLC_OBJECT_VLM );
+ p_vlm = vlc_custom_create( p_this, sizeof( *p_vlm ), VLC_OBJECT_VLM,
+ vlm_object_name );
if( !p_vlm )
{
vlc_mutex_unlock( lockval.p_address );
TAB_INIT( p_vlm->i_schedule, p_vlm->schedule );
p_vlm->i_vod = 0;
p_vlm->p_vod = NULL;
- vlc_object_yield( p_vlm );
vlc_object_attach( p_vlm, p_this->p_libvlc );
if( vlc_thread_create( p_vlm, "vlm thread",
Manage, VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
{
vlc_mutex_destroy( &p_vlm->lock );
- vlc_object_destroy( p_vlm );
+ vlc_object_release( p_vlm );
return NULL;
}
}
free(psz_vlmconf);
+ vlc_object_set_destructor( p_vlm, (vlc_destructor_t)vlm_Destructor );
vlc_mutex_unlock( lockval.p_address );
return p_vlm;
*****************************************************************************/
void vlm_Delete( vlm_t *p_vlm )
{
- vlc_value_t lockval;
-
- var_Get( p_vlm->p_libvlc, "vlm_mutex", &lockval );
- vlc_mutex_lock( lockval.p_address );
-
vlc_object_release( p_vlm );
+}
- if( p_vlm->i_refcount > 0 )
- {
- vlc_mutex_unlock( lockval.p_address );
- return;
- }
-
- vlc_object_kill( p_vlm );
- vlc_thread_join( p_vlm );
-
- vlc_object_detach( p_vlm );
-
+/*****************************************************************************
+ * vlm_Destructor:
+ *****************************************************************************/
+static void vlm_Destructor( vlm_t *p_vlm )
+{
vlm_ControlInternal( p_vlm, VLM_CLEAR_MEDIAS );
TAB_CLEAN( p_vlm->i_media, p_vlm->media );
TAB_CLEAN( p_vlm->schedule, p_vlm->schedule );
vlc_mutex_destroy( &p_vlm->lock );
-
- vlc_object_destroy( p_vlm );
- vlc_mutex_unlock( lockval.p_address );
}
/*****************************************************************************
if( p_schedule != NULL )
{
- vlm_ScheduleDelete( p_vlm, p_schedule, NULL );
+ vlm_ScheduleDelete( p_vlm, p_schedule );
}
else if( p_media != NULL )
{
return VLC_EGENERIC;
}
- *pp_status = vlm_MessageNew( "del", NULL );
+ *pp_status = vlm_MessageNew( "del", vlm_NULL );
return VLC_SUCCESS;
}
return VLC_SUCCESS;
}
-static int ExecuteHelp( vlm_t *p_vlm, vlm_message_t **pp_status )
+static int ExecuteHelp( vlm_message_t *p_status )
{
- *pp_status = vlm_Help( p_vlm, NULL );
+ vlm_message_t *message_child;
+
+#define MessageAdd( a ) \
+ vlm_MessageAdd( p_status, vlm_MessageNew( a, vlm_NULL ) );
+#define MessageAddChild( a ) \
+ vlm_MessageAdd( message_child, vlm_MessageNew( a, vlm_NULL ) );
+
+ p_status = vlm_MessageNew( "help", vlm_NULL );
+
+ message_child = MessageAdd( "Commands Syntax:" );
+ MessageAddChild( "new (name) vod|broadcast|schedule [properties]" );
+ MessageAddChild( "setup (name) (properties)" );
+ MessageAddChild( "show [(name)|media|schedule]" );
+ MessageAddChild( "del (name)|all|media|schedule" );
+ MessageAddChild( "control (name) [instance_name] (command)" );
+ MessageAddChild( "save (config_file)" );
+ MessageAddChild( "export" );
+ MessageAddChild( "load (config_file)" );
+
+ message_child = MessageAdd( "Media Proprieties Syntax:" );
+ MessageAddChild( "input (input_name)" );
+ MessageAddChild( "inputdel (input_name)|all" );
+ MessageAddChild( "inputdeln input_number" );
+ MessageAddChild( "output (output_name)" );
+ MessageAddChild( "option (option_name)[=value]" );
+ MessageAddChild( "enabled|disabled" );
+ MessageAddChild( "loop|unloop (broadcast only)" );
+ MessageAddChild( "mux (mux_name)" );
+
+ message_child = MessageAdd( "Schedule Proprieties Syntax:" );
+ MessageAddChild( "enabled|disabled" );
+ MessageAddChild( "append (command_until_rest_of_the_line)" );
+ MessageAddChild( "date (year)/(month)/(day)-(hour):(minutes):"
+ "(seconds)|now" );
+ MessageAddChild( "period (years_aka_12_months)/(months_aka_30_days)/"
+ "(days)-(hours):(minutes):(seconds)" );
+ MessageAddChild( "repeat (number_of_repetitions)" );
+
+ message_child = MessageAdd( "Control Commands Syntax:" );
+ MessageAddChild( "play [input_number]" );
+ MessageAddChild( "pause" );
+ MessageAddChild( "stop" );
+ MessageAddChild( "seek [+-](percentage) | [+-](seconds)s | [+-](miliseconds)ms" );
+
return VLC_SUCCESS;
}
*pp_status = vlm_MessageNew( "control", "unknown error" );
return VLC_SUCCESS;
}
- *pp_status = vlm_MessageNew( "control", NULL );
+ *pp_status = vlm_MessageNew( "control", vlm_NULL );
return VLC_SUCCESS;
}
free( psz_save );
fclose( f );
- *pp_status = vlm_MessageNew( "save", NULL );
+ *pp_status = vlm_MessageNew( "save", vlm_NULL );
return VLC_SUCCESS;
error:
free( psz_buffer );
- *pp_status = vlm_MessageNew( "load", NULL );
+ *pp_status = vlm_MessageNew( "load", vlm_NULL );
return VLC_SUCCESS;
}
if( i + 1 >= i_property )
{
if( b_new )
- vlm_ScheduleDelete( p_vlm, p_schedule, NULL );
+ vlm_ScheduleDelete( p_vlm, p_schedule );
return ExecuteSyntaxError( psz_cmd, pp_status );
}
i++;
}
}
- *pp_status = vlm_MessageNew( psz_cmd, NULL );
+ *pp_status = vlm_MessageNew( psz_cmd, vlm_NULL );
return VLC_SUCCESS;
}
int i_result;
int i;
+#undef ERROR
+#undef MISSING
#define ERROR( txt ) do { *pp_status = vlm_MessageNew( psz_cmd, txt); goto error; } while(0)
if( vlm_ControlInternal( p_vlm, VLM_GET_MEDIA, id, &p_cfg ) )
ERROR( "unknown media" );
int i_index;
MISSING( "inputdeln" );
-
+
i_index = atoi( psz_value );
if( i_index > 0 && i_index <= p_cfg->i_input )
TAB_REMOVE( p_cfg->i_input, p_cfg->ppsz_input, p_cfg->ppsz_input[i_index-1] );
{
MISSING( "output" );
- if( p_cfg->psz_output != NULL )
- free( p_cfg->psz_output );
+ free( p_cfg->psz_output );
p_cfg->psz_output = *psz_value ? strdup( psz_value ) : NULL;
i++;
}
if( !p_cfg->b_vod )
ERROR( "invalid mux option for broadcast" );
- if( p_cfg->vod.psz_mux )
- free( p_cfg->vod.psz_mux );
+ free( p_cfg->vod.psz_mux );
p_cfg->vod.psz_mux = *psz_value ? strdup( psz_value ) : NULL;
i++;
}
i_result = vlm_ControlInternal( p_vlm, VLM_CHANGE_MEDIA, p_cfg );
vlm_media_Delete( p_cfg );
- *pp_status = vlm_MessageNew( psz_cmd, NULL );
+ *pp_status = vlm_MessageNew( psz_cmd, vlm_NULL );
return i_result;
error:
}
return VLC_EGENERIC;
}
+
static int ExecuteNew( vlm_t *p_vlm, const char *psz_name, const char *psz_type, const int i_property, char *ppsz_property[], vlm_message_t **pp_status )
{
/* Check name */
/* support for comments */
if( i_command == 0 && *psz_command == '#')
{
- p_message = vlm_MessageNew( "", NULL );
+ p_message = vlm_MessageNew( "", vlm_NULL );
goto success;
}
#define IF_EXECUTE( name, check, cmd ) if( !strcmp(ppsz_command[0], name ) ) { if( (check) ) goto syntax_error; if( (cmd) ) goto error; goto success; }
if( i_command == 0 )
{
- p_message = vlm_MessageNew( "", NULL );
+ p_message = vlm_MessageNew( "", vlm_NULL );
goto success;
}
else IF_EXECUTE( "del", (i_command != 2), ExecuteDel(p_vlm, ppsz_command[1], &p_message) )
else IF_EXECUTE( "show", (i_command > 2), ExecuteShow(p_vlm, i_command > 1 ? ppsz_command[1] : NULL, &p_message) )
- else IF_EXECUTE( "help", (i_command != 1), ExecuteHelp(p_vlm, &p_message) )
+ else IF_EXECUTE( "help", (i_command != 1), ExecuteHelp( p_message) )
else IF_EXECUTE( "control", (i_command < 3), ExecuteControl(p_vlm, ppsz_command[1], i_command - 2, &ppsz_command[2], &p_message) )
else IF_EXECUTE( "save", (i_command != 2), ExecuteSave(p_vlm, ppsz_command[1], &p_message) )
else IF_EXECUTE( "export", (i_command != 1), ExecuteExport(p_vlm, &p_message) )
ftime( &tm );
return ((int64_t)tm.time) * 1000000 + ((int64_t)tm.millitm) * 1000;
#else
- return mdate();
+ struct timeval tv_date;
+
+ /* gettimeofday() cannot fail given &tv_date is a valid address */
+ (void)gettimeofday( &tv_date, NULL );
+ return (mtime_t) tv_date.tv_sec * 1000000 + (mtime_t) tv_date.tv_usec;
#endif
}
}
/* for now, simple delete. After, del with options (last arg) */
-static void vlm_ScheduleDelete( vlm_t *vlm, vlm_schedule_sys_t *sched,
- const char *psz_name )
+static void vlm_ScheduleDelete( vlm_t *vlm, vlm_schedule_sys_t *sched )
{
if( sched == NULL ) return;
TAB_REMOVE( vlm->i_schedule, vlm->schedule, sched );
- if( vlm->i_schedule == 0 && vlm->schedule ) free( vlm->schedule );
+ if( vlm->i_schedule == 0 ) free( vlm->schedule );
free( sched->psz_name );
while( sched->i_command )
{
void vlm_MessageDelete( vlm_message_t *p_message )
{
- if( p_message->psz_name ) free( p_message->psz_name );
- if( p_message->psz_value ) free( p_message->psz_value );
+ free( p_message->psz_name );
+ free( p_message->psz_value );
while( p_message->i_child-- )
vlm_MessageDelete( p_message->child[p_message->i_child] );
- if( p_message->child ) free( p_message->child );
+ free( p_message->child );
free( p_message );
}
/*****************************************************************************
* Misc utility functions
*****************************************************************************/
-static vlm_message_t *vlm_ShowMedia( vlm_t *p_vlm, vlm_media_sys_t *p_media )
+static vlm_message_t *vlm_ShowMedia( vlm_media_sys_t *p_media )
{
vlm_media_t *p_cfg = &p_media->cfg;
vlm_message_t *p_msg;
vlm_message_t *p_msg_sub;
int i;
- p_msg = vlm_MessageNew( p_cfg->psz_name, 0 );
+ p_msg = vlm_MessageNew( p_cfg->psz_name, vlm_NULL );
vlm_MessageAdd( p_msg,
vlm_MessageNew( "type", p_cfg->b_vod ? "vod" : "broadcast" ) );
vlm_MessageAdd( p_msg,
vlm_MessageAdd( p_msg,
vlm_MessageNew( "loop", p_cfg->broadcast.b_loop ? "yes" : "no" ) );
- p_msg_sub = vlm_MessageAdd( p_msg, vlm_MessageNew( "inputs", NULL ) );
+ p_msg_sub = vlm_MessageAdd( p_msg, vlm_MessageNew( "inputs", vlm_NULL ) );
for( i = 0; i < p_cfg->i_input; i++ )
{
char *psz_tmp;
vlm_MessageAdd( p_msg,
vlm_MessageNew( "output", p_cfg->psz_output ? p_cfg->psz_output : "" ) );
- p_msg_sub = vlm_MessageAdd( p_msg, vlm_MessageNew( "options", 0 ) );
+ p_msg_sub = vlm_MessageAdd( p_msg, vlm_MessageNew( "options", vlm_NULL ) );
for( i = 0; i < p_cfg->i_option; i++ )
- vlm_MessageAdd( p_msg_sub, vlm_MessageNew( p_cfg->ppsz_option[i], 0 ) );
+ vlm_MessageAdd( p_msg_sub, vlm_MessageNew( p_cfg->ppsz_option[i], vlm_NULL ) );
- p_msg_sub = vlm_MessageAdd( p_msg, vlm_MessageNew( "instances", NULL ) );
+ p_msg_sub = vlm_MessageAdd( p_msg, vlm_MessageNew( "instances", vlm_NULL ) );
for( i = 0; i < p_media->i_instance; i++ )
{
vlm_media_instance_sys_t *p_instance = p_media->instance[i];
if( p_instance->p_input )
var_Get( p_instance->p_input, "state", &val );
- p_msg_instance = vlm_MessageAdd( p_msg_sub, vlm_MessageNew( "instance" , NULL ) );
+ p_msg_instance = vlm_MessageAdd( p_msg_sub, vlm_MessageNew( "instance" , vlm_NULL ) );
vlm_MessageAdd( p_msg_instance,
vlm_MessageNew( "name" , p_instance->psz_name ? p_instance->psz_name : "default" ) );
{
if( media != NULL )
{
- vlm_message_t *p_msg = vlm_MessageNew( "show", NULL );
+ vlm_message_t *p_msg = vlm_MessageNew( "show", vlm_NULL );
if( p_msg )
- vlm_MessageAdd( p_msg, vlm_ShowMedia( vlm, media ) );
+ vlm_MessageAdd( p_msg, vlm_ShowMedia( media ) );
return p_msg;
}
vlm_message_t *msg_child;
char buffer[100];
- msg = vlm_MessageNew( "show", NULL );
+ msg = vlm_MessageNew( "show", vlm_NULL );
msg_schedule =
- vlm_MessageAdd( msg, vlm_MessageNew( schedule->psz_name, 0 ) );
+ vlm_MessageAdd( msg, vlm_MessageNew( schedule->psz_name, vlm_NULL ) );
vlm_MessageAdd( msg_schedule, vlm_MessageNew("type", "schedule") );
time_t i_time = (time_t)( schedule->i_date / 1000000 );
char *psz_date;
-#ifdef HAVE_LOCALTIME_R
localtime_r( &i_time, &date);
-#else
- struct tm *p_date = localtime( &i_time );
- date = *p_date;
-#endif
-
asprintf( &psz_date, "%d/%d/%d-%d:%d:%d",
date.tm_year + 1900, date.tm_mon + 1, date.tm_mday,
date.tm_hour, date.tm_min, date.tm_sec );
vlm_MessageAdd( msg_schedule, vlm_MessageNew( "repeat", buffer ) );
msg_child =
- vlm_MessageAdd( msg_schedule, vlm_MessageNew("commands", 0) );
+ vlm_MessageAdd( msg_schedule, vlm_MessageNew("commands", vlm_NULL ) );
for( i = 0; i < schedule->i_command; i++ )
{
vlm_MessageAdd( msg_child,
- vlm_MessageNew( schedule->command[i], NULL ) );
+ vlm_MessageNew( schedule->command[i], vlm_NULL ) );
}
return msg;
asprintf( &psz_count, "( %d broadcast - %d vod )", i_broadcast, i_vod);
- p_msg = vlm_MessageNew( "show", NULL );
+ p_msg = vlm_MessageNew( "show", vlm_NULL );
p_msg_child = vlm_MessageAdd( p_msg, vlm_MessageNew( "media", psz_count ) );
free( psz_count );
for( i = 0; i < vlm->i_media; i++ )
- vlm_MessageAdd( p_msg_child, vlm_ShowMedia( vlm, vlm->media[i] ) );
+ vlm_MessageAdd( p_msg_child, vlm_ShowMedia( vlm->media[i] ) );
return p_msg;
}
vlm_message_t *msg;
vlm_message_t *msg_child;
- msg = vlm_MessageNew( "show", NULL );
- msg_child = vlm_MessageAdd( msg, vlm_MessageNew( "schedule", NULL ) );
+ msg = vlm_MessageNew( "show", vlm_NULL );
+ msg_child = vlm_MessageAdd( msg, vlm_MessageNew( "schedule", vlm_NULL ) );
for( i = 0; i < vlm->i_schedule; i++ )
{
mtime_t i_time, i_next_date;
msg_schedule = vlm_MessageAdd( msg_child,
- vlm_MessageNew( s->psz_name, 0 ) );
+ vlm_MessageNew( s->psz_name, vlm_NULL ) );
vlm_MessageAdd( msg_schedule,
vlm_MessageNew( "enabled", s->b_enabled ?
"yes" : "no" ) );
else
{
- return vlm_MessageNew( "show", NULL );
+ return vlm_MessageNew( "show", vlm_NULL );
}
}
-static vlm_message_t *vlm_Help( vlm_t *vlm, char *psz_filter )
-{
- vlm_message_t *message, *message_child;
-
-#define MessageAdd( a ) \
- vlm_MessageAdd( message, vlm_MessageNew( a, NULL ) );
-#define MessageAddChild( a ) \
- vlm_MessageAdd( message_child, vlm_MessageNew( a, NULL ) );
-
- if( psz_filter == NULL )
- {
- message = vlm_MessageNew( "help", NULL );
-
- message_child = MessageAdd( "Commands Syntax:" );
- MessageAddChild( "new (name) vod|broadcast|schedule [properties]" );
- MessageAddChild( "setup (name) (properties)" );
- MessageAddChild( "show [(name)|media|schedule]" );
- MessageAddChild( "del (name)|all|media|schedule" );
- MessageAddChild( "control (name) [instance_name] (command)" );
- MessageAddChild( "save (config_file)" );
- MessageAddChild( "export" );
- MessageAddChild( "load (config_file)" );
-
- message_child = MessageAdd( "Media Proprieties Syntax:" );
- MessageAddChild( "input (input_name)" );
- MessageAddChild( "inputdel (input_name)|all" );
- MessageAddChild( "inputdeln input_number" );
- MessageAddChild( "output (output_name)" );
- MessageAddChild( "option (option_name)[=value]" );
- MessageAddChild( "enabled|disabled" );
- MessageAddChild( "loop|unloop (broadcast only)" );
- MessageAddChild( "mux (mux_name)" );
-
- message_child = MessageAdd( "Schedule Proprieties Syntax:" );
- MessageAddChild( "enabled|disabled" );
- MessageAddChild( "append (command_until_rest_of_the_line)" );
- MessageAddChild( "date (year)/(month)/(day)-(hour):(minutes):"
- "(seconds)|now" );
- MessageAddChild( "period (years_aka_12_months)/(months_aka_30_days)/"
- "(days)-(hours):(minutes):(seconds)" );
- MessageAddChild( "repeat (number_of_repetitions)" );
-
- message_child = MessageAdd( "Control Commands Syntax:" );
- MessageAddChild( "play [input_number]" );
- MessageAddChild( "pause" );
- MessageAddChild( "stop" );
- MessageAddChild( "seek [+-](percentage) | [+-](seconds)s | [+-](miliseconds)ms" );
-
- return message;
- }
-
- return vlm_MessageNew( "help", NULL );
-}
-
/*****************************************************************************
* Config handling functions
*****************************************************************************/
/* now we have the length of save */
p = save = malloc( i_length );
+ if( !save ) return NULL;
*save = '\0';
p += sprintf( p, "%s", psz_header );
struct tm date;
time_t i_time = (time_t) ( schedule->i_date / 1000000 );
-#ifdef HAVE_LOCALTIME_R
localtime_r( &i_time, &date);
-#else
- struct tm *p_date = localtime( &i_time );
- date = *p_date;
-#endif
-
p += sprintf( p, "new %s schedule ", schedule->psz_name);
if( schedule->b_enabled == VLC_TRUE )
char *psz_dup;
int i;
- input_ItemClean( &p_media->vod.item );
- input_ItemInit( VLC_OBJECT(p_vlm), &p_media->vod.item );
+ vlc_gc_decref( p_media->vod.p_item );
+ p_media->vod.p_item = input_ItemNew( p_vlm, p_cfg->ppsz_input[0],
+ p_cfg->psz_name );
if( p_cfg->psz_output )
asprintf( &psz_output, "%s:description", p_cfg->psz_output );
else
asprintf( &psz_output, "#description" );
- p_media->vod.item.psz_uri = strdup( p_cfg->ppsz_input[0] );
-
- TAB_INIT( p_media->vod.item.i_options, p_media->vod.item.ppsz_options );
-
asprintf( &psz_dup, "sout=%s", psz_output);
- TAB_APPEND( p_media->vod.item.i_options, p_media->vod.item.ppsz_options, psz_dup );
+ input_ItemAddOption( p_media->vod.p_item, psz_dup );
+ free( psz_dup );
for( i = 0; i < p_cfg->i_option; i++ )
- {
- psz_dup = strdup( p_cfg->ppsz_option[i] );
- TAB_APPEND( p_media->vod.item.i_options, p_media->vod.item.ppsz_options, psz_dup );
- }
- psz_dup = strdup( "no-sout-keep" );
- TAB_APPEND( p_media->vod.item.i_options, p_media->vod.item.ppsz_options, psz_dup );
+ input_ItemAddOption( p_media->vod.p_item,
+ p_cfg->ppsz_option[i] );
+ input_ItemAddOption( p_media->vod.p_item, "no-sout-keep" );
asprintf( &psz_header, _("Media: %s"), p_cfg->psz_name );
- if( (p_input = input_CreateThreadExtended( p_vlm, &p_media->vod.item, psz_header, NULL ) ) )
+ if( (p_input = input_CreateThreadExtended( p_vlm, p_media->vod.p_item, psz_header, NULL ) ) )
{
while( !p_input->b_eof && !p_input->b_error )
msleep( 100000 );
input_StopThread( p_input );
- input_DestroyThreadExtended( p_input, NULL );
+ vlc_object_release( p_input );
}
free( psz_output );
free( psz_header );
fourcc[0] = tolower(fourcc[0]); fourcc[1] = tolower(fourcc[1]);
fourcc[2] = tolower(fourcc[2]); fourcc[3] = tolower(fourcc[3]);
- item = p_media->vod.item;
+ /* XXX: Don't do it that way, but properly use a new input item ref. */
+ item = *p_media->vod.p_item;
item.i_es = 1;
item.es = &p_es;
es_format_Init( &es, VIDEO_ES, *((int *)fourcc) );
else
{
p_media->vod.p_media =
- p_vlm->p_vod->pf_media_new( p_vlm->p_vod, p_cfg->psz_name, &p_media->vod.item );
+ p_vlm->p_vod->pf_media_new( p_vlm->p_vod, p_cfg->psz_name, p_media->vod.p_item );
}
}
}
return vlm_OnMediaUpdate( p_vlm, p_media );
}
+
static int vlm_ControlMediaAdd( vlm_t *p_vlm, vlm_media_t *p_cfg, int64_t *p_id )
{
vlm_media_sys_t *p_media;
/* Check if we need to load the VOD server */
if( p_cfg->b_vod && !p_vlm->i_vod )
{
- p_vlm->p_vod = vlc_object_create( p_vlm, VLC_OBJECT_VOD );
+ p_vlm->p_vod = vlc_custom_create( VLC_OBJECT(p_vlm), sizeof( vod_t ),
+ VLC_OBJECT_GENERIC, "vod server" );
vlc_object_attach( p_vlm->p_vod, p_vlm );
p_vlm->p_vod->p_module = module_Need( p_vlm->p_vod, "vod server", 0, 0 );
if( !p_vlm->p_vod->p_module )
{
msg_Err( p_vlm, "cannot find vod server" );
vlc_object_detach( p_vlm->p_vod );
- vlc_object_destroy( p_vlm->p_vod );
+ vlc_object_release( p_vlm->p_vod );
p_vlm->p_vod = 0;
return VLC_EGENERIC;
}
p_vlm->p_vod->p_data = p_vlm;
p_vlm->p_vod->pf_media_control = vlm_MediaVodControl;
}
- if( p_cfg->b_vod )
- p_vlm->i_vod++;
p_media = malloc( sizeof( vlm_media_sys_t ) );
+ if( !p_media )
+ {
+ msg_Err( p_vlm, "out of memory" );
+ return VLC_ENOMEM;
+ }
memset( p_media, 0, sizeof(vlm_media_sys_t) );
+ if( p_cfg->b_vod )
+ p_vlm->i_vod++;
+
vlm_media_Copy( &p_media->cfg, p_cfg );
p_media->cfg.id = p_vlm->i_id++;
/* FIXME do we do something here if enabled is true ? */
- input_ItemInit( VLC_OBJECT(p_vlm), &p_media->vod.item );
+ p_media->vod.p_item = input_ItemNew( p_vlm, NULL, NULL );
p_media->vod.p_media = NULL;
TAB_INIT( p_media->i_instance, p_media->instance );
vlm_media_Clean( &p_media->cfg );
- input_ItemClean( &p_media->vod.item );
+ vlc_gc_decref( p_media->vod.p_item );
TAB_REMOVE( p_vlm->i_media, p_vlm->media, p_media );
{
module_Unneed( p_vlm->p_vod, p_vlm->p_vod->p_module );
vlc_object_detach( p_vlm->p_vod );
- vlc_object_destroy( p_vlm->p_vod );
+ vlc_object_release( p_vlm->p_vod );
p_vlm->p_vod = NULL;
}
return VLC_SUCCESS;
if( psz_name )
p_instance->psz_name = strdup( psz_name );
- input_ItemInit( VLC_OBJECT(p_vlm), &p_instance->item );
+ p_instance->p_item = input_ItemNew( p_vlm, NULL, NULL );
p_instance->i_index = 0;
p_instance->b_sout_keep = VLC_FALSE;
if( p_instance->p_input )
{
input_StopThread( p_instance->p_input );
- input_DestroyThreadExtended( p_instance->p_input, &p_instance->p_sout );
+ p_instance->p_sout = input_DetachSout( p_instance->p_input );
+ vlc_object_release( p_instance->p_input );
}
if( p_instance->p_sout )
sout_DeleteInstance( p_instance->p_sout );
- input_ItemClean( &p_instance->item );
- if( p_instance->psz_name )
- free( p_instance->psz_name );
+ vlc_gc_decref( p_instance->p_item );
+ free( p_instance->psz_name );
free( p_instance );
}
if( !p_instance )
{
vlm_media_t *p_cfg = &p_media->cfg;
- char *psz_keep;
+ const char *psz_keep;
int i;
p_instance = vlm_MediaInstanceNew( p_vlm, psz_id );
if( !p_instance )
return VLC_ENOMEM;
- TAB_INIT( p_instance->item.i_options, p_instance->item.ppsz_options );
-
if( p_cfg->psz_output != NULL || psz_vod_output != NULL )
{
char *psz_buffer;
p_cfg->psz_output ? p_cfg->psz_output : "",
(p_cfg->psz_output && psz_vod_output) ? ":" : psz_vod_output ? "#" : "",
psz_vod_output ? psz_vod_output : "" );
- TAB_APPEND( p_instance->item.i_options, p_instance->item.ppsz_options, psz_buffer );
+ input_ItemAddOption( p_instance->p_item, psz_buffer );
+ free( psz_buffer );
}
for( i = 0; i < p_cfg->i_option; i++ )
else if( !strcmp( p_cfg->ppsz_option[i], "nosout-keep" ) || !strcmp( p_cfg->ppsz_option[i], "no-sout-keep" ) )
p_instance->b_sout_keep = VLC_FALSE;
else
- TAB_APPEND( p_instance->item.i_options, p_instance->item.ppsz_options, strdup( p_cfg->ppsz_option[i] ) );
+ input_ItemAddOption( p_instance->p_item, p_cfg->ppsz_option[i] );
}
/* We force the right sout-keep value (avoid using the sout-keep from the global configuration)
* FIXME implement input list for VOD (need sout-keep)
* */
if( !p_cfg->b_vod && p_instance->b_sout_keep )
- psz_keep = strdup( "sout-keep" );
+ psz_keep = "sout-keep";
else
- psz_keep = strdup( "no-sout-keep" );
- TAB_APPEND( p_instance->item.i_options, p_instance->item.ppsz_options, psz_keep );
+ psz_keep = "no-sout-keep";
+ input_ItemAddOption( p_instance->p_item, psz_keep );
TAB_APPEND( p_media->i_instance, p_media->instance, p_instance );
}
}
input_StopThread( p_instance->p_input );
- input_DestroyThreadExtended( p_instance->p_input, &p_instance->p_sout );
+ p_instance->p_sout = input_DetachSout( p_instance->p_input );
+ vlc_object_release( p_instance->p_input );
if( !p_instance->b_sout_keep && p_instance->p_sout )
{
sout_DeleteInstance( p_instance->p_sout );
/* Start new one */
p_instance->i_index = i_input_index;
- input_item_SetURI( &p_instance->item, p_media->cfg.ppsz_input[p_instance->i_index] ) ;
+ input_item_SetURI( p_instance->p_item, p_media->cfg.ppsz_input[p_instance->i_index] ) ;
asprintf( &psz_log, _("Media: %s"), p_media->cfg.psz_name );
- p_instance->p_input = input_CreateThreadExtended( p_vlm, &p_instance->item, psz_log, p_instance->p_sout );
+ p_instance->p_input = input_CreateThreadExtended( p_vlm, p_instance->p_item, psz_log, p_instance->p_sout );
if( !p_instance->p_input )
{
TAB_REMOVE( p_media->i_instance, p_media->instance, p_instance );
static int vlm_ControlScheduleClear( vlm_t *p_vlm )
{
while( p_vlm->i_schedule > 0 )
- vlm_ScheduleDelete( p_vlm, p_vlm->schedule[0], NULL );
+ vlm_ScheduleDelete( p_vlm, p_vlm->schedule[0] );
return VLC_SUCCESS;
}
msg_Err( a, "VideoLAN manager support is disabled" );
return NULL;
}
+
void vlm_Delete( vlm_t *a )
{
- ;
+ (void)a;
}
-int vlm_ExecuteCommand( vlm_t *a, char *b, vlm_message_t **c )
+
+int vlm_ExecuteCommand( vlm_t *a, const char *b, vlm_message_t **c )
{
- return -1;
+ abort();
}
+
vlm_message_t *vlm_MessageNew( const char *psz_name,
const char *psz_format, ... )
{
+ (void)psz_name; (void)psz_format;
return NULL;
}
+
vlm_message_t *vlm_MessageAdd( vlm_message_t *p_message,
vlm_message_t *p_child )
{
- return NULL;
+ abort();
}
+
void vlm_MessageDelete( vlm_message_t *a )
{
- ;
+ (void)a;
}
int vlm_Control( vlm_t *p_vlm, int i_query, ... )
{
+ (void)p_vlm; (void)i_query;
return VLC_EGENERIC;
}