X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fvalerie%2Fvalerie.c;h=b7f1cc69029a7689091787e831eaed66d2de4859;hb=ced3d0b8c0520e4c8208166e3218e0caacba1efa;hp=8499f440b8e05a9bbfba46dee4631c8c2d8d56d0;hpb=8cf0f77981284b7549c811b67283eb73d0c520d6;p=melted diff --git a/src/valerie/valerie.c b/src/valerie/valerie.c index 8499f44..b7f1cc6 100644 --- a/src/valerie/valerie.c +++ b/src/valerie/valerie.c @@ -117,7 +117,7 @@ static valerie_error_code valerie_get_error_code( valerie this, valerie_response /** Execute a command. */ -valerie_error_code valerie_execute( valerie this, size_t size, char *format, ... ) +valerie_error_code valerie_execute( valerie this, size_t size, const char *format, ... ) { valerie_error_code error = valerie_server_unavailable; char *command = malloc( size ); @@ -148,7 +148,38 @@ valerie_error_code valerie_execute( valerie this, size_t size, char *format, ... /** Execute a command. */ -valerie_error_code valerie_push( valerie this, mlt_service service, size_t size, char *format, ... ) +valerie_error_code valerie_receive( valerie this, char *doc, size_t size, const 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, const char *format, ... ) { valerie_error_code error = valerie_server_unavailable; char *command = malloc( size ); @@ -286,6 +317,14 @@ valerie_error_code valerie_unit_append( valerie this, int unit, char *file, int3 /** 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 ); @@ -307,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. */ @@ -487,7 +534,7 @@ valerie_error_code valerie_unit_clear_in_out( valerie this, int unit ) /** Set a unit configuration property. */ -valerie_error_code valerie_unit_set( valerie this, int unit, char *name, char *value ) +valerie_error_code valerie_unit_set( valerie this, int unit, const char *name, const char *value ) { return valerie_execute( this, 1024, "USET U%d %s=%s", unit, name, value ); } @@ -540,7 +587,7 @@ valerie_notifier valerie_get_notifier( valerie this ) /** List the contents of the specified directory. */ -valerie_dir valerie_dir_init( valerie this, char *directory ) +valerie_dir valerie_dir_init( valerie this, const char *directory ) { valerie_dir dir = malloc( sizeof( valerie_dir_t ) ); if ( dir != NULL ) @@ -864,9 +911,9 @@ valerie_response valerie_get_last_response( valerie this ) /** Obtain a printable message associated to the error code provided. */ -char *valerie_error_description( valerie_error_code error ) +const char *valerie_error_description( valerie_error_code error ) { - char *msg = "Unrecognised error"; + const char *msg = "Unrecognised error"; switch( error ) { case valerie_ok: