Complete methods for properties and playlist; reversed NULL handling on service class
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 16 Aug 2004 07:46:14 +0000 (07:46 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 16 Aug 2004 07:46:14 +0000 (07:46 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt++@367 d19143bc-622f-0410-bfdd-b5b2a6649095

mlt++/src/MltPlaylist.cpp
mlt++/src/MltPlaylist.h
mlt++/src/MltProperties.cpp
mlt++/src/MltProperties.h
mlt++/src/MltService.cpp

index 1e3a1cd..54b79ba 100644 (file)
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <string.h>
+#include <stdlib.h>
 #include "MltPlaylist.h"
 using namespace Mlt;
 
+ClipInfo::ClipInfo( mlt_playlist_clip_info *info ) :
+       clip( info->clip ),
+       producer( new ProducerInstance( info->producer ) ),
+       service( new ServiceInstance( info->service ) ),
+       start( info->start ),
+       resource( strdup( info->resource ) ),
+       frame_in( info->frame_in ),
+       frame_out( info->frame_out ),
+       frame_count( info->frame_count ),
+       length( info->length ),
+       fps( info->fps )
+{
+}
+
+ClipInfo::~ClipInfo( )
+{
+       delete producer;
+       delete service;
+       free( resource );
+}
+
+PlaylistInstance::PlaylistInstance( ) :
+       destroy( true ),
+       instance( NULL )
+{
+       instance = mlt_playlist_init( );
+}
+
+PlaylistInstance::PlaylistInstance( Playlist &playlist ) :
+       destroy( false ),
+       instance( playlist.get_playlist( ) )
+{
+}
+
+PlaylistInstance::PlaylistInstance( mlt_playlist playlist ) :
+       destroy( false ),
+       instance( playlist )
+{
+}
+
+PlaylistInstance::~PlaylistInstance( )
+{
+       if ( destroy )
+               mlt_playlist_close( instance );
+}
+
+mlt_playlist PlaylistInstance::get_playlist( )
+{
+       return instance;
+}
+
 mlt_producer Playlist::get_producer( )
 {
        return mlt_playlist_producer( get_playlist( ) );
@@ -46,33 +99,46 @@ int Playlist::blank( mlt_position length )
        return mlt_playlist_blank( get_playlist( ), length );
 }
 
-mlt_playlist PlaylistInstance::get_playlist( )
+mlt_position Playlist::clip( mlt_whence whence, int index )
 {
-       return instance;
+       return mlt_playlist_clip( get_playlist( ), whence, index );
 }
 
-PlaylistInstance::PlaylistInstance( ) :
-       destroy( true ),
-       instance( NULL )
+int Playlist::current_clip( )
 {
-       instance = mlt_playlist_init( );
+       return mlt_playlist_current_clip( get_playlist( ) );
 }
 
-PlaylistInstance::PlaylistInstance( Playlist &playlist ) :
-       destroy( false ),
-       instance( playlist.get_playlist( ) )
+Producer *Playlist::current( )
 {
+       return new ProducerInstance( mlt_playlist_current( get_playlist( ) ) );
 }
 
-PlaylistInstance::PlaylistInstance( mlt_playlist playlist ) :
-       destroy( false ),
-       instance( playlist )
+ClipInfo *Playlist::clip_info( int index )
 {
+       mlt_playlist_clip_info info;
+       mlt_playlist_get_clip_info( get_playlist( ), &info, index );
+       return new ClipInfo( &info );
 }
 
-PlaylistInstance::~PlaylistInstance( )
+int Playlist::insert( Producer &producer, int where, mlt_position in, mlt_position out )
 {
-       if ( destroy )
-               mlt_playlist_close( instance );
+       return mlt_playlist_insert( get_playlist( ), producer.get_producer( ), where, in, out );
+}
+
+int Playlist::remove( int where )
+{
+       return mlt_playlist_remove( get_playlist( ), where );
 }
 
+int Playlist::move( int from, int to )
+{
+       return mlt_playlist_move( get_playlist( ), from, to );
+}
+
+int Playlist::resize_clip( int clip, mlt_position in, mlt_position out )
+{
+       return mlt_playlist_resize_clip( get_playlist( ), clip, in, out );
+}
+
+
index 1326ca7..e70e933 100644 (file)
 
 namespace Mlt
 {
+       class ClipInfo
+       {
+               public:
+                       ClipInfo( mlt_playlist_clip_info *info );
+                       ~ClipInfo( );
+                       int clip;
+                       Producer *producer;
+                       Service *service;
+                       mlt_position start;
+                       char *resource;
+                       mlt_position frame_in;
+                       mlt_position frame_out;
+                       mlt_position frame_count;
+                       mlt_position length;
+                       float fps;
+       };
+
        class Playlist : public Producer
        {
                public:
@@ -36,6 +53,14 @@ namespace Mlt
                        int clear( );
                        int append( Producer &producer, mlt_position in = -1, mlt_position out = -1 );
                        int blank( mlt_position length );
+                       mlt_position clip( mlt_whence whence, int index );
+                       int current_clip( );
+                       Producer *current( );
+                       ClipInfo *clip_info( int index );
+                       int insert( Producer &producer, int where, mlt_position in = -1, mlt_position out = -1 );
+                       int remove( int where );
+                       int move( int from, int to );
+                       int resize_clip( int clip, mlt_position in, mlt_position out );
        };
        
        class PlaylistInstance : public Playlist
index 9558fcc..592368b 100644 (file)
@@ -40,12 +40,24 @@ PropertiesInstance::PropertiesInstance( mlt_properties properties ) :
 {
 }
 
+PropertiesInstance::PropertiesInstance( char *file ) :
+       destroy( true ),
+       instance( NULL )
+{
+       instance = mlt_properties_load( file );
+}
+
 PropertiesInstance::~PropertiesInstance( )
 {
        if ( destroy )
                mlt_properties_close( instance );
 }
 
+mlt_properties PropertiesInstance::get_properties( )
+{
+       return instance;
+}
+
 bool Properties::is_valid( )
 {
        return get_properties( ) != NULL;
@@ -96,9 +108,47 @@ int Properties::set( char *name, void *value, int size, mlt_destructor destructo
        return mlt_properties_set_data( get_properties( ), name, value, size, destructor, serialiser );
 }
 
-mlt_properties PropertiesInstance::get_properties( )
+int Properties::pass( Properties &that, char *prefix )
 {
-       return instance;
+       return mlt_properties_pass( get_properties( ), that.get_properties( ), prefix );
+}
+
+int Properties::parse( char *namevalue )
+{
+       return mlt_properties_parse( get_properties( ), namevalue );
+}
+
+char *Properties::get_name( int index )
+{
+       return mlt_properties_get_name( get_properties( ), index );
 }
 
+char *Properties::get( int index )
+{
+       return mlt_properties_get_value( get_properties( ), index );
+}
+
+void *Properties::get_data( int index, int &size )
+{
+       return mlt_properties_get_data_at( get_properties( ), index, &size );
+}
+
+void Properties::mirror( Properties &that )
+{
+       mlt_properties_mirror( get_properties( ), that.get_properties( ) );
+}
 
+int Properties::inherit( Properties &that )
+{
+       return mlt_properties_inherit( get_properties( ), that.get_properties( ) );
+}
+
+int Properties::rename( char *source, char *dest )
+{
+       return mlt_properties_rename( get_properties( ), source, dest );
+}
+
+void Properties::dump( FILE *output )
+{
+       mlt_properties_dump( get_properties( ), output );
+}
index 51d0952..594fce9 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef _MLTPP_PROPERTIES_H_
 #define _MLTPP_PROPERTIES_H_
 
+#include <stdio.h>
 #include <framework/mlt.h>
 
 namespace Mlt 
@@ -42,7 +43,15 @@ namespace Mlt
                        int set( char *name, int value );
                        int set( char *name, double value );
                        int set( char *name, void *value, int size, mlt_destructor destroy = NULL, mlt_serialiser serial = NULL );
-
+                       int pass( Properties &that, char *prefix );
+                       int parse( char *namevalue );
+                       char *get_name( int index );
+                       char *get( int index );
+                       void *get_data( int index, int &size );
+                       void mirror( Properties &that );
+                       int inherit( Properties &that );
+                       int rename( char *source, char *dest );
+                       void dump( FILE *output = stderr );
        };
        
        /** Instance class.
@@ -58,6 +67,7 @@ namespace Mlt
                        PropertiesInstance( );
                        PropertiesInstance( Properties &properties );
                        PropertiesInstance( mlt_properties properties );
+                       PropertiesInstance( char *file );
                        virtual ~PropertiesInstance( );
        };
 }
index 03f8261..b836bea 100644 (file)
@@ -33,18 +33,12 @@ int Service::connect_producer( Service &producer, int index )
 
 Service *Service::producer( )
 {
-       if ( get_service( ) != NULL )
-               return new ServiceInstance( mlt_service_producer( get_service( ) ) );
-       else
-               return NULL;
+       return new ServiceInstance( mlt_service_producer( get_service( ) ) );
 }
 
 Service *Service::consumer( )
 {
-       if ( get_service( ) != NULL )
-               return new ServiceInstance( mlt_service_consumer( get_service( ) ) );
-       else
-               return NULL;
+       return new ServiceInstance( mlt_service_consumer( get_service( ) ) );
 }
 
 Frame *Service::get_frame( int index )