char *filename = (char*) cmd_arg->argument;
char fullname[1024];
int flush = 1;
+ char *service;
if ( filename[0] == '!' )
{
filename ++;
}
- if ( filename[0] == '/' )
- filename++;
+ service = strchr( filename, ':' );
+ if ( service != NULL )
+ {
+ service = filename;
+ filename = strchr( service, ':' );
+ *filename ++ = '\0';
+
+ if ( strlen( cmd_arg->root_dir ) && filename[0] == '/' )
+ filename++;
+
+ snprintf( fullname, 1023, "%s:%s%s", service, cmd_arg->root_dir, filename );
+ }
+ else
+ {
+ if ( strlen( cmd_arg->root_dir ) && filename[0] == '/' )
+ filename++;
- snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename );
+ snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename );
+ }
if (unit == NULL)
return RESPONSE_INVALID_UNIT;
else
{
- double in = -1, out = -1;
+ int32_t in = -1, out = -1;
if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 )
{
- in = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) );
- out = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) );
+ in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) );
+ out = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) );
}
if ( miracle_unit_load( unit, fullname, in, out, flush ) != valerie_ok )
return RESPONSE_BAD_FILE;
char *filename = (char*) cmd_arg->argument;
char fullname[1024];
- if ( filename[0] == '/' )
+ if ( strlen( cmd_arg->root_dir ) && filename[0] == '/' )
filename++;
snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename );
return RESPONSE_SUCCESS;
}
+int miracle_wipe( command_argument cmd_arg )
+{
+ miracle_unit unit = miracle_get_unit(cmd_arg->unit);
+
+ if (unit == NULL)
+ return RESPONSE_INVALID_UNIT;
+ else
+ {
+ if ( miracle_unit_wipe( unit ) != valerie_ok )
+ return RESPONSE_BAD_FILE;
+ }
+ return RESPONSE_SUCCESS;
+}
+
+int miracle_clear( command_argument cmd_arg )
+{
+ miracle_unit unit = miracle_get_unit(cmd_arg->unit);
+
+ if (unit == NULL)
+ return RESPONSE_INVALID_UNIT;
+ else
+ {
+ if ( miracle_unit_clear( unit ) != valerie_ok )
+ return RESPONSE_BAD_FILE;
+ }
+ return RESPONSE_SUCCESS;
+}
+
int miracle_move( command_argument cmd_arg )
{
miracle_unit unit = miracle_get_unit(cmd_arg->unit);
char *filename = (char*) cmd_arg->argument;
char fullname[1024];
- if ( filename[0] == '/' )
+ if ( strlen( cmd_arg->root_dir ) && filename[0] == '/' )
filename++;
snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename );
return RESPONSE_INVALID_UNIT;
else
{
- double in = -1, out = -1;
+ int32_t in = -1, out = -1;
if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 )
{
- in = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) );
- out = atof( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) );
+ in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) );
+ out = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) );
}
switch ( miracle_unit_append( unit, fullname, in, out ) )
{
return RESPONSE_SUCCESS;
}
+int miracle_push( command_argument cmd_arg, mlt_service service )
+{
+ miracle_unit unit = miracle_get_unit(cmd_arg->unit);
+ if ( unit != NULL && service != NULL )
+ if ( miracle_unit_append_service( unit, service ) == valerie_ok )
+ return RESPONSE_SUCCESS;
+ return RESPONSE_BAD_FILE;
+}
+
+int miracle_receive( command_argument cmd_arg, char *doc )
+{
+ mlt_producer producer = mlt_factory_producer( "westley-xml", doc );
+ miracle_unit unit = miracle_get_unit(cmd_arg->unit);
+ if ( unit != NULL && producer != NULL )
+ {
+ if ( miracle_unit_append_service( unit, MLT_PRODUCER_SERVICE( producer ) ) == valerie_ok )
+ {
+ mlt_producer_close( producer );
+ return RESPONSE_SUCCESS;
+ }
+ }
+ mlt_producer_close( producer );
+ return RESPONSE_BAD_FILE;
+}
+
int miracle_play( command_argument cmd_arg )
{
miracle_unit unit = miracle_get_unit(cmd_arg->unit);
if ( unit == NULL )
return RESPONSE_INVALID_UNIT;
else
- miracle_unit_play( unit, 0 );
+ miracle_unit_terminate( unit );
return RESPONSE_SUCCESS;
}
int miracle_set_in_point( command_argument cmd_arg )
{
- /*
- dv_unit unit = miracle_get_unit(cmd_arg->unit);
+ miracle_unit unit = miracle_get_unit(cmd_arg->unit);
int clip = parse_clip( cmd_arg, 3 );
-
- if (unit == NULL || dv_unit_is_offline(unit))
+
+ if ( unit == NULL )
return RESPONSE_INVALID_UNIT;
else
{
int position = *(int *) cmd_arg->argument;
- switch( dv_unit_set_clip_in( unit, clip, position ) )
+ switch( miracle_unit_set_clip_in( unit, clip, position ) )
{
case -1:
return RESPONSE_BAD_FILE;
return RESPONSE_OUT_OF_RANGE;
}
}
- */
return RESPONSE_SUCCESS;
}
int miracle_set_out_point( command_argument cmd_arg )
{
- /*
- dv_unit unit = miracle_get_unit(cmd_arg->unit);
+ miracle_unit unit = miracle_get_unit(cmd_arg->unit);
int clip = parse_clip( cmd_arg, 3 );
- if (unit == NULL || dv_unit_is_offline(unit))
+ if ( unit == NULL )
return RESPONSE_INVALID_UNIT;
else
{
int position = *(int *) cmd_arg->argument;
- switch( dv_unit_set_clip_out( unit, clip, position ) )
+ switch( miracle_unit_set_clip_out( unit, clip, position ) )
{
case -1:
return RESPONSE_BAD_FILE;
return RESPONSE_OUT_OF_RANGE;
}
}
- */
+
return RESPONSE_SUCCESS;
}
int miracle_set_unit_property( command_argument cmd_arg )
{
- /*
- dv_unit unit = miracle_get_unit(cmd_arg->unit);
-
+ miracle_unit unit = miracle_get_unit(cmd_arg->unit);
+ char *name_value = (char*) cmd_arg->argument;
if (unit == NULL)
return RESPONSE_INVALID_UNIT;
else
- {
- char *key = (char*) cmd_arg->argument;
- char *value = NULL;
-
- value = strchr( key, '=' );
- if (value == NULL)
- return RESPONSE_OUT_OF_RANGE;
- value[0] = 0;
- value++;
- miracle_log( LOG_DEBUG, "USET %s = %s", key, value );
- if ( strncasecmp( key, "eof", 1024) == 0 )
- {
- if ( strncasecmp( value, "pause", 1024) == 0)
- dv_unit_set_eof_action( unit, dv_player_pause );
- else if ( strncasecmp( value, "loop", 1024) == 0)
- dv_unit_set_eof_action( unit, dv_player_loop );
- else if ( strncasecmp( value, "stop", 1024) == 0)
- dv_unit_set_eof_action( unit, dv_player_terminate );
- else if ( strncasecmp( value, "clean", 1024) == 0)
- dv_unit_set_eof_action( unit, dv_player_clean_loop );
- else
- return RESPONSE_OUT_OF_RANGE;
- }
- else if ( strncasecmp( key, "points", 1024) == 0 )
- {
- if ( strncasecmp( value, "use", 1024) == 0)
- dv_unit_set_mode( unit, dv_clip_mode_restricted );
- else if ( strncasecmp( value, "ignore", 1024) == 0)
- dv_unit_set_mode( unit, dv_clip_mode_unrestricted );
- else
- return RESPONSE_OUT_OF_RANGE;
- }
- else if ( strncasecmp( key, "syt_offset", 1024) == 0 )
- {
- dv_unit_set_syt_offset( unit, atoi( value ) );
- }
- else if ( strncasecmp( key, "cip_n", 1024) == 0 )
- {
- dv_unit_set_cip_n( unit, atoi( value ) );
- }
- else if ( strncasecmp( key, "cip_d", 1024) == 0 )
- {
- dv_unit_set_cip_d( unit, atoi( value ) );
- }
- else if ( strncasecmp( key, "size", 1024) == 0 )
- {
- dv_unit_set_buffer_size( unit, atoi( value ) );
- }
- else if ( strncasecmp( key, "n_frames", 1024) == 0 )
- {
- dv_unit_set_n_frames( unit, atoi( value ) );
- }
- else if ( strncasecmp( key, "n_fill", 1024) == 0 )
- {
- dv_unit_set_n_fill( unit, atoi( value ) );
- }
- else
- return RESPONSE_OUT_OF_RANGE;
- }
- */
+ miracle_unit_set( unit, name_value );
return RESPONSE_SUCCESS;
}
int miracle_get_unit_property( command_argument cmd_arg )
{
- /*
- dv_unit unit = miracle_get_unit(cmd_arg->unit);
-
+ miracle_unit unit = miracle_get_unit(cmd_arg->unit);
+ char *name = (char*) cmd_arg->argument;
+ char *value = miracle_unit_get( unit, name );
if (unit == NULL)
return RESPONSE_INVALID_UNIT;
- else
- {
- char *key = (char*) cmd_arg->argument;
-
- if ( strncasecmp( key, "eof", 1024) == 0 )
- {
- switch ( dv_unit_get_eof_action( unit ) )
- {
- case dv_player_pause:
- dv_response_write( cmd_arg->response, "pause", strlen("pause") );
- break;
- case dv_player_loop:
- dv_response_write( cmd_arg->response, "loop", strlen("loop") );
- break;
- case dv_player_terminate:
- dv_response_write( cmd_arg->response, "stop", strlen("stop") );
- break;
- case dv_player_clean_loop:
- dv_response_write( cmd_arg->response, "clean", strlen("clean") );
- break;
- }
- return RESPONSE_SUCCESS_1;
- }
- else if ( strncasecmp( key, "points", 1024) == 0 )
- {
- if ( dv_unit_get_mode( unit ) == dv_clip_mode_restricted )
- dv_response_write( cmd_arg->response, "use", strlen("use") );
- else
- dv_response_write( cmd_arg->response, "ignore", strlen("ignore") );
- return RESPONSE_SUCCESS_1;
- }
- else if ( strncasecmp( key, "syt_offset", 1024) == 0 )
- {
- dv_response_printf( cmd_arg->response, 1024, "%d\n",
- dv_unit_get_syt_offset( unit ) );
- return RESPONSE_SUCCESS_1;
- }
- else if ( strncasecmp( key, "cip_n", 1024) == 0 )
- {
- dv_response_printf( cmd_arg->response, 1024, "%d\n",
- dv_unit_get_cip_n( unit ) );
- return RESPONSE_SUCCESS_1;
- }
- else if ( strncasecmp( key, "cip_d", 1024) == 0 )
- {
- dv_response_printf( cmd_arg->response, 1024, "%d\n",
- dv_unit_get_cip_d( unit ) );
- return RESPONSE_SUCCESS_1;
- }
- else if ( strncasecmp( key, "size", 1024) == 0 )
- {
- dv_response_printf( cmd_arg->response, 1024, "%d\n",
- dv_unit_get_buffer_size( unit ) );
- return RESPONSE_SUCCESS_1;
- }
- else if ( strncasecmp( key, "n_frames", 1024) == 0 )
- {
- dv_response_printf( cmd_arg->response, 1024, "%d\n",
- dv_unit_get_n_frames( unit ) );
- return RESPONSE_SUCCESS_1;
- }
- else if ( strncasecmp( key, "n_fill", 1024) == 0 )
- {
- dv_response_printf( cmd_arg->response, 1024, "%d\n",
- dv_unit_get_n_fill( unit ) );
- return RESPONSE_SUCCESS_1;
- }
- else if ( strncasecmp( key, "all", 1024 ) == 0 )
- {
- switch ( dv_unit_get_eof_action( unit ) )
- {
- case dv_player_pause:
- dv_response_write( cmd_arg->response, "eof=pause\n", strlen("pause") );
- break;
- case dv_player_loop:
- dv_response_write( cmd_arg->response, "eof=loop\n", strlen("loop") );
- break;
- case dv_player_terminate:
- dv_response_write( cmd_arg->response, "eof=stop\n", strlen("stop") );
- break;
- case dv_player_clean_loop:
- dv_response_write( cmd_arg->response, "eof=clean\n", strlen("clean") );
- break;
- }
- if ( dv_unit_get_mode( unit ) == dv_clip_mode_restricted )
- dv_response_write( cmd_arg->response, "points=use\n", strlen("use") );
- else
- dv_response_write( cmd_arg->response, "points=ignore\n", strlen("ignore") );
- dv_response_printf( cmd_arg->response, 1024, "syt_offset=%d\n", dv_unit_get_syt_offset( unit ) );
- dv_response_printf( cmd_arg->response, 1024, "cip_n=%d\n", dv_unit_get_cip_n( unit ) );
- dv_response_printf( cmd_arg->response, 1024, "cip_d=%d\n", dv_unit_get_cip_d( unit ) );
- dv_response_printf( cmd_arg->response, 1024, "size=%d\n", dv_unit_get_buffer_size( unit ) );
- dv_response_printf( cmd_arg->response, 1024, "n_frames=%d\n", dv_unit_get_n_frames( unit ) );
- dv_response_printf( cmd_arg->response, 1024, "n_fill=%d\n", dv_unit_get_n_fill( unit ) );
- }
- }
- */
+ else if ( value != NULL )
+ valerie_response_printf( cmd_arg->response, 1024, "%s\n", value );
return RESPONSE_SUCCESS;
}
int miracle_transfer( command_argument cmd_arg )
{
- /*
- dv_unit src_unit = miracle_get_unit(cmd_arg->unit);
+ miracle_unit src_unit = miracle_get_unit(cmd_arg->unit);
int dest_unit_id = -1;
char *string = (char*) cmd_arg->argument;
if ( string != NULL && ( string[ 0 ] == 'U' || string[ 0 ] == 'u' ) && strlen( string ) > 1 )
if ( src_unit != NULL && dest_unit_id != -1 )
{
- dv_unit dest_unit = miracle_get_unit( dest_unit_id );
- if ( dest_unit != NULL && !dv_unit_is_offline(dest_unit) && dest_unit != src_unit )
+ miracle_unit dest_unit = miracle_get_unit( dest_unit_id );
+ if ( dest_unit != NULL && !miracle_unit_is_offline(dest_unit) && dest_unit != src_unit )
{
- dv_unit_transfer( dest_unit, src_unit );
+ miracle_unit_transfer( dest_unit, src_unit );
return RESPONSE_SUCCESS;
}
}
- */
return RESPONSE_INVALID_UNIT;
}