]> git.sesse.net Git - mlt/blob - src/tests/charlie.c
Factory implementation
[mlt] / src / tests / charlie.c
1 #include <framework/mlt_factory.h>
2
3 #include <framework/mlt_producer.h>
4 #include <framework/mlt_consumer.h>
5 #include <framework/mlt_filter.h>
6 #include <framework/mlt_tractor.h>
7 #include <framework/mlt_transition.h>
8 #include <framework/mlt_multitrack.h>
9
10 #include <stdio.h>
11
12 int main( int argc, char **argv )
13 {
14         char temp[ 132 ];
15         char *file1 = NULL;
16         char *file2 = NULL;
17
18         mlt_factory_init( "../modules" );
19
20         if ( argc >= 2 )
21                 file1 = argv[ 1 ];
22         if ( argc >= 3 )
23                 file2 = argv[ 2 ];
24
25         // Start the consumer...
26         mlt_consumer sdl_out = mlt_factory_consumer( "sdl", NULL );
27
28         fprintf( stderr, "Press return to continue\n" );
29         fgets( temp, 132, stdin );
30
31         // Create the producer(s)
32         mlt_producer dv1 = mlt_factory_producer( "libdv", file1 );
33         mlt_producer dv2 = mlt_factory_producer( "libdv", file2 );
34         //mlt_producer dv1 = producer_ppm_init( NULL );
35         //mlt_producer dv2 = producer_ppm_init( NULL );
36
37         // Connect a producer to our sdl consumer
38         mlt_consumer_connect( sdl_out, mlt_producer_service( dv1 ) );
39
40         fprintf( stderr, "Press return to continue\n" );
41         fgets( temp, 132, stdin );
42
43         // Register producers(s) with a multitrack object
44         mlt_multitrack multitrack = mlt_multitrack_init( );
45         mlt_multitrack_connect( multitrack, dv1, 0 );
46         mlt_multitrack_connect( multitrack, dv2, 1 );
47
48         // Create a filter and associate it to track 0
49         mlt_filter filter = mlt_factory_filter( "deinterlace", NULL );
50         mlt_filter_connect( filter, mlt_multitrack_service( multitrack ), 0 );
51         mlt_filter_set_in_and_out( filter, 0, 5 );
52
53         // Create another
54         mlt_filter greyscale = mlt_factory_filter( "greyscale", NULL );
55         mlt_filter_connect( greyscale, mlt_filter_service( filter ), 0 );
56         mlt_filter_set_in_and_out( greyscale, 0, 10 );
57
58         // Buy a tractor and connect it to the filter
59         mlt_tractor tractor = mlt_tractor_init( );
60         mlt_tractor_connect( tractor, mlt_filter_service( greyscale ) );
61
62         // Connect the tractor to the consumer
63         mlt_consumer_connect( sdl_out, mlt_tractor_service( tractor ) );
64
65         // Do stuff until we're told otherwise...
66         fprintf( stderr, "Press return to continue\n" );
67         fgets( temp, 132, stdin );
68
69         // Close everything...
70         //mlt_consumer_close( sdl_out );
71         //mlt_tractor_close( tractor );
72         //mlt_filter_close( filter );
73         //mlt_filter_close( greyscale );
74         //mlt_multitrack_close( multitrack );
75         //mlt_producer_close( dv1 );
76         //mlt_producer_close( dv2 );
77
78         mlt_factory_close( );
79
80         return 0;
81 }