#include <vlc_charset.h>
#include <vlc_sout.h>
#include "../stream_output/stream_output.h"
+#include "../libvlc.h"
/*****************************************************************************
* Local prototypes.
* 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, ... );
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",
}
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->p_internals->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_release( p_vlm );
- vlc_mutex_unlock( lockval.p_address );
}
/*****************************************************************************
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 );
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] );
-
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 );
input_StopThread( p_input );
- input_DestroyThread( p_input );
+ 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 );
}
}
}
/* 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 );
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;
{
input_StopThread( p_instance->p_input );
p_instance->p_sout = input_DetachSout( p_instance->p_input );
- input_DestroyThread( 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 );
+ 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 );
}
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
- 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 );
}
input_StopThread( p_instance->p_input );
p_instance->p_sout = input_DetachSout( p_instance->p_input );
- input_DestroyThread( 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 );