]> git.sesse.net Git - mlt/commitdiff
add support for time string to playlist blanks
authorDan Dennedy <dan@dennedy.org>
Sun, 24 Jun 2012 01:46:18 +0000 (18:46 -0700)
committerDan Dennedy <dan@dennedy.org>
Sun, 24 Jun 2012 01:46:18 +0000 (18:46 -0700)
src/framework/mlt_playlist.c
src/framework/mlt_playlist.h
src/mlt++/MltPlaylist.cpp
src/mlt++/MltPlaylist.h
src/modules/core/producer_melt.c
src/modules/xml/producer_xml.c

index 356b0d79de09543136165e8c1b8adfe05e41980c..324f6aaded096000d7c6db58228bb9f792da3380 100644 (file)
@@ -102,6 +102,23 @@ mlt_playlist mlt_playlist_init( )
        return self;
 }
 
+/** Construct a playlist with a profile.
+ *
+ * Sets the resource property to "<playlist>".
+ * Set the mlt_type to property to "mlt_producer".
+ * \public \memberof mlt_playlist_s
+ * \param profile the profile to use with the profile
+ * \return a new playlist
+ */
+
+mlt_playlist mlt_playlist_new( mlt_profile profile )
+{
+    mlt_playlist self = mlt_playlist_init();
+    if ( self )
+        mlt_properties_set_data( MLT_PLAYLIST_PROPERTIES( self ), "_profile", profile, 0, NULL, NULL );
+    return self;
+}
+
 /** Get the producer associated to this playlist.
  *
  * \public \memberof mlt_playlist_s
@@ -702,15 +719,36 @@ int mlt_playlist_append_io( mlt_playlist self, mlt_producer producer, mlt_positi
  *
  * \public \memberof mlt_playlist_s
  * \param self a playlist
- * \param length the ending time of the blank entry, not its duration
+ * \param out the ending time of the blank entry, not its duration
  * \return true if there was an error
  */
 
-int mlt_playlist_blank( mlt_playlist self, mlt_position length )
+int mlt_playlist_blank( mlt_playlist self, mlt_position out )
 {
        // Append to the virtual list
-       if (length >= 0)
-               return mlt_playlist_virtual_append( self, &self->blank, 0, length );
+       if ( out >= 0 )
+               return mlt_playlist_virtual_append( self, &self->blank, 0, out );
+       else
+               return 1;
+}
+
+/** Append a blank item to the playlist with duration as a time string.
+ *
+ * \public \memberof mlt_playlist_s
+ * \param self a playlist
+ * \param length the duration of the blank entry as a time string
+ * \return true if there was an error
+ */
+
+int mlt_playlist_blank_time( mlt_playlist self, const char* length )
+{
+       if ( self && length )
+       {
+               mlt_properties properties = MLT_PLAYLIST_PROPERTIES( self );
+               mlt_properties_set( properties , "_blank_time", length );
+               mlt_position duration = mlt_properties_get_position( properties, "_blank_time" );
+               return mlt_playlist_blank( self, duration - 1 );
+       }
        else
                return 1;
 }
@@ -1067,7 +1105,7 @@ int mlt_playlist_join( mlt_playlist self, int clip, int count, int merge )
        if ( error == 0 )
        {
                int i = clip;
-               mlt_playlist new_clip = mlt_playlist_init( );
+               mlt_playlist new_clip = mlt_playlist_new( mlt_service_profile( MLT_PLAYLIST_SERVICE(self) ) );
                mlt_events_block( MLT_PLAYLIST_PROPERTIES( self ), self );
                if ( clip + count >= self->count )
                        count = self->count - clip - 1;
index a6364316e943d9e4e4f596a122aadc8455df9495..ee5411b579bace13ad04b941857ce4569f8fbc5f 100644 (file)
@@ -80,6 +80,7 @@ struct mlt_playlist_s
 #define MLT_PLAYLIST_PROPERTIES( playlist )    MLT_SERVICE_PROPERTIES( MLT_PLAYLIST_SERVICE( playlist ) )
 
 extern mlt_playlist mlt_playlist_init( );
+extern mlt_playlist mlt_playlist_new( mlt_profile profile );
 extern mlt_producer mlt_playlist_producer( mlt_playlist self );
 extern mlt_service mlt_playlist_service( mlt_playlist self );
 extern mlt_properties mlt_playlist_properties( mlt_playlist self );
@@ -87,7 +88,8 @@ extern int mlt_playlist_count( mlt_playlist self );
 extern int mlt_playlist_clear( mlt_playlist self );
 extern int mlt_playlist_append( mlt_playlist self, mlt_producer producer );
 extern int mlt_playlist_append_io( mlt_playlist self, mlt_producer producer, mlt_position in, mlt_position out );
-extern int mlt_playlist_blank( mlt_playlist self, mlt_position length );
+extern int mlt_playlist_blank( mlt_playlist self, mlt_position out );
+extern int mlt_playlist_blank_time( mlt_playlist self, const char *length );
 extern mlt_position mlt_playlist_clip( mlt_playlist self, mlt_whence whence, int index );
 extern int mlt_playlist_current_clip( mlt_playlist self );
 extern mlt_producer mlt_playlist_current( mlt_playlist self );
index a13faf35a5e0e1c3b4934139c3818f8767352ef9..557cd7d65d4bef6afe6b35b292e687fe71195f6f 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include "MltPlaylist.h"
 #include "MltTransition.h"
+#include "MltProfile.h"
 using namespace Mlt;
 
 ClipInfo::ClipInfo( ) :
@@ -85,6 +86,12 @@ Playlist::Playlist( ) :
        instance = mlt_playlist_init( );
 }
 
