2 * factory.c -- the factory method interfaces
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4 * Author: Charles Yates <charles.yates@pandora.be>
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.
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.
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.
24 #include <framework/mlt_factory.h>
25 #include "producer_avformat.h"
26 #include "consumer_avformat.h"
28 // ffmpeg Header files
29 #include <ffmpeg/avformat.h>
31 // A static flag used to determine if avformat has been initialised
32 static int avformat_initialised
= 0;
35 static pthread_mutex_t avformat_mutex
;
38 // These 3 functions should override the alloc functions in libavformat
39 // but some formats or codecs seem to crash when used (wmv in particular)
41 void *av_malloc( unsigned int size
)
43 return mlt_pool_alloc( size
);
46 void *av_realloc( void *ptr
, unsigned int size
)
48 return mlt_pool_realloc( ptr
, size
);
51 void av_free( void *ptr
)
53 return mlt_pool_release( ptr
);
57 void avformat_destroy( void *ignore
)
63 pthread_mutex_destroy( &avformat_mutex
);
69 pthread_mutex_lock( &avformat_mutex
);
72 void avformat_unlock( )
74 // Unlock the mutex now
75 pthread_mutex_unlock( &avformat_mutex
);
78 static void avformat_init( )
80 // Initialise avformat if necessary
81 if ( avformat_initialised
== 0 )
83 avformat_initialised
= 1;
84 pthread_mutex_init( &avformat_mutex
, NULL
);
86 mlt_factory_register_for_clean_up( NULL
, avformat_destroy
);
90 void *mlt_create_producer( char *id
, void *arg
)
93 if ( !strcmp( id
, "avformat" ) )
94 return producer_avformat_init( arg
);
98 void *mlt_create_filter( char *id
, void *arg
)
103 void *mlt_create_transition( char *id
, void *arg
)
108 void *mlt_create_consumer( char *id
, void *arg
)
111 if ( !strcmp( id
, "avformat" ) )
112 return consumer_avformat_init( arg
);