5 #include <framework/mlt.h>
9 static void transport_action( mlt_producer producer
, char *value
)
11 mlt_properties properties
= mlt_producer_properties( producer
);
12 mlt_multitrack multitrack
= mlt_properties_get_data( properties
, "multitrack", NULL
);
14 if ( strlen( value
) == 1 )
19 mlt_properties_set_int( properties
, "done", 1 );
22 mlt_producer_set_speed( producer
, 1 );
23 mlt_producer_seek( producer
, 0 );
26 mlt_producer_set_speed( producer
, -10 );
29 mlt_producer_set_speed( producer
, -5 );
32 mlt_producer_set_speed( producer
, -2 );
35 mlt_producer_set_speed( producer
, -1 );
38 mlt_producer_set_speed( producer
, 0 );
42 mlt_producer_set_speed( producer
, 1 );
45 mlt_producer_set_speed( producer
, 2 );
48 mlt_producer_set_speed( producer
, 5 );
51 mlt_producer_set_speed( producer
, 10 );
54 if ( multitrack
!= NULL
)
57 mlt_position last
= -1;
58 for ( i
= 0; 1; i
++ )
60 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_start
, i
);
64 fprintf( stderr
, "%d: %lld\n", i
, time
);
70 if ( multitrack
!= NULL
)
72 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_current
, 0 );
73 mlt_producer_seek( producer
, time
);
77 if ( multitrack
!= NULL
)
79 mlt_position position
= mlt_producer_position( producer
);
80 mlt_producer_set_speed( producer
, 0 );
81 mlt_producer_seek( producer
, position
- 1 >= 0 ? position
- 1 : 0 );
85 if ( multitrack
!= NULL
)
87 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_current
, 1 );
88 mlt_producer_seek( producer
, time
);
92 if ( multitrack
!= NULL
)
94 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_current
, -1 );
95 mlt_producer_seek( producer
, time
);
99 if ( multitrack
!= NULL
)
101 mlt_position position
= mlt_producer_position( producer
);
102 mlt_producer_set_speed( producer
, 0 );
103 mlt_producer_seek( producer
, position
+ 1 );
110 static mlt_consumer
create_consumer( char *id
, mlt_producer producer
)
112 char *arg
= strchr( id
, ':' );
115 mlt_consumer consumer
= mlt_factory_consumer( id
, arg
);
116 if ( consumer
!= NULL
)
118 mlt_properties properties
= mlt_consumer_properties( consumer
);
119 mlt_properties_set_data( properties
, "transport_callback", transport_action
, 0, NULL
, NULL
);
120 mlt_properties_set_data( properties
, "transport_producer", producer
, 0, NULL
, NULL
);
125 static void transport( mlt_producer producer
)
127 mlt_properties properties
= mlt_producer_properties( producer
);
131 fprintf( stderr
, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
132 fprintf( stderr
, "|1=-10| |2= -5| |3= -2| |4= -1| |5= 0| |6= 1| |7= 2| |8= 5| |9= 10|\n" );
133 fprintf( stderr
, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
135 fprintf( stderr
, "+---------------------------------------------------------------------+\n" );
136 fprintf( stderr
, "| h = previous, l = next |\n" );
137 fprintf( stderr
, "| g = start of clip, j = next clip, k = previous clip |\n" );
138 fprintf( stderr
, "| 0 = restart, q = quit, space = play |\n" );
139 fprintf( stderr
, "+---------------------------------------------------------------------+\n" );
141 while( mlt_properties_get_int( properties
, "done" ) == 0 )
143 int value
= term_read( );
145 transport_action( producer
, ( char * )&value
);
149 int main( int argc
, char **argv
)
152 mlt_consumer consumer
= NULL
;
153 mlt_producer inigo
= NULL
;
157 // Construct the factory
158 mlt_factory_init( getenv( "MLT_REPOSITORY" ) );
160 for ( i
= 1; i
< argc
; i
++ )
162 if ( !strcmp( argv
[ i
], "-serialise" ) )
165 if ( strstr( name
, ".inigo" ) )
166 store
= fopen( name
, "w" );
170 // Get inigo producer
171 inigo
= mlt_factory_producer( "inigo", &argv
[ 1 ] );
173 if ( argc
> 1 && inigo
!= NULL
&& mlt_producer_get_length( inigo
) > 0 )
175 // Get inigo's properties
176 mlt_properties inigo_props
= mlt_producer_properties( inigo
);
178 // Get the field service from inigo
179 mlt_field field
= mlt_properties_get_data( inigo_props
, "field", 0 );
181 // Get the last group
182 mlt_properties group
= mlt_properties_get_data( inigo_props
, "group", 0 );
184 // Parse the arguments
185 for ( i
= 1; i
< argc
; i
++ )
187 if ( !strcmp( argv
[ i
], "-consumer" ) )
189 consumer
= create_consumer( argv
[ ++ i
], inigo
);
190 while ( argv
[ i
+ 1 ] != NULL
&& strstr( argv
[ i
+ 1 ], "=" ) )
191 mlt_properties_parse( group
, argv
[ ++ i
] );
193 else if ( !strcmp( argv
[ i
], "-serialise" ) )
200 fprintf( store
, "%s\n", argv
[ i
] );
204 while ( argv
[ i
] != NULL
&& argv
[ i
][ 0 ] != '-' )
207 fprintf( store
, "%s\n", argv
[ i
] );
215 // If we have no consumer, default to sdl
216 if ( store
== NULL
&& consumer
== NULL
)
217 consumer
= create_consumer( "sdl", inigo
);
219 if ( consumer
!= NULL
&& store
== NULL
)
221 // Apply group settings
222 mlt_properties properties
= mlt_consumer_properties( consumer
);
223 mlt_properties_inherit( properties
, group
);
225 // Connect consumer to tractor
226 mlt_consumer_connect( consumer
, mlt_field_service( field
) );
228 // Transport functionality
231 else if ( store
!= NULL
)
233 fprintf( stderr
, "Project saved as %s.\n", name
);
240 fprintf( stderr
, "Usage: inigo [ -group [ name=value ]* ]\n"
241 " [ -consumer id[:arg] [ name=value ]* ]\n"
242 " [ -filter id[:arg] [ name=value ] * ]\n"
243 " [ -transition id[:arg] [ name=value ] * ]\n"
246 " [ producer [ name=value ] * ]+\n" );
249 // Close the consumer
250 if ( consumer
!= NULL
)
251 mlt_consumer_close( consumer
);
253 // Close the producer
255 mlt_producer_close( inigo
);
258 mlt_factory_close( );