File: plugin.h

package info (click to toggle)
dvbstreamer 2.1.0-5.8
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 5,676 kB
  • sloc: ansic: 42,193; sh: 10,230; python: 519; makefile: 363
file content (399 lines) | stat: -rwxr-xr-x 13,144 bytes parent folder | download | duplicates (6)
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
/*
Copyright (C) 2006  Adam Charrett

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA

plugin.h

Plugin Interface structures and macros.

*/
#ifndef _PLUGIN_H
#define _PLUGIN_H

/* Annoyingly libdvbpsi causes a preprocessor warning when its header files are included more than once! */
#ifndef _DVBPSI_DVBPSI_H_
#include <dvbpsi/dvbpsi.h>
#endif
#ifndef _DVBPSI_DESCRIPTOR_H_
#include <dvbpsi/descriptor.h>
#endif
#ifndef _DVBPSI_PSI_H_
#include <dvbpsi/psi.h>
#endif
#ifndef _DVBPSI_PAT_H_
#include <dvbpsi/pat.h>
#endif
#ifndef _DVBPSI_PMT_H_
#include <dvbpsi/pmt.h>
#endif
#ifndef _DVBPSI_DEMUX_H_
#include <dvbpsi/demux.h>
#endif
#ifndef _DVBPSI_SDT_H_
#include <dvbpsi/sdt.h>
#endif
#include "dvbpsi/datetime.h"
#include "dvbpsi/nit.h"
#include "dvbpsi/tdttot.h"
#include "dvbpsi/atsc/mgt.h"
#include "dvbpsi/atsc/stt.h"
#include "dvbpsi/atsc/vct.h"

#include "config.h"
#include "types.h"
#include "ts.h"
#include "commands.h"
#include "events.h"
#include "deliverymethod.h"

/**
 * @defgroup Plugin Plugin Interface
 * @{
 */

/**
 * Constant for No Feature, use to end a list of features.
 */
#define PLUGIN_FEATURE_TYPE_NONE             0x00
/**
 * Constant for Event Listener callback.
 */
#define PLUGIN_FEATURE_TYPE_EVENT_LISTENER   0x01
/**
 * Constant for a PAT processor plugin feature.
 */
#define PLUGIN_FEATURE_TYPE_PATPROCESSOR     0x02
/**
 * Constant for a PMT processor plugin feature.
 */
#define PLUGIN_FEATURE_TYPE_PMTPROCESSOR     0x03
/**
 * Constant for a Delivery Method plugin feature.
 */
#define PLUGIN_FEATURE_TYPE_DELIVERYMETHOD   0x04
/**
 * Constant for a SDT processor plugin feature.
 */
#define PLUGIN_FEATURE_TYPE_SDTPROCESSOR     0x05
/**
 * Constant for a NIT processor plugin feature.
 */
#define PLUGIN_FEATURE_TYPE_NITPROCESSOR     0x06
/**
 * Constant for a TDT/TOT processor plugin feature.
 */
#define PLUGIN_FEATURE_TYPE_TDTPROCESSOR     0x07
/**
 * Constant for a MGT processor plugin feature.
 */
#define PLUGIN_FEATURE_TYPE_MGTPROCESSOR     0x08
/**
 * Constant for a STT processor plugin feature.
 */
#define PLUGIN_FEATURE_TYPE_STTPROCESSOR     0x09
/**
 * Constant for a VCT processor plugin feature.
 */
#define PLUGIN_FEATURE_TYPE_VCTPROCESSOR     0x0A
/**
 * Constant for the plugin installed feature.
 */
#define PLUGIN_FEATURE_TYPE_INSTALL          0xFF

typedef struct PluginEventListenerDetails_s
{
    char *name;
    EventListener_t callback;
    void *arg;
}PluginEventListenerDetails_t;

/**
 * Function pointer to function to call when a new PAT arrives.
 * For use with the PLUGIN_FEATURE_TYPE_PATPROCESSOR feature type, only 1 per
 * plugin is expected (allowed).
 */
