From da3b0d0be0203fcd0000ab4726373c7b720e170d Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Thu, 14 May 2009 23:53:24 -0700 Subject: [PATCH] Fix build of melted. Signed-off-by: Dan Dennedy --- src/melted/melted.c | 28 ++-- src/melted/melted_commands.c | 74 +++++----- src/melted/melted_commands.h | 34 +++--- src/melted/melted_connection.c | 90 ++++++------ src/melted/melted_connection.h | 20 ++-- src/melted/melted_local.c | 280 ++++++++++++++++++------------------ src/melted/melted_local.h | 12 +- src/melted/melted_log.c | 12 +- src/melted/melted_log.h | 12 +- src/melted/melted_server.c | 136 +++++++++--------- src/melted/melted_server.h | 32 ++-- src/melted/melted_unit.c | 229 +++++++++++++++--------------- src/melted/melted_unit.h | 80 +++++------ src/melted/melted_unit_commands.c | 202 +++++++++++++------------- src/melted/melted_unit_commands.h | 54 ++++---- 15 files changed, 645 insertions(+), 650 deletions(-) diff --git a/src/melted/melted.c b/src/melted/melted.c index 24aac66..1802d3d 100644 --- a/src/melted/melted.c +++ b/src/melted/melted.c @@ -1,7 +1,7 @@ /* - * miracle.c -- MLT Video TCP Server + * melted.c -- MLT Video TCP Server * - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Authors: * Dan Dennedy * Charles Yates @@ -33,20 +33,20 @@ #include /* Application header files */ -#include "miracle_server.h" -#include "miracle_log.h" +#include "melted_server.h" +#include "melted_log.h" -/** Our dv server. +/** Our server context. */ -static miracle_server server = NULL; +static melted_server server = NULL; /** atexit shutdown handler for the server. */ static void main_cleanup( ) { - miracle_server_close( server ); + melted_server_close( server ); } /** Report usage and exit. @@ -78,14 +78,14 @@ int main( int argc, char **argv ) mlt_factory_init( NULL ); - server = miracle_server_init( argv[ 0 ] ); + server = melted_server_init( argv[ 0 ] ); for ( index = 1; index < argc; index ++ ) { if ( !strcmp( argv[ index ], "-port" ) ) - miracle_server_set_port( server, atoi( argv[ ++ index ] ) ); + melted_server_set_port( server, atoi( argv[ ++ index ] ) ); else if ( !strcmp( argv[ index ], "-proxy" ) ) - miracle_server_set_proxy( server, argv[ ++ index ] ); + melted_server_set_proxy( server, argv[ ++ index ] ); else if ( !strcmp( argv[ index ], "-test" ) ) background = 0; else @@ -99,20 +99,20 @@ int main( int argc, char **argv ) if ( fork() ) return 0; setsid(); - miracle_log_init( log_syslog, LOG_INFO ); + melted_log_init( log_syslog, LOG_INFO ); } else { - miracle_log_init( log_stderr, LOG_DEBUG ); + melted_log_init( log_stderr, LOG_DEBUG ); } atexit( main_cleanup ); /* Set the config script */ - miracle_server_set_config( server, "/etc/miracle.conf" ); + melted_server_set_config( server, "/etc/melted.conf" ); /* Execute the server */ - error = miracle_server_execute( server ); + error = melted_server_execute( server ); /* We need to wait until we're exited.. */ while ( !server->shutdown ) diff --git a/src/melted/melted_commands.c b/src/melted/melted_commands.c index c95a4d0..c865a3d 100644 --- a/src/melted/melted_commands.c +++ b/src/melted/melted_commands.c @@ -1,6 +1,6 @@ /* - * global_commands.c - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_commands.c - global commands + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Dan Dennedy * * This program is free software; you can redistribute it and/or modify @@ -29,17 +29,17 @@ #include #include -#include "miracle_unit.h" -#include "miracle_commands.h" -#include "miracle_log.h" +#include "melted_unit.h" +#include "melted_commands.h" +#include "melted_log.h" -static miracle_unit g_units[MAX_UNITS]; +static melted_unit g_units[MAX_UNITS]; -/** Return the miracle_unit given a numeric index. +/** Return the melted_unit given a numeric index. */ -miracle_unit miracle_get_unit( int n ) +melted_unit melted_get_unit( int n ) { if (n < MAX_UNITS) return g_units[n]; @@ -47,19 +47,19 @@ miracle_unit miracle_get_unit( int n ) return NULL; } -/** Destroy the miracle_unit given its numeric index. +/** Destroy the melted_unit given its numeric index. */ -void miracle_delete_unit( int n ) +void melted_delete_unit( int n ) { if (n < MAX_UNITS) { - miracle_unit unit = miracle_get_unit(n); + melted_unit unit = melted_get_unit(n); if (unit != NULL) { - miracle_unit_close( unit ); + melted_unit_close( unit ); g_units[ n ] = NULL; - miracle_log( LOG_NOTICE, "Deleted unit U%d.", n ); + melted_log( LOG_NOTICE, "Deleted unit U%d.", n ); } } } @@ -67,22 +67,22 @@ void miracle_delete_unit( int n ) /** Destroy all allocated units on the server. */ -void miracle_delete_all_units( void ) +void melted_delete_all_units( void ) { int i; for (i = 0; i < MAX_UNITS; i++) { - if ( miracle_get_unit(i) != NULL ) + if ( melted_get_unit(i) != NULL ) { - miracle_unit_close( miracle_get_unit(i) ); - miracle_log( LOG_NOTICE, "Deleted unit U%d.", i ); + melted_unit_close( melted_get_unit(i) ); + melted_log( LOG_NOTICE, "Deleted unit U%d.", i ); } } } -/** Add a DV virtual vtr to the server. +/** Add a virtual vtr to the server. */ -response_codes miracle_add_unit( command_argument cmd_arg ) +response_codes melted_add_unit( command_argument cmd_arg ) { int i = 0; for ( i = 0; i < MAX_UNITS; i ++ ) @@ -92,15 +92,15 @@ response_codes miracle_add_unit( command_argument cmd_arg ) if ( i < MAX_UNITS ) { char *arg = cmd_arg->argument; - g_units[ i ] = miracle_unit_init( i, arg ); + g_units[ i ] = melted_unit_init( i, arg ); if ( g_units[ i ] != NULL ) { - miracle_unit_set_notifier( g_units[ i ], valerie_parser_get_notifier( cmd_arg->parser ), cmd_arg->root_dir ); - valerie_response_printf( cmd_arg->response, 10, "U%1d\n\n", i ); + melted_unit_set_notifier( g_units[ i ], mvcp_parser_get_notifier( cmd_arg->parser ), cmd_arg->root_dir ); + mvcp_response_printf( cmd_arg->response, 10, "U%1d\n\n", i ); } return g_units[ i ] != NULL ? RESPONSE_SUCCESS_N : RESPONSE_ERROR; } - valerie_response_printf( cmd_arg->response, 1024, "no more units can be created\n\n" ); + mvcp_response_printf( cmd_arg->response, 1024, "no more units can be created\n\n" ); return RESPONSE_ERROR; } @@ -108,7 +108,7 @@ response_codes miracle_add_unit( command_argument cmd_arg ) /** List all AV/C nodes on the bus. */ -response_codes miracle_list_nodes( command_argument cmd_arg ) +response_codes melted_list_nodes( command_argument cmd_arg ) { response_codes error = RESPONSE_SUCCESS_N; return error; @@ -117,24 +117,24 @@ response_codes miracle_list_nodes( command_argument cmd_arg ) /** List units already added to server. */ -response_codes miracle_list_units( command_argument cmd_arg ) +response_codes melted_list_units( command_argument cmd_arg ) { response_codes error = RESPONSE_SUCCESS_N; int i = 0; for ( i = 0; i < MAX_UNITS; i ++ ) { - miracle_unit unit = miracle_get_unit( i ); + melted_unit unit = melted_get_unit( i ); if ( unit != NULL ) { mlt_properties properties = unit->properties; char *constructor = mlt_properties_get( properties, "constructor" ); int node = mlt_properties_get_int( properties, "node" ); int online = !mlt_properties_get_int( properties, "offline" ); - valerie_response_printf( cmd_arg->response, 1024, "U%d %02d %s %d\n", i, node, constructor, online ); + mvcp_response_printf( cmd_arg->response, 1024, "U%d %02d %s %d\n", i, node, constructor, online ); } } - valerie_response_printf( cmd_arg->response, 1024, "\n" ); + mvcp_response_printf( cmd_arg->response, 1024, "\n" ); return error; } @@ -146,7 +146,7 @@ static int filter_files( const struct dirent *de ) /** List clips in a directory. */ -response_codes miracle_list_clips( command_argument cmd_arg ) +response_codes melted_list_clips( command_argument cmd_arg ) { response_codes error = RESPONSE_BAD_FILE; const char *dir_name = (const char*) cmd_arg->argument; @@ -166,19 +166,19 @@ response_codes miracle_list_clips( command_argument cmd_arg ) { snprintf( fullname, 1023, "%s%s/%s", cmd_arg->root_dir, dir_name, de[i]->d_name ); if ( stat( fullname, &info ) == 0 && S_ISDIR( info.st_mode ) ) - valerie_response_printf( cmd_arg->response, 1024, "\"%s/\"\n", de[i]->d_name ); + mvcp_response_printf( cmd_arg->response, 1024, "\"%s/\"\n", de[i]->d_name ); } for (i = 0; i < n; i++ ) { snprintf( fullname, 1023, "%s%s/%s", cmd_arg->root_dir, dir_name, de[i]->d_name ); if ( lstat( fullname, &info ) == 0 && ( S_ISREG( info.st_mode ) || S_ISLNK( info.st_mode ) || ( strstr( fullname, ".clip" ) && info.st_mode | S_IXUSR ) ) ) - valerie_response_printf( cmd_arg->response, 1024, "\"%s\" %llu\n", de[i]->d_name, (unsigned long long) info.st_size ); + mvcp_response_printf( cmd_arg->response, 1024, "\"%s\" %llu\n", de[i]->d_name, (unsigned long long) info.st_size ); free( de[ i ] ); } free( de ); closedir( dir ); - valerie_response_write( cmd_arg->response, "\n", 1 ); + mvcp_response_write( cmd_arg->response, "\n", 1 ); } return error; @@ -187,7 +187,7 @@ response_codes miracle_list_clips( command_argument cmd_arg ) /** Set a server configuration property. */ -response_codes miracle_set_global_property( command_argument cmd_arg ) +response_codes melted_set_global_property( command_argument cmd_arg ) { char *key = (char*) cmd_arg->argument; char *value = NULL; @@ -197,7 +197,7 @@ response_codes miracle_set_global_property( command_argument cmd_arg ) return RESPONSE_OUT_OF_RANGE; *value = 0; value++; - miracle_log( LOG_DEBUG, "SET %s = %s", key, value ); + melted_log( LOG_DEBUG, "SET %s = %s", key, value ); if ( strncasecmp( key, "root", 1024) == 0 ) { @@ -208,7 +208,7 @@ response_codes miracle_set_global_property( command_argument cmd_arg ) for (i = 0; i < MAX_UNITS; i++) { if (g_units[i] != NULL) - miracle_unit_terminate( g_units[i] ); + melted_unit_terminate( g_units[i] ); } /* set the property */ @@ -230,13 +230,13 @@ response_codes miracle_set_global_property( command_argument cmd_arg ) /** Get a server configuration property. */ -response_codes miracle_get_global_property( command_argument cmd_arg ) +response_codes melted_get_global_property( command_argument cmd_arg ) { char *key = (char*) cmd_arg->argument; if ( strncasecmp( key, "root", 1024) == 0 ) { - valerie_response_write( cmd_arg->response, cmd_arg->root_dir, strlen(cmd_arg->root_dir) ); + mvcp_response_write( cmd_arg->response, cmd_arg->root_dir, strlen(cmd_arg->root_dir) ); return RESPONSE_SUCCESS_1; } else diff --git a/src/melted/melted_commands.h b/src/melted/melted_commands.h index 9d79683..3501ca2 100644 --- a/src/melted/melted_commands.h +++ b/src/melted/melted_commands.h @@ -1,6 +1,6 @@ /* - * global_commands.h - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_commands.h - global commands + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Dan Dennedy * * This program is free software; you can redistribute it and/or modify @@ -19,31 +19,31 @@ */ -#ifndef _GLOBAL_COMMANDS_H_ -#define _GLOBAL_COMMANDS_H_ +#ifndef _MELTED_COMMANDS_H_ +#define _MELTED_COMMANDS_H_ -#include -#include "miracle_unit.h" -#include "miracle_connection.h" +#include +#include "melted_unit.h" +#include "melted_connection.h" #ifdef __cplusplus extern "C" { #endif -extern miracle_unit miracle_get_unit( int ); -extern void miracle_delete_unit( int ); -extern void miracle_delete_all_units( void ); -extern int miracle_unit_status( int n, valerie_status status, int root_offset ); +extern melted_unit melted_get_unit( int ); +extern void melted_delete_unit( int ); +extern void melted_delete_all_units( void ); +extern int melted_unit_status( int n, mvcp_status status, int root_offset ); //extern void raw1394_start_service_threads( void ); //extern void raw1394_stop_service_threads( void ); -extern response_codes miracle_add_unit( command_argument ); -extern response_codes miracle_list_nodes( command_argument ); -extern response_codes miracle_list_units( command_argument ); -extern response_codes miracle_list_clips( command_argument ); -extern response_codes miracle_set_global_property( command_argument ); -extern response_codes miracle_get_global_property( command_argument ); +extern response_codes melted_add_unit( command_argument ); +extern response_codes melted_list_nodes( command_argument ); +extern response_codes melted_list_units( command_argument ); +extern response_codes melted_list_clips( command_argument ); +extern response_codes melted_set_global_property( command_argument ); +extern response_codes melted_get_global_property( command_argument ); #ifdef __cplusplus } diff --git a/src/melted/melted_connection.c b/src/melted/melted_connection.c index 7f287e3..1fdc110 100644 --- a/src/melted/melted_connection.c +++ b/src/melted/melted_connection.c @@ -1,6 +1,6 @@ /* - * miracle_connection.c -- DV Connection Handler - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_connection.c -- Connection Handler + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Charles Yates * * This program is free software; you can redistribute it and/or modify @@ -34,13 +34,13 @@ #include #include -#include +#include /* Application header files */ -#include "miracle_commands.h" -#include "miracle_connection.h" -#include "miracle_server.h" -#include "miracle_log.h" +#include "melted_commands.h" +#include "melted_connection.h" +#include "melted_server.h" +#include "melted_log.h" /** This is a generic replacement for fgets which operates on a file descriptor. Unlike fgets, we can also specify a line terminator. Maximum @@ -81,46 +81,46 @@ int fdgetline( int fd, char *buf, int max, char line_terminator, int *eof_chk ) } static int connection_initiate( int ); -static int connection_send( int, valerie_response ); +static int connection_send( int, mvcp_response ); static int connection_read( int, char *, int ); static void connection_close( int ); static int connection_initiate( int fd ) { int error = 0; - valerie_response response = valerie_response_init( ); - valerie_response_set_error( response, 100, "VTR Ready" ); + mvcp_response response = mvcp_response_init( ); + mvcp_response_set_error( response, 100, "VTR Ready" ); error = connection_send( fd, response ); - valerie_response_close( response ); + mvcp_response_close( response ); return error; } -static int connection_send( int fd, valerie_response response ) +static int connection_send( int fd, mvcp_response response ) { int error = 0; int index = 0; - int code = valerie_response_get_error_code( response ); + int code = mvcp_response_get_error_code( response ); if ( code != -1 ) { - int items = valerie_response_count( response ); + int items = mvcp_response_count( response ); if ( items == 0 ) - valerie_response_set_error( response, 500, "Unknown error" ); + mvcp_response_set_error( response, 500, "Unknown error" ); if ( code == 200 && items > 2 ) - valerie_response_set_error( response, 201, "OK" ); + mvcp_response_set_error( response, 201, "OK" ); else if ( code == 200 && items > 1 ) - valerie_response_set_error( response, 202, "OK" ); + mvcp_response_set_error( response, 202, "OK" ); - code = valerie_response_get_error_code( response ); - items = valerie_response_count( response ); + code = mvcp_response_get_error_code( response ); + items = mvcp_response_count( response ); for ( index = 0; !error && index < items; index ++ ) { - char *line = valerie_response_get_line( response, index ); + char *line = mvcp_response_get_line( response, index ); int length = strlen( line ); - if ( length == 0 && index != valerie_response_count( response ) - 1 && write( fd, " ", 1 ) != 1 ) + if ( length == 0 && index != mvcp_response_count( response ) - 1 && write( fd, " ", 1 ) != 1 ) error = -1; else if ( length > 0 && write( fd, line, length ) != length ) error = -1; @@ -128,15 +128,15 @@ static int connection_send( int fd, valerie_response response ) error = -1; } - if ( ( code == 201 || code == 500 ) && strcmp( valerie_response_get_line( response, items - 1 ), "" ) ) + if ( ( code == 201 || code == 500 ) && strcmp( mvcp_response_get_line( response, items - 1 ), "" ) ) if ( write( fd, "\r\n", 2 ) != 2 ) - miracle_log( LOG_ERR, "write(\"\\r\\n\") failed!" ); + melted_log( LOG_ERR, "write(\"\\r\\n\") failed!" ); } else { const char *message = "500 Empty Response\r\n\r\n"; if ( write( fd, message, strlen( message ) ) != strlen( message )) - miracle_log( LOG_ERR, "write(%s) failed!", message ); + melted_log( LOG_ERR, "write(%s) failed!", message ); } return error; @@ -154,27 +154,27 @@ static int connection_read( int fd, char *command, int length ) return nchars; } -int connection_status( int fd, valerie_notifier notifier ) +int connection_status( int fd, mvcp_notifier notifier ) { int error = 0; int index = 0; - valerie_status_t status; + mvcp_status_t status; char text[ 10240 ]; - valerie_socket socket = valerie_socket_init_fd( fd ); + mvcp_socket socket = mvcp_socket_init_fd( fd ); for ( index = 0; !error && index < MAX_UNITS; index ++ ) { - valerie_notifier_get( notifier, &status, index ); - valerie_status_serialise( &status, text, sizeof( text ) ); - error = valerie_socket_write_data( socket, text, strlen( text ) ) != strlen( text ); + mvcp_notifier_get( notifier, &status, index ); + mvcp_status_serialise( &status, text, sizeof( text ) ); + error = mvcp_socket_write_data( socket, text, strlen( text ) ) != strlen( text ); } while ( !error ) { - if ( valerie_notifier_wait( notifier, &status ) == 0 ) + if ( mvcp_notifier_wait( notifier, &status ) == 0 ) { - valerie_status_serialise( &status, text, sizeof( text ) ); - error = valerie_socket_write_data( socket, text, strlen( text ) ) != strlen( text ); + mvcp_status_serialise( &status, text, sizeof( text ) ); + error = mvcp_socket_write_data( socket, text, strlen( text ) ) != strlen( text ); } else { @@ -189,7 +189,7 @@ int connection_status( int fd, valerie_notifier notifier ) } } - valerie_socket_close( socket ); + mvcp_socket_close( socket ); return error; } @@ -207,8 +207,8 @@ void *parser_thread( void *arg ) char address[ 512 ]; char command[ 1024 ]; int fd = connection->fd; - valerie_parser parser = connection->parser; - valerie_response response = NULL; + mvcp_parser parser = connection->parser; + mvcp_response response = NULL; /* Get the connecting clients ip information */ he = gethostbyaddr( (char *) &( connection->sin.sin_addr.s_addr ), sizeof(u_int32_t), AF_INET); @@ -217,7 +217,7 @@ void *parser_thread( void *arg ) else inet_ntop( AF_INET, &( connection->sin.sin_addr.s_addr), address, 32 ); - miracle_log( LOG_NOTICE, "Connection established with %s (%d)", address, fd ); + melted_log( LOG_NOTICE, "Connection established with %s (%d)", address, fd ); /* Execute the commands received. */ if ( connection_initiate( fd ) == 0 ) @@ -255,15 +255,15 @@ void *parser_thread( void *arg ) service = ( mlt_service )mlt_factory_producer( NULL, "westley-xml", buffer ); mlt_events_fire( owner, "push-received", &response, command, service, NULL ); if ( response == NULL ) - response = valerie_parser_push( parser, command, service ); + response = mvcp_parser_push( parser, command, service ); } else { - response = valerie_parser_received( parser, command, buffer ); + response = mvcp_parser_received( parser, command, buffer ); } } error = connection_send( fd, response ); - valerie_response_close( response ); + mvcp_response_close( response ); mlt_service_close( service ); free( buffer ); } @@ -271,14 +271,14 @@ void *parser_thread( void *arg ) { mlt_events_fire( owner, "command-received", &response, command, NULL ); if ( response == NULL ) - response = valerie_parser_execute( parser, command ); - miracle_log( LOG_INFO, "%s \"%s\" %d", address, command, valerie_response_get_error_code( response ) ); + response = mvcp_parser_execute( parser, command ); + melted_log( LOG_INFO, "%s \"%s\" %d", address, command, mvcp_response_get_error_code( response ) ); error = connection_send( fd, response ); - valerie_response_close( response ); + mvcp_response_close( response ); } else { - error = connection_status( fd, valerie_parser_get_notifier( parser ) ); + error = connection_status( fd, mvcp_parser_get_notifier( parser ) ); } } } @@ -286,7 +286,7 @@ void *parser_thread( void *arg ) /* Free the resources associated with this connection. */ connection_close( fd ); - miracle_log( LOG_NOTICE, "Connection with %s (%d) closed", address, fd ); + melted_log( LOG_NOTICE, "Connection with %s (%d) closed", address, fd ); free( connection ); diff --git a/src/melted/melted_connection.h b/src/melted/melted_connection.h index 8734c6c..bb79f1f 100644 --- a/src/melted/melted_connection.h +++ b/src/melted/melted_connection.h @@ -1,6 +1,6 @@ /* - * miracle_connection.h -- DV Connection Handler - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_connection.h -- Connection Handler + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Charles Yates * * This program is free software; you can redistribute it and/or modify @@ -18,15 +18,15 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _DV_CONNECTION_H_ -#define _DV_CONNECTION_H_ +#ifndef _MELTED_CONNECTION_H_ +#define _MELTED_CONNECTION_H_ #include #include #include -#include -#include +#include +#include #ifdef __cplusplus extern "C" @@ -41,7 +41,7 @@ typedef struct mlt_properties owner; int fd; struct sockaddr_in sin; - valerie_parser parser; + mvcp_parser parser; } connection_t; @@ -69,9 +69,9 @@ response_codes; typedef struct { - valerie_parser parser; - valerie_response response; - valerie_tokeniser tokeniser; + mvcp_parser parser; + mvcp_response response; + mvcp_tokeniser tokeniser; char *command; int unit; void *argument; diff --git a/src/melted/melted_local.c b/src/melted/melted_local.c index c1029a1..580aedf 100644 --- a/src/melted/melted_local.c +++ b/src/melted/melted_local.c @@ -1,6 +1,6 @@ /* - * miracle_local.c -- Local Miracle Parser - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_local.c -- Local Melted Parser + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Charles Yates * * This program is free software; you can redistribute it and/or modify @@ -32,63 +32,63 @@ #include #endif -/* Valerie header files */ -#include +/* mvcp header files */ +#include /* MLT header files. */ #include /* Application header files */ -#include "miracle_local.h" -#include "miracle_connection.h" -#include "miracle_commands.h" -#include "miracle_unit_commands.h" -#include "miracle_log.h" +#include "melted_local.h" +#include "melted_connection.h" +#include "melted_commands.h" +#include "melted_unit_commands.h" +#include "melted_log.h" -/** Private miracle_local structure. +/** Private melted_local structure. */ typedef struct { - valerie_parser parser; + mvcp_parser parser; char root_dir[1024]; } -*miracle_local, miracle_local_t; +*melted_local, melted_local_t; /** Forward declarations. */ -static valerie_response miracle_local_connect( miracle_local ); -static valerie_response miracle_local_execute( miracle_local, char * ); -static valerie_response miracle_local_push( miracle_local, char *, mlt_service ); -static valerie_response miracle_local_receive( miracle_local, char *, char * ); -static void miracle_local_close( miracle_local ); -response_codes miracle_help( command_argument arg ); -response_codes miracle_run( command_argument arg ); -response_codes miracle_shutdown( command_argument arg ); +static mvcp_response melted_local_connect( melted_local ); +static mvcp_response melted_local_execute( melted_local, char * ); +static mvcp_response melted_local_push( melted_local, char *, mlt_service ); +static mvcp_response melted_local_receive( melted_local, char *, char * ); +static void melted_local_close( melted_local ); +response_codes melted_help( command_argument arg ); +response_codes melted_run( command_argument arg ); +response_codes melted_shutdown( command_argument arg ); -/** DV Parser constructor. +/** MVCP Parser constructor. */ -valerie_parser miracle_parser_init_local( ) +mvcp_parser melted_parser_init_local( ) { - valerie_parser parser = malloc( sizeof( valerie_parser_t ) ); - miracle_local local = malloc( sizeof( miracle_local_t ) ); + mvcp_parser parser = malloc( sizeof( mvcp_parser_t ) ); + melted_local local = malloc( sizeof( melted_local_t ) ); if ( parser != NULL ) { - memset( parser, 0, sizeof( valerie_parser_t ) ); + memset( parser, 0, sizeof( mvcp_parser_t ) ); - parser->connect = (parser_connect)miracle_local_connect; - parser->execute = (parser_execute)miracle_local_execute; - parser->push = (parser_push)miracle_local_push; - parser->received = (parser_received)miracle_local_receive; - parser->close = (parser_close)miracle_local_close; + parser->connect = (parser_connect)melted_local_connect; + parser->execute = (parser_execute)melted_local_execute; + parser->push = (parser_push)melted_local_push; + parser->received = (parser_received)melted_local_receive; + parser->close = (parser_close)melted_local_close; parser->real = local; if ( local != NULL ) { - memset( local, 0, sizeof( miracle_local_t ) ); + memset( local, 0, sizeof( melted_local_t ) ); local->parser = parser; local->root_dir[0] = '/'; } @@ -169,37 +169,37 @@ command_t; static command_t vocabulary[] = { {"BYE", NULL, 0, ATYPE_NONE, "Terminates the session. Units are not removed and task queue is not flushed."}, - {"HELP", miracle_help, 0, ATYPE_NONE, "Display this information!"}, - {"NLS", miracle_list_nodes, 0, ATYPE_NONE, "List the AV/C nodes on the 1394 bus."}, - {"UADD", miracle_add_unit, 0, ATYPE_STRING, "Create a new DV unit (virtual VTR) to transmit to receiver specified in GUID argument."}, - {"ULS", miracle_list_units, 0, ATYPE_NONE, "Lists the units that have already been added to the server."}, - {"CLS", miracle_list_clips, 0, ATYPE_STRING, "Lists the clips at directory name argument."}, - {"SET", miracle_set_global_property, 0, ATYPE_PAIR, "Set a server configuration property."}, - {"GET", miracle_get_global_property, 0, ATYPE_STRING, "Get a server configuration property."}, - {"RUN", miracle_run, 0, ATYPE_STRING, "Run a batch file." }, - {"LIST", miracle_list, 1, ATYPE_NONE, "List the playlist associated to a unit."}, - {"LOAD", miracle_load, 1, ATYPE_STRING, "Load clip specified in absolute filename argument."}, - {"INSERT", miracle_insert, 1, ATYPE_STRING, "Insert a clip at the given clip index."}, - {"REMOVE", miracle_remove, 1, ATYPE_NONE, "Remove a clip at the given clip index."}, - {"CLEAN", miracle_clean, 1, ATYPE_NONE, "Clean a unit by removing all but the currently playing clip."}, - {"WIPE", miracle_wipe, 1, ATYPE_NONE, "Clean a unit by removing everything before the currently playing clip."}, - {"CLEAR", miracle_clear, 1, ATYPE_NONE, "Clear a unit by removing all clips."}, - {"MOVE", miracle_move, 1, ATYPE_INT, "Move a clip to another clip index."}, - {"APND", miracle_append, 1, ATYPE_STRING, "Append a clip specified in absolute filename argument."}, - {"PLAY", miracle_play, 1, ATYPE_NONE, "Play a loaded clip at speed -2000 to 2000 where 1000 = normal forward speed."}, - {"STOP", miracle_stop, 1, ATYPE_NONE, "Stop a loaded and playing clip."}, - {"PAUSE", miracle_pause, 1, ATYPE_NONE, "Pause a playing clip."}, - {"REW", miracle_rewind, 1, ATYPE_NONE, "Rewind a unit. If stopped, seek to beginning of clip. If playing, play fast backwards."}, - {"FF", miracle_ff, 1, ATYPE_NONE, "Fast forward a unit. If stopped, seek to beginning of clip. If playing, play fast forwards."}, - {"STEP", miracle_step, 1, ATYPE_INT, "Step argument number of frames forward or backward."}, - {"GOTO", miracle_goto, 1, ATYPE_INT, "Jump to frame number supplied as argument."}, - {"SIN", miracle_set_in_point, 1, ATYPE_INT, "Set the IN point of the loaded clip to frame number argument. -1 = reset in point to 0"}, - {"SOUT", miracle_set_out_point, 1, ATYPE_INT, "Set the OUT point of the loaded clip to frame number argument. -1 = reset out point to maximum."}, - {"USTA", miracle_get_unit_status, 1, ATYPE_NONE, "Report information about the unit."}, - {"USET", miracle_set_unit_property, 1, ATYPE_PAIR, "Set a unit configuration property."}, - {"UGET", miracle_get_unit_property, 1, ATYPE_STRING, "Get a unit configuration property."}, - {"XFER", miracle_transfer, 1, ATYPE_STRING, "Transfer the unit's clip to another unit specified as argument."}, - {"SHUTDOWN", miracle_shutdown, 0, ATYPE_NONE, "Shutdown the server."}, + {"HELP", melted_help, 0, ATYPE_NONE, "Display this information!"}, + {"NLS", melted_list_nodes, 0, ATYPE_NONE, "List the AV/C nodes on the 1394 bus."}, + {"UADD", melted_add_unit, 0, ATYPE_STRING, "Create a new playout unit (virtual VTR) to transmit to receiver specified in GUID argument."}, + {"ULS", melted_list_units, 0, ATYPE_NONE, "Lists the units that have already been added to the server."}, + {"CLS", melted_list_clips, 0, ATYPE_STRING, "Lists the clips at directory name argument."}, + {"SET", melted_set_global_property, 0, ATYPE_PAIR, "Set a server configuration property."}, + {"GET", melted_get_global_property, 0, ATYPE_STRING, "Get a server configuration property."}, + {"RUN", melted_run, 0, ATYPE_STRING, "Run a batch file." }, + {"LIST", melted_list, 1, ATYPE_NONE, "List the playlist associated to a unit."}, + {"LOAD", melted_load, 1, ATYPE_STRING, "Load clip specified in absolute filename argument."}, + {"INSERT", melted_insert, 1, ATYPE_STRING, "Insert a clip at the given clip index."}, + {"REMOVE", melted_remove, 1, ATYPE_NONE, "Remove a clip at the given clip index."}, + {"CLEAN", melted_clean, 1, ATYPE_NONE, "Clean a unit by removing all but the currently playing clip."}, + {"WIPE", melted_wipe, 1, ATYPE_NONE, "Clean a unit by removing everything before the currently playing clip."}, + {"CLEAR", melted_clear, 1, ATYPE_NONE, "Clear a unit by removing all clips."}, + {"MOVE", melted_move, 1, ATYPE_INT, "Move a clip to another clip index."}, + {"APND", melted_append, 1, ATYPE_STRING, "Append a clip specified in absolute filename argument."}, + {"PLAY", melted_play, 1, ATYPE_NONE, "Play a loaded clip at speed -2000 to 2000 where 1000 = normal forward speed."}, + {"STOP", melted_stop, 1, ATYPE_NONE, "Stop a loaded and playing clip."}, + {"PAUSE", melted_pause, 1, ATYPE_NONE, "Pause a playing clip."}, + {"REW", melted_rewind, 1, ATYPE_NONE, "Rewind a unit. If stopped, seek to beginning of clip. If playing, play fast backwards."}, + {"FF", melted_ff, 1, ATYPE_NONE, "Fast forward a unit. If stopped, seek to beginning of clip. If playing, play fast forwards."}, + {"STEP", melted_step, 1, ATYPE_INT, "Step argument number of frames forward or backward."}, + {"GOTO", melted_goto, 1, ATYPE_INT, "Jump to frame number supplied as argument."}, + {"SIN", melted_set_in_point, 1, ATYPE_INT, "Set the IN point of the loaded clip to frame number argument. -1 = reset in point to 0"}, + {"SOUT", melted_set_out_point, 1, ATYPE_INT, "Set the OUT point of the loaded clip to frame number argument. -1 = reset out point to maximum."}, + {"USTA", melted_get_unit_status, 1, ATYPE_NONE, "Report information about the unit."}, + {"USET", melted_set_unit_property, 1, ATYPE_PAIR, "Set a unit configuration property."}, + {"UGET", melted_get_unit_property, 1, ATYPE_STRING, "Get a unit configuration property."}, + {"XFER", melted_transfer, 1, ATYPE_STRING, "Transfer the unit's clip to another unit specified as argument."}, + {"SHUTDOWN", melted_shutdown, 0, ATYPE_NONE, "Shutdown the server."}, {NULL, NULL, 0, ATYPE_NONE, NULL} }; @@ -207,7 +207,7 @@ static command_t vocabulary[] = */ static char helpstr [] = - "Miracle -- A Multimedia Playout Server\n" + "melted -- A Multimedia Playout Server\n" " Copyright (C) 2002-2003 Ushodaya Enterprises Limited\n" " Authors:\n" " Dan Dennedy \n" @@ -224,22 +224,22 @@ inline const char *get_response_msg( int code ) return responses[ i ].message; } -/** Tell the user the miracle command set +/** Tell the user the melted command set */ -response_codes miracle_help( command_argument cmd_arg ) +response_codes melted_help( command_argument cmd_arg ) { int i = 0; - valerie_response_printf( cmd_arg->response, 10240, "%s", helpstr ); + mvcp_response_printf( cmd_arg->response, 10240, "%s", helpstr ); for ( i = 0; vocabulary[ i ].command != NULL; i ++ ) - valerie_response_printf( cmd_arg->response, 1024, + mvcp_response_printf( cmd_arg->response, 1024, "%-10.10s%s\n", vocabulary[ i ].command, vocabulary[ i ].help ); - valerie_response_printf( cmd_arg->response, 2, "\n" ); + mvcp_response_printf( cmd_arg->response, 2, "\n" ); return RESPONSE_SUCCESS_N; } @@ -247,28 +247,28 @@ response_codes miracle_help( command_argument cmd_arg ) /** Execute a batch file. */ -response_codes miracle_run( command_argument cmd_arg ) +response_codes melted_run( command_argument cmd_arg ) { - valerie_response temp = valerie_parser_run( cmd_arg->parser, (char *)cmd_arg->argument ); + mvcp_response temp = mvcp_parser_run( cmd_arg->parser, (char *)cmd_arg->argument ); if ( temp != NULL ) { int index = 0; - valerie_response_set_error( cmd_arg->response, - valerie_response_get_error_code( temp ), - valerie_response_get_error_string( temp ) ); + mvcp_response_set_error( cmd_arg->response, + mvcp_response_get_error_code( temp ), + mvcp_response_get_error_string( temp ) ); - for ( index = 1; index < valerie_response_count( temp ); index ++ ) - valerie_response_printf( cmd_arg->response, 10240, "%s\n", valerie_response_get_line( temp, index ) ); + for ( index = 1; index < mvcp_response_count( temp ); index ++ ) + mvcp_response_printf( cmd_arg->response, 10240, "%s\n", mvcp_response_get_line( temp, index ) ); - valerie_response_close( temp ); + mvcp_response_close( temp ); } - return valerie_response_get_error_code( cmd_arg->response ); + return mvcp_response_get_error_code( cmd_arg->response ); } -response_codes miracle_shutdown( command_argument cmd_arg ) +response_codes melted_shutdown( command_argument cmd_arg ) { exit( 0 ); return RESPONSE_SUCCESS; @@ -289,9 +289,9 @@ void signal_handler( int sig ) { #ifdef _GNU_SOURCE - miracle_log( LOG_DEBUG, "Received %s - shutting down.", strsignal(sig) ); + melted_log( LOG_DEBUG, "Received %s - shutting down.", strsignal(sig) ); #else - miracle_log( LOG_DEBUG, "Received signal %i - shutting down.", sig ); + melted_log( LOG_DEBUG, "Received signal %i - shutting down.", sig ); #endif exit(EXIT_SUCCESS); @@ -306,21 +306,21 @@ static void sigsegv_handler() char **strings; size_t i; - miracle_log( LOG_CRIT, "\a\nMiracle experienced a segmentation fault.\n" + melted_log( LOG_CRIT, "\a\nmelted experienced a segmentation fault.\n" "Dumping stack from the offending thread\n\n" ); size = backtrace( array, 10 ); strings = backtrace_symbols( array, size ); - miracle_log( LOG_CRIT, "Obtained %zd stack frames.\n", size ); + melted_log( LOG_CRIT, "Obtained %zd stack frames.\n", size ); for ( i = 0; i < size; i++ ) - miracle_log( LOG_CRIT, "%s", strings[ i ] ); + melted_log( LOG_CRIT, "%s", strings[ i ] ); free( strings ); - miracle_log( LOG_CRIT, "\nDone dumping - exiting.\n" ); + melted_log( LOG_CRIT, "\nDone dumping - exiting.\n" ); #else - miracle_log( LOG_CRIT, "\a\nMiracle experienced a segmentation fault.\n" ); + melted_log( LOG_CRIT, "\a\nmelted experienced a segmentation fault.\n" ); #endif exit( EXIT_FAILURE ); } @@ -330,13 +330,13 @@ static void sigsegv_handler() /** Local 'connect' function. */ -static valerie_response miracle_local_connect( miracle_local local ) +static mvcp_response melted_local_connect( melted_local local ) { - valerie_response response = valerie_response_init( ); + mvcp_response response = mvcp_response_init( ); self = pthread_self( ); - valerie_response_set_error( response, 100, "VTR Ready" ); + mvcp_response_set_error( response, 100, "VTR Ready" ); signal( SIGHUP, signal_handler ); signal( SIGINT, signal_handler ); @@ -354,18 +354,18 @@ static valerie_response miracle_local_connect( miracle_local local ) /** Set the error and determine the message associated to this command. */ -void miracle_command_set_error( command_argument cmd, response_codes code ) +void melted_command_set_error( command_argument cmd, response_codes code ) { - valerie_response_set_error( cmd->response, code, get_response_msg( code ) ); + mvcp_response_set_error( cmd->response, code, get_response_msg( code ) ); } /** Parse the unit argument. */ -int miracle_command_parse_unit( command_argument cmd, int argument ) +int melted_command_parse_unit( command_argument cmd, int argument ) { int unit = -1; - char *string = valerie_tokeniser_get_string( cmd->tokeniser, argument ); + char *string = mvcp_tokeniser_get_string( cmd->tokeniser, argument ); if ( string != NULL && ( string[ 0 ] == 'U' || string[ 0 ] == 'u' ) && strlen( string ) > 1 ) unit = atoi( string + 1 ); return unit; @@ -374,10 +374,10 @@ int miracle_command_parse_unit( command_argument cmd, int argument ) /** Parse a normal argument. */ -void *miracle_command_parse_argument( command_argument cmd, int argument, arguments_types type, char *command ) +void *melted_command_parse_argument( command_argument cmd, int argument, arguments_types type, char *command ) { void *ret = NULL; - char *value = valerie_tokeniser_get_string( cmd->tokeniser, argument ); + char *value = mvcp_tokeniser_get_string( cmd->tokeniser, argument ); if ( value != NULL ) { @@ -423,9 +423,9 @@ void *miracle_command_parse_argument( command_argument cmd, int argument, argume /** Get the error code - note that we simply the success return. */ -response_codes miracle_command_get_error( command_argument cmd ) +response_codes melted_command_get_error( command_argument cmd ) { - response_codes ret = valerie_response_get_error_code( cmd->response ); + response_codes ret = mvcp_response_get_error_code( cmd->response ); if ( ret == RESPONSE_SUCCESS_N || ret == RESPONSE_SUCCESS_1 ) ret = RESPONSE_SUCCESS; return ret; @@ -434,30 +434,30 @@ response_codes miracle_command_get_error( command_argument cmd ) /** Execute the command. */ -static valerie_response miracle_local_execute( miracle_local local, char *command ) +static mvcp_response melted_local_execute( melted_local local, char *command ) { command_argument_t cmd; cmd.parser = local->parser; - cmd.response = valerie_response_init( ); - cmd.tokeniser = valerie_tokeniser_init( ); + cmd.response = mvcp_response_init( ); + cmd.tokeniser = mvcp_tokeniser_init( ); cmd.command = command; cmd.unit = -1; cmd.argument = NULL; cmd.root_dir = local->root_dir; /* Set the default error */ - miracle_command_set_error( &cmd, RESPONSE_UNKNOWN_COMMAND ); + melted_command_set_error( &cmd, RESPONSE_UNKNOWN_COMMAND ); /* Parse the command */ - if ( valerie_tokeniser_parse_new( cmd.tokeniser, command, " " ) > 0 ) + if ( mvcp_tokeniser_parse_new( cmd.tokeniser, command, " " ) > 0 ) { int index = 0; - char *value = valerie_tokeniser_get_string( cmd.tokeniser, 0 ); + char *value = mvcp_tokeniser_get_string( cmd.tokeniser, 0 ); int found = 0; /* Strip quotes from all tokens */ - for ( index = 0; index < valerie_tokeniser_count( cmd.tokeniser ); index ++ ) - valerie_util_strip( valerie_tokeniser_get_string( cmd.tokeniser, index ), '\"' ); + for ( index = 0; index < mvcp_tokeniser_count( cmd.tokeniser ); index ++ ) + mvcp_util_strip( mvcp_tokeniser_get_string( cmd.tokeniser, index ), '\"' ); /* Search the vocabulary array for value */ for ( index = 1; !found && vocabulary[ index ].command != NULL; index ++ ) @@ -469,115 +469,115 @@ static valerie_response miracle_local_execute( miracle_local local, char *comman { int position = 1; - miracle_command_set_error( &cmd, RESPONSE_SUCCESS ); + melted_command_set_error( &cmd, RESPONSE_SUCCESS ); if ( vocabulary[ index ].is_unit ) { - cmd.unit = miracle_command_parse_unit( &cmd, position ); + cmd.unit = melted_command_parse_unit( &cmd, position ); if ( cmd.unit == -1 ) - miracle_command_set_error( &cmd, RESPONSE_MISSING_ARG ); + melted_command_set_error( &cmd, RESPONSE_MISSING_ARG ); position ++; } - if ( miracle_command_get_error( &cmd ) == RESPONSE_SUCCESS ) + if ( melted_command_get_error( &cmd ) == RESPONSE_SUCCESS ) { - cmd.argument = miracle_command_parse_argument( &cmd, position, vocabulary[ index ].type, command ); + cmd.argument = melted_command_parse_argument( &cmd, position, vocabulary[ index ].type, command ); if ( cmd.argument == NULL && vocabulary[ index ].type != ATYPE_NONE ) - miracle_command_set_error( &cmd, RESPONSE_MISSING_ARG ); + melted_command_set_error( &cmd, RESPONSE_MISSING_ARG ); position ++; } - if ( miracle_command_get_error( &cmd ) == RESPONSE_SUCCESS ) + if ( melted_command_get_error( &cmd ) == RESPONSE_SUCCESS ) { response_codes error = vocabulary[ index ].operation( &cmd ); - miracle_command_set_error( &cmd, error ); + melted_command_set_error( &cmd, error ); } free( cmd.argument ); } } - valerie_tokeniser_close( cmd.tokeniser ); + mvcp_tokeniser_close( cmd.tokeniser ); return cmd.response; } -static valerie_response miracle_local_receive( miracle_local local, char *command, char *doc ) +static mvcp_response melted_local_receive( melted_local local, char *command, char *doc ) { command_argument_t cmd; cmd.parser = local->parser; - cmd.response = valerie_response_init( ); - cmd.tokeniser = valerie_tokeniser_init( ); + cmd.response = mvcp_response_init( ); + cmd.tokeniser = mvcp_tokeniser_init( ); cmd.command = command; cmd.unit = -1; cmd.argument = NULL; cmd.root_dir = local->root_dir; /* Set the default error */ - miracle_command_set_error( &cmd, RESPONSE_SUCCESS ); + melted_command_set_error( &cmd, RESPONSE_SUCCESS ); /* Parse the command */ - if ( valerie_tokeniser_parse_new( cmd.tokeniser, command, " " ) > 0 ) + if ( mvcp_tokeniser_parse_new( cmd.tokeniser, command, " " ) > 0 ) { int index = 0; int position = 1; /* Strip quotes from all tokens */ - for ( index = 0; index < valerie_tokeniser_count( cmd.tokeniser ); index ++ ) - valerie_util_strip( valerie_tokeniser_get_string( cmd.tokeniser, index ), '\"' ); + for ( index = 0; index < mvcp_tokeniser_count( cmd.tokeniser ); index ++ ) + mvcp_util_strip( mvcp_tokeniser_get_string( cmd.tokeniser, index ), '\"' ); - cmd.unit = miracle_command_parse_unit( &cmd, position ); + cmd.unit = melted_command_parse_unit( &cmd, position ); if ( cmd.unit == -1 ) - miracle_command_set_error( &cmd, RESPONSE_MISSING_ARG ); + melted_command_set_error( &cmd, RESPONSE_MISSING_ARG ); position ++; - miracle_receive( &cmd, doc ); - miracle_command_set_error( &cmd, RESPONSE_SUCCESS ); + melted_receive( &cmd, doc ); + melted_command_set_error( &cmd, RESPONSE_SUCCESS ); free( cmd.argument ); } - valerie_tokeniser_close( cmd.tokeniser ); + mvcp_tokeniser_close( cmd.tokeniser ); return cmd.response; } -static valerie_response miracle_local_push( miracle_local local, char *command, mlt_service service ) +static mvcp_response melted_local_push( melted_local local, char *command, mlt_service service ) { command_argument_t cmd; cmd.parser = local->parser; - cmd.response = valerie_response_init( ); - cmd.tokeniser = valerie_tokeniser_init( ); + cmd.response = mvcp_response_init( ); + cmd.tokeniser = mvcp_tokeniser_init( ); cmd.command = command; cmd.unit = -1; cmd.argument = NULL; cmd.root_dir = local->root_dir; /* Set the default error */ - miracle_command_set_error( &cmd, RESPONSE_SUCCESS ); + melted_command_set_error( &cmd, RESPONSE_SUCCESS ); /* Parse the command */ - if ( valerie_tokeniser_parse_new( cmd.tokeniser, command, " " ) > 0 ) + if ( mvcp_tokeniser_parse_new( cmd.tokeniser, command, " " ) > 0 ) { int index = 0; int position = 1; /* Strip quotes from all tokens */ - for ( index = 0; index < valerie_tokeniser_count( cmd.tokeniser ); index ++ ) - valerie_util_strip( valerie_tokeniser_get_string( cmd.tokeniser, index ), '\"' ); + for ( index = 0; index < mvcp_tokeniser_count( cmd.tokeniser ); index ++ ) + mvcp_util_strip( mvcp_tokeniser_get_string( cmd.tokeniser, index ), '\"' ); - cmd.unit = miracle_command_parse_unit( &cmd, position ); + cmd.unit = melted_command_parse_unit( &cmd, position ); if ( cmd.unit == -1 ) - miracle_command_set_error( &cmd, RESPONSE_MISSING_ARG ); + melted_command_set_error( &cmd, RESPONSE_MISSING_ARG ); position ++; - miracle_push( &cmd, service ); - miracle_command_set_error( &cmd, RESPONSE_SUCCESS ); + melted_push( &cmd, service ); + melted_command_set_error( &cmd, RESPONSE_SUCCESS ); free( cmd.argument ); } - valerie_tokeniser_close( cmd.tokeniser ); + mvcp_tokeniser_close( cmd.tokeniser ); return cmd.response; } @@ -585,12 +585,12 @@ static valerie_response miracle_local_push( miracle_local local, char *command, /** Close the parser. */ -static void miracle_local_close( miracle_local local ) +static void melted_local_close( melted_local local ) { - miracle_delete_all_units(); + melted_delete_all_units(); #ifdef linux //pthread_kill_other_threads_np(); - miracle_log( LOG_DEBUG, "Clean shutdown." ); + melted_log( LOG_DEBUG, "Clean shutdown." ); //free( local ); //mlt_factory_close( ); #endif diff --git a/src/melted/melted_local.h b/src/melted/melted_local.h index ffccb17..1cc1bc9 100644 --- a/src/melted/melted_local.h +++ b/src/melted/melted_local.h @@ -1,6 +1,6 @@ /* - * miracle_local.h -- Local Miracle Parser - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_local.h -- Local Melted Parser + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Charles Yates * * This program is free software; you can redistribute it and/or modify @@ -18,11 +18,11 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _MIRACLE_LOCAL_H_ -#define _MIRACLE_LOCAL_H_ +#ifndef _MELTED_LOCAL_H_ +#define _MELTED_LOCAL_H_ /* Application header files */ -#include +#include #ifdef __cplusplus extern "C" @@ -32,7 +32,7 @@ extern "C" /** Local parser API. */ -extern valerie_parser miracle_parser_init_local( ); +extern mvcp_parser melted_parser_init_local( ); #ifdef __cplusplus } diff --git a/src/melted/melted_log.c b/src/melted/melted_log.c index 62b7f73..21ebc7a 100644 --- a/src/melted/melted_log.c +++ b/src/melted/melted_log.c @@ -1,6 +1,6 @@ /* - * miracle_log.c -- logging facility implementation - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_log.c -- logging facility implementation + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Dan Dennedy * * This program is free software; you can redistribute it and/or modify @@ -22,21 +22,21 @@ #include #include -#include "miracle_log.h" +#include "melted_log.h" static int log_output = log_stderr; static int threshold = LOG_DEBUG; -void miracle_log_init( enum log_output method, int new_threshold ) +void melted_log_init( enum log_output method, int new_threshold ) { log_output = method; threshold = new_threshold; if (method == log_syslog) - openlog( "miracle", LOG_CONS, LOG_DAEMON ); + openlog( "melted", LOG_CONS, LOG_DAEMON ); } -void miracle_log( int priority, const char *format, ... ) +void melted_log( int priority, const char *format, ... ) { va_list list; va_start( list, format ); diff --git a/src/melted/melted_log.h b/src/melted/melted_log.h index be21893..48f1c9b 100644 --- a/src/melted/melted_log.h +++ b/src/melted/melted_log.h @@ -1,6 +1,6 @@ /* - * miracle_log.h -- logging facility header - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_log.h -- logging facility header + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Dan Dennedy * * This program is free software; you can redistribute it and/or modify @@ -18,8 +18,8 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _LOG_H_ -#define _LOG_H_ +#ifndef _MELTED_LOG_H_ +#define _MELTED_LOG_H_ #include @@ -33,8 +33,8 @@ enum log_output { log_syslog }; -void miracle_log_init( enum log_output method, int threshold ); -void miracle_log( int priority, const char *format, ... ); +void melted_log_init( enum log_output method, int threshold ); +void melted_log( int priority, const char *format, ... ); #ifdef __cplusplus } diff --git a/src/melted/melted_server.c b/src/melted/melted_server.c index 629da55..8b55d90 100644 --- a/src/melted/melted_server.c +++ b/src/melted/melted_server.c @@ -1,6 +1,6 @@ /* - * miracle_server.c - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_server.c + * Copyright (C) 2002-20039 Ushodaya Enterprises Limited * Author: Charles Yates * * This program is free software; you can redistribute it and/or modify @@ -37,42 +37,42 @@ #include /* Application header files */ -#include "miracle_server.h" -#include "miracle_connection.h" -#include "miracle_local.h" -#include "miracle_log.h" -#include "miracle_commands.h" -#include -#include +#include "melted_server.h" +#include "melted_connection.h" +#include "melted_local.h" +#include "melted_log.h" +#include "melted_commands.h" +#include +#include -#define VERSION "0.0.1" +#define VERSION "0.2.0" -static void miracle_command_received( mlt_listener listener, mlt_properties owner, miracle_server this, void **args ) +static void melted_command_received( mlt_listener listener, mlt_properties owner, melted_server this, void **args ) { if ( listener != NULL ) - listener( owner, this, ( valerie_response ** )args[ 0 ], ( char * )args[ 1 ] ); + listener( owner, this, ( mvcp_response ** )args[ 0 ], ( char * )args[ 1 ] ); } -static void miracle_doc_received( mlt_listener listener, mlt_properties owner, miracle_server this, void **args ) +static void melted_doc_received( mlt_listener listener, mlt_properties owner, melted_server this, void **args ) { if ( listener != NULL ) - listener( owner, this, ( valerie_response ** )args[ 0 ], ( char * )args[ 1 ], ( char * )args[ 2 ] ); + listener( owner, this, ( mvcp_response ** )args[ 0 ], ( char * )args[ 1 ], ( char * )args[ 2 ] ); } -static void miracle_push_received( mlt_listener listener, mlt_properties owner, miracle_server this, void **args ) +static void melted_push_received( mlt_listener listener, mlt_properties owner, melted_server this, void **args ) { if ( listener != NULL ) - listener( owner, this, ( valerie_response ** )args[ 0 ], ( char * )args[ 1 ], ( mlt_service )args[ 2 ] ); + listener( owner, this, ( mvcp_response ** )args[ 0 ], ( char * )args[ 1 ], ( mlt_service )args[ 2 ] ); } /** Initialise a server structure. */ -miracle_server miracle_server_init( char *id ) +melted_server melted_server_init( char *id ) { - miracle_server server = malloc( sizeof( miracle_server_t ) ); + melted_server server = malloc( sizeof( melted_server_t ) ); if ( server != NULL ) - memset( server, 0, sizeof( miracle_server_t ) ); + memset( server, 0, sizeof( melted_server_t ) ); if ( server != NULL && mlt_properties_init( &server->parent, server ) == 0 ) { server->id = id; @@ -80,19 +80,19 @@ miracle_server miracle_server_init( char *id ) server->socket = -1; server->shutdown = 1; mlt_events_init( &server->parent ); - mlt_events_register( &server->parent, "command-received", ( mlt_transmitter )miracle_command_received ); - mlt_events_register( &server->parent, "doc-received", ( mlt_transmitter )miracle_doc_received ); - mlt_events_register( &server->parent, "push-received", ( mlt_transmitter )miracle_push_received ); + mlt_events_register( &server->parent, "command-received", ( mlt_transmitter )melted_command_received ); + mlt_events_register( &server->parent, "doc-received", ( mlt_transmitter )melted_doc_received ); + mlt_events_register( &server->parent, "push-received", ( mlt_transmitter )melted_push_received ); } return server; } -const char *miracle_server_id( miracle_server server ) +const char *melted_server_id( melted_server server ) { - return server != NULL && server->id != NULL ? server->id : "miracle"; + return server != NULL && server->id != NULL ? server->id : "melted"; } -void miracle_server_set_config( miracle_server server, const char *config ) +void melted_server_set_config( melted_server server, const char *config ) { if ( server != NULL ) { @@ -104,27 +104,27 @@ void miracle_server_set_config( miracle_server server, const char *config ) /** Set the port of the server. */ -void miracle_server_set_port( miracle_server server, int port ) +void melted_server_set_port( melted_server server, int port ) { server->port = port; } -void miracle_server_set_proxy( miracle_server server, char *proxy ) +void melted_server_set_proxy( melted_server server, char *proxy ) { - valerie_tokeniser tokeniser = valerie_tokeniser_init( ); + mvcp_tokeniser tokeniser = mvcp_tokeniser_init( ); server->proxy = 1; server->remote_port = DEFAULT_TCP_PORT; - valerie_tokeniser_parse_new( tokeniser, proxy, ":" ); - strcpy( server->remote_server, valerie_tokeniser_get_string( tokeniser, 0 ) ); - if ( valerie_tokeniser_count( tokeniser ) == 2 ) - server->remote_port = atoi( valerie_tokeniser_get_string( tokeniser, 1 ) ); - valerie_tokeniser_close( tokeniser ); + mvcp_tokeniser_parse_new( tokeniser, proxy, ":" ); + strcpy( server->remote_server, mvcp_tokeniser_get_string( tokeniser, 0 ) ); + if ( mvcp_tokeniser_count( tokeniser ) == 2 ) + server->remote_port = atoi( mvcp_tokeniser_get_string( tokeniser, 1 ) ); + mvcp_tokeniser_close( tokeniser ); } /** Wait for a connection. */ -static int miracle_server_wait_for_connect( miracle_server server ) +static int melted_server_wait_for_connect( melted_server server ) { struct timeval tv; fd_set rfds; @@ -142,9 +142,9 @@ static int miracle_server_wait_for_connect( miracle_server server ) /** Run the server thread. */ -static void *miracle_server_run( void *arg ) +static void *melted_server_run( void *arg ) { - miracle_server server = arg; + melted_server server = arg; pthread_t cmd_parse_info; connection_t *tmp = NULL; pthread_attr_t thread_attributes; @@ -152,7 +152,7 @@ static void *miracle_server_run( void *arg ) socksize = sizeof( struct sockaddr ); - miracle_log( LOG_NOTICE, "%s version %s listening on port %i", server->id, VERSION, server->port ); + melted_log( LOG_NOTICE, "%s version %s listening on port %i", server->id, VERSION, server->port ); /* Create the initial thread. We want all threads to be created detached so their resources get freed automatically. (CY: ... hmmph...) */ @@ -162,7 +162,7 @@ static void *miracle_server_run( void *arg ) while ( !server->shutdown ) { /* Wait for a new connection. */ - if ( miracle_server_wait_for_connect( server ) ) + if ( melted_server_wait_for_connect( server ) ) { /* Create a new block of data to hold a copy of the incoming connection for our server thread. The thread should free this when it terminates. */ @@ -178,7 +178,7 @@ static void *miracle_server_run( void *arg ) } } - miracle_log( LOG_NOTICE, "%s version %s server terminated.", server->id, VERSION ); + melted_log( LOG_NOTICE, "%s version %s server terminated.", server->id, VERSION ); return NULL; } @@ -186,10 +186,10 @@ static void *miracle_server_run( void *arg ) /** Execute the server thread. */ -int miracle_server_execute( miracle_server server ) +int melted_server_execute( melted_server server ) { int error = 0; - valerie_response response = NULL; + mvcp_response response = NULL; int index = 0; struct sockaddr_in ServerAddr; int flag = 1; @@ -208,7 +208,7 @@ int miracle_server_execute( miracle_server server ) { server->shutdown = 1; perror( "socket" ); - miracle_log( LOG_ERR, "%s unable to create socket.", server->id ); + melted_log( LOG_ERR, "%s unable to create socket.", server->id ); return -1; } @@ -218,7 +218,7 @@ int miracle_server_execute( miracle_server server ) { server->shutdown = 1; perror( "bind" ); - miracle_log( LOG_ERR, "%s unable to bind to port %d.", server->id, server->port ); + melted_log( LOG_ERR, "%s unable to bind to port %d.", server->id, server->port ); return -1; } @@ -226,7 +226,7 @@ int miracle_server_execute( miracle_server server ) { server->shutdown = 1; perror( "listen" ); - miracle_log( LOG_ERR, "%s unable to listen on port %d.", server->id, server->port ); + melted_log( LOG_ERR, "%s unable to listen on port %d.", server->id, server->port ); return -1; } @@ -234,49 +234,49 @@ int miracle_server_execute( miracle_server server ) if ( !server->proxy ) { - miracle_log( LOG_NOTICE, "Starting server on %d.", server->port ); - server->parser = miracle_parser_init_local( ); + melted_log( LOG_NOTICE, "Starting server on %d.", server->port ); + server->parser = melted_parser_init_local( ); } else { - miracle_log( LOG_NOTICE, "Starting proxy for %s:%d on %d.", server->remote_server, server->remote_port, server->port ); - server->parser = valerie_parser_init_remote( server->remote_server, server->remote_port ); + melted_log( LOG_NOTICE, "Starting proxy for %s:%d on %d.", server->remote_server, server->remote_port, server->port ); + server->parser = mvcp_parser_init_remote( server->remote_server, server->remote_port ); } - response = valerie_parser_connect( server->parser ); + response = mvcp_parser_connect( server->parser ); - if ( response != NULL && valerie_response_get_error_code( response ) == 100 ) + if ( response != NULL && mvcp_response_get_error_code( response ) == 100 ) { /* read configuration file */ if ( response != NULL && !server->proxy && server->config != NULL ) { - valerie_response_close( response ); - response = valerie_parser_run( server->parser, server->config ); + mvcp_response_close( response ); + response = mvcp_parser_run( server->parser, server->config ); - if ( valerie_response_count( response ) > 1 ) + if ( mvcp_response_count( response ) > 1 ) { - if ( valerie_response_get_error_code( response ) > 299 ) - miracle_log( LOG_ERR, "Error evaluating server configuration. Processing stopped." ); - for ( index = 0; index < valerie_response_count( response ); index ++ ) - miracle_log( LOG_DEBUG, "%4d: %s", index, valerie_response_get_line( response, index ) ); + if ( mvcp_response_get_error_code( response ) > 299 ) + melted_log( LOG_ERR, "Error evaluating server configuration. Processing stopped." ); + for ( index = 0; index < mvcp_response_count( response ); index ++ ) + melted_log( LOG_DEBUG, "%4d: %s", index, mvcp_response_get_line( response, index ) ); } } if ( response != NULL ) { int result; - valerie_response_close( response ); - result = pthread_create( &server->thread, NULL, miracle_server_run, server ); + mvcp_response_close( response ); + result = pthread_create( &server->thread, NULL, melted_server_run, server ); if ( result ) { - miracle_log( LOG_CRIT, "Failed to launch TCP listener thread" ); + melted_log( LOG_CRIT, "Failed to launch TCP listener thread" ); error = -1; } } } else { - miracle_log( LOG_ERR, "Error connecting to parser. Processing stopped." ); + melted_log( LOG_ERR, "Error connecting to parser. Processing stopped." ); server->shutdown = 1; error = -1; } @@ -287,23 +287,23 @@ int miracle_server_execute( miracle_server server ) /** Fetch a units properties */ -mlt_properties miracle_server_fetch_unit( miracle_server server, int index ) +mlt_properties melted_server_fetch_unit( melted_server server, int index ) { - miracle_unit unit = miracle_get_unit( index ); + melted_unit unit = melted_get_unit( index ); return unit != NULL ? unit->properties : NULL; } /** Shutdown the server. */ -void miracle_server_shutdown( miracle_server server ) +void melted_server_shutdown( melted_server server ) { if ( server != NULL && !server->shutdown ) { server->shutdown = 1; pthread_join( server->thread, NULL ); - miracle_server_set_config( server, NULL ); - valerie_parser_close( server->parser ); + melted_server_set_config( server, NULL ); + mvcp_parser_close( server->parser ); server->parser = NULL; close( server->socket ); } @@ -312,12 +312,12 @@ void miracle_server_shutdown( miracle_server server ) /** Close the server. */ -void miracle_server_close( miracle_server server ) +void melted_server_close( melted_server server ) { if ( server != NULL && mlt_properties_dec_ref( &server->parent ) <= 0 ) { mlt_properties_close( &server->parent ); - miracle_server_shutdown( server ); + melted_server_shutdown( server ); free( server ); } } diff --git a/src/melted/melted_server.h b/src/melted/melted_server.h index 592ff3a..d37168a 100644 --- a/src/melted/melted_server.h +++ b/src/melted/melted_server.h @@ -1,6 +1,6 @@ /* - * miracle_server.h - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_server.h + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Charles Yates * * This program is free software; you can redistribute it and/or modify @@ -18,14 +18,14 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _MIRACLE_SERVER_H_ -#define _MIRACLE_SERVER_H_ +#ifndef _MELTED_SERVER_H_ +#define _MELTED_SERVER_H_ /* System header files */ #include /* Application header files */ -#include +#include #ifdef __cplusplus extern "C" @@ -46,7 +46,7 @@ typedef struct char *id; int port; int socket; - valerie_parser parser; + mvcp_parser parser; pthread_t thread; int shutdown; int proxy; @@ -54,20 +54,20 @@ typedef struct int remote_port; char *config; } -*miracle_server, miracle_server_t; +*melted_server, melted_server_t; /** API for the server */ -extern miracle_server miracle_server_init( char * ); -extern const char *miracle_server_id( miracle_server ); -extern void miracle_server_set_config( miracle_server, const char * ); -extern void miracle_server_set_port( miracle_server, int ); -extern void miracle_server_set_proxy( miracle_server, char * ); -extern int miracle_server_execute( miracle_server ); -extern mlt_properties miracle_server_fetch_unit( miracle_server, int ); -extern void miracle_server_shutdown( miracle_server ); -extern void miracle_server_close( miracle_server ); +extern melted_server melted_server_init( char * ); +extern const char *melted_server_id( melted_server ); +extern void melted_server_set_config( melted_server, const char * ); +extern void melted_server_set_port( melted_server, int ); +extern void melted_server_set_proxy( melted_server, char * ); +extern int melted_server_execute( melted_server ); +extern mlt_properties melted_server_fetch_unit( melted_server, int ); +extern void melted_server_shutdown( melted_server ); +extern void melted_server_close( melted_server ); #ifdef __cplusplus } diff --git a/src/melted/melted_unit.c b/src/melted/melted_unit.c index 4974e38..8a86764 100644 --- a/src/melted/melted_unit.c +++ b/src/melted/melted_unit.c @@ -1,6 +1,6 @@ /* - * miracle_unit.c -- Transmission Unit Implementation - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_unit.c -- Playout Implementation + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Dan Dennedy * * This program is free software; you can redistribute it and/or modify @@ -37,23 +37,23 @@ #include -#include "miracle_unit.h" -#include "miracle_log.h" -#include "miracle_local.h" +#include "melted_unit.h" +#include "melted_log.h" +#include "melted_local.h" #include /* Forward references */ -static void miracle_unit_status_communicate( miracle_unit ); +static void melted_unit_status_communicate( melted_unit ); -/** Allocate a new DV transmission unit. +/** Allocate a new playout unit. - \return A new miracle_unit handle. + \return A new melted_unit handle. */ -miracle_unit miracle_unit_init( int index, char *constructor ) +melted_unit melted_unit_init( int index, char *constructor ) { - miracle_unit this = NULL; + melted_unit this = NULL; mlt_consumer consumer = NULL; char *id = strdup( constructor ); @@ -67,7 +67,7 @@ miracle_unit miracle_unit_init( int index, char *constructor ) if ( consumer != NULL ) { mlt_playlist playlist = mlt_playlist_init( ); - this = calloc( sizeof( miracle_unit_t ), 1 ); + this = calloc( sizeof( melted_unit_t ), 1 ); this->properties = mlt_properties_new( ); mlt_properties_init( this->properties, this ); mlt_properties_set_int( this->properties, "unit", index ); @@ -83,7 +83,7 @@ miracle_unit miracle_unit_init( int index, char *constructor ) return this; } -static char *strip_root( miracle_unit unit, char *file ) +static char *strip_root( melted_unit unit, char *file ) { mlt_properties properties = unit->properties; char *root = mlt_properties_get( properties, "root" ); @@ -101,25 +101,25 @@ static char *strip_root( miracle_unit unit, char *file ) /** Communicate the current status to all threads waiting on the notifier. */ -static void miracle_unit_status_communicate( miracle_unit unit ) +static void melted_unit_status_communicate( melted_unit unit ) { if ( unit != NULL ) { mlt_properties properties = unit->properties; char *root_dir = mlt_properties_get( properties, "root" ); - valerie_notifier notifier = mlt_properties_get_data( properties, "notifier", NULL ); - valerie_status_t status; + mvcp_notifier notifier = mlt_properties_get_data( properties, "notifier", NULL ); + mvcp_status_t status; if ( root_dir != NULL && notifier != NULL ) { - if ( miracle_unit_get_status( unit, &status ) == 0 ) + if ( melted_unit_get_status( unit, &status ) == 0 ) /* if ( !( ( status.status == unit_playing || status.status == unit_paused ) && strcmp( status.clip, "" ) && !strcmp( status.tail_clip, "" ) && status.position == 0 && status.in == 0 && status.out == 0 ) ) */ - valerie_notifier_put( notifier, &status ); + mvcp_notifier_put( notifier, &status ); } } } @@ -127,7 +127,7 @@ static void miracle_unit_status_communicate( miracle_unit unit ) /** Set the notifier info */ -void miracle_unit_set_notifier( miracle_unit this, valerie_notifier notifier, char *root_dir ) +void melted_unit_set_notifier( melted_unit this, mvcp_notifier notifier, char *root_dir ) { mlt_properties properties = this->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -136,15 +136,15 @@ void miracle_unit_set_notifier( miracle_unit this, valerie_notifier notifier, ch mlt_properties_set( properties, "root", root_dir ); mlt_properties_set_data( properties, "notifier", notifier, 0, NULL, NULL ); mlt_properties_set_data( playlist_properties, "notifier_arg", this, 0, NULL, NULL ); - mlt_properties_set_data( playlist_properties, "notifier", miracle_unit_status_communicate, 0, NULL, NULL ); + mlt_properties_set_data( playlist_properties, "notifier", melted_unit_status_communicate, 0, NULL, NULL ); - miracle_unit_status_communicate( this ); + melted_unit_status_communicate( this ); } /** Create or locate a producer for the file specified. */ -static mlt_producer locate_producer( miracle_unit unit, char *file ) +static mlt_producer locate_producer( melted_unit unit, char *file ) { // Try to get the profile from the consumer mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL ); @@ -160,7 +160,7 @@ static mlt_producer locate_producer( miracle_unit unit, char *file ) /** Update the generation count. */ -static void update_generation( miracle_unit unit ) +static void update_generation( melted_unit unit ) { mlt_properties properties = unit->properties; int generation = mlt_properties_get_int( properties, "generation" ); @@ -170,7 +170,7 @@ static void update_generation( miracle_unit unit ) /** Wipe all clips on the playlist for this unit. */ -static void clear_unit( miracle_unit unit ) +static void clear_unit( melted_unit unit ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -187,7 +187,7 @@ static void clear_unit( miracle_unit unit ) /** Wipe all but the playing clip from the unit. */ -static void clean_unit( miracle_unit unit ) +static void clean_unit( melted_unit unit ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -217,7 +217,7 @@ static void clean_unit( miracle_unit unit ) /** Remove everything up to the current clip from the unit. */ -static void wipe_unit( miracle_unit unit ) +static void wipe_unit( melted_unit unit ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -238,14 +238,14 @@ static void wipe_unit( miracle_unit unit ) /** Generate a report on all loaded clips. */ -void miracle_unit_report_list( miracle_unit unit, valerie_response response ) +void melted_unit_report_list( melted_unit unit, mvcp_response response ) { int i; mlt_properties properties = unit->properties; int generation = mlt_properties_get_int( properties, "generation" ); mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - valerie_response_printf( response, 1024, "%d\n", generation ); + mvcp_response_printf( response, 1024, "%d\n", generation ); for ( i = 0; i < mlt_playlist_count( playlist ); i ++ ) { @@ -255,7 +255,7 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) title = mlt_properties_get( MLT_PRODUCER_PROPERTIES( info.producer ), "title" ); if ( title == NULL ) title = strip_root( unit, info.resource ); - valerie_response_printf( response, 10240, "%d \"%s\" %d %d %d %d %.2f\n", + mvcp_response_printf( response, 10240, "%d \"%s\" %d %d %d %d %.2f\n", i, title, info.frame_in, @@ -264,19 +264,19 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) info.length, info.fps ); } - valerie_response_printf( response, 1024, "\n" ); + mvcp_response_printf( response, 1024, "\n" ); } /** Load a clip into the unit clearing existing play list. \todo error handling - \param unit A miracle_unit handle. + \param unit A melted_unit handle. \param clip The absolute file name of the clip to load. \param in The starting frame (-1 for 0) \param out The ending frame (-1 for maximum) */ -valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int32_t in, int32_t out, int flush ) +mvcp_error_code melted_unit_load( melted_unit unit, char *clip, int32_t in, int32_t out, int flush ) { // Now try to create a producer mlt_producer instance = locate_producer( unit, clip ); @@ -290,17 +290,17 @@ valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int32_t in, mlt_playlist_append_io( playlist, instance, in, out ); mlt_playlist_remove_region( playlist, 0, original ); mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) ); - miracle_log( LOG_DEBUG, "loaded clip %s", clip ); + melted_log( LOG_DEBUG, "loaded clip %s", clip ); update_generation( unit ); - miracle_unit_status_communicate( unit ); + melted_unit_status_communicate( unit ); mlt_producer_close( instance ); - return valerie_ok; + return mvcp_ok; } - return valerie_invalid_file; + return mvcp_invalid_file; } -valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int32_t in, int32_t out ) +mvcp_error_code melted_unit_insert( melted_unit unit, char *clip, int index, int32_t in, int32_t out ) { mlt_producer instance = locate_producer( unit, clip ); @@ -312,78 +312,78 @@ valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) ); mlt_playlist_insert( playlist, instance, index, in, out ); mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) ); - miracle_log( LOG_DEBUG, "inserted clip %s at %d", clip, index ); + melted_log( LOG_DEBUG, "inserted clip %s at %d", clip, index ); update_generation( unit ); - miracle_unit_status_communicate( unit ); + melted_unit_status_communicate( unit ); mlt_producer_close( instance ); - return valerie_ok; + return mvcp_ok; } - return valerie_invalid_file; + return mvcp_invalid_file; } -valerie_error_code miracle_unit_remove( miracle_unit unit, int index ) +mvcp_error_code melted_unit_remove( melted_unit unit, int index ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) ); mlt_playlist_remove( playlist, index ); mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) ); - miracle_log( LOG_DEBUG, "removed clip at %d", index ); + melted_log( LOG_DEBUG, "removed clip at %d", index ); update_generation( unit ); - miracle_unit_status_communicate( unit ); - return valerie_ok; + melted_unit_status_communicate( unit ); + return mvcp_ok; } -valerie_error_code miracle_unit_clean( miracle_unit unit ) +mvcp_error_code melted_unit_clean( melted_unit unit ) { clean_unit( unit ); - miracle_log( LOG_DEBUG, "Cleaned playlist" ); - miracle_unit_status_communicate( unit ); - return valerie_ok; + melted_log( LOG_DEBUG, "Cleaned playlist" ); + melted_unit_status_communicate( unit ); + return mvcp_ok; } -valerie_error_code miracle_unit_wipe( miracle_unit unit ) +mvcp_error_code melted_unit_wipe( melted_unit unit ) { wipe_unit( unit ); - miracle_log( LOG_DEBUG, "Wiped playlist" ); - miracle_unit_status_communicate( unit ); - return valerie_ok; + melted_log( LOG_DEBUG, "Wiped playlist" ); + melted_unit_status_communicate( unit ); + return mvcp_ok; } -valerie_error_code miracle_unit_clear( miracle_unit unit ) +mvcp_error_code melted_unit_clear( melted_unit unit ) { mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL ); clear_unit( unit ); mlt_consumer_purge( consumer ); - miracle_log( LOG_DEBUG, "Cleared playlist" ); - miracle_unit_status_communicate( unit ); - return valerie_ok; + melted_log( LOG_DEBUG, "Cleared playlist" ); + melted_unit_status_communicate( unit ); + return mvcp_ok; } -valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ) +mvcp_error_code melted_unit_move( melted_unit unit, int src, int dest ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) ); mlt_playlist_move( playlist, src, dest ); mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) ); - miracle_log( LOG_DEBUG, "moved clip %d to %d", src, dest ); + melted_log( LOG_DEBUG, "moved clip %d to %d", src, dest ); update_generation( unit ); - miracle_unit_status_communicate( unit ); - return valerie_ok; + melted_unit_status_communicate( unit ); + return mvcp_ok; } /** Add a clip to the unit play list. \todo error handling - \param unit A miracle_unit handle. + \param unit A melted_unit handle. \param clip The absolute file name of the clip to load. \param in The starting frame (-1 for 0) \param out The ending frame (-1 for maximum) */ -valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int32_t in, int32_t out ) +mvcp_error_code melted_unit_append( melted_unit unit, char *clip, int32_t in, int32_t out ) { mlt_producer instance = locate_producer( unit, clip ); @@ -393,45 +393,45 @@ valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int32_t i mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) ); mlt_playlist_append_io( playlist, instance, in, out ); - miracle_log( LOG_DEBUG, "appended clip %s", clip ); + melted_log( LOG_DEBUG, "appended clip %s", clip ); mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) ); update_generation( unit ); - miracle_unit_status_communicate( unit ); + melted_unit_status_communicate( unit ); mlt_producer_close( instance ); - return valerie_ok; + return mvcp_ok; } - return valerie_invalid_file; + return mvcp_invalid_file; } /** Add an mlt_service to the playlist - \param unit A miracle_unit handle. + \param unit A melted_unit handle. \param service the service to add */ -valerie_error_code miracle_unit_append_service( miracle_unit unit, mlt_service service ) +mvcp_error_code melted_unit_append_service( melted_unit unit, mlt_service service ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) ); mlt_playlist_append( playlist, ( mlt_producer )service ); mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) ); - miracle_log( LOG_DEBUG, "appended clip" ); + melted_log( LOG_DEBUG, "appended clip" ); update_generation( unit ); - miracle_unit_status_communicate( unit ); - return valerie_ok; + melted_unit_status_communicate( unit ); + return mvcp_ok; } /** Start playing the unit. \todo error handling - \param unit A miracle_unit handle. + \param unit A melted_unit handle. \param speed An integer that specifies the playback rate as a percentage multiplied by 100. */ -void miracle_unit_play( miracle_unit_t *unit, int speed ) +void melted_unit_play( melted_unit_t *unit, int speed ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -439,33 +439,33 @@ void miracle_unit_play( miracle_unit_t *unit, int speed ) mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL ); mlt_producer_set_speed( producer, ( double )speed / 1000 ); mlt_consumer_start( consumer ); - miracle_unit_status_communicate( unit ); + melted_unit_status_communicate( unit ); } /** Stop playback. - Terminates the dv_pump and halts dv1394 transmission. + Terminates the consumer and halts playout. - \param unit A miracle_unit handle. + \param unit A melted_unit handle. */ -void miracle_unit_terminate( miracle_unit unit ) +void melted_unit_terminate( melted_unit unit ) { mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL ); mlt_playlist playlist = mlt_properties_get_data( unit->properties, "playlist", NULL ); mlt_producer producer = MLT_PLAYLIST_PRODUCER( playlist ); mlt_producer_set_speed( producer, 0 ); mlt_consumer_stop( consumer ); - miracle_unit_status_communicate( unit ); + melted_unit_status_communicate( unit ); } /** Query the status of unit playback. - \param unit A miracle_unit handle. + \param unit A melted_unit handle. \return 1 if the unit is not playing, 0 if playing. */ -int miracle_unit_has_terminated( miracle_unit unit ) +int melted_unit_has_terminated( melted_unit unit ) { mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL ); return mlt_consumer_is_stopped( consumer ); @@ -474,7 +474,7 @@ int miracle_unit_has_terminated( miracle_unit unit ) /** Transfer the currently loaded clip to another unit */ -int miracle_unit_transfer( miracle_unit dest_unit, miracle_unit src_unit ) +int melted_unit_transfer( melted_unit dest_unit, melted_unit src_unit ) { int i; mlt_properties dest_properties = dest_unit->properties; @@ -506,7 +506,7 @@ int miracle_unit_transfer( miracle_unit dest_unit, miracle_unit src_unit ) mlt_service_unlock( MLT_PLAYLIST_SERVICE( dest_playlist ) ); update_generation( dest_unit ); - miracle_unit_status_communicate( dest_unit ); + melted_unit_status_communicate( dest_unit ); mlt_playlist_close( tmp_playlist ); @@ -516,7 +516,7 @@ int miracle_unit_transfer( miracle_unit dest_unit, miracle_unit src_unit ) /** Determine if unit is offline. */ -int miracle_unit_is_offline( miracle_unit unit ) +int melted_unit_is_offline( melted_unit unit ) { return 0; } @@ -524,11 +524,11 @@ int miracle_unit_is_offline( miracle_unit unit ) /** Obtain the status for a given unit */ -int miracle_unit_get_status( miracle_unit unit, valerie_status status ) +int melted_unit_get_status( melted_unit unit, mvcp_status status ) { int error = unit == NULL; - memset( status, 0, sizeof( valerie_status_t ) ); + memset( status, 0, sizeof( mvcp_status_t ) ); if ( !error ) { @@ -564,7 +564,7 @@ int miracle_unit_get_status( miracle_unit unit, valerie_status status ) status->generation = mlt_properties_get_int( properties, "generation" ); - if ( miracle_unit_has_terminated( unit ) ) + if ( melted_unit_has_terminated( unit ) ) status->status = unit_stopped; else if ( !strcmp( status->clip, "" ) ) status->status = unit_not_loaded; @@ -586,7 +586,7 @@ int miracle_unit_get_status( miracle_unit unit, valerie_status status ) /** Change position in the playlist. */ -void miracle_unit_change_position( miracle_unit unit, int clip, int32_t position ) +void melted_unit_change_position( melted_unit unit, int clip, int32_t position ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -619,13 +619,13 @@ void miracle_unit_change_position( miracle_unit unit, int clip, int32_t position mlt_producer_seek( producer, frame_start + frame_offset - info.frame_in ); } - miracle_unit_status_communicate( unit ); + melted_unit_status_communicate( unit ); } /** Get the index of the current clip. */ -int miracle_unit_get_current_clip( miracle_unit unit ) +int melted_unit_get_current_clip( melted_unit unit ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -636,7 +636,7 @@ int miracle_unit_get_current_clip( miracle_unit unit ) /** Set a clip's in point */ -int miracle_unit_set_clip_in( miracle_unit unit, int index, int32_t position ) +int melted_unit_set_clip_in( melted_unit unit, int index, int32_t position ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -645,12 +645,12 @@ int miracle_unit_set_clip_in( miracle_unit unit, int index, int32_t position ) if ( error == 0 ) { - miracle_unit_play( unit, 0 ); + melted_unit_play( unit, 0 ); mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) ); error = mlt_playlist_resize_clip( playlist, index, position, info.frame_out ); mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) ); update_generation( unit ); - miracle_unit_change_position( unit, index, 0 ); + melted_unit_change_position( unit, index, 0 ); } return error; @@ -659,7 +659,7 @@ int miracle_unit_set_clip_in( miracle_unit unit, int index, int32_t position ) /** Set a clip's out point. */ -int miracle_unit_set_clip_out( miracle_unit unit, int index, int32_t position ) +int melted_unit_set_clip_out( melted_unit unit, int index, int32_t position ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -668,13 +668,13 @@ int miracle_unit_set_clip_out( miracle_unit unit, int index, int32_t position ) if ( error == 0 ) { - miracle_unit_play( unit, 0 ); + melted_unit_play( unit, 0 ); mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) ); error = mlt_playlist_resize_clip( playlist, index, info.frame_in, position ); mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) ); update_generation( unit ); - miracle_unit_status_communicate( unit ); - miracle_unit_change_position( unit, index, -1 ); + melted_unit_status_communicate( unit ); + melted_unit_change_position( unit, index, -1 ); } return error; @@ -683,7 +683,7 @@ int miracle_unit_set_clip_out( miracle_unit unit, int index, int32_t position ) /** Step by specified position. */ -void miracle_unit_step( miracle_unit unit, int32_t offset ) +void melted_unit_step( melted_unit unit, int32_t offset ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -695,43 +695,43 @@ void miracle_unit_step( miracle_unit unit, int32_t offset ) /** Set the unit's clip mode regarding in and out points. */ -//void miracle_unit_set_mode( miracle_unit unit, dv_player_clip_mode mode ) +//void melted_unit_set_mode( melted_unit unit, dv_player_clip_mode mode ) //{ - //dv_player player = miracle_unit_get_dv_player( unit ); + //dv_player player = melted_unit_get_dv_player( unit ); //if ( player != NULL ) //dv_player_set_clip_mode( player, mode ); - //miracle_unit_status_communicate( unit ); + //melted_unit_status_communicate( unit ); //} /** Get the unit's clip mode regarding in and out points. */ -//dv_player_clip_mode miracle_unit_get_mode( miracle_unit unit ) +//dv_player_clip_mode melted_unit_get_mode( melted_unit unit ) //{ - //dv_player player = miracle_unit_get_dv_player( unit ); + //dv_player player = melted_unit_get_dv_player( unit ); //return dv_player_get_clip_mode( player ); //} /** Set the unit's clip mode regarding eof handling. */ -//void miracle_unit_set_eof_action( miracle_unit unit, dv_player_eof_action action ) +//void melted_unit_set_eof_action( melted_unit unit, dv_player_eof_action action ) //{ - //dv_player player = miracle_unit_get_dv_player( unit ); + //dv_player player = melted_unit_get_dv_player( unit ); //dv_player_set_eof_action( player, action ); - //miracle_unit_status_communicate( unit ); + //melted_unit_status_communicate( unit ); //} /** Get the unit's clip mode regarding eof handling. */ -//dv_player_eof_action miracle_unit_get_eof_action( miracle_unit unit ) +//dv_player_eof_action melted_unit_get_eof_action( melted_unit unit ) //{ - //dv_player player = miracle_unit_get_dv_player( unit ); + //dv_player player = melted_unit_get_dv_player( unit ); //return dv_player_get_eof_action( player ); //} -int miracle_unit_set( miracle_unit unit, char *name_value ) +int melted_unit_set( melted_unit unit, char *name_value ) { mlt_properties properties = NULL; @@ -750,7 +750,7 @@ int miracle_unit_set( miracle_unit unit, char *name_value ) return mlt_properties_parse( properties, name_value ); } -char *miracle_unit_get( miracle_unit unit, char *name ) +char *melted_unit_get( melted_unit unit, char *name ) { mlt_playlist playlist = mlt_properties_get_data( unit->properties, "playlist", NULL ); mlt_properties properties = MLT_PLAYLIST_PROPERTIES( playlist ); @@ -760,18 +760,17 @@ char *miracle_unit_get( miracle_unit unit, char *name ) /** Release the unit \todo error handling - \param unit A miracle_unit handle. + \param unit A melted_unit handle. */ -void miracle_unit_close( miracle_unit unit ) +void melted_unit_close( melted_unit unit ) { if ( unit != NULL ) { - miracle_log( LOG_DEBUG, "closing unit..." ); - miracle_unit_terminate( unit ); + melted_log( LOG_DEBUG, "closing unit..." ); + melted_unit_terminate( unit ); mlt_properties_close( unit->properties ); free( unit ); - miracle_log( LOG_DEBUG, "... unit closed." ); + melted_log( LOG_DEBUG, "... unit closed." ); } } - diff --git a/src/melted/melted_unit.h b/src/melted/melted_unit.h index a78500f..3e1425d 100644 --- a/src/melted/melted_unit.h +++ b/src/melted/melted_unit.h @@ -1,6 +1,6 @@ /* - * dvunit.h -- Transmission Unit Header - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_unit.h -- Playout Unit Header + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Dan Dennedy * * This program is free software; you can redistribute it and/or modify @@ -18,13 +18,13 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _DV_UNIT_H_ -#define _DV_UNIT_H_ +#ifndef _MELTED_UNIT_H_ +#define _MELTED_UNIT_H_ #include #include -#include +#include #ifdef __cplusplus extern "C" @@ -35,44 +35,40 @@ typedef struct { mlt_properties properties; } -miracle_unit_t, *miracle_unit; +melted_unit_t, *melted_unit; -extern miracle_unit miracle_unit_init( int index, char *arg ); -extern void miracle_unit_report_list( miracle_unit unit, valerie_response response ); -extern void miracle_unit_allow_stdin( miracle_unit unit, int flag ); -extern valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int32_t in, int32_t out, int flush ); -extern valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int32_t in, int32_t out ); -extern valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int32_t in, int32_t out ); -extern valerie_error_code miracle_unit_append_service( miracle_unit unit, mlt_service service ); -extern valerie_error_code miracle_unit_remove( miracle_unit unit, int index ); -extern valerie_error_code miracle_unit_clean( miracle_unit unit ); -extern valerie_error_code miracle_unit_wipe( miracle_unit unit ); -extern valerie_error_code miracle_unit_clear( miracle_unit unit ); -extern valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ); -extern int miracle_unit_transfer( miracle_unit dest_unit, miracle_unit src_unit ); -extern void miracle_unit_play( miracle_unit_t *unit, int speed ); -extern void miracle_unit_terminate( miracle_unit ); -extern int miracle_unit_has_terminated( miracle_unit ); -extern int miracle_unit_get_nodeid( miracle_unit unit ); -extern int miracle_unit_get_channel( miracle_unit unit ); -extern int miracle_unit_is_offline( miracle_unit unit ); -extern void miracle_unit_set_notifier( miracle_unit, valerie_notifier, char * ); -extern int miracle_unit_get_status( miracle_unit, valerie_status ); -extern void miracle_unit_change_position( miracle_unit, int, int32_t position ); -extern void miracle_unit_change_speed( miracle_unit unit, int speed ); -extern int miracle_unit_set_clip_in( miracle_unit unit, int index, int32_t position ); -extern int miracle_unit_set_clip_out( miracle_unit unit, int index, int32_t position ); -//extern void miracle_unit_set_mode( miracle_unit unit, dv_player_clip_mode mode ); -//extern dv_player_clip_mode miracle_unit_get_mode( miracle_unit unit ); -//extern void miracle_unit_set_eof_action( miracle_unit unit, dv_player_eof_action mode ); -//extern dv_player_eof_action miracle_unit_get_eof_action( miracle_unit unit ); -extern void miracle_unit_step( miracle_unit unit, int32_t offset ); -extern void miracle_unit_close( miracle_unit unit ); -extern void miracle_unit_suspend( miracle_unit ); -extern void miracle_unit_restore( miracle_unit ); -extern int miracle_unit_set( miracle_unit, char *name_value ); -extern char * miracle_unit_get( miracle_unit, char *name ); -extern int miracle_unit_get_current_clip( miracle_unit ); +extern melted_unit melted_unit_init( int index, char *arg ); +extern void melted_unit_report_list( melted_unit unit, mvcp_response response ); +extern void melted_unit_allow_stdin( melted_unit unit, int flag ); +extern mvcp_error_code melted_unit_load( melted_unit unit, char *clip, int32_t in, int32_t out, int flush ); +extern mvcp_error_code melted_unit_insert( melted_unit unit, char *clip, int index, int32_t in, int32_t out ); +extern mvcp_error_code melted_unit_append( melted_unit unit, char *clip, int32_t in, int32_t out ); +extern mvcp_error_code melted_unit_append_service( melted_unit unit, mlt_service service ); +extern mvcp_error_code melted_unit_remove( melted_unit unit, int index ); +extern mvcp_error_code melted_unit_clean( melted_unit unit ); +extern mvcp_error_code melted_unit_wipe( melted_unit unit ); +extern mvcp_error_code melted_unit_clear( melted_unit unit ); +extern mvcp_error_code melted_unit_move( melted_unit unit, int src, int dest ); +extern int melted_unit_transfer( melted_unit dest_unit, melted_unit src_unit ); +extern void melted_unit_play( melted_unit_t *unit, int speed ); +extern void melted_unit_terminate( melted_unit ); +extern int melted_unit_has_terminated( melted_unit ); +extern int melted_unit_get_nodeid( melted_unit unit ); +extern int melted_unit_get_channel( melted_unit unit ); +extern int melted_unit_is_offline( melted_unit unit ); +extern void melted_unit_set_notifier( melted_unit, mvcp_notifier, char * ); +extern int melted_unit_get_status( melted_unit, mvcp_status ); +extern void melted_unit_change_position( melted_unit, int, int32_t position ); +extern void melted_unit_change_speed( melted_unit unit, int speed ); +extern int melted_unit_set_clip_in( melted_unit unit, int index, int32_t position ); +extern int melted_unit_set_clip_out( melted_unit unit, int index, int32_t position ); +extern void melted_unit_step( melted_unit unit, int32_t offset ); +extern void melted_unit_close( melted_unit unit ); +extern void melted_unit_suspend( melted_unit ); +extern void melted_unit_restore( melted_unit ); +extern int melted_unit_set( melted_unit, char *name_value ); +extern char * melted_unit_get( melted_unit, char *name ); +extern int melted_unit_get_current_clip( melted_unit ); #ifdef __cplusplus diff --git a/src/melted/melted_unit_commands.c b/src/melted/melted_unit_commands.c index 97fb2dd..ca94e78 100644 --- a/src/melted/melted_unit_commands.c +++ b/src/melted/melted_unit_commands.c @@ -1,6 +1,6 @@ /* - * unit_commands.c - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_unit_commands.c + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Dan Dennedy * * This program is free software; you can redistribute it and/or modify @@ -30,13 +30,13 @@ #include #include -#include "miracle_unit.h" -#include "miracle_commands.h" -#include "miracle_log.h" +#include "melted_unit.h" +#include "melted_commands.h" +#include "melted_log.h" -int miracle_load( command_argument cmd_arg ) +int melted_load( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); char *filename = (char*) cmd_arg->argument; char fullname[1024]; int flush = 1; @@ -73,24 +73,24 @@ int miracle_load( command_argument cmd_arg ) else { int32_t in = -1, out = -1; - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 ) + if ( mvcp_tokeniser_count( cmd_arg->tokeniser ) == 5 ) { - in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); - out = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); + in = atol( mvcp_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); + out = atol( mvcp_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); } - if ( miracle_unit_load( unit, fullname, in, out, flush ) != valerie_ok ) + if ( melted_unit_load( unit, fullname, in, out, flush ) != mvcp_ok ) return RESPONSE_BAD_FILE; } return RESPONSE_SUCCESS; } -int miracle_list( command_argument cmd_arg ) +int melted_list( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit( cmd_arg->unit ); + melted_unit unit = melted_get_unit( cmd_arg->unit ); if ( unit != NULL ) { - miracle_unit_report_list( unit, cmd_arg->response ); + melted_unit_report_list( unit, cmd_arg->response ); return RESPONSE_SUCCESS; } @@ -99,12 +99,12 @@ int miracle_list( command_argument cmd_arg ) static int parse_clip( command_argument cmd_arg, int arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - int clip = miracle_unit_get_current_clip( unit ); + melted_unit unit = melted_get_unit(cmd_arg->unit); + int clip = melted_unit_get_current_clip( unit ); - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) > arg ) + if ( mvcp_tokeniser_count( cmd_arg->tokeniser ) > arg ) { - char *token = valerie_tokeniser_get_string( cmd_arg->tokeniser, arg ); + char *token = mvcp_tokeniser_get_string( cmd_arg->tokeniser, arg ); if ( token[ 0 ] == '+' ) clip += atoi( token + 1 ); else if ( token[ 0 ] == '-' ) @@ -116,9 +116,9 @@ static int parse_clip( command_argument cmd_arg, int arg ) return clip; } -int miracle_insert( command_argument cmd_arg ) +int melted_insert( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); char *filename = (char*) cmd_arg->argument; char fullname[1024]; @@ -134,15 +134,15 @@ int miracle_insert( command_argument cmd_arg ) long in = -1, out = -1; int index = parse_clip( cmd_arg, 3 ); - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 6 ) + if ( mvcp_tokeniser_count( cmd_arg->tokeniser ) == 6 ) { - in = atoi( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); - out = atoi( valerie_tokeniser_get_string( cmd_arg->tokeniser, 5 ) ); + in = atoi( mvcp_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); + out = atoi( mvcp_tokeniser_get_string( cmd_arg->tokeniser, 5 ) ); } - switch( miracle_unit_insert( unit, fullname, index, in, out ) ) + switch( melted_unit_insert( unit, fullname, index, in, out ) ) { - case valerie_ok: + case mvcp_ok: return RESPONSE_SUCCESS; default: return RESPONSE_BAD_FILE; @@ -151,9 +151,9 @@ int miracle_insert( command_argument cmd_arg ) return RESPONSE_SUCCESS; } -int miracle_remove( command_argument cmd_arg ) +int melted_remove( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if (unit == NULL) return RESPONSE_INVALID_UNIT; @@ -161,66 +161,66 @@ int miracle_remove( command_argument cmd_arg ) { int index = parse_clip( cmd_arg, 2 ); - if ( miracle_unit_remove( unit, index ) != valerie_ok ) + if ( melted_unit_remove( unit, index ) != mvcp_ok ) return RESPONSE_BAD_FILE; } return RESPONSE_SUCCESS; } -int miracle_clean( command_argument cmd_arg ) +int melted_clean( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if (unit == NULL) return RESPONSE_INVALID_UNIT; else { - if ( miracle_unit_clean( unit ) != valerie_ok ) + if ( melted_unit_clean( unit ) != mvcp_ok ) return RESPONSE_BAD_FILE; } return RESPONSE_SUCCESS; } -int miracle_wipe( command_argument cmd_arg ) +int melted_wipe( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if (unit == NULL) return RESPONSE_INVALID_UNIT; else { - if ( miracle_unit_wipe( unit ) != valerie_ok ) + if ( melted_unit_wipe( unit ) != mvcp_ok ) return RESPONSE_BAD_FILE; } return RESPONSE_SUCCESS; } -int miracle_clear( command_argument cmd_arg ) +int melted_clear( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if (unit == NULL) return RESPONSE_INVALID_UNIT; else { - if ( miracle_unit_clear( unit ) != valerie_ok ) + if ( melted_unit_clear( unit ) != mvcp_ok ) return RESPONSE_BAD_FILE; } return RESPONSE_SUCCESS; } -int miracle_move( command_argument cmd_arg ) +int melted_move( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if ( unit != NULL ) { - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) > 2 ) + if ( mvcp_tokeniser_count( cmd_arg->tokeniser ) > 2 ) { int src = parse_clip( cmd_arg, 2 ); int dest = parse_clip( cmd_arg, 3 ); - if ( miracle_unit_move( unit, src, dest ) != valerie_ok ) + if ( melted_unit_move( unit, src, dest ) != mvcp_ok ) return RESPONSE_BAD_FILE; } else @@ -236,9 +236,9 @@ int miracle_move( command_argument cmd_arg ) return RESPONSE_SUCCESS; } -int miracle_append( command_argument cmd_arg ) +int melted_append( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); char *filename = (char*) cmd_arg->argument; char fullname[1024]; @@ -252,14 +252,14 @@ int miracle_append( command_argument cmd_arg ) else { int32_t in = -1, out = -1; - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 ) + if ( mvcp_tokeniser_count( cmd_arg->tokeniser ) == 5 ) { - in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); - out = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); + in = atol( mvcp_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); + out = atol( mvcp_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); } - switch ( miracle_unit_append( unit, fullname, in, out ) ) + switch ( melted_unit_append( unit, fullname, in, out ) ) { - case valerie_ok: + case mvcp_ok: return RESPONSE_SUCCESS; default: return RESPONSE_BAD_FILE; @@ -268,18 +268,18 @@ int miracle_append( command_argument cmd_arg ) return RESPONSE_SUCCESS; } -int miracle_push( command_argument cmd_arg, mlt_service service ) +int melted_push( command_argument cmd_arg, mlt_service service ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if ( unit != NULL && service != NULL ) - if ( miracle_unit_append_service( unit, service ) == valerie_ok ) + if ( melted_unit_append_service( unit, service ) == mvcp_ok ) return RESPONSE_SUCCESS; return RESPONSE_BAD_FILE; } -int miracle_receive( command_argument cmd_arg, char *doc ) +int melted_receive( command_argument cmd_arg, char *doc ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if ( unit != NULL ) { // Get the consumer's profile @@ -288,7 +288,7 @@ int miracle_receive( command_argument cmd_arg, char *doc ) mlt_producer producer = mlt_factory_producer( profile, "westley-xml", doc ); if ( producer != NULL ) { - if ( miracle_unit_append_service( unit, MLT_PRODUCER_SERVICE( producer ) ) == valerie_ok ) + if ( melted_unit_append_service( unit, MLT_PRODUCER_SERVICE( producer ) ) == mvcp_ok ) { mlt_producer_close( producer ); return RESPONSE_SUCCESS; @@ -299,9 +299,9 @@ int miracle_receive( command_argument cmd_arg, char *doc ) return RESPONSE_BAD_FILE; } -int miracle_play( command_argument cmd_arg ) +int melted_play( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if ( unit == NULL ) { @@ -310,83 +310,83 @@ int miracle_play( command_argument cmd_arg ) else { int speed = 1000; - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 3 ) - speed = atoi( valerie_tokeniser_get_string( cmd_arg->tokeniser, 2 ) ); - miracle_unit_play( unit, speed ); + if ( mvcp_tokeniser_count( cmd_arg->tokeniser ) == 3 ) + speed = atoi( mvcp_tokeniser_get_string( cmd_arg->tokeniser, 2 ) ); + melted_unit_play( unit, speed ); } return RESPONSE_SUCCESS; } -int miracle_stop( command_argument cmd_arg ) +int melted_stop( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if ( unit == NULL ) return RESPONSE_INVALID_UNIT; else - miracle_unit_terminate( unit ); + melted_unit_terminate( unit ); return RESPONSE_SUCCESS; } -int miracle_pause( command_argument cmd_arg ) +int melted_pause( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if ( unit == NULL ) return RESPONSE_INVALID_UNIT; else - miracle_unit_play( unit, 0 ); + melted_unit_play( unit, 0 ); return RESPONSE_SUCCESS; } -int miracle_rewind( command_argument cmd_arg ) +int melted_rewind( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if ( unit == NULL ) return RESPONSE_INVALID_UNIT; else - miracle_unit_play( unit, -2000 ); + melted_unit_play( unit, -2000 ); return RESPONSE_SUCCESS; } -int miracle_step( command_argument cmd_arg ) +int melted_step( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if (unit == NULL) return RESPONSE_INVALID_UNIT; else { - miracle_unit_play( unit, 0 ); - miracle_unit_step( unit, *(int*) cmd_arg->argument ); + melted_unit_play( unit, 0 ); + melted_unit_step( unit, *(int*) cmd_arg->argument ); } return RESPONSE_SUCCESS; } -int miracle_goto( command_argument cmd_arg ) +int melted_goto( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); int clip = parse_clip( cmd_arg, 3 ); - if (unit == NULL || miracle_unit_is_offline(unit)) + if (unit == NULL || melted_unit_is_offline(unit)) return RESPONSE_INVALID_UNIT; else - miracle_unit_change_position( unit, clip, *(int*) cmd_arg->argument ); + melted_unit_change_position( unit, clip, *(int*) cmd_arg->argument ); return RESPONSE_SUCCESS; } -int miracle_ff( command_argument cmd_arg ) +int melted_ff( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); if ( unit == NULL ) return RESPONSE_INVALID_UNIT; else - miracle_unit_play( unit, 2000 ); + melted_unit_play( unit, 2000 ); return RESPONSE_SUCCESS; } -int miracle_set_in_point( command_argument cmd_arg ) +int melted_set_in_point( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); int clip = parse_clip( cmd_arg, 3 ); if ( unit == NULL ) @@ -395,7 +395,7 @@ int miracle_set_in_point( command_argument cmd_arg ) { int position = *(int *) cmd_arg->argument; - switch( miracle_unit_set_clip_in( unit, clip, position ) ) + switch( melted_unit_set_clip_in( unit, clip, position ) ) { case -1: return RESPONSE_BAD_FILE; @@ -406,9 +406,9 @@ int miracle_set_in_point( command_argument cmd_arg ) return RESPONSE_SUCCESS; } -int miracle_set_out_point( command_argument cmd_arg ) +int melted_set_out_point( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); int clip = parse_clip( cmd_arg, 3 ); if ( unit == NULL ) @@ -417,7 +417,7 @@ int miracle_set_out_point( command_argument cmd_arg ) { int position = *(int *) cmd_arg->argument; - switch( miracle_unit_set_clip_out( unit, clip, position ) ) + switch( melted_unit_set_clip_out( unit, clip, position ) ) { case -1: return RESPONSE_BAD_FILE; @@ -429,50 +429,50 @@ int miracle_set_out_point( command_argument cmd_arg ) return RESPONSE_SUCCESS; } -int miracle_get_unit_status( command_argument cmd_arg ) +int melted_get_unit_status( command_argument cmd_arg ) { - valerie_status_t status; - int error = miracle_unit_get_status( miracle_get_unit( cmd_arg->unit ), &status ); + mvcp_status_t status; + int error = melted_unit_get_status( melted_get_unit( cmd_arg->unit ), &status ); if ( error == -1 ) return RESPONSE_INVALID_UNIT; else { char text[ 10240 ]; - valerie_response_printf( cmd_arg->response, sizeof( text ), valerie_status_serialise( &status, text, sizeof( text ) ) ); + mvcp_response_printf( cmd_arg->response, sizeof( text ), mvcp_status_serialise( &status, text, sizeof( text ) ) ); return RESPONSE_SUCCESS_1; } return 0; } -int miracle_set_unit_property( command_argument cmd_arg ) +int melted_set_unit_property( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); char *name_value = (char*) cmd_arg->argument; if (unit == NULL) return RESPONSE_INVALID_UNIT; else - miracle_unit_set( unit, name_value ); + melted_unit_set( unit, name_value ); return RESPONSE_SUCCESS; } -int miracle_get_unit_property( command_argument cmd_arg ) +int melted_get_unit_property( command_argument cmd_arg ) { - miracle_unit unit = miracle_get_unit(cmd_arg->unit); + melted_unit unit = melted_get_unit(cmd_arg->unit); char *name = (char*) cmd_arg->argument; - char *value = miracle_unit_get( unit, name ); + char *value = melted_unit_get( unit, name ); if (unit == NULL) return RESPONSE_INVALID_UNIT; else if ( value != NULL ) - valerie_response_printf( cmd_arg->response, 1024, "%s\n", value ); + mvcp_response_printf( cmd_arg->response, 1024, "%s\n", value ); return RESPONSE_SUCCESS; } -int miracle_transfer( command_argument cmd_arg ) +int melted_transfer( command_argument cmd_arg ) { - miracle_unit src_unit = miracle_get_unit(cmd_arg->unit); + melted_unit src_unit = melted_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 ) @@ -480,10 +480,10 @@ int miracle_transfer( command_argument cmd_arg ) if ( src_unit != NULL && dest_unit_id != -1 ) { - miracle_unit dest_unit = miracle_get_unit( dest_unit_id ); - if ( dest_unit != NULL && !miracle_unit_is_offline(dest_unit) && dest_unit != src_unit ) + melted_unit dest_unit = melted_get_unit( dest_unit_id ); + if ( dest_unit != NULL && !melted_unit_is_offline(dest_unit) && dest_unit != src_unit ) { - miracle_unit_transfer( dest_unit, src_unit ); + melted_unit_transfer( dest_unit, src_unit ); return RESPONSE_SUCCESS; } } diff --git a/src/melted/melted_unit_commands.h b/src/melted/melted_unit_commands.h index cfd51a7..6659e82 100644 --- a/src/melted/melted_unit_commands.h +++ b/src/melted/melted_unit_commands.h @@ -1,6 +1,6 @@ /* - * unit_commands.h - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited + * melted_unit_commands.h + * Copyright (C) 2002-2009 Ushodaya Enterprises Limited * Author: Dan Dennedy * * This program is free software; you can redistribute it and/or modify @@ -22,37 +22,37 @@ #ifndef _UNIT_COMMANDS_H_ #define _UNIT_COMMANDS_H_ -#include "miracle_connection.h" +#include "melted_connection.h" #ifdef __cplusplus extern "C" { #endif -extern response_codes miracle_list( command_argument ); -extern response_codes miracle_load( command_argument ); -extern response_codes miracle_insert( command_argument ); -extern response_codes miracle_remove( command_argument ); -extern response_codes miracle_clean( command_argument ); -extern response_codes miracle_wipe( command_argument ); -extern response_codes miracle_clear( command_argument ); -extern response_codes miracle_move( command_argument ); -extern response_codes miracle_append( command_argument ); -extern response_codes miracle_play( command_argument ); -extern response_codes miracle_stop( command_argument ); -extern response_codes miracle_pause( command_argument ); -extern response_codes miracle_rewind( command_argument ); -extern response_codes miracle_step( command_argument ); -extern response_codes miracle_goto( command_argument ); -extern response_codes miracle_ff( command_argument ); -extern response_codes miracle_set_in_point( command_argument ); -extern response_codes miracle_set_out_point( command_argument ); -extern response_codes miracle_get_unit_status( command_argument ); -extern response_codes miracle_set_unit_property( command_argument ); -extern response_codes miracle_get_unit_property( command_argument ); -extern response_codes miracle_transfer( command_argument ); -extern response_codes miracle_push( command_argument, mlt_service ); -extern response_codes miracle_receive( command_argument, char * ); +extern response_codes melted_list( command_argument ); +extern response_codes melted_load( command_argument ); +extern response_codes melted_insert( command_argument ); +extern response_codes melted_remove( command_argument ); +extern response_codes melted_clean( command_argument ); +extern response_codes melted_wipe( command_argument ); +extern response_codes melted_clear( command_argument ); +extern response_codes melted_move( command_argument ); +extern response_codes melted_append( command_argument ); +extern response_codes melted_play( command_argument ); +extern response_codes melted_stop( command_argument ); +extern response_codes melted_pause( command_argument ); +extern response_codes melted_rewind( command_argument ); +extern response_codes melted_step( command_argument ); +extern response_codes melted_goto( command_argument ); +extern response_codes melted_ff( command_argument ); +extern response_codes melted_set_in_point( command_argument ); +extern response_codes melted_set_out_point( command_argument ); +extern response_codes melted_get_unit_status( command_argument ); +extern response_codes melted_set_unit_property( command_argument ); +extern response_codes melted_get_unit_property( command_argument ); +extern response_codes melted_transfer( command_argument ); +extern response_codes melted_push( command_argument, mlt_service ); +extern response_codes melted_receive( command_argument, char * ); #ifdef __cplusplus } -- 1.7.4.4