2
mediastreamer2 library - modular sound and video processing and streaming
3
Copyright (C) 2006 Simon MORLAT (simon.morlat@linphone.org)
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License
7
as published by the Free Software Foundation; either version 2
8
of the License, or (at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
#include "allfilters.h"
27
typedef void (*MSFilterFunc)(struct _MSFilter *f);
28
typedef int (*MSFilterMethodFunc)(struct _MSFilter *f, void *arg);
29
typedef void (*MSFilterNotifyFunc)(void *userdata , unsigned int id, void *arg);
31
struct _MSFilterMethod{
33
MSFilterMethodFunc method;
36
typedef struct _MSFilterMethod MSFilterMethod;
38
enum _MSFilterCategory{
44
typedef enum _MSFilterCategory MSFilterCategory;
47
MSFilterId id; /* the id declared in allfilters.h */
48
const char *name; /* filter name */
49
const char *text; /*some descriptive text*/
50
MSFilterCategory category;
51
const char *enc_fmt; /* must be set if MS_FILTER_ENCODER/MS_FILTER_DECODER */
52
int ninputs; /*number of inputs */
53
int noutputs; /*number of outputs */
55
MSFilterFunc preprocess; /* called once before processing */
56
MSFilterFunc process; /* called every tick to do the filter's job*/
57
MSFilterFunc postprocess; /*called once after processing */
59
MSFilterMethod *methods;
62
typedef struct _MSFilterDesc MSFilterDesc;
66
/*protected attributes */
70
MSFilterNotifyFunc notify;
73
struct _MSTicker *ticker;
74
/*private attributes */
79
typedef struct _MSFilter MSFilter;
85
/* useful for plugins only */
86
void ms_filter_register(MSFilterDesc *desc);
87
/* functions to retrieve encoders/decoders according to codec name */
88
MSFilterDesc * ms_filter_get_encoder(const char *mime);
89
MSFilterDesc * ms_filter_get_decoder(const char *mime);
90
MSFilter * ms_filter_create_encoder(const char *mime);
91
MSFilter * ms_filter_create_decoder(const char *mime);
92
bool_t ms_filter_codec_supported(const char *mime);
94
MSFilter *ms_filter_new(MSFilterId id);
95
MSFilter *ms_filter_new_from_name(const char *name);
96
int ms_filter_link(MSFilter *f1, int pin1, MSFilter *f2, int pin2);
97
int ms_filter_unlink(MSFilter *f1, int pin1, MSFilter *f2, int pin2);
98
int ms_filter_call_method(MSFilter *f, unsigned int id, void *arg);
99
int ms_filter_call_method_noarg(MSFilter *f, unsigned int id);
100
void ms_filter_set_notify_callback(MSFilter *f, MSFilterNotifyFunc fn, void *userdata);
101
MSFilterId ms_filter_get_id(MSFilter *f);
102
void ms_filter_destroy(MSFilter *f);
108
/* I define the id taking the lower bits of the address of the MSFilterDesc object,
109
the method index (_cnt_) and the argument size */
110
/* I hope using this to avoid type mismatch (calling a method on the wrong filter)*/
111
#define MS_FILTER_METHOD_ID(_id_,_cnt_,_argsize_) \
112
( (((unsigned long)(_id_)) & 0xFFFF)<<16 | (_cnt_<<8) | (_argsize_ & 0xFF ))
114
#define MS_FILTER_METHOD(_id_,_count_,_argtype_) \
115
MS_FILTER_METHOD_ID(_id_,_count_,sizeof(_argtype_))
117
#define MS_FILTER_METHOD_NO_ARG(_id_,_count_) \
118
MS_FILTER_METHOD_ID(_id_,_count_,0)
121
#define MS_FILTER_BASE_METHOD(_count_,_argtype_) \
122
MS_FILTER_METHOD_ID(MS_FILTER_BASE_ID,_count_,sizeof(_argtype_))
124
#define MS_FILTER_EVENT(_id_,_count_,_argtype_) \
125
MS_FILTER_METHOD_ID(_id_,_count_,sizeof(_argtype_))
127
#define MS_FILTER_EVENT_NO_ARG(_id_,_count_)\
128
MS_FILTER_METHOD_ID(_id_,_count_,0)
130
/* some MSFilter base methods:*/
131
#define MS_FILTER_SET_SAMPLE_RATE MS_FILTER_BASE_METHOD(0,int)
132
#define MS_FILTER_GET_SAMPLE_RATE MS_FILTER_BASE_METHOD(1,int)
133
#define MS_FILTER_SET_BITRATE MS_FILTER_BASE_METHOD(2,int)
134
#define MS_FILTER_GET_BITRATE MS_FILTER_BASE_METHOD(3,int)
135
#define MS_FILTER_SET_FMTP MS_FILTER_BASE_METHOD(4,const char)
136
#define MS_FILTER_GET_NCHANNELS MS_FILTER_BASE_METHOD(5,int)
137
#define MS_FILTER_SET_NCHANNELS MS_FILTER_BASE_METHOD(6,int)
138
#define MS_FILTER_ADD_FMTP MS_FILTER_BASE_METHOD(7,const char)
139
#define MS_FILTER_ADD_ATTR MS_FILTER_BASE_METHOD(8,const char)
140
#define MS_FILTER_SET_MTU MS_FILTER_BASE_METHOD(9,int)
141
#define MS_FILTER_GET_MTU MS_FILTER_BASE_METHOD(10,int)
145
MSFilter *ms_filter_new_from_desc(MSFilterDesc *desc);
146
void ms_filter_process(MSFilter *f);
147
void ms_filter_preprocess(MSFilter *f, struct _MSTicker *t);
148
void ms_filter_postprocess(MSFilter *f);
149
bool_t ms_filter_inputs_have_data(MSFilter *f);
150
void ms_filter_notify(MSFilter *f, unsigned int id, void *arg);
151
void ms_filter_notify_no_arg(MSFilter *f, unsigned int id);
152
#define ms_filter_lock(f) ms_mutex_lock(&(f)->lock)
153
#define ms_filter_unlock(f) ms_mutex_unlock(&(f)->lock)
154
void ms_filter_unregister_all(void);
156
/* used by awk script in Makefile.am to generate alldescs.c */
157
#define MS_FILTER_DESC_EXPORT(desc)