adding the rock thrower...
[melted] / src / miracle / miracle_unit.c
index f7023d0..255dad4 100644 (file)
@@ -127,10 +127,15 @@ void miracle_unit_set_notifier( miracle_unit this, valerie_notifier notifier, ch
        miracle_unit_status_communicate( this );
 }
 
+static mlt_producer create_producer( char *file )
+{
+       return mlt_factory_producer( "fezzik", file );
+}
+
 /** Create or locate a producer for the file specified.
 */
 
-static mlt_producer create_producer( miracle_unit unit, char *file )
+static mlt_producer locate_producer( miracle_unit unit, char *file )
 {
        // Get the unit properties
        mlt_properties properties = unit->producers;
@@ -140,45 +145,12 @@ static mlt_producer create_producer( miracle_unit unit, char *file )
 
        if ( result == NULL )
        {
-               // 1st Line preferences
-               if ( strstr( file, ".inigo" ) )
-               {
-                       char *args[ 2 ] = { file, NULL };
-                       result = mlt_factory_producer( "inigo", args );
-               }
-               else if ( strstr( file, ".mpg" ) )
-                       result = mlt_factory_producer( "mcmpeg", file );
-               else if ( strstr( file, ".mpeg" ) )
-                       result = mlt_factory_producer( "mcmpeg", file );
-               else if ( strstr( file, ".dv" ) )
-                       result = mlt_factory_producer( "mcdv", file );
-               else if ( strstr( file, ".dif" ) )
-                       result = mlt_factory_producer( "mcdv", file );
-               else if ( strstr( file, ".jpg" ) )
-                       result = mlt_factory_producer( "pixbuf", file );
-               else if ( strstr( file, ".JPG" ) )
-                       result = mlt_factory_producer( "pixbuf", file );
-               else if ( strstr( file, ".jpeg" ) )
-                       result = mlt_factory_producer( "pixbuf", file );
-               else if ( strstr( file, ".png" ) )
-                       result = mlt_factory_producer( "pixbuf", file );
-               else if ( strstr( file, ".tga" ) )
-                       result = mlt_factory_producer( "pixbuf", file );
-               else if ( strstr( file, ".txt" ) )
-                       result = mlt_factory_producer( "pango", file );
-       
-               // 2nd Line fallbacks
-               if ( result == NULL && strstr( file, ".dv" ) )
-                       result = mlt_factory_producer( "libdv", file );
-               else if ( result == NULL && strstr( file, ".dif" ) )
-                       result = mlt_factory_producer( "libdv", file );
-       
-               // 3rd line fallbacks 
-               if ( result == NULL )
-                       result = mlt_factory_producer( "ffmpeg", file );
+               // Create the producer
+               result = create_producer( file );
 
                // Now store the result
-               mlt_properties_set_data( properties, file, result, 0, ( mlt_destructor )mlt_producer_close, NULL );
+               if ( result != NULL )
+                       mlt_properties_set_data( properties, file, result, 0, ( mlt_destructor )mlt_producer_close, NULL );
        }
 
        return result;
@@ -251,15 +223,14 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response )
 
 valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in, int64_t out, int flush )
 {
-       // Have to clear the unit first
-       clear_unit( unit );
-
        // Now try to create an producer
-       mlt_producer instance = create_producer( unit, clip );
+       mlt_producer instance = create_producer( clip );
 
        if ( instance != NULL )
        {
+               clear_unit( unit );
                mlt_properties properties = unit->properties;
+               mlt_properties_set_data( unit->producers, clip, instance, 0, ( mlt_destructor )mlt_producer_close, NULL );
                mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
                mlt_playlist_append_io( playlist, instance, in, out );
                miracle_log( LOG_DEBUG, "loaded clip %s", clip );
@@ -272,7 +243,7 @@ valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in,
 
 valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int64_t in, int64_t out )
 {
-       mlt_producer instance = create_producer( unit, clip );
+       mlt_producer instance = locate_producer( unit, clip );
 
        if ( instance != NULL )
        {
@@ -329,7 +300,7 @@ valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest )
 
 valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int64_t in, int64_t out )
 {
-       mlt_producer instance = create_producer( unit, clip );
+       mlt_producer instance = locate_producer( unit, clip );
 
        if ( instance != NULL )
        {