File: filter_template.c

package info (click to toggle)
transcode 3%3A1.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 11,644 kB
  • sloc: ansic: 116,927; sh: 11,468; xml: 2,849; makefile: 1,891; perl: 1,492; pascal: 526; php: 191; python: 144; sed: 43
file content (294 lines) | stat: -rw-r--r-- 7,270 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/*
 * filter_template.c -- template code for NMS and back compatible 
 *                      transcode filters
 * Written     by Andrew Church <achurch@achurch.org>
 * Templatized by Francesco Romani <fromani at gmail dot com>
 *
 * This file is part of transcode, a video stream processing tool.
 * transcode is free software, distributable under the terms of the GNU
 * General Public License (version 2 or later).  See the file COPYING
 * for details.
 */

#define MOD_NAME        "filter_template.so"
#define MOD_VERSION     "v1.1.0 (2007-05-31)"
#define MOD_CAP         "WRITE SUMMARY OF THE MODULE HERE"
#define MOD_AUTHOR      "Andrew Church, Francesco Romani"

#define MOD_FEATURES \
    TC_MODULE_FEATURE_FILTER|TC_MODULE_FEATURE_VIDEO|TC_MODULE_FEATURE_AUDIO
#define MOD_FLAGS \
    TC_MODULE_FLAG_RECONFIGURABLE

#include "transcode.h"
#include "filter.h"
#include "libtc/libtc.h"
#include "libtc/optstr.h"
#include "libtc/tcmodule-plugin.h"

static const char help_string[] = \
    "WRITE LONG AND DETAILED DESCRIPTION OF THE MODULE HERE";

/*************************************************************************/

typedef struct {
    ;
} PrivateData;

/*************************************************************************/
/*************************************************************************/

/* Module interface routines and data. */

/*************************************************************************/

/**
 * template_init:  Initialize this instance of the module.  See
 * tcmodule-data.h for function details.
 */

static int template_init(TCModuleInstance *self, uint32_t features)
{
    PrivateData *pd;

    TC_MODULE_SELF_CHECK(self, "init");
    TC_MODULE_INIT_CHECK(self, MOD_FEATURES, features);

    pd = tc_malloc(sizeof(PrivateData));
    if (!pd) {
        tc_log_error(MOD_NAME, "init: out of memory!");
        return TC_ERROR;
    }
    self->userdata = pd;

    /* initialize data */

    if (verbose) {
        tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP);
    }
    return TC_OK;
}

/*************************************************************************/

/**
 * template_fini:  Clean up after this instance of the module.  See
 * tcmodule-data.h for function details.
 */

static int template_fini(TCModuleInstance *self)
{
    PrivateData *pd;

    TC_MODULE_SELF_CHECK(self, "fini");

    pd = self->userdata;

    /* free data allocated in _init */

    tc_free(self->userdata);
    self->userdata = NULL;
    return TC_OK;
}

/*************************************************************************/

/**
 * template_configure:  Configure this instance of the module.  See
 * tcmodule-data.h for function details.
 */

static int template_configure(TCModuleInstance *self,
                               const char *options, vob_t *vob)
{
    PrivateData *pd = NULL;

    TC_MODULE_SELF_CHECK(self, "configure");

    pd = self->userdata;

    if (options) {
        /* optstr_get() them */
    }

    /* handle other options */

    return TC_OK;
}

/*************************************************************************/

/**
 * template_stop:  Reset this instance of the module.  See tcmodule-data.h
 * for function details.
 */

static int template_stop(TCModuleInstance *self)
{
    PrivateData *pd = NULL;

    TC_MODULE_SELF_CHECK(self, "stop");

    pd = self->userdata;

    /* reverse all stuff done in _configure */

    return TC_OK;
}

/*************************************************************************/

/**
 * template_inspect:  Return the value of an option in this instance of
 * the module.  See tcmodule-data.h for function details.
 */

static int template_inspect(TCModuleInstance *self,
                             const char *param, const char **value)
{
    PrivateData *pd = NULL;

    TC_MODULE_SELF_CHECK(self, "inspect");
    TC_MODULE_SELF_CHECK(param, "inspect");
    TC_MODULE_SELF_CHECK(value, "inspect");

    pd = self->userdata;

    if (optstr_lookup(param, "help")) {
        *value = help_string; 
    }
    /* put back configurable options */

    return TC_OK;
}

/*************************************************************************/

/**
 * template_filter_video:  Perform the filter operation on the video
 * stream.  See tcmodule-data.h for function details.
 */

static int template_filter_video(TCModuleInstance *self, vframe_list_t *frame)
{
    PrivateData *pd = NULL;

    TC_MODULE_SELF_CHECK(self, "filter_video");
    TC_MODULE_SELF_CHECK(frame, "filter_video");

    pd = self->userdata;

    /* do the magic */

    return TC_OK;
}

/*************************************************************************/

/**
 * template_filter_audio:  Perform the filter operation on the audio
 * stream.  See tcmodule-data.h for function details.
 */

static int template_filter_audio(TCModuleInstance *self, aframe_list_t *frame)
{
    PrivateData *pd = NULL;

    TC_MODULE_SELF_CHECK(self, "filter_audio");
    TC_MODULE_SELF_CHECK(frame, "filter_audio");

    pd = self->userdata;

    /* do the magic */

    return TC_OK;
}

/*************************************************************************/

static const TCCodecID template_codecs_in[] = { 
    TC_CODEC_ERROR 
};
static const TCCodecID template_codecs_out[] = { 
    TC_CODEC_ERROR 
};
static const TCFormatID template_formats[] = { 
    TC_FORMAT_ERROR
};

static const TCModuleInfo template_info = {
    .features    = MOD_FEATURES,
    .flags       = MOD_FLAGS,
    .name        = MOD_NAME,
    .version     = MOD_VERSION,
    .description = MOD_CAP,
    .codecs_in   = template_codecs_in,
    .codecs_out  = template_codecs_out,
    .formats_in  = template_formats,
    .formats_out = template_formats
};

static const TCModuleClass template_class = {
    .info         = &template_info,

    .init         = template_init,
    .fini         = template_fini,
    .configure    = template_configure,
    .stop         = template_stop,
    .inspect      = template_inspect,

    .filter_video = template_filter_video,
    /* We have to handle the audio too! */
    .filter_audio = template_filter_audio,
};

extern const TCModuleClass *tc_plugin_setup(void)
{
    return &template_class;
}

/*************************************************************************/

static int template_get_config(TCModuleInstance *self, char *options)
{
    PrivateData *pd = NULL;

    TC_MODULE_SELF_CHECK(self, "get_config");

    pd = self->userdata;

    optstr_filter_desc(options, MOD_NAME, MOD_CAP, MOD_VERSION,
                       MOD_AUTHOR, "VAMEO", "1");

    /* use optstr_param to do introspection */

    return TC_OK;
}

static int template_process(TCModuleInstance *self, 
                            frame_list_t *frame)
{
    TC_MODULE_SELF_CHECK(self, "process");

    /* choose what to do by frame->tag */

    return TC_OK;
}

/*************************************************************************/

/* Old-fashioned module interface. */

TC_FILTER_OLDINTERFACE(template)

/*************************************************************************/

/*
 * Local variables:
 *   c-file-style: "stroustrup"
 *   c-file-offsets: ((case-label . *) (statement-case-intro . *))
 *   indent-tabs-mode: nil
 * End:
 *
 * vim: expandtab shiftwidth=4:
 */