X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fvalerie%2Fvalerie.c;h=f6a79d8c0302588c0bf76323f9b8f6a3fe2021eb;hb=f4d4669b66a9f23be85527f65dec19a566db561c;hp=ba8e228025d5f8798f9d33eb397530aea2b32b56;hpb=c7f4475afeaa2f77f774db9abc69334425a4fdcb;p=melted diff --git a/src/valerie/valerie.c b/src/valerie/valerie.c index ba8e228..f6a79d8 100644 --- a/src/valerie/valerie.c +++ b/src/valerie/valerie.c @@ -145,6 +145,68 @@ valerie_error_code valerie_execute( valerie this, size_t size, char *format, ... return error; } +/** Execute a command. +*/ + +valerie_error_code valerie_receive( valerie this, char *doc, size_t size, char *format, ... ) +{ + valerie_error_code error = valerie_server_unavailable; + char *command = malloc( size ); + if ( this != NULL && command != NULL ) + { + va_list list; + va_start( list, format ); + if ( vsnprintf( command, size, format, list ) != 0 ) + { + valerie_response response = valerie_parser_received( this->parser, command, doc ); + valerie_set_last_response( this, response ); + error = valerie_get_error_code( this, response ); + } + else + { + error = valerie_invalid_command; + } + va_end( list ); + } + else + { + error = valerie_malloc_failed; + } + free( command ); + return error; +} + +/** Execute a command. +*/ + +valerie_error_code valerie_push( valerie this, mlt_service service, size_t size, char *format, ... ) +{ + valerie_error_code error = valerie_server_unavailable; + char *command = malloc( size ); + if ( this != NULL && command != NULL ) + { + va_list list; + va_start( list, format ); + if ( vsnprintf( command, size, format, list ) != 0 ) + { + valerie_response response = valerie_parser_push( this->parser, command, service ); + valerie_set_last_response( this, response ); + error = valerie_get_error_code( this, response ); + } + else + { + error = valerie_invalid_command; + } + va_end( list ); + } + else + { + error = valerie_malloc_failed; + } + free( command ); + return error; +} + /** Set a global property. */ @@ -252,6 +314,22 @@ valerie_error_code valerie_unit_append( valerie this, int unit, char *file, int3 return valerie_execute( this, 10240, "APND U%d \"%s\" %d %d", unit, file, in, out ); } +/** Push a service on to a unit. +*/ + +valerie_error_code valerie_unit_receive( valerie this, int unit, char *command, char *doc ) +{ + return valerie_receive( this, doc, 10240, "PUSH U%d %s", unit, command ); +} + +/** Push a service on to a unit. +*/ + +valerie_error_code valerie_unit_push( valerie this, int unit, char *command, mlt_service service ) +{ + return valerie_push( this, service, 10240, "PUSH U%d %s", unit, command ); +} + /** Clean the unit - this function removes all but the currently playing clip. */ @@ -268,6 +346,14 @@ valerie_error_code valerie_unit_clear( valerie this, int unit ) return valerie_execute( this, 1024, "CLEAR U%d", unit ); } +/** Wipe the unit - this function removes all clips before the current one. +*/ + +valerie_error_code valerie_unit_wipe( valerie this, int unit ) +{ + return valerie_execute( this, 1024, "WIPE U%d", unit ); +} + /** Move clips on the units playlist. */