X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Finigo%2Fproducer_inigo.c;h=e27e4dac33be8bd2a730d2de3c138f7b16e8de3f;hb=803598588d14d90ced4324a90456bca641f17bc9;hp=2a46fed02730db9ec8e8a1e3f31785bef60964d3;hpb=702e73b84d90830062ebe07ba01b72ad59d48d93;p=melted diff --git a/src/modules/inigo/producer_inigo.c b/src/modules/inigo/producer_inigo.c index 2a46fed..e27e4da 100644 --- a/src/modules/inigo/producer_inigo.c +++ b/src/modules/inigo/producer_inigo.c @@ -3,30 +3,30 @@ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited * Author: Charles Yates * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "producer_inigo.h" - #include #include #include #include -mlt_producer producer_inigo_file_init( char *file ) +mlt_producer producer_inigo_init( mlt_profile profile, mlt_service_type type, const char *id, char **argv ); + +mlt_producer producer_inigo_file_init( mlt_profile profile, mlt_service_type type, const char *id, char *file ) { FILE *input = fopen( file, "r" ); char **args = calloc( sizeof( char * ), 1000 ); @@ -43,7 +43,7 @@ mlt_producer producer_inigo_file_init( char *file ) } } - mlt_producer result = producer_inigo_init( args ); + mlt_producer result = producer_inigo_init( profile, type, id, args ); if ( result != NULL ) { @@ -67,9 +67,9 @@ static void track_service( mlt_field field, void *service, mlt_destructor destru mlt_properties_set_int( properties, "registered", ++ registered ); } -static mlt_producer create_producer( mlt_field field, char *file ) +static mlt_producer create_producer( mlt_profile profile, mlt_field field, char *file ) { - mlt_producer result = mlt_factory_producer( "fezzik", file ); + mlt_producer result = mlt_factory_producer( profile, "fezzik", file ); if ( result != NULL ) track_service( field, result, ( mlt_destructor )mlt_producer_close ); @@ -77,26 +77,26 @@ static mlt_producer create_producer( mlt_field field, char *file ) return result; } -static mlt_filter create_attach( mlt_field field, char *id, int track ) +static mlt_filter create_attach( mlt_profile profile, mlt_field field, char *id, int track ) { char *temp = strdup( id ); char *arg = strchr( temp, ':' ); if ( arg != NULL ) *arg ++ = '\0'; - mlt_filter filter = mlt_factory_filter( temp, arg ); + mlt_filter filter = mlt_factory_filter( profile, temp, arg ); if ( filter != NULL ) track_service( field, filter, ( mlt_destructor )mlt_filter_close ); free( temp ); return filter; } -static mlt_filter create_filter( mlt_field field, char *id, int track ) +static mlt_filter create_filter( mlt_profile profile, mlt_field field, char *id, int track ) { char *temp = strdup( id ); char *arg = strchr( temp, ':' ); if ( arg != NULL ) *arg ++ = '\0'; - mlt_filter filter = mlt_factory_filter( temp, arg ); + mlt_filter filter = mlt_factory_filter( profile, temp, arg ); if ( filter != NULL ) { mlt_field_plant_filter( field, filter, track ); @@ -106,12 +106,12 @@ static mlt_filter create_filter( mlt_field field, char *id, int track ) return filter; } -static mlt_transition create_transition( mlt_field field, char *id, int track ) +static mlt_transition create_transition( mlt_profile profile, mlt_field field, char *id, int track ) { char *arg = strchr( id, ':' ); if ( arg != NULL ) *arg ++ = '\0'; - mlt_transition transition = mlt_factory_transition( id, arg ); + mlt_transition transition = mlt_factory_transition( profile, id, arg ); if ( transition != NULL ) { mlt_field_plant_transition( field, transition, track, track + 1 ); @@ -120,7 +120,7 @@ static mlt_transition create_transition( mlt_field field, char *id, int track ) return transition; } -mlt_producer producer_inigo_init( char **argv ) +mlt_producer producer_inigo_init( mlt_profile profile, mlt_service_type type, const char *id, char **argv ) { int i; int track = 0; @@ -135,6 +135,9 @@ mlt_producer producer_inigo_init( char **argv ) mlt_multitrack multitrack = mlt_tractor_multitrack( tractor ); char *title = NULL; + // Assistance for template construction (allows -track usage to specify the first track) + mlt_properties_set_int( MLT_PLAYLIST_PROPERTIES( playlist ), "_inigo_first", 1 ); + // We need to track the number of registered filters mlt_properties_set_int( field_properties, "registered", 0 ); @@ -159,7 +162,7 @@ mlt_producer producer_inigo_init( char **argv ) int type = !strcmp( argv[ i ], "-attach" ) ? 0 : !strcmp( argv[ i ], "-attach-cut" ) ? 1 : !strcmp( argv[ i ], "-attach-track" ) ? 2 : 3; - mlt_filter filter = create_attach( field, argv[ ++ i ], track ); + mlt_filter filter = create_attach( profile, field, argv[ ++ i ], track ); if ( producer != NULL && !mlt_producer_is_cut( producer ) ) { mlt_playlist_clip_info info; @@ -251,7 +254,11 @@ mlt_producer producer_inigo_init( char **argv ) if ( mlt_playlist_count( playlist ) > 0 ) { mlt_playlist_clip_info info; - mlt_playlist_join( playlist, mlt_playlist_count( playlist ) - clips - 1, clips, 0 ); + int clip = clips <= 0 ? 0 : mlt_playlist_count( playlist ) - clips - 1; + if ( clip < 0 ) clip = 0; + if ( clip >= mlt_playlist_count( playlist ) ) clip = mlt_playlist_count( playlist ) - 2; + if ( clips < 0 ) clips = mlt_playlist_count( playlist ) - 1; + mlt_playlist_join( playlist, clip, clips, 0 ); mlt_playlist_get_clip_info( playlist, &info, mlt_playlist_count( playlist ) - 1 ); producer = info.cut; properties = MLT_PRODUCER_PROPERTIES( producer ); @@ -308,7 +315,7 @@ mlt_producer producer_inigo_init( char **argv ) mlt_transition transition = NULL; if ( arg != NULL ) *arg ++ = '\0'; - transition = mlt_factory_transition( id, arg ); + transition = mlt_factory_transition( profile, id, arg ); if ( transition != NULL ) { properties = MLT_TRANSITION_PROPERTIES( transition ); @@ -327,7 +334,7 @@ mlt_producer producer_inigo_init( char **argv ) } else if ( !strcmp( argv[ i ], "-filter" ) ) { - mlt_filter filter = create_filter( field, argv[ ++ i ], track ); + mlt_filter filter = create_filter( profile, field, argv[ ++ i ], track ); if ( filter != NULL ) { properties = MLT_FILTER_PROPERTIES( filter ); @@ -336,7 +343,7 @@ mlt_producer producer_inigo_init( char **argv ) } else if ( !strcmp( argv[ i ], "-transition" ) ) { - mlt_transition transition = create_transition( field, argv[ ++ i ], track - 1 ); + mlt_transition transition = create_transition( profile, field, argv[ ++ i ], track - 1 ); if ( transition != NULL ) { properties = MLT_TRANSITION_PROPERTIES( transition ); @@ -361,7 +368,8 @@ mlt_producer producer_inigo_init( char **argv ) if ( producer != NULL && !mlt_producer_is_cut( producer ) ) mlt_playlist_append( playlist, producer ); producer = NULL; - if ( mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( playlist ) ) > 0 ) + if ( !mlt_properties_get_int( MLT_PLAYLIST_PROPERTIES( playlist ), "_inigo_first" ) || + 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 ); @@ -388,7 +396,7 @@ mlt_producer producer_inigo_init( char **argv ) mlt_playlist_append( playlist, producer ); if ( title == NULL && strstr( argv[ i ], " 0 ) + if ( !mlt_properties_get_int( MLT_PLAYLIST_PROPERTIES( playlist ), "_inigo_first" ) || + mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( playlist ) ) > 0 ) mlt_multitrack_connect( multitrack, MLT_PLAYLIST_PRODUCER( playlist ), track ); mlt_producer prod = MLT_TRACTOR_PRODUCER( tractor ); @@ -426,7 +442,6 @@ mlt_producer producer_inigo_init( char **argv ) mlt_properties_set_data( props, "group", group, 0, ( mlt_destructor )mlt_properties_close, NULL ); mlt_properties_set_position( props, "length", mlt_producer_get_out( MLT_MULTITRACK_PRODUCER( multitrack ) ) + 1 ); mlt_producer_set_in_and_out( prod, 0, mlt_producer_get_out( MLT_MULTITRACK_PRODUCER( multitrack ) ) ); - mlt_properties_set_double( props, "fps", mlt_producer_get_fps( MLT_MULTITRACK_PRODUCER( multitrack ) ) ); if ( title != NULL ) mlt_properties_set( props, "title", strchr( title, '/' ) ? strrchr( title, '/' ) + 1 : title );