]> git.sesse.net Git - mlt/blob - src/framework/mlt_factory.c
3b40464d6fb729531ca4e93399276fd98a92a375
[mlt] / src / framework / mlt_factory.c
1 /*
2  * mlt_factory.c -- the factory method interfaces
3  * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4  * Author: Charles Yates <charles.yates@pandora.be>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #include "config.h"
22 #include "mlt_factory.h"
23 #include "mlt_repository.h"
24
25 #include <stdlib.h>
26
27 /** Singleton repositories
28 */
29
30 static mlt_repository producers = NULL;
31 static mlt_repository filters = NULL;
32 static mlt_repository transitions = NULL;
33 static mlt_repository consumers = NULL;
34
35 /** Construct the factories.
36 */
37
38 int mlt_factory_init( )
39 {
40         producers = mlt_repository_init( PREFIX_DATA "/producers.dat", "mlt_create_producer" );
41         filters = mlt_repository_init( PREFIX_DATA "/filters.dat", "mlt_create_filter" );
42         transitions = mlt_repository_init( PREFIX_DATA "/transitions.dat", "mlt_create_transition" );
43         consumers = mlt_repository_init( PREFIX_DATA "/consumers.dat", "mlt_create_consumer" );
44         return 0;
45 }
46
47 /** Fetch a producer from the repository.
48 */
49
50 mlt_producer mlt_factory_producer( char *service, void *input )
51 {
52         return ( mlt_producer )mlt_repository_fetch( producers, service, input );
53 }
54
55 /** Fetch a filter from the repository.
56 */
57
58 mlt_filter mlt_factory_filter( char *service, void *input )
59 {
60         return ( mlt_filter )mlt_repository_fetch( filters, service, input );
61 }
62
63 /** Fetch a transition from the repository.
64 */
65
66 mlt_transition mlt_transition_filter( char *service, void *input )
67 {
68         return ( mlt_transition )mlt_repository_fetch( transitions, service, input );
69 }
70
71 /** Fetch a consumer from the repository
72 */
73
74 mlt_consumer mlt_factory_consumer( char *service, void *input )
75 {
76         return ( mlt_consumer )mlt_repository_fetch( consumers, service, input );
77 }
78
79 /** Close the factory.
80 */
81
82 void mlt_factory_close( )
83 {
84         mlt_repository_close( producers );
85         mlt_repository_close( filters );
86         mlt_repository_close( transitions );
87         mlt_repository_close( consumers );
88 }
89