From a748638a86c7023aa12e7ca6e49813821fe804fd Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Tue, 23 Mar 2004 12:49:35 +0000 Subject: [PATCH] added clear to the miracle command set and valerie api git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@233 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/miracle/miracle_local.c | 1 + src/miracle/miracle_unit.c | 8 ++++++++ src/miracle/miracle_unit.h | 1 + src/miracle/miracle_unit_commands.c | 18 ++++++++++++++++-- src/miracle/miracle_unit_commands.h | 1 + src/valerie/valerie.c | 8 ++++++++ src/valerie/valerie.h | 1 + 7 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/miracle/miracle_local.c b/src/miracle/miracle_local.c index 9929e12..51f35f8 100644 --- a/src/miracle/miracle_local.c +++ b/src/miracle/miracle_local.c @@ -174,6 +174,7 @@ static command_t vocabulary[] = {"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."}, + {"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."}, diff --git a/src/miracle/miracle_unit.c b/src/miracle/miracle_unit.c index 83f0f02..ff60723 100644 --- a/src/miracle/miracle_unit.c +++ b/src/miracle/miracle_unit.c @@ -325,6 +325,14 @@ valerie_error_code miracle_unit_clean( miracle_unit unit ) return valerie_ok; } +valerie_error_code miracle_unit_clear( miracle_unit unit ) +{ + clear_unit( unit ); + miracle_log( LOG_DEBUG, "Cleared playlist" ); + miracle_unit_status_communicate( unit ); + return valerie_ok; +} + valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ) { mlt_properties properties = unit->properties; diff --git a/src/miracle/miracle_unit.h b/src/miracle/miracle_unit.h index 07d3834..3ba8751 100644 --- a/src/miracle/miracle_unit.h +++ b/src/miracle/miracle_unit.h @@ -47,6 +47,7 @@ extern valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, i extern valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int32_t in, int32_t out ); 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_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 ); diff --git a/src/miracle/miracle_unit_commands.c b/src/miracle/miracle_unit_commands.c index f190429..95737f4 100644 --- a/src/miracle/miracle_unit_commands.c +++ b/src/miracle/miracle_unit_commands.c @@ -106,7 +106,7 @@ int miracle_insert( command_argument cmd_arg ) char *filename = (char*) cmd_arg->argument; char fullname[1024]; - if ( filename[0] == '/' ) + if ( strlen( cmd_arg->root_dir ) && filename[0] == '/' ) filename++; snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename ); @@ -165,6 +165,20 @@ int miracle_clean( command_argument cmd_arg ) return RESPONSE_SUCCESS; } +int miracle_clear( command_argument cmd_arg ) +{ + miracle_unit unit = miracle_get_unit(cmd_arg->unit); + + if (unit == NULL) + return RESPONSE_INVALID_UNIT; + else + { + if ( miracle_unit_clear( unit ) != valerie_ok ) + return RESPONSE_BAD_FILE; + } + return RESPONSE_SUCCESS; +} + int miracle_move( command_argument cmd_arg ) { miracle_unit unit = miracle_get_unit(cmd_arg->unit); @@ -198,7 +212,7 @@ int miracle_append( command_argument cmd_arg ) char *filename = (char*) cmd_arg->argument; char fullname[1024]; - if ( filename[0] == '/' ) + if ( strlen( cmd_arg->root_dir ) && filename[0] == '/' ) filename++; snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename ); diff --git a/src/miracle/miracle_unit_commands.h b/src/miracle/miracle_unit_commands.h index 575ff1b..b4bde3a 100644 --- a/src/miracle/miracle_unit_commands.h +++ b/src/miracle/miracle_unit_commands.h @@ -34,6 +34,7 @@ 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_clear( command_argument ); extern response_codes miracle_move( command_argument ); extern response_codes miracle_append( command_argument ); extern response_codes miracle_play( command_argument ); diff --git a/src/valerie/valerie.c b/src/valerie/valerie.c index b1c5f94..5b0d330 100644 --- a/src/valerie/valerie.c +++ b/src/valerie/valerie.c @@ -260,6 +260,14 @@ valerie_error_code valerie_unit_clean( valerie this, int unit ) return valerie_execute( this, 1024, "CLEAN U%d", unit ); } +/** Clear the unit - this function removes all clips. +*/ + +valerie_error_code valerie_unit_clear( valerie this, int unit ) +{ + return valerie_execute( this, 1024, "CLEAR U%d", unit ); +} + /** Move clips on the units playlist. */ diff --git a/src/valerie/valerie.h b/src/valerie/valerie.h index 2ff0020..663b6c2 100644 --- a/src/valerie/valerie.h +++ b/src/valerie/valerie.h @@ -95,6 +95,7 @@ extern valerie_error_code valerie_unit_load_back( valerie, int, char * ); extern valerie_error_code valerie_unit_load_back_clipped( valerie, int, char *, int32_t, int32_t ); extern valerie_error_code valerie_unit_append( valerie, int, char *, int32_t, int32_t ); extern valerie_error_code valerie_unit_clean( valerie, int ); +extern valerie_error_code valerie_unit_clear( valerie, int ); extern valerie_error_code valerie_unit_clip_move( valerie, int, valerie_clip_offset, int, valerie_clip_offset, int ); extern valerie_error_code valerie_unit_clip_remove( valerie, int, valerie_clip_offset, int ); extern valerie_error_code valerie_unit_remove_current_clip( valerie, int ); -- 1.7.4.4