]> git.sesse.net Git - mlt/commitdiff
Corrections to playlist manipulations and producer type determination
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 9 Dec 2004 18:12:43 +0000 (18:12 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 9 Dec 2004 18:12:43 +0000 (18:12 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@552 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/mlt_playlist.c
src/framework/mlt_service.c
src/modules/inigo/producer_inigo.c

index d563d7dcaf12afa80881bf2fd02b87e2ddd61a38..22cd256b60c8147524432e120a24b8c3ea03aaf7 100644 (file)
@@ -755,6 +755,9 @@ int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_position in, mlt_
        {
                playlist_entry *entry = this->list[ clip ];
                mlt_producer producer = entry->producer;
+               mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this );
+
+               mlt_events_block( properties, properties );
 
                if ( mlt_producer_is_blank( producer ) )
                {
@@ -762,9 +765,9 @@ int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_position in, mlt_
                        if ( out - in + 1 > mlt_producer_get_length( &this->blank ) )
                        {
                                mlt_properties blank_props = MLT_PRODUCER_PROPERTIES( &this->blank );
-                               mlt_events_block( blank_props, blank_props );
-                               mlt_producer_set_in_and_out( &this->blank, in, out );
-                               mlt_events_unblock( blank_props, blank_props );
+                               mlt_properties_set_int( blank_props, "length", out - in + 1 );
+                               mlt_properties_set_int( MLT_PRODUCER_PROPERTIES( producer ), "length", out - in + 1 );
+                               mlt_producer_set_in_and_out( &this->blank, 0, out - in );
                        }
                }
 
@@ -781,6 +784,8 @@ int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_position in, mlt_
                }
 
                mlt_producer_set_in_and_out( producer, in, out );
+               mlt_events_unblock( properties, properties );
+               mlt_playlist_virtual_refresh( this );
        }
        return error;
 }
@@ -803,8 +808,17 @@ int mlt_playlist_split( mlt_playlist this, int clip, mlt_position position )
                        mlt_playlist_resize_clip( this, clip, in, in + position );
                        if ( !mlt_producer_is_blank( entry->producer ) )
                        {
+                               int i = 0;
+                               mlt_properties entry_properties = MLT_PRODUCER_PROPERTIES( entry->producer );
                                mlt_producer split = mlt_producer_cut( entry->producer, in + position + 1, out );
+                               mlt_properties split_properties = MLT_PRODUCER_PROPERTIES( split );
                                mlt_playlist_insert( this, split, clip + 1, 0, -1 );
+                               for ( i = 0; i < mlt_properties_count( entry_properties ); i ++ )
+                               {
+                                       char *name = mlt_properties_get_name( entry_properties, i );
+                                       if ( name != NULL && !strncmp( name, "meta.", 5 ) )
+                                               mlt_properties_set( split_properties, name, mlt_properties_get_value( entry_properties, i ) );
+                               }
                                mlt_producer_close( split );
                        }
                        else
@@ -1120,8 +1134,7 @@ void mlt_playlist_consolidate_blanks( mlt_playlist this, int keep_length )
                        playlist_entry *left = this->list[ i - 1 ];
                        playlist_entry *right = this->list[ i ];
 
-                       if ( mlt_producer_cut_parent( left->producer ) == mlt_producer_cut_parent( right->producer ) && 
-                                mlt_producer_is_blank( left->producer ) )
+                       if ( mlt_producer_is_blank( left->producer ) && mlt_producer_is_blank( right->producer ) )
                        {
                                mlt_playlist_resize_clip( this, i - 1, 0, left->frame_count + right->frame_count - 1 );
                                mlt_playlist_remove( this, i -- );
@@ -1166,9 +1179,9 @@ mlt_producer mlt_playlist_replace_with_blank( mlt_playlist this, int clip )
                mlt_playlist_remove( this, clip );
                mlt_playlist_blank( this, out - in );
                mlt_playlist_move( this, this->count - 1, clip );
-               mlt_producer_set_in_and_out( producer, in, out );
                mlt_events_unblock( properties, properties );
                mlt_playlist_virtual_refresh( this );
+               mlt_producer_set_in_and_out( producer, in, out );
        }
        return producer;
 }
