]> git.sesse.net Git - mlt/blobdiff - src/miracle/miracle_unit_commands.c
Merge ../mlt++
[mlt] / src / miracle / miracle_unit_commands.c
index 66f84bb89bd5ca70352d978a3801a4713ca7dbf7..97fb2dd0934aeb3a6e5edc25a08357e682cfcb30 100644 (file)
@@ -40,6 +40,7 @@ int miracle_load( command_argument cmd_arg )
        char *filename = (char*) cmd_arg->argument;
        char fullname[1024];
        int flush = 1;
+       char *service;
 
        if ( filename[0] == '!' )
        {
@@ -47,16 +48,31 @@ int miracle_load( command_argument cmd_arg )
                filename ++;
        }
 
-       if ( filename[0] == '/' )
-               filename++;
+       service = strchr( filename, ':' );
+       if ( service != NULL )
+       {
+               service = filename;
+               filename = strchr( service, ':' );
+               *filename ++ = '\0';
+               
+               if ( strlen( cmd_arg->root_dir ) && filename[0] == '/' )
+                       filename++;
+       
+               snprintf( fullname, 1023, "%s:%s%s", service, cmd_arg->root_dir, filename );
+       }
+       else
+       {
+               if ( strlen( cmd_arg->root_dir ) && filename[0] == '/' )
+                       filename++;
 
-       snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename );
+               snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename );
+       }
        
        if (unit == NULL)
                return RESPONSE_INVALID_UNIT;
        else
        {
-               int64_t in = -1, out = -1;
+               int32_t in = -1, out = -1;
                if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 )
                {
                        in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) );
@@ -106,7 +122,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 +181,34 @@ int miracle_clean( command_argument cmd_arg )
        return RESPONSE_SUCCESS;
 }
 
+int miracle_wipe( command_argument cmd_arg )
+{
+       miracle_unit unit = miracle_get_unit(cmd_arg->unit);
+       
+       if (unit == NULL)
+               return RESPONSE_INVALID_UNIT;
+       else
+       {
+               if ( miracle_unit_wipe( unit ) != valerie_ok )
+                       return RESPONSE_BAD_FILE;
+       }
+       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 +242,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 );
@@ -207,7 +251,7 @@ int miracle_append( command_argument cmd_arg )
                return RESPONSE_INVALID_UNIT;
        else
        {
-               int64_t in = -1, out = -1;
+               int32_t in = -1, out = -1;
                if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 )
                {
                        in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) );
@@ -224,6 +268,37 @@ int miracle_append( command_argument cmd_arg )
        return RESPONSE_SUCCESS;
 }
 
+int miracle_push( command_argument cmd_arg, mlt_service service )
+{
+       miracle_unit unit = miracle_get_unit(cmd_arg->unit);
+       if ( unit != NULL && service != NULL )
+               if ( miracle_unit_append_service( unit, service ) == valerie_ok )
+                       return RESPONSE_SUCCESS;
+       return RESPONSE_BAD_FILE;
+}
+
+int miracle_receive( command_argument cmd_arg, char *doc )
+{
+       miracle_unit unit = miracle_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 );
+               if ( producer != NULL )
+               {
+                       if ( miracle_unit_append_service( unit, MLT_PRODUCER_SERVICE( producer ) ) == valerie_ok )
+                       {
+                               mlt_producer_close( producer );
+                               return RESPONSE_SUCCESS;
+                       }
+                       mlt_producer_close( producer );
+               }
+       }
+       return RESPONSE_BAD_FILE;
+}
+
 int miracle_play( command_argument cmd_arg )
 {
        miracle_unit unit = miracle_get_unit(cmd_arg->unit);