typedef void (*PluginPATProcessor_t)(dvbpsi_pat_t* newpat);

/**
 * Function pointer to function to call when a new PMT arrives.
 * For use with the PLUGIN_FEATURE_TYPE_PMTPROCESSOR feature type, only 1 per
 * plugin is expected (allowed).
 */
typedef void (*PluginPMTProcessor_t)(dvbpsi_pmt_t* newpmt);

/**
 * Function pointer to function to call when a new SDT arrives.
 * For use with the PLUGIN_FEATURE_TYPE_SDTPROCESSOR feature type, only 1 per
 * plugin is expected (allowed).
 */
typedef void (*PluginSDTProcessor_t)(dvbpsi_sdt_t* newsdt);

/**
 * Function pointer to function to call when a new NIT arrives.
 * For use with the PLUGIN_FEATURE_TYPE_NITPROCESSOR feature type, only 1 per
 * plugin is expected (allowed).
 */
typedef void (*PluginNITProcessor_t)(dvbpsi_nit_t* newnit);

/**
 * Function pointer to function to call when a new TDT/TOT arrives.
 * For use with the PLUGIN_FEATURE_TYPE_TDTPROCESSOR feature type, only 1 per
 * plugin is expected (allowed).
 */
typedef void (*PluginTDTProcessor_t)(dvbpsi_tdt_tot_t* newtdttot);

/**
 * Function pointer to function to call when a new MGT arrives.
 * For use with the PLUGIN_FEATURE_TYPE_MGTPROCESSOR feature type, only 1 per
 * plugin is expected (allowed).
 */
typedef void (*PluginMGTProcessor_t)(dvbpsi_atsc_mgt_t* newmgt);

/**
 * Function pointer to function to call when a new STT arrives.
 * For use with the PLUGIN_FEATURE_TYPE_STTPROCESSOR feature type, only 1 per
 * plugin is expected (allowed).
 */
typedef void (*PluginSTTProcessor_t)(dvbpsi_atsc_stt_t* newstt);

/**
 * Function pointer to function to call when a new VCT arrives.
 * For use with the PLUGIN_FEATURE_TYPE_VCTPROCESSOR feature type, only 1 per
 * plugin is expected (allowed).
 */
typedef void (*PluginVCTProcessor_t)(dvbpsi_atsc_vct_t* newvct);

/**
 * Function pointer to function to call after the primary service
 * filter is updated. The newMultiplex argument will contain the multiplex currently
 * being used and the newService will contain the service now being filtered.
 * For use with the PLUGIN_FEATURE_TYPE_CHANNELCHANGED feature type, only 1 per
 * plugin is expected (allowed).
 */
typedef void (*PluginChannelChanged_t)(Multiplex_t *newMultiplex, Service_t *newService);

/**
 * Function pointer to a function to call when the plugin is (un)installed.
 * installed is TRUE when the plugin is installed and FALSE when being uninstalled.
 */
typedef void (*PluginInstallCallback_t)(bool installed);

/**
 * Structure used to describe a single 'feature' of a plugin.
 */
typedef struct PluginFeature_t
{
    int type;       /**< Type of this feature. Use PLUGIN_FEATURE_TYPE_NONE to end a list.*/
    union{
        PluginEventListenerDetails_t eventDetails;
        DeliveryMethodHandler_t dmHandler;
        PluginPMTProcessor_t    patCB;
        PluginPMTProcessor_t    pmtCB;
        PluginSDTProcessor_t    sdtCB;
        PluginNITProcessor_t    nitCB;
        PluginTDTProcessor_t    tdtCB;
        PluginMGTProcessor_t    mgtCB;
        PluginSTTProcessor_t    sttCB;
        PluginVCTProcessor_t    vctCB;
        PluginChannelChanged_t  channelChangeCB;
        PluginInstallCallback_t installCB;
    }details;
}PluginFeature_t;

/**
 * Constant for a plugin that is just for use when processing DVB signals.
 */