@@ -1226,11 +1239,18 @@ int mlt_playlist_insert_at( mlt_playlist this, int position, mlt_producer produc
                mlt_events_block( properties, this );
                if ( clip < this->count && mlt_playlist_is_blank( this, clip ) )
                {
-                       mlt_playlist_split( this, clip, position - info.start );
-                       mlt_playlist_get_clip_info( this, &info, ++ clip );
+                       // Split and move to new clip if need be
+                       if ( mlt_playlist_split( this, clip, position - info.start ) == 0 )
+                               mlt_playlist_get_clip_info( this, &info, ++ clip );
+
+                       // Split again if need be
                        if ( length < info.frame_count )
-                               mlt_playlist_split( this, clip, length );
+                               mlt_playlist_split( this, clip, length - 1 );
+
+                       // Remove
                        mlt_playlist_remove( this, clip );
+
+                       // Insert
                        mlt_playlist_insert( this, producer, clip, -1, -1 );
                        ret = clip;
                }
index 36f79e0515d926ccfbe42237e57b93aa73a21ec1..d8173d670d6b902c10372efee05a776c70ee8651 100644 (file)
@@ -124,19 +124,16 @@ mlt_service_type mlt_service_identify( mlt_service this )
                char *resource = mlt_properties_get( properties, "resource" );
                if ( mlt_type == NULL )
                        type = unknown_type;
+               else if ( resource == NULL || !strcmp( resource, "<producer>" ) )
+                       type = producer_type;
+               else if ( !strcmp( resource, "<playlist>" ) )
+                       type = playlist_type;
+               else if ( !strcmp( resource, "<tractor>" ) )
+                       type = tractor_type;
+               else if ( !strcmp( resource, "<multitrack>" ) )
+                       type = multitrack_type;
                else if ( !strcmp( mlt_type, "producer" ) )
                        type = producer_type;
-               else if ( !strcmp( mlt_type, "mlt_producer" ) )
-               {
-                       if ( resource == NULL || !strcmp( resource, "<producer>" ) )
-                               type = producer_type;
-                       else if ( !strcmp( resource, "<playlist>" ) )
-                               type = playlist_type;
-                       else if ( !strcmp( resource, "<tractor>" ) )
-                               type = tractor_type;
-                       else if ( !strcmp( resource, "<multitrack>" ) )
-                               type = multitrack_type;
-               }
                else if ( !strcmp( mlt_type, "filter" ) )
                        type = filter_type;
                else if ( !strcmp( mlt_type, "transition" ) )
index e5263c40a2f105322d5311dfd302e1dfc89ea758..707fb774fc7cc51c5aff44c06ade057dfcc9c61e 100644 (file)
@@ -124,8 +124,8 @@ mlt_producer producer_inigo_init( char **argv )
        mlt_tractor mix = NULL;
        mlt_playlist playlist = mlt_playlist_init( );
        mlt_properties group = mlt_properties_new( );
-       mlt_properties properties = group;
        mlt_tractor tractor = mlt_tractor_new( );
+       mlt_properties properties = MLT_TRACTOR_PROPERTIES( tractor );
        mlt_field field = mlt_tractor_field( tractor );
        mlt_properties field_properties = mlt_field_properties( field );
        mlt_multitrack multitrack = mlt_tractor_multitrack( tractor );
@@ -338,6 +338,9 @@ mlt_producer producer_inigo_init( char **argv )
                        mlt_playlist_blank( playlist, atof( argv[ ++ i ] ) );
                }
                else if ( !strcmp( argv[ i ], "-track" ) ||
+                                 !strcmp( argv[ i ], "-null-track" ) ||
+                                 !strcmp( argv[ i ], "-video-track" ) ||
+                                 !strcmp( argv[ i ], "-audio-track" ) ||
                                  !strcmp( argv[ i ], "-hide-track" ) ||
                                  !strcmp( argv[ i ], "-hide-video" ) ||
                                  !strcmp( argv[ i ], "-hide-audio" ) )
@@ -345,17 +348,20 @@ mlt_producer producer_inigo_init( char **argv )
                        if ( producer != NULL && !mlt_producer_is_cut( producer ) )
                                mlt_playlist_append( playlist, producer );
                        producer = NULL;
-                       mlt_multitrack_connect( multitrack, MLT_PLAYLIST_PRODUCER( playlist ), track ++ );
-                       track_service( field, playlist, ( mlt_destructor )mlt_playlist_close );
-                       playlist = mlt_playlist_init( );
+                       if ( mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( playlist ) ) > 0 )
+                       {
+                               mlt_multitrack_connect( multitrack, MLT_PLAYLIST_PRODUCER( playlist ), track ++ );
+                               track_service( field, playlist, ( mlt_destructor )mlt_playlist_close );
+                               playlist = mlt_playlist_init( );
+                       }
                        if ( playlist != NULL )
                        {
                                properties = MLT_PLAYLIST_PROPERTIES( playlist );
-                               if ( !strcmp( argv[ i ], "-hide-track" ) )
+                               if ( !strcmp( argv[ i ], "-null-track" ) || !strcmp( argv[ i ], "-hide-track" ) )
                                        mlt_properties_set_int( properties, "hide", 3 );
-                               else if ( !strcmp( argv[ i ], "-hide-video" ) )
+                               else if ( !strcmp( argv[ i ], "-audio-track" ) || !strcmp( argv[ i ], "-hide-video" ) )
                                        mlt_properties_set_int( properties, "hide", 1 );
-                               else if ( !strcmp( argv[ i ], "-hide-audio" ) )
+                               else if ( !strcmp( argv[ i ], "-video-track" ) || !strcmp( argv[ i ], "-hide-audio" ) )
                                        mlt_properties_set_int( properties, "hide", 2 );
                        }
                }