<html><head></head><body>Hi,<br><br>There has not been anything related to VLM schedules in month. The last related change must have been removal of VoD and vlc_atomic_wait. I find your accusations inadequate. The only recent thing potentially related to VLM was the player naming but that's VLM broadcasts not VLM schedules.<br><br>And if there were, it's much better to remove stuff first than to waste time reworking something that gets removed pronto.<br><br><div class="gmail_quote">Le 29 août 2020 17:48:56 GMT+03:00, Alexandre Janniaux <ajanni@videolabs.io> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Hi,<br><br>While I don't have arguments for or against removal of this<br>feature, I find it a bit inadequate to remove it just when<br>another developer mentioned to be working on subject around<br>it, without first asking what was planned first.<br><br>I'd suggest to delay the removal if it is needed, at least<br>until more context from Romain's work is brought here.<br>Maybe it's totally independant but it's quite unclear here.<br><br>Regards,<br>--<br>Alexandre Janniaux<br>Videolabs<br><br>On Thu, Aug 27, 2020 at 07:43:21PM +0300, Rémi Denis-Courmont wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> Way back when, VLC developers cared primarily about live TV. VLM<br> broadcast was the immediate VCR and VLM schedule was the programmed VCR.<br><br> Nobody uses this. On the fora, you'll see people having troubles with<br> VLC from crontab, not with VLM schedule. (By the way, this never grew<br> support for daylight saving offsets, forget time zones.)<hr> src/input/vlm.c | 99 +------<br> src/input/vlm_internal.h | 25 --<br> src/input/vlmshell.c | 600 ++-------------------------------------<br> 3 files changed, 20 insertions(+), 704 deletions(-)<br><br> diff --git a/src/input/vlm.c b/src/input/vlm.c<br> index 116fc5296e..124a092d8a 100644<br> --- a/src/input/vlm.c<br> +++ b/src/input/vlm.c<br> @@ -143,7 +143,6 @@ vlm_t *vlm_New( libvlc_int_t *libvlc, const char *psz_vlmconf )<br> p_vlm->exiting = false;<br> p_vlm->i_id = 1;<br> TAB_INIT( p_vlm->i_media, p_vlm->media );<br> - TAB_INIT( p_vlm->i_schedule, p_vlm->schedule );<br> var_Create( p_vlm, "intf-event", VLC_VAR_ADDRESS );<br><br> if( vlc_clone( &p_vlm->thread, Manage, p_vlm, VLC_THREAD_PRIORITY_LOW ) )<br> @@ -202,9 +201,6 @@ void vlm_Delete( vlm_t *p_vlm )<br> vlc_mutex_lock( &p_vlm->lock );<br> vlm_ControlInternal( p_vlm, VLM_CLEAR_MEDIAS );<br> TAB_CLEAN( p_vlm->i_media, p_vlm->media );<br> -<br> - vlm_ControlInternal( p_vlm, VLM_CLEAR_SCHEDULES );<br> - TAB_CLEAN( p_vlm->i_schedule, p_vlm->schedule );<br> vlc_mutex_unlock( &p_vlm->lock );<br><br> vlc_mutex_lock( &p_vlm->lock_manage );<br> @@ -247,9 +243,6 @@ static void* Manage( void* p_object )<br><br> do<br> {<br> - char **ppsz_scheduled_commands = NULL;<br> - int i_scheduled_commands = 0;<br> -<br> /* destroy the inputs that wants to die, and launch the next input */<br> vlc_mutex_lock( &vlm->lock );<br> for( int i = 0; i < vlm->i_media; i++ )<br> @@ -286,89 +279,12 @@ static void* Manage( void* p_object )<br> }<br> }<br><br> - /* scheduling */<br> - time_t now, nextschedule = 0;<br> -<br> - time(&now);<br> -<br> - for( int i = 0; i < vlm->i_schedule; i++ )<br> - {<br> - time_t real_date = vlm->schedule[i]->date;<br> -<br> - if( vlm->schedule[i]->b_enabled )<br> - {<br> - bool b_now = false;<br> - if( vlm->schedule[i]->date == 0 ) // now !<br> - {<br> - vlm->schedule[i]->date = now;<br> - real_date = now;<br> - b_now = true;<br> - }<br> - else if( vlm->schedule[i]->period != 0 )<br> - {<br> - int j = 0;<br> - while( ((vlm->schedule[i]->date + j *<br> - vlm->schedule[i]->period) <= lastcheck) &&<br> - ( vlm->schedule[i]->i_repeat > j ||<br> - vlm->schedule[i]->i_repeat < 0 ) )<br> - {<br> - j++;<br> - }<br> -<br> - real_date = vlm->schedule[i]->date + j *<br> - vlm->schedule[i]->period;<br> - }<br> -<br> - if( real_date <= now )<br> - {<br> - if( real_date > lastcheck || b_now )<br> - {<br> - for( int j = 0; j < vlm->schedule[i]->i_command; j++ )<br> - {<br> - TAB_APPEND( i_scheduled_commands,<br> - ppsz_scheduled_commands,<br> - strdup(vlm->schedule[i]->command[j] ) );<br> - }<br> - }<br> - }<br> - else if( nextschedule == 0 || real_date < nextschedule )<br> - {<br> - nextschedule = real_date;<br> - }<br> - }<br> - }<br> -<br> - while( i_scheduled_commands )<br> - {<br> - vlm_message_t *message = NULL;<br> - char *psz_command = ppsz_scheduled_commands[0];<br> - ExecuteCommand( vlm, psz_command,&message );<br> -<br> - /* for now, drop the message */<br> - vlm_MessageDelete( message );<br> - TAB_REMOVE( i_scheduled_commands,<br> - ppsz_scheduled_commands,<br> - psz_command );<br> - free( psz_command );<br> - }<br> -<br> - lastcheck = now;<br> vlc_mutex_unlock( &vlm->lock );<br><br> vlc_mutex_lock( &vlm->lock_manage );<br><br> while( !vlm->input_state_changed && !(exiting = vlm->exiting) )<br> - {<br> - if( nextschedule )<br> - {<br> - if( vlc_cond_timedwait_daytime( &vlm->wait_manage,<br> - &vlm->lock_manage,<br> - nextschedule ) )<br> - break;<br> - }<br> - else<br> - vlc_cond_wait( &vlm->wait_manage, &vlm->lock_manage );<br> - }<br> + vlc_cond_wait( &vlm->wait_manage, &vlm->lock_manage );<br> vlm->input_state_changed = false;<br> vlc_mutex_unlock( &vlm->lock_manage );<br> }<br> @@ -414,7 +330,7 @@ static vlm_media_sys_t *vlm_ControlMediaGetByName( vlm_t *p_vlm, const char *psz<br> static int vlm_MediaDescriptionCheck( vlm_t *p_vlm, vlm_media_t *p_cfg )<br> {<br> if( !p_cfg || !p_cfg->psz_name ||<br> - !strcmp( p_cfg->psz_name, "all" ) || !strcmp( p_cfg->psz_name, "media" ) || !strcmp( p_cfg->psz_name, "schedule" ) )<br> + !strcmp( p_cfg->psz_name, "all" ) || !strcmp( p_cfg->psz_name, "media" ) )<br> return VLC_EGENERIC;<br><br> for( int i = 0; i < p_vlm->i_media; i++ )<br> @@ -845,14 +761,6 @@ static int vlm_ControlMediaInstanceClear( vlm_t *p_vlm, int64_t id )<br> return VLC_SUCCESS;<br> }<br><br> -static int vlm_ControlScheduleClear( vlm_t *p_vlm )<br> -{<br> - while( p_vlm->i_schedule > 0 )<br> - vlm_ScheduleDelete( p_vlm, p_vlm->schedule[0] );<br> -<br> - return VLC_SUCCESS;<br> -}<br> -<br> static int vlm_vaControlInternal( vlm_t *p_vlm, int i_query, va_list args )<br> {<br> vlm_media_t *p_dsc;<br> @@ -955,9 +863,6 @@ static int vlm_vaControlInternal( vlm_t *p_vlm, int i_query, va_list args )<br> d_double = (double)va_arg( args, double );<br> return vlm_ControlMediaInstanceSetTimePosition( p_vlm, id, psz_id, -1, d_double );<br><br> - case VLM_CLEAR_SCHEDULES:<br> - return vlm_ControlScheduleClear( p_vlm );<br> -<br> default:<br> msg_Err( p_vlm, "unknown VLM query" );<br> return VLC_EGENERIC;<br> diff --git a/src/input/vlm_internal.h b/src/input/vlm_internal.h<br> index 2a74930343..40036f054f 100644<br> --- a/src/input/vlm_internal.h<br> +++ b/src/input/vlm_internal.h<br> @@ -54,26 +54,6 @@ typedef struct<br> vlm_media_instance_sys_t **instance;<br> } vlm_media_sys_t;<br><br> -typedef struct<br> -{<br> - /* names "schedule" is reserved */<br> - char *psz_name;<br> - bool b_enabled;<br> - /* list of commands to execute on date */<br> - int i_command;<br> - char **command;<br> -<br> - /* the date of 1st execution */<br> - time_t date;<br> -<br> - /* if != 0, repeat period in seconds */<br> - time_t period;<br> - /* number of times you have to repeat<br> - i_repeat < 0 : endless repeat */<br> - int i_repeat;<br> -} vlm_schedule_sys_t;<br> -<br> -<br> struct vlm_t<br> {<br> struct vlc_object_t obj;<br> @@ -93,14 +73,9 @@ struct vlm_t<br> /* Media list */<br> int i_media;<br> vlm_media_sys_t **media;<br> -<br> - /* Schedule list */<br> - int i_schedule;<br> - vlm_schedule_sys_t **schedule;<br> };<br><br> int vlm_ControlInternal( vlm_t *p_vlm, int i_query, ... );<br> int ExecuteCommand( vlm_t *, const char *, vlm_message_t ** );<br> -void vlm_ScheduleDelete( vlm_t *vlm, vlm_schedule_sys_t *sched );<br><br> #endif<br> diff --git a/src/input/vlmshell.c b/src/input/vlmshell.c<br> index 8b4b0fb309..661a64c782 100644<br> --- a/src/input/vlmshell.c<br> +++ b/src/input/vlmshell.c<br> @@ -39,7 +39,6 @@<br><br> #ifdef ENABLE_VLM<br><br> -#include <time.h> /* ctime() */<br> #include <limits.h><br> #include <fcntl.h><br> #include <sys/stat.h><br> @@ -59,17 +58,11 @@<br> *****************************************************************************/<br><br> /* */<br> -static vlm_message_t *vlm_Show( vlm_t *, vlm_media_sys_t *, vlm_schedule_sys_t *, const char * );<br> -<br> -static vlm_schedule_sys_t *vlm_ScheduleSearch( vlm_t *, const char * );<br> +static vlm_message_t *vlm_Show( vlm_t *, vlm_media_sys_t *, const char * );<br><br> static char *Save( vlm_t * );<br> static int Load( vlm_t *, char * );<br><br> -static vlm_schedule_sys_t *vlm_ScheduleNew( vlm_t *vlm, const char *psz_name );<br> -static int vlm_ScheduleSetup( vlm_schedule_sys_t *schedule, const char *psz_cmd,<br> - const char *psz_value );<br> -<br> /* */<br> static vlm_media_sys_t *vlm_MediaSearch( vlm_t *, const char *);<br><br> @@ -224,42 +217,21 @@ static bool ExecuteIsMedia( vlm_t *p_vlm, const char *psz_name )<br> return false;<br> return true;<br> }<br> -static bool ExecuteIsSchedule( vlm_t *p_vlm, const char *psz_name )<br> -{<br> - if( !psz_name || !vlm_ScheduleSearch( p_vlm, psz_name ) )<br> - return false;<br> - return true;<br> -}<br><br> static int ExecuteDel( vlm_t *p_vlm, const char *psz_name, vlm_message_t **pp_status )<br> {<br> vlm_media_sys_t *p_media;<br> - vlm_schedule_sys_t *p_schedule;<br><br> p_media = vlm_MediaSearch( p_vlm, psz_name );<br> - p_schedule = vlm_ScheduleSearch( p_vlm, psz_name );<br><br> - if( p_schedule != NULL )<br> - {<br> - vlm_ScheduleDelete( p_vlm, p_schedule );<br> - }<br> - else if( p_media != NULL )<br> + if( p_media != NULL )<br> {<br> vlm_ControlInternal( p_vlm, VLM_DEL_MEDIA, p_media->cfg.id );<br> }<br> - else if( !strcmp(psz_name, "media") )<br> + else if( !strcmp(psz_name, "media") || !strcmp(psz_name, "all") )<br> {<br> vlm_ControlInternal( p_vlm, VLM_CLEAR_MEDIAS );<br> }<br> - else if( !strcmp(psz_name, "schedule") )<br> - {<br> - vlm_ControlInternal( p_vlm, VLM_CLEAR_SCHEDULES );<br> - }<br> - else if( !strcmp(psz_name, "all") )<br> - {<br> - vlm_ControlInternal( p_vlm, VLM_CLEAR_MEDIAS );<br> - vlm_ControlInternal( p_vlm, VLM_CLEAR_SCHEDULES );<br> - }<br> else<br> {<br> *pp_status = vlm_MessageNew( "del", "%s: media unknown", psz_name );<br> @@ -273,23 +245,19 @@ static int ExecuteDel( vlm_t *p_vlm, const char *psz_name, vlm_message_t **pp_st<br> static int ExecuteShow( vlm_t *p_vlm, const char *psz_name, vlm_message_t **pp_status )<br> {<br> vlm_media_sys_t *p_media;<br> - vlm_schedule_sys_t *p_schedule;<br><br> if( !psz_name )<br> {<br> - *pp_status = vlm_Show( p_vlm, NULL, NULL, NULL );<br> + *pp_status = vlm_Show( p_vlm, NULL, NULL );<br> return VLC_SUCCESS;<br> }<br><br> p_media = vlm_MediaSearch( p_vlm, psz_name );<br> - p_schedule = vlm_ScheduleSearch( p_vlm, psz_name );<br><br> - if( p_schedule != NULL )<br> - *pp_status = vlm_Show( p_vlm, NULL, p_schedule, NULL );<br> - else if( p_media != NULL )<br> - *pp_status = vlm_Show( p_vlm, p_media, NULL, NULL );<br> + if( p_media != NULL )<br> + *pp_status = vlm_Show( p_vlm, p_media, NULL );<br> else<br> - *pp_status = vlm_Show( p_vlm, NULL, NULL, psz_name );<br> + *pp_status = vlm_Show( p_vlm, NULL, psz_name );<br><br> return VLC_SUCCESS;<br> }<br> @@ -306,10 +274,10 @@ static int ExecuteHelp( vlm_message_t **pp_status )<br> *pp_status = vlm_MessageSimpleNew( "help" );<br><br> message_child = MessageAdd( "Commands Syntax:" );<br> - MessageAddChild( "new (name) broadcast|schedule [properties]" );<br> + MessageAddChild( "new (name) broadcast [properties]" );<br> MessageAddChild( "setup (name) (properties)" );<br> - MessageAddChild( "show [(name)|media|schedule]" );<br> - MessageAddChild( "del (name)|all|media|schedule" );<br> + MessageAddChild( "show [(name)|media]" );<br> + MessageAddChild( "del (name)|all|media" );<br> MessageAddChild( "control (name) [instance_name] (command)" );<br> MessageAddChild( "save (config_file)" );<br> MessageAddChild( "export" );<br> @@ -325,15 +293,6 @@ static int ExecuteHelp( vlm_message_t **pp_status )<br> MessageAddChild( "loop|unloop (broadcast only)" );<br> MessageAddChild( "mux (mux_name)" );<br><br> - message_child = MessageAdd( "Schedule Proprieties Syntax:" );<br> - MessageAddChild( "enabled|disabled" );<br> - MessageAddChild( "append (command_until_rest_of_the_line)" );<br> - MessageAddChild( "date (year)/(month)/(day)-(hour):(minutes):"<br> - "(seconds)|now" );<br> - MessageAddChild( "period (years_aka_12_months)/(months_aka_30_days)/"<br> - "(days)-(hours):(minutes):(seconds)" );<br> - MessageAddChild( "repeat (number_of_repetitions)" );<br> -<br> message_child = MessageAdd( "Control Commands Syntax:" );<br> MessageAddChild( "play [input_number]" );<br> MessageAddChild( "pause" );<br> @@ -563,88 +522,6 @@ static int ExecuteLoad( vlm_t *p_vlm, const char *psz_path, vlm_message_t **pp_s<br> return VLC_SUCCESS;<br> }<br><br> -static int ExecuteScheduleProperty( vlm_t *p_vlm, vlm_schedule_sys_t *p_schedule, bool b_new,<br> - const int i_property, char *ppsz_property[], vlm_message_t **pp_status )<br> -{<br> - const char *psz_cmd = b_new ? "new" : "setup";<br> - int i;<br> -<br> - for( i = 0; i < i_property; i++ )<br> - {<br> - if( !strcmp( ppsz_property[i], "enabled" ) ||<br> - !strcmp( ppsz_property[i], "disabled" ) )<br> - {<br> - if ( vlm_ScheduleSetup( p_schedule, ppsz_property[i], NULL ) )<br> - goto error;<br> - }<br> - else if( !strcmp( ppsz_property[i], "append" ) )<br> - {<br> - char *psz_line, *psz_realloc;<br> - int j, i_ret = VLC_SUCCESS;<br> - /* Beware: everything behind append is considered as<br> - * command line */<br> -<br> - if( ++i >= i_property )<br> - break;<br> -<br> - psz_line = strdup( ppsz_property[i] );<br> - if( unlikely(psz_line == NULL) )<br> - goto error;<br> -<br> - for( j = i+1; j < i_property; j++ )<br> - {<br> - psz_realloc = realloc( psz_line,<br> - strlen(psz_line) + strlen(ppsz_property[j]) + 1 + 1 );<br> - if( likely(psz_realloc) )<br> - {<br> - psz_line = psz_realloc;<br> - strcat( psz_line, " " );<br> - strcat( psz_line, ppsz_property[j] );<br> - }<br> - else<br> - {<br> - i_ret = VLC_ENOMEM;<br> - break;<br> - }<br> - }<br> -<br> - if( i_ret == VLC_SUCCESS )<br> - i_ret = vlm_ScheduleSetup( p_schedule, "append", psz_line );<br> - free( psz_line );<br> -<br> - if( i_ret )<br> - goto error;<br> - break;<br> - }<br> - else<br> - {<br> - if( i + 1 >= i_property )<br> - {<br> - if( b_new )<br> - vlm_ScheduleDelete( p_vlm, p_schedule );<br> - return ExecuteSyntaxError( psz_cmd, pp_status );<br> - }<br> -<br> - if( vlm_ScheduleSetup( p_schedule, ppsz_property[i], ppsz_property[i+1] ) )<br> - goto error;<br> - i++;<br> - }<br> - }<br> - *pp_status = vlm_MessageSimpleNew( psz_cmd );<br> -<br> - vlc_mutex_lock( &p_vlm->lock_manage );<br> - p_vlm->input_state_changed = true;<br> - vlc_cond_signal( &p_vlm->wait_manage );<br> - vlc_mutex_unlock( &p_vlm->lock_manage );<br> -<br> - return VLC_SUCCESS;<br> -<br> -error:<br> - *pp_status = vlm_MessageNew( psz_cmd, "Error while setting the property '%s' to the schedule",<br> - ppsz_property[i] );<br> - return VLC_EGENERIC;<br> -}<br> -<br> static int ExecuteMediaProperty( vlm_t *p_vlm, int64_t id, bool b_new,<br> const int i_property, char *ppsz_property[], vlm_message_t **pp_status )<br> {<br> @@ -762,28 +639,18 @@ error:<br> 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 )<br> {<br> /* Check name */<br> - if( !strcmp( psz_name, "all" ) || !strcmp( psz_name, "media" ) || !strcmp( psz_name, "schedule" ) )<br> + if( !strcmp( psz_name, "all" ) || !strcmp( psz_name, "media" ) )<br> {<br> - *pp_status = vlm_MessageNew( "new", "\"all\", \"media\" and \"schedule\" are reserved names" );<br> + *pp_status = vlm_MessageNew( "new", "\"all\" and \"media\" are reserved names" );<br> return VLC_EGENERIC;<br> }<br> - if( ExecuteIsMedia( p_vlm, psz_name ) || ExecuteIsSchedule( p_vlm, psz_name ) )<br> + if( ExecuteIsMedia( p_vlm, psz_name ) )<br> {<br> *pp_status = vlm_MessageNew( "new", "%s: Name already in use", psz_name );<br> return VLC_EGENERIC;<br> }<br> /* */<br> - if( !strcmp( psz_type, "schedule" ) )<br> - {<br> - vlm_schedule_sys_t *p_schedule = vlm_ScheduleNew( p_vlm, psz_name );<br> - if( !p_schedule )<br> - {<br> - *pp_status = vlm_MessageNew( "new", "could not create schedule" );<br> - return VLC_EGENERIC;<br> - }<br> - return ExecuteScheduleProperty( p_vlm, p_schedule, true, i_property, ppsz_property, pp_status );<br> - }<br> - else if( !strcmp( psz_type, "broadcast" ) )<br> + if( !strcmp( psz_type, "broadcast" ) )<br> {<br> vlm_media_t cfg;<br> int64_t id;<br> @@ -802,19 +669,14 @@ static int ExecuteNew( vlm_t *p_vlm, const char *psz_name, const char *psz_type,<br> }<br> else<br> {<br> - *pp_status = vlm_MessageNew( "new", "%s: Choose between broadcast or schedule", psz_type );<br> + *pp_status = vlm_MessageNew( "new", "%s: unknown media type", psz_type );<br> return VLC_EGENERIC;<br> }<br> }<br><br> static int ExecuteSetup( vlm_t *p_vlm, const char *psz_name, const int i_property, char *ppsz_property[], vlm_message_t **pp_status )<br> {<br> - if( ExecuteIsSchedule( p_vlm, psz_name ) )<br> - {<br> - vlm_schedule_sys_t *p_schedule = vlm_ScheduleSearch( p_vlm, psz_name );<br> - return ExecuteScheduleProperty( p_vlm, p_schedule, false, i_property, ppsz_property, pp_status );<br> - }<br> - else if( ExecuteIsMedia( p_vlm, psz_name ) )<br> + if( ExecuteIsMedia( p_vlm, psz_name ) )<br> {<br> int64_t id;<br> if( vlm_ControlInternal( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) )<br> @@ -948,246 +810,6 @@ vlm_media_sys_t *vlm_MediaSearch( vlm_t *vlm, const char *psz_name )<br> return NULL;<br> }<br><br> -/*****************************************************************************<br> - * Schedule handling<br> - *****************************************************************************/<br> -static vlm_schedule_sys_t *vlm_ScheduleNew( vlm_t *vlm, const char *psz_name )<br> -{<br> - if( !psz_name )<br> - return NULL;<br> -<br> - vlm_schedule_sys_t *p_sched = malloc( sizeof( vlm_schedule_sys_t ) );<br> - if( !p_sched )<br> - return NULL;<br> -<br> - p_sched->psz_name = strdup( psz_name );<br> - p_sched->b_enabled = false;<br> - p_sched->i_command = 0;<br> - p_sched->command = NULL;<br> - p_sched->date = 0;<br> - p_sched->period = 0;<br> - p_sched->i_repeat = -1;<br> -<br> - TAB_APPEND( vlm->i_schedule, vlm->schedule, p_sched );<br> -<br> - return p_sched;<br> -}<br> -<br> -/* for now, simple delete. After, del with options (last arg) */<br> -void vlm_ScheduleDelete( vlm_t *vlm, vlm_schedule_sys_t *sched )<br> -{<br> - int i;<br> - if( sched == NULL ) return;<br> -<br> - TAB_REMOVE( vlm->i_schedule, vlm->schedule, sched );<br> -<br> - if( vlm->i_schedule == 0 ) free( vlm->schedule );<br> - free( sched->psz_name );<br> -<br> - for ( i = 0; i < sched->i_command; i++ )<br> - free( sched->command[i] );<br> - free( sched->command );<br> - free( sched );<br> -}<br> -<br> -static vlm_schedule_sys_t *vlm_ScheduleSearch( vlm_t *vlm, const char *psz_name )<br> -{<br> - int i;<br> -<br> - for( i = 0; i < vlm->i_schedule; i++ )<br> - {<br> - if( strcmp( psz_name, vlm->schedule[i]->psz_name ) == 0 )<br> - {<br> - return vlm->schedule[i];<br> - }<br> - }<br> -<br> - return NULL;<br> -}<br> -<br> -/* Ok, setup schedule command will be able to support only one (argument value) at a time */<br> -static int vlm_ScheduleSetup( vlm_schedule_sys_t *schedule, const char *psz_cmd,<br> - const char *psz_value )<br> -{<br> - if( !strcmp( psz_cmd, "enabled" ) )<br> - {<br> - schedule->b_enabled = true;<br> - }<br> - else if( !strcmp( psz_cmd, "disabled" ) )<br> - {<br> - schedule->b_enabled = false;<br> - }<br> - else if( !strcmp( psz_cmd, "date" ) )<br> - {<br> - struct tm time;<br> - const char *p;<br> -<br> - time.tm_sec = 0; /* seconds */<br> - time.tm_min = 0; /* minutes */<br> - time.tm_hour = 0; /* hours */<br> - time.tm_mday = 0; /* day of the month */<br> - time.tm_mon = 0; /* month */<br> - time.tm_year = 0; /* year */<br> - time.tm_wday = 0; /* day of the week */<br> - time.tm_yday = 0; /* day in the year */<br> - time.tm_isdst = -1; /* daylight saving time */<br> -<br> - /* date should be year/month/day-hour:minutes:seconds */<br> - p = strchr( psz_value, '-' );<br> -<br> - if( !strcmp( psz_value, "now" ) )<br> - {<br> - schedule->date = 0;<br> - }<br> - else if(p == NULL)<br> - {<br> - return 1;<br> - }<br> - else<br> - {<br> - unsigned i,j,k;<br> -<br> - switch( sscanf( p + 1, "%u:%u:%u", &i, &j, &k ) )<br> - {<br> - case 1:<br> - time.tm_sec = i;<br> - break;<br> - case 2:<br> - time.tm_min = i;<br> - time.tm_sec = j;<br> - break;<br> - case 3:<br> - time.tm_hour = i;<br> - time.tm_min = j;<br> - time.tm_sec = k;<br> - break;<br> - default:<br> - return 1;<br> - }<br> -<br> - switch( sscanf( psz_value, "%d/%d/%d", &i, &j, &k ) )<br> - {<br> - case 1:<br> - time.tm_mday = i;<br> - break;<br> - case 2:<br> - time.tm_mon = i - 1;<br> - time.tm_mday = j;<br> - break;<br> - case 3:<br> - time.tm_year = i - 1900;<br> - time.tm_mon = j - 1;<br> - time.tm_mday = k;<br> - break;<br> - default:<br> - return 1;<br> - }<br> -<br> - schedule->date = mktime(&time);<br> - }<br> - }<br> - else if( !strcmp( psz_cmd, "period" ) )<br> - {<br> - struct tm time;<br> - const char *p;<br> - const char *psz_time = NULL, *psz_date = NULL;<br> - unsigned i,j,k;<br> -<br> - /* First, if date or period are modified, repeat should be equal to -1 */<br> - schedule->i_repeat = -1;<br> -<br> - time.tm_sec = 0; /* seconds */<br> - time.tm_min = 0; /* minutes */<br> - time.tm_hour = 0; /* hours */<br> - time.tm_mday = 0; /* day of the month */<br> - time.tm_mon = 0; /* month */<br> - time.tm_year = 0; /* year */<br> - time.tm_wday = 0; /* day of the week */<br> - time.tm_yday = 0; /* day in the year */<br> - time.tm_isdst = -1; /* daylight saving time */<br> -<br> - /* date should be year/month/day-hour:minutes:seconds */<br> - p = strchr( psz_value, '-' );<br> - if( p )<br> - {<br> - psz_date = psz_value;<br> - psz_time = p + 1;<br> - }<br> - else<br> - {<br> - psz_time = psz_value;<br> - }<br> -<br> - switch( sscanf( psz_time, "%u:%u:%u", &i, &j, &k ) )<br> - {<br> - case 1:<br> - time.tm_sec = i;<br> - break;<br> - case 2:<br> - time.tm_min = i;<br> - time.tm_sec = j;<br> - break;<br> - case 3:<br> - time.tm_hour = i;<br> - time.tm_min = j;<br> - time.tm_sec = k;<br> - break;<br> - default:<br> - return 1;<br> - }<br> - if( psz_date )<br> - {<br> - switch( sscanf( psz_date, "%u/%u/%u", &i, &j, &k ) )<br> - {<br> - case 1:<br> - time.tm_mday = i;<br> - break;<br> - case 2:<br> - time.tm_mon = i;<br> - time.tm_mday = j;<br> - break;<br> - case 3:<br> - time.tm_year = i;<br> - time.tm_mon = j;<br> - time.tm_mday = k;<br> - break;<br> - default:<br> - return 1;<br> - }<br> - }<br> -<br> - /* ok, that's stupid... who is going to schedule streams every 42 years ? */<br> - schedule->period = ((((time.tm_year * 12 + time.tm_mon) * 30<br> - + time.tm_mday) * 24 + time.tm_hour) * 60 + time.tm_min) * 60<br> - + time.tm_sec;<br> - }<br> - else if( !strcmp( psz_cmd, "repeat" ) )<br> - {<br> - int i;<br> -<br> - if( sscanf( psz_value, "%d", &i ) == 1 )<br> - {<br> - schedule->i_repeat = i;<br> - }<br> - else<br> - {<br> - return 1;<br> - }<br> - }<br> - else if( !strcmp( psz_cmd, "append" ) )<br> - {<br> - char *command = strdup( psz_value );<br> -<br> - TAB_APPEND( schedule->i_command, schedule->command, command );<br> - }<br> - else<br> - {<br> - return 1;<br> - }<br> -<br> - return 0;<br> -}<br> -<br> /*****************************************************************************<br> * Message handling functions<br> *****************************************************************************/<br> @@ -1342,7 +964,6 @@ static vlm_message_t *vlm_ShowMedia( vlm_media_sys_t *p_media )<br> }<br><br> static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_sys_t *media,<br> - vlm_schedule_sys_t *schedule,<br> const char *psz_filter )<br> {<br> if( media != NULL )<br> @@ -1353,80 +974,6 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_sys_t *media,<br> return p_msg;<br> }<br><br> - else if( schedule != NULL )<br> - {<br> - int i;<br> - vlm_message_t *msg;<br> - vlm_message_t *msg_schedule;<br> - vlm_message_t *msg_child;<br> - char buffer[100];<br> -<br> - msg = vlm_MessageSimpleNew( "show" );<br> - msg_schedule =<br> - vlm_MessageAdd( msg, vlm_MessageSimpleNew( schedule->psz_name ) );<br> -<br> - vlm_MessageAdd( msg_schedule, vlm_MessageNew("type", "schedule") );<br> -<br> - vlm_MessageAdd( msg_schedule,<br> - vlm_MessageNew( "enabled", schedule->b_enabled ?<br> - "yes" : "no" ) );<br> -<br> - if( schedule->date != 0 )<br> - {<br> - struct tm date;<br> -<br> - localtime_r( &schedule->date, &date);<br> - vlm_MessageAdd( msg_schedule,<br> - vlm_MessageNew( "date", "%d/%d/%d-%d:%d:%d",<br> - date.tm_year + 1900, date.tm_mon + 1,<br> - date.tm_mday, date.tm_hour, date.tm_min,<br> - date.tm_sec ) );<br> - }<br> - else<br> - vlm_MessageAdd( msg_schedule, vlm_MessageNew("date", "now") );<br> -<br> - if( schedule->period != 0 )<br> - {<br> - div_t d;<br> - struct tm date;<br> -<br> - d = div(schedule->period, 60);<br> - date.tm_sec = d.rem;<br> - d = div(d.quot, 60);<br> - date.tm_min = d.rem;<br> - d = div(d.quot, 24);<br> - date.tm_hour = d.rem;<br> - /* okay, okay, months are not always 30 days long */<br> - d = div(d.quot, 30);<br> - date.tm_mday = d.rem;<br> - d = div(d.quot, 12);<br> - date.tm_mon = d.rem;<br> - date.tm_year = d.quot;<br> -<br> - sprintf( buffer, "%d/%d/%d-%d:%d:%d", date.tm_year, date.tm_mon,<br> - date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec);<br> -<br> - vlm_MessageAdd( msg_schedule, vlm_MessageNew("period", "%s", buffer) );<br> - }<br> - else<br> - vlm_MessageAdd( msg_schedule, vlm_MessageNew("period", "0") );<br> -<br> - sprintf( buffer, "%d", schedule->i_repeat );<br> - vlm_MessageAdd( msg_schedule, vlm_MessageNew( "repeat", "%s", buffer ) );<br> -<br> - msg_child =<br> - vlm_MessageAdd( msg_schedule, vlm_MessageSimpleNew("commands" ) );<br> -<br> - for( i = 0; i < schedule->i_command; i++ )<br> - {<br> - vlm_MessageAdd( msg_child,<br> - vlm_MessageSimpleNew( schedule->command[i] ) );<br> - }<br> -<br> - return msg;<br> -<br> - }<br> -<br> else if( psz_filter && !strcmp( psz_filter, "media" ) )<br> {<br> vlm_message_t *p_msg;<br> @@ -1443,72 +990,9 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_sys_t *media,<br> return p_msg;<br> }<br><br> - else if( psz_filter && !strcmp( psz_filter, "schedule" ) )<br> + else if( ( psz_filter == NULL ) && ( media == NULL ) )<br> {<br> - int i;<br> - vlm_message_t *msg;<br> - vlm_message_t *msg_child;<br> -<br> - msg = vlm_MessageSimpleNew( "show" );<br> - msg_child = vlm_MessageAdd( msg, vlm_MessageSimpleNew( "schedule" ) );<br> -<br> - for( i = 0; i < vlm->i_schedule; i++ )<br> - {<br> - vlm_schedule_sys_t *s = vlm->schedule[i];<br> - vlm_message_t *msg_schedule;<br> - time_t now, next_date;<br> -<br> - msg_schedule = vlm_MessageAdd( msg_child,<br> - vlm_MessageSimpleNew( s->psz_name ) );<br> - vlm_MessageAdd( msg_schedule,<br> - vlm_MessageNew( "enabled", s->b_enabled ?<br> - "yes" : "no" ) );<br> -<br> - /* calculate next date */<br> - time(&now);<br> - next_date = s->date;<br> -<br> - if( s->period != 0 )<br> - {<br> - int j = 0;<br> - while( ((s->date + j * s->period) <= now) &&<br> - ( s->i_repeat > j || s->i_repeat < 0 ) )<br> - {<br> - j++;<br> - }<br> -<br> - next_date = s->date + j * s->period;<br> - }<br> -<br> - if( next_date > now )<br> - {<br> - struct tm tm;<br> - char psz_date[32];<br> -<br> - strftime( psz_date, sizeof(psz_date), "%Y-%m-%d %H:%M:%S (%a)",<br> - localtime_r( &next_date, &tm ) );<br> - vlm_MessageAdd( msg_schedule,<br> - vlm_MessageNew( "next launch", "%s", psz_date ) );<br> - }<br> - }<br> -<br> - return msg;<br> - }<br> -<br> - else if( ( psz_filter == NULL ) && ( media == NULL ) && ( schedule == NULL ) )<br> - {<br> - vlm_message_t *show1 = vlm_Show( vlm, NULL, NULL, "media" );<br> - vlm_message_t *show2 = vlm_Show( vlm, NULL, NULL, "schedule" );<br> -<br> - vlm_MessageAdd( show1, show2->child[0] );<br> -<br> - /* We must destroy the parent node "show" of show2<br> - * and not the children */<br> - free( show2->child );<br> - free( show2->psz_name );<br> - free( show2 );<br> -<br> - return show1;<br> + return vlm_Show( vlm, NULL, "media" );<br> }<br><br> else<br> @@ -1599,54 +1083,6 @@ static char *Save( vlm_t *vlm )<br> p_cfg->psz_name, p_cfg->ppsz_option[j] );<br> }<br><br> - /* and now, the schedule scripts */<br> - for( int i = 0; i < vlm->i_schedule; i++ )<br> - {<br> - vlm_schedule_sys_t *schedule = vlm->schedule[i];<br> - struct tm tm;<br> -<br> - localtime_r( &schedule->date, &tm );<br> - vlc_memstream_printf( &stream, "new %s schedule date "<br> - "%d/%d/%d-%d:%d:%d %sabled\n",<br> - schedule->psz_name,<br> - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,<br> - tm.tm_hour, tm.tm_min, tm.tm_sec,<br> - schedule->b_enabled ? "en" : "dis" );<br> -<br> - if( schedule->period != 0 )<br> - {<br> - div_t d;<br> -<br> - d = div(schedule->period, 60);<br> - tm.tm_sec = d.rem;<br> - d = div(d.quot, 60);<br> - tm.tm_min = d.rem;<br> - d = div(d.quot, 24);<br> - tm.tm_hour = d.rem;<br> - d = div(d.quot, 30);<br> - tm.tm_mday = d.rem;<br> - /* okay, okay, months are not always 30 days long */<br> - d = div(d.quot, 12);<br> - tm.tm_mon = d.rem;<br> - tm.tm_year = d.quot;<br> -<br> - vlc_memstream_printf( &stream, "setup %s "<br> - "period %d/%d/%d-%d:%d:%d\n",<br> - schedule->psz_name,<br> - tm.tm_year, tm.tm_mon, tm.tm_mday,<br> - tm.tm_hour, tm.tm_min, tm.tm_sec);<br> - }<br> -<br> - if( schedule->i_repeat >= 0 )<br> - vlc_memstream_printf( &stream, "setup %s repeat %d",<br> - schedule->psz_name, schedule->i_repeat );<br> - vlc_memstream_putc( &stream, '\n' );<br> -<br> - for( int j = 0; j < schedule->i_command; j++ )<br> - vlc_memstream_printf( &stream, "setup %s append %s\n",<br> - schedule->psz_name, schedule->command[j] );<br> - }<br> -<br> if( vlc_memstream_close( &stream ) )<br> return NULL;<br> return stream.ptr;<br> --<br> 2.28.0<hr> vlc-devel mailing list<br> To unsubscribe or modify your subscription options:<br> <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>