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"
27 #include "filter_avdeinterlace.h"
28 #include "filter_avresample.h"
30 // ffmpeg Header files
31 #include <ffmpeg/avformat.h>
33 // A static flag used to determine if avformat has been initialised
34 static int avformat_initialised
= 0;
37 static pthread_mutex_t avformat_mutex
;
40 // These 3 functions should override the alloc functions in libavformat
41 // but some formats or codecs seem to crash when used (wmv in particular)
43 void *av_malloc( unsigned int size
)
45 return mlt_pool_alloc( size
);
48 void *av_realloc( void *ptr
, unsigned int size
)
50 return mlt_pool_realloc( ptr
, size
);
53 void av_free( void *ptr
)
55 return mlt_pool_release( ptr
);
59 void avformat_destroy( void *ignore
)
65 pthread_mutex_destroy( &avformat_mutex
);
71 pthread_mutex_lock( &avformat_mutex
);
74 void avformat_unlock( )
76 // Unlock the mutex now
77 pthread_mutex_unlock( &avformat_mutex
);
80 static void avformat_init( )
82 // Initialise avformat if necessary
83 if ( avformat_initialised
== 0 )
85 avformat_initialised
= 1;
86 pthread_mutex_init( &avformat_mutex
, NULL
);
88 mlt_factory_register_for_clean_up( NULL
, avformat_destroy
);
92 void *mlt_create_producer( char *id
, void *arg
)
95 if ( !strcmp( id
, "avformat" ) )
96 return producer_avformat_init( arg
);
100 void *mlt_create_filter( char *id
, void *arg
)
103 if ( !strcmp( id
, "avdeinterlace" ) )
104 return filter_avdeinterlace_init( arg
);
105 if ( !strcmp( id
, "avresample" ) )
106 return filter_avresample_init( arg
);
110 void *mlt_create_transition( char *id
, void *arg
)
115 void *mlt_create_consumer( char *id
, void *arg
)
118 if ( !strcmp( id
, "avformat" ) )
119 return consumer_avformat_init( arg
);