+Playlist::Playlist( Profile& profile ) :
+       instance( NULL )
+{
+       instance = mlt_playlist_new( profile.get_profile() );
+}
+
 Playlist::Playlist( Service &producer ) :
        instance( NULL )
 {
@@ -138,9 +145,14 @@ int Playlist::append( Producer &producer, int in, int out )
        return mlt_playlist_append_io( get_playlist( ), producer.get_producer( ), in, out );
 }
 
-int Playlist::blank( int length )
+int Playlist::blank( int out )
+{
+       return mlt_playlist_blank( get_playlist( ), out );
+}
+
+int Playlist::blank( const char *length )
 {
-       return mlt_playlist_blank( get_playlist( ), length );
+       return mlt_playlist_blank_time( get_playlist( ), length );
 }
 
 int Playlist::clip( mlt_whence whence, int index )
index 1a48503286c0654919a87b4ed0589d7ef0a64fd3..7d0325562e7b48da1957ab4da9a587c13b98528c 100644 (file)
@@ -33,6 +33,7 @@ namespace Mlt
        class Service;
        class Playlist;
        class Transition;
+       class Profile;
 
        class MLTPP_DECLSPEC ClipInfo
        {
@@ -60,6 +61,7 @@ namespace Mlt
                        mlt_playlist instance;
                public:
                        Playlist( );
+                       Playlist( Profile& profile );
                        Playlist( Service &playlist );
                        Playlist( Playlist &playlist );
                        Playlist( mlt_playlist playlist );
@@ -69,7 +71,8 @@ namespace Mlt
                        int count( );
                        int clear( );
                        int append( Producer &producer, int in = -1, int out = -1 );
-                       int blank( int length );
+                       int blank( int out );
+                       int blank( const char *length );
                        int clip( mlt_whence whence, int index );
                        int current_clip( );
                        Producer *current( );
index 3c8368cbd06fb0f9f90dbbc3dd0abb2ab8860dd1..47307f643b2142a847e4f97f0867b84870f5f4fc 100644 (file)
@@ -126,7 +126,7 @@ mlt_producer producer_melt_init( mlt_profile profile, mlt_service_type type, con
        int track = 0;
        mlt_producer producer = NULL;
        mlt_tractor mix = NULL;
-       mlt_playlist playlist = mlt_playlist_init( );
+       mlt_playlist playlist = mlt_playlist_new( profile );
        mlt_properties group = mlt_properties_new( );
        mlt_tractor tractor = mlt_tractor_new( );
        mlt_properties properties = MLT_TRACTOR_PROPERTIES( tractor );
@@ -373,7 +373,11 @@ mlt_producer producer_melt_init( mlt_profile profile, mlt_service_type type, con
                        if ( producer != NULL && !mlt_producer_is_cut( producer ) )
                                mlt_playlist_append( playlist, producer );
                        producer = NULL;
-                       mlt_playlist_blank( playlist, atof( argv[ ++ i ] ) );
+                       if ( strchr( argv[ i + 1 ], ':' ) )
+                               mlt_playlist_blank_time( playlist, argv[ ++ i ] );
+                       else
+                               // support for legacy where plain int is an out point instead of length
+                               mlt_playlist_blank( playlist, atof( argv[ ++ i ] ) );
                }
                else if ( !strcmp( argv[ i ], "-track" ) ||
                                  !strcmp( argv[ i ], "-null-track" ) ||
@@ -391,7 +395,7 @@ mlt_producer producer_melt_init( mlt_profile profile, mlt_service_type type, con
                        {
                                mlt_multitrack_connect( multitrack, MLT_PLAYLIST_PRODUCER( playlist ), track ++ );
                                track_service( field, playlist, ( mlt_destructor )mlt_playlist_close );
-                               playlist = mlt_playlist_init( );
+                               playlist = mlt_playlist_new( profile );
                        }
                        if ( playlist != NULL )
                        {
index 2b41e7a16ebd2063a03174a502766b90a4c0011c..88d7eebcda232d0baffd492791f7335478d262f2 100644 (file)
@@ -466,7 +466,7 @@ static void on_end_multitrack( deserialise_context context, const xmlChar *name
 
 static void on_start_playlist( deserialise_context context, const xmlChar *name, const xmlChar **atts)
 {
-       mlt_playlist playlist = mlt_playlist_init( );
+       mlt_playlist playlist = mlt_playlist_new( context->profile );
        mlt_service service = MLT_PLAYLIST_SERVICE( playlist );
        mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
 
@@ -675,7 +675,6 @@ static void on_start_blank( deserialise_context context, const xmlChar *name, co
        // Get the playlist from the stack
        enum service_type type;
        mlt_service service = context_pop_service( context, &type );
-       mlt_position length = 0;
        
        if ( type == mlt_playlist_type && service != NULL )
        {
@@ -684,14 +683,12 @@ static void on_start_blank( deserialise_context context, const xmlChar *name, co
                {
                        if ( xmlStrcmp( atts[0], _x("length") ) == 0 )
                        {
-                               length = atoll( _s(atts[1]) );
+                               // Append a blank to the playlist
+                               mlt_playlist_blank_time( MLT_PLAYLIST( service ), _s(atts[1]) );
                                break;
                        }
                }
 
-               // Append a blank to the playlist
-               mlt_playlist_blank( MLT_PLAYLIST( service ), length - 1 );
-
                // Push the playlist back onto the stack
                context_push_service( context, service, type );
        }