X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmelted%2Fmelted_unit_commands.c;h=b6d8f340426a5c39ff59de826751dfe800d4aee0;hb=91af795798049db85f9ad3814edc85fd474a5866;hp=97fb2dd0934aeb3a6e5edc25a08357e682cfcb30;hpb=27f0329aa8f434794f1f18e018fc3221e58b77a4;p=melted diff --git a/src/melted/melted_unit_commands.c b/src/melted/melted_unit_commands.c index 97fb2dd..b6d8f34 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,27 +268,27 @@ 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 mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL ); mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( consumer ) ); - mlt_producer producer = mlt_factory_producer( profile, "westley-xml", doc ); + mlt_producer producer = mlt_factory_producer( profile, "xml-string", 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,87 @@ 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 ); + else if ( melted_unit_has_terminated( unit ) ) + melted_unit_change_position( unit, 0, 0 ); + else + 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 ); + else if ( melted_unit_has_terminated( unit ) ) + melted_unit_change_position( unit, 0, 0 ); + else + 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 +399,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 +410,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 +421,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 +433,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 +484,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; } }