File: multiplexes.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 (221 lines) | stat: -rw-r--r-- 6,879 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
/*
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

multiplexes.h

Manage multiplexes and tuning parameters.

*/
#ifndef _MULTIPLEX_H_
#define _MULTIPLEX_H_
#include <sys/types.h>
#include <linux/dvb/dmx.h>
#include <linux/dvb/frontend.h>
#include "objects.h"
#include "dvbadapter.h"
#include "list.h"
#include "dbase.h"
#include "events.h"

/**
 * @defgroup Multiplex Multiplex information
 * This module is used to store and retrieve the multiplex information in the 
 * adapters database.
 * @{
 */

/**
 * Structure describing a multiplex.
 */
typedef struct Multiplex_s
{    
    int uid;        /**< Unique ID for this multiplex */
    int tsId;       /**< Transport Stream ID. */
    int networkId;  /**< Network ID */
    int patVersion; /**< Last processed version of the PAT */
    DVBDeliverySystem_e deliverySystem; /**< Delivery system used to broadcast this multiplex */
    char *tuningParams; /**< Tuning parameters */
}Multiplex_t;

/**
 * A Collection of Multiplex_t objects.
 */
typedef struct MultiplexList_s
{
    int nrofMultiplexes;         /**< Number of multiplex objects contained in this list. */
    Multiplex_t *multiplexes[0]; /**< Array of pointers to multiplex objects. */
}MultiplexList_t;

/**
 * Handle for enumerating multiplexes.
 */
typedef void * MultiplexEnumerator_t;

/**
 * Macro to compare 2 Multiplex_t structures.
 */
#define MultiplexAreEqual(_multiplex1, _multiplex2) \
    ((_multiplex1)->uid == (_multiplex2)->uid)

/**
 * Initialise the multiplex module for use.
 * @return 0 on success.
 */
int MultiplexInit(void);

/**
 * Release resources used by the multiplex module.
 * @return 0 on success.
 */
int MultiplexDeInit(void);

/**
 * Number of multiplexes stored in the database.
 * @return The number of multiplexes in the database.
 */
#define MultiplexCount() DBaseCount(MULTIPLEXES_TABLE, NULL)

/**
 * Retrieve a Multiplex_t structure for the string mux.
 * mux is tried as (in order) UID, netid.tsid and finally frequency.
 * @return A Mulitplex_t or NULL if the frequency could not be found.
 */
Multiplex_t *MultiplexFind(char *mux);

/**
 * Retrieve the Multiplex_t structure for the UID.
 * The returned structured should be released using MultiplexRefDec.
 * @param uid Unique ID of the multiplex to retrieve.
 * @return A Mulitplex_t or NULL if the frequency could not be found.
 */
Multiplex_t *MultiplexFindUID(int uid);

/**
 * Retrieve the Multiplex_t structure for the network and TS id.
 * The returned structured should be released using MultiplexRefDec.
 * @param netid Network id to find.
 * @param tsid Transport stream id to find.
 * @return A Mulitplex_t or NULL if the frequency could not be found.
 */
Multiplex_t *MultiplexFindId(int netid, int tsid);


/**
 * Retrieve an enumerator for all the multiplexes in the database.
 * @return An enumerator instance or NULL if there was not enough memory.
 */
MultiplexEnumerator_t MultiplexEnumeratorGet();

/**
 * Retrieve a MultiplexList_t object containing all the multiplexes in the database.
 * @return A MultiplexList_t instance containing Multiplex_t objects or NULL if there was
 * not enough memory.
 */
MultiplexList_t *MultiplexGetAll();

/**
 * Destroy an enumerator return by MultiplexEnumeratorGet().
 * @param enumerator The enumerator to free.
 */
void MultiplexEnumeratorDestroy(MultiplexEnumerator_t enumerator);

/**
 * Retrieve the next multiplex from an enumerator.
 * The returned structured should be free'd using free().
 * @param enumerator The enumerator to retrieve the next multiplex from.
 * @return A Multiplex_t instance or NULL if there are no more multiplexes.
 */
Multiplex_t *MultiplexGetNext(MultiplexEnumerator_t enumerator);

/**
 * Add a multiplex to the database.
 * @param type The type of frontend used to receive this transport stream.
 * @param tuningParams String containing a YAML Document describing the tuning parameters.
 * @param mux On exit, if successful, contains a pointer to a Multiplex_t object.
 * @return 0 on success, otherwise an SQLite error code.
 */
int MultiplexAdd(DVBDeliverySystem_e type, char *tuningParams, Multiplex_t **mux);

/**
 * Remove a multiplex and all its services from the database.
 * @param multiplex The multiplex to delete.
 * @return 0 on success, otherwise an SQLite error code.
 */
int MultiplexDelete(Multiplex_t *multiplex);

/**
 * Set the PAT version of a multiplex.
 * @param multiplex The multiplex to update.
 * @param patversion The version of the PAT to set.
 * @return 0 on success, otherwise an SQLite error code.
 */
int MultiplexPATVersionSet(Multiplex_t *multiplex, int patversion);

/**
 * Set the TS ID of the multiplex.
 * @param multiplex The multiplex to update.
 * @param tsid The ID of TS set.
 * @return 0 on success, otherwise an SQLite error code.
 */
int MultiplexTSIdSet(Multiplex_t *multiplex, int tsid);

/**
 * Set the network ID of the multiplex.
 * @param multiplex The multiplex to update.
 * @param netid The network id to set.
 * @return 0 on success, otherwise an SQLite error code.
 */
int MultiplexNetworkIdSet(Multiplex_t *multiplex, int netid);


/**
 * Create a new multiplex object.
 */
#define MultiplexNew() (Multiplex_t*)ObjectCreateType(Multiplex_t)

/**
 * Increment the references to the specified multiplex object.
 * @param __multiplex The multiplex instance to increment the reference count of. (Multiplex can be NULL.)
 */
#define MultiplexRefInc(__multiplex) \
        do{ \
            if ((__multiplex)) \
            { \
                ObjectRefInc((__multiplex)); \
            } \
        }while(0)

/**
 * Decrement the references of the specified multiplex object. If the reference 
 * count reaches 0 the instance is free'd.
 * @param __multiplex The multiplex instance to decrement the reference count of. (Multiplex can be NULL.)
 */
#define MultiplexRefDec(__multiplex) \
        do{ \
            if ((__multiplex)) \
            { \
                ObjectRefDec((__multiplex)); \
            } \
        }while(0)

/**
 * Use as the toString parameter when registering an event where the payload will
 * be a multiplex object.
 */
int MultiplexEventToString(yaml_document_t *document, Event_t event,void * payload);
/** @} */
#endif