#define PLUGIN_FOR_DVB  0x01
/**
 * Constant for a plugin this is just for use when processing ATSC signals.
 */
#define PLUGIN_FOR_ATSC 0x02
/**
 * Constant for a plugin that should be loaded for any type of signal.
 */
#define PLUGIN_FOR_ALL  0xff

/**
 * Structure used to define a plugin.
 * To create a plugin the shared object should have a global variable of this
 * type called PluginInterface.
 * @code
 *
 * Command_t myCommands[] = {...,
 *                              {NULL, FALSE, 0, 0, NULL,NULL}
 *                          };
 *
 * PluginFeature_t myFeatures[]  = {...,
 *                                      {PLUGIN_FEATURE_TYPE_NONE, NULL}
 *                                 };
 *
 * Plugin_t PluginInterface = {
 *  DVBSTREAMER_VERSION,
 *  "Example",
 *  "0.1",
 *  "Example Plugin",
 *  "An Author",
 *   myCommands,
 *   myFeatures
 * };
 * @endcode
 */
typedef struct Plugin_t
{
    unsigned int requiredVersion; /**< Version of DVBStreamer required to run this plugin */
    unsigned int pluginFor;       /**< What type of transport stream this plugin is meant for. */
	char *name;                   /**< Name of the plugin */
	char *version;                /**< String describing the version of the plugin */
	char *description;            /**< Description of the plugin */
	char *author;                 /**< Author/Contact address for bugs */
	Command_t *commands;          /**< NULL terminated array of commands or NULL for no commands */
	PluginFeature_t *features;    /**< A PLUGIN_FEATURE_NONE terminated list of features or NULL for no features. */
}Plugin_t;

/**
 * Simple macro to help in defining the Plugin Interface with only commands.
 */
#define PLUGIN_INTERFACE_C(_for, _name, _version, _desc, _author) \
    Plugin_t PluginInterface = { DVBSTREAMER_VERSION, _for, _name, _version, _desc, _author, PluginCommands, NULL}

/**
 * Simple macro to help in defining the Plugin Interface with only features.
 */
#define PLUGIN_INTERFACE_F(_for, _name, _version, _desc, _author) \
    Plugin_t PluginInterface = { DVBSTREAMER_VERSION, _for, _name, _version, _desc, _author, NULL, PluginFeatures}

/**
 * Simple macro to help in defining the Plugin Interface with both commands and
 * features
 */
#define PLUGIN_INTERFACE_CF(_for, _name, _version, _desc, _author) \
    Plugin_t PluginInterface = { DVBSTREAMER_VERSION, _for, _name, _version, _desc, _author, PluginCommands, PluginFeatures}

/**
 * Use this macro to define the commands a plugin provides.
 * This should be used before PLUGININTERFACE.
 * for example:
 * @code
 * PLUGIN_COMMANDS({"example", TRUE, 1, 1,"An example command", "example <arg>\nPrint out <arg>",ExampleCommand});
 * PLUGININTERFACE("Example", "0.1", "An example plugin", "A Coder");
 * @endcode
 */
#define PLUGIN_COMMANDS(_commands...) \
    static Command_t PluginCommands[] = {\
        _commands,\
        COMMANDS_SENTINEL\
    }

/**
 * Use this macro to define the features a plugin provides.
 * This should be used before PLUGININTERFACE.
 * for example:
 * @code
 * PLUGIN_FEATURES(
 *  PLUGIN_FEATURE_FILTER(myfilterfeature)
 * );
 * PLUGININTERFACE("Example", "0.1", "An example plugin", "A Coder");
 * @endcode
 * @param _features A list of features provided by this plugin.
 */
#define PLUGIN_FEATURES(_features...) \
    static PluginFeature_t PluginFeatures[] = {\
        _features,\
        {PLUGIN_FEATURE_TYPE_NONE, .details.installCB=NULL}\
    }

