#include <vlc_charset.h>
#include <vlc_sout.h>
#include "../stream_output/stream_output.h"
+#include "../libvlc.h"
/*****************************************************************************
* Local prototypes.
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 );
vlc_object_attach( p_vlm, p_this->p_libvlc );
if( vlc_thread_create( p_vlm, "vlm thread",
- Manage, VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
+ Manage, VLC_THREAD_PRIORITY_LOW, false ) )
{
vlc_mutex_destroy( &p_vlm->lock );
vlc_object_release( p_vlm );
*****************************************************************************/
static void vlm_Destructor( vlm_t *p_vlm )
{
- vlc_object_kill( p_vlm );
- vlc_thread_join( p_vlm );
-
vlm_ControlInternal( p_vlm, VLM_CLEAR_MEDIAS );
TAB_CLEAN( p_vlm->i_media, p_vlm->media );
return VLC_EGENERIC;
}
-static vlc_bool_t ExecuteIsMedia( vlm_t *p_vlm, const char *psz_name )
+static bool ExecuteIsMedia( vlm_t *p_vlm, const char *psz_name )
{
int64_t id;
if( !psz_name || vlm_ControlInternal( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) )
- return VLC_FALSE;
- return VLC_TRUE;
+ return false;
+ return true;
}
-static vlc_bool_t ExecuteIsSchedule( vlm_t *p_vlm, const char *psz_name )
+static bool ExecuteIsSchedule( vlm_t *p_vlm, const char *psz_name )
{
if( !psz_name || !vlm_ScheduleSearch( p_vlm, psz_name ) )
- return VLC_FALSE;
- return VLC_TRUE;
+ return false;
+ return true;
}
static int ExecuteDel( vlm_t *p_vlm, const char *psz_name, vlm_message_t **pp_status )
{
if( psz_argument )
{
- vlc_bool_t b_relative;
+ bool b_relative;
if( psz_argument[0] == '+' || psz_argument[0] == '-' )
- b_relative = VLC_TRUE;
+ b_relative = true;
else
- b_relative = VLC_FALSE;
+ b_relative = false;
if( strstr( psz_argument, "ms" ) || strstr( psz_argument, "s" ) )
{
return VLC_SUCCESS;
}
-static int ExecuteScheduleProperty( vlm_t *p_vlm, vlm_schedule_sys_t *p_schedule, vlc_bool_t b_new,
+static int ExecuteScheduleProperty( vlm_t *p_vlm, vlm_schedule_sys_t *p_schedule, bool b_new,
const int i_property, char *ppsz_property[], vlm_message_t **pp_status )
{
const char *psz_cmd = b_new ? "new" : "setup";
return VLC_SUCCESS;
}
-static int ExecuteMediaProperty( vlm_t *p_vlm, int64_t id, vlc_bool_t b_new,
+static int ExecuteMediaProperty( vlm_t *p_vlm, int64_t id, bool b_new,
const int i_property, char *ppsz_property[], vlm_message_t **pp_status )
{
const char *psz_cmd = b_new ? "new" : "setup";
if( !strcmp( psz_option, "enabled" ) )
{
- p_cfg->b_enabled = VLC_TRUE;
+ p_cfg->b_enabled = true;
}
else if( !strcmp( psz_option, "disabled" ) )
{
- p_cfg->b_enabled = VLC_FALSE;
+ p_cfg->b_enabled = false;
}
else if( !strcmp( psz_option, "input" ) )
{
{
if( p_cfg->b_vod )
ERROR( "invalid loop option for vod" );
- p_cfg->broadcast.b_loop = VLC_TRUE;
+ p_cfg->broadcast.b_loop = true;
}
else if( !strcmp( psz_option, "unloop" ) )
{
if( p_cfg->b_vod )
ERROR( "invalid unloop option for vod" );
- p_cfg->broadcast.b_loop = VLC_FALSE;
+ p_cfg->broadcast.b_loop = false;
}
else if( !strcmp( psz_option, "mux" ) )
{
*pp_status = vlm_MessageNew( "new", "could not create schedule" );
return VLC_EGENERIC;
}
- return ExecuteScheduleProperty( p_vlm, p_schedule, VLC_TRUE, i_property, ppsz_property, pp_status );
+ return ExecuteScheduleProperty( p_vlm, p_schedule, true, i_property, ppsz_property, pp_status );
}
else if( !strcmp( psz_type, "vod" ) || !strcmp( psz_type, "broadcast" ) )
{
return VLC_EGENERIC;
}
vlm_media_Clean( &cfg );
- return ExecuteMediaProperty( p_vlm, id, VLC_TRUE, i_property, ppsz_property, pp_status );
+ return ExecuteMediaProperty( p_vlm, id, true, i_property, ppsz_property, pp_status );
}
else
{
if( ExecuteIsSchedule( p_vlm, psz_name ) )
{
vlm_schedule_sys_t *p_schedule = vlm_ScheduleSearch( p_vlm, psz_name );
- return ExecuteScheduleProperty( p_vlm, p_schedule, VLC_FALSE, i_property, ppsz_property, pp_status );
+ return ExecuteScheduleProperty( p_vlm, p_schedule, false, i_property, ppsz_property, pp_status );
}
else if( ExecuteIsMedia( p_vlm, psz_name ) )
{
int64_t id;
if( vlm_ControlInternal( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) )
goto error;
- return ExecuteMediaProperty( p_vlm, id, VLC_FALSE, i_property, ppsz_property, pp_status );
+ return ExecuteMediaProperty( p_vlm, id, false, i_property, ppsz_property, pp_status );
}
error:
}
p_sched->psz_name = strdup( psz_name );
- p_sched->b_enabled = VLC_FALSE;
+ p_sched->b_enabled = false;
p_sched->i_command = 0;
p_sched->command = NULL;
p_sched->i_date = 0;
{
if( !strcmp( psz_cmd, "enabled" ) )
{
- schedule->b_enabled = VLC_TRUE;
+ schedule->b_enabled = true;
}
else if( !strcmp( psz_cmd, "disabled" ) )
{
- schedule->b_enabled = VLC_FALSE;
+ schedule->b_enabled = false;
}
#if !defined( UNDER_CE )
else if( !strcmp( psz_cmd, "date" ) )
else
i_length += strlen( "new * broadcast " ) + strlen(p_cfg->psz_name);
- if( p_cfg->b_enabled == VLC_TRUE )
+ if( p_cfg->b_enabled == true )
i_length += strlen( "enabled" );
else
i_length += strlen( "disabled" );
- if( !p_cfg->b_vod && p_cfg->broadcast.b_loop == VLC_TRUE )
+ if( !p_cfg->b_vod && p_cfg->broadcast.b_loop == true )
i_length += strlen( " loop\n" );
else
i_length += strlen( "\n" );
i_length += strlen( "new schedule " ) + strlen( schedule->psz_name );
- if( schedule->b_enabled == VLC_TRUE )
+ if( schedule->b_enabled == true )
{
i_length += strlen( "date //-:: enabled\n" ) + 14;
}
localtime_r( &i_time, &date);
p += sprintf( p, "new %s schedule ", schedule->psz_name);
- if( schedule->b_enabled == VLC_TRUE )
+ if( schedule->b_enabled == true )
{
p += sprintf( p, "date %d/%d/%d-%d:%d:%d enabled\n",
date.tm_year + 1900, date.tm_mon + 1, date.tm_mday,
{
mtime_t i_real_date = vlm->schedule[i]->i_date;
- if( vlm->schedule[i]->b_enabled == VLC_TRUE )
+ if( vlm->schedule[i]->b_enabled == true )
{
if( vlm->schedule[i]->i_date == 0 ) // now !
{
struct
{
int i_count;
- vlc_bool_t b_playing;
+ bool b_playing;
int i_playing_index;
} broadcast;
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] );
-
asprintf( &psz_dup, "sout=%s", psz_output);
- input_ItemAddOption( &p_media->vod.item, psz_dup );
+ input_ItemAddOption( p_media->vod.p_item, psz_dup );
free( psz_dup );
for( i = 0; i < p_cfg->i_option; i++ )
- input_ItemAddOption( &p_media->vod.item,
+ input_ItemAddOption( p_media->vod.p_item,
p_cfg->ppsz_option[i] );
- input_ItemAddOption( &p_media->vod.item, "no-sout-keep" );
+ 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 );
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 );
}
}
}
/* 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 )
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 );
if( p_media->cfg.b_vod )
{
- p_media->cfg.b_enabled = VLC_FALSE;
+ p_media->cfg.b_enabled = false;
vlm_OnMediaUpdate( p_vlm, p_media );
p_vlm->i_vod--;
}
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 );
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;
+ p_instance->b_sout_keep = false;
p_instance->p_input = NULL;
p_instance->p_sout = NULL;
if( p_instance->p_sout )
sout_DeleteInstance( p_instance->p_sout );
- input_ItemClean( &p_instance->item );
+ vlc_gc_decref( p_instance->p_item );
free( p_instance->psz_name );
free( p_instance );
}
p_cfg->psz_output ? p_cfg->psz_output : "",
(p_cfg->psz_output && psz_vod_output) ? ":" : psz_vod_output ? "#" : "",
psz_vod_output ? psz_vod_output : "" );
- input_ItemAddOption( &p_instance->item, psz_buffer );
+ input_ItemAddOption( p_instance->p_item, psz_buffer );
free( psz_buffer );
}
for( i = 0; i < p_cfg->i_option; i++ )
{
if( !strcmp( p_cfg->ppsz_option[i], "sout-keep" ) )
- p_instance->b_sout_keep = VLC_TRUE;
+ p_instance->b_sout_keep = true;
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;
+ p_instance->b_sout_keep = false;
else
- input_ItemAddOption( &p_instance->item, 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)
psz_keep = "sout-keep";
else
psz_keep = "no-sout-keep";
- input_ItemAddOption( &p_instance->item, psz_keep );
+ input_ItemAddOption( p_instance->p_item, psz_keep );
TAB_APPEND( p_media->i_instance, p_media->instance, p_instance );
}
/* 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 );
p_idsc->i_length = var_GetTime( p_instance->p_input, "length" );
p_idsc->d_position = var_GetFloat( p_instance->p_input, "position" );
if( var_GetInteger( p_instance->p_input, "state" ) == PAUSE_S )
- p_idsc->b_paused = VLC_TRUE;
+ p_idsc->b_paused = true;
p_idsc->i_rate = var_GetInteger( p_instance->p_input, "rate" );
}