/**
 * Simple macro to define an event listener feature.
 * @param _details A PluginEventListenerDetails_t containing the event name and 
 *                 the callback to call when the event occurs.
 */
#define PLUGIN_FEATURE_EVENT_LISTENER(_event, _listener, _arg)\
    {.type=PLUGIN_FEATURE_TYPE_EVENT_LISTENER, .details.eventDetails={_event, _listener, _arg}}
/**
 * Simple macro to define a PAT Processor feature.
 * @param _processor Function to call when a new PAT arrives.
 */
#define PLUGIN_FEATURE_PATPROCESSOR(_processor)\
    {.type=PLUGIN_FEATURE_TYPE_PATPROCESSOR, .details.patCB=_processor}
/**
 * Simple macro to define a PMT Processor feature.
 * @param _processor Function to call when a new PMT arrives.
 */
#define PLUGIN_FEATURE_PMTPROCESSOR(_processor)\
    {.type=PLUGIN_FEATURE_TYPE_PMTPROCESSOR, .details.pmtCB=_processor}
/**
 * Simple macro to define a delivery method feature.
 * @param _method A DeliveryMethod_t instance (will be dereferenced).
 */
#define PLUGIN_FEATURE_DELIVERYMETHOD(_canHandle, _newInstance)\
    {.type=PLUGIN_FEATURE_TYPE_DELIVERYMETHOD, .details.dmHandler={_canHandle,_newInstance}}

/**
 * Simple macro to define a Channel Changed feature.
 * @param _cchanged Function to call when the Primary service filter is updated.
 */
#define PLUGIN_FEATURE_CHANNELCHANGED(_cchanged)\
    {.type=PLUGIN_FEATURE_TYPE_CHANNELCHANGED, .details.channelChangeCB =_cchanged}

/**
 * Simple macro to define a SDT Processor feature.
 * @param _processor Function to call when a new SDT arrives.
 */
#define PLUGIN_FEATURE_SDTPROCESSOR(_processor)\
    {.type=PLUGIN_FEATURE_TYPE_SDTPROCESSOR, .details.sdtCB=_processor}
/**
 * Simple macro to define a NIT Processor feature.
 * @param _processor Function to call when a new NIT arrives.
 */
#define PLUGIN_FEATURE_NITPROCESSOR(_processor)\
    {.type=PLUGIN_FEATURE_TYPE_NITPROCESSOR, .details.nitCB=_processor}
/**
 * Simple macro to define a TDT/TOT Processor feature.
 * @param _processor Function to call when a new TDT or TOT arrives.
 */
#define PLUGIN_FEATURE_TDTPROCESSOR(_processor)\
    {.type=PLUGIN_FEATURE_TYPE_TDTPROCESSOR, .details.tdtCB=_processor}
/**
 * Simple macro to define a MGT Processor feature.
 * @param _processor Function to call when a new MGT arrives.
 */
#define PLUGIN_FEATURE_MGTPROCESSOR(_processor)\
    {.type=PLUGIN_FEATURE_TYPE_MGTPROCESSOR, .details.mgtCB=_processor}

/**
 * Simple macro to define a STT Processor feature.
 * @param _processor Function to call when a new STT arrives.
 */
#define PLUGIN_FEATURE_STTPROCESSOR(_processor)\
    {.type=PLUGIN_FEATURE_TYPE_STTPROCESSOR, .details.sttCB=_processor}

/**
 * Simple macro to define a VCT Processor feature.
 * @param _processor Function to call when a new VCT arrives.
 */
#define PLUGIN_FEATURE_VCTPROCESSOR(_processor)\
    {.type=PLUGIN_FEATURE_TYPE_VCTPROCESSOR, .details.vctCB=_processor}

/**
 * Simple macro to define an install callback.
 * @param _callback A PluginInstallCallback_t to call when the plugin is (un)installed.
 */
#define PLUGIN_FEATURE_INSTALL(_callback)\
    {.type=PLUGIN_FEATURE_TYPE_INSTALL, .details.installCB=_callback}


/** @} */
#endif