libdvbv5  1.4.0
Library to work with Digital TV streams
dvb-file.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation version 2
7  * of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  */
14 #ifndef _DVB_FILE_H
15 #define _DVB_FILE_H
16 
17 #include "dvb-fe.h"
18 
39 /*
40  * DVB structures used to represent all files opened by the libdvbv5 library.
41  *
42  * Those structs represents each individual entry on a file, and the file
43  * as a hole.
44  */
45 
54  uint8_t type;
55  uint16_t pid;
56 };
57 
92 struct dvb_entry {
93  struct dtv_property props[DTV_MAX_COMMAND];
94  unsigned int n_props;
95  struct dvb_entry *next;
96  uint16_t service_id;
97  uint16_t *video_pid, *audio_pid;
100  char *channel;
101  char *vchannel;
102 
103  char *location;
104 
106  unsigned freq_bpf;
107  unsigned diseqc_wait;
108  char *lnb;
109 };
110 
119 struct dvb_file {
120  char *fname;
123 };
124 
125 /*
126  * DVB file format tables
127  *
128  * The structs below are used to represent oneline formats like the ones
129  * commonly found on DVB legacy applications.
130  */
131 
146  unsigned int prop;
147  const char **table;
148  unsigned int size;
152 };
164  char *id;
165  uint32_t delsys;
166  const struct dvb_parse_table *table;
167  unsigned int size;
168 };
169 
183  char *delimiter;
185 };
186 
206 };
207 
208 struct dvb_v5_descriptors;
209 
210 #ifdef __cplusplus
211 extern "C" {
212 #endif
213 
223 static inline void dvb_file_free(struct dvb_file *dvb_file)
224 {
225  struct dvb_entry *entry = dvb_file->first_entry, *next;
226  while (entry) {
227  next = entry->next;
228  if (entry->channel)
229  free(entry->channel);
230  if (entry->vchannel)
231  free(entry->vchannel);
232  if (entry->location)
233  free(entry->location);
234  if (entry->video_pid)
235  free(entry->video_pid);
236  if (entry->audio_pid)
237  free(entry->audio_pid);
238  if (entry->other_el_pid)
239  free(entry->other_el_pid);
240  if (entry->lnb)
241  free(entry->lnb);
242  free(entry);
243  entry = next;
244  }
245  free(dvb_file);
246 }
247 
248 /*
249  * File format description structures defined for the several formats that
250  * the library can read natively.
251  */
252 
254 extern const struct dvb_parse_file channel_file_format;
255 
257 extern const struct dvb_parse_file channel_file_zap_format;
258 
259 /*
260  * Prototypes for the several functions defined at dvb-file.c
261  */
262 
272 struct dvb_file *dvb_read_file(const char *fname);
273 
283 int dvb_write_file(const char *fname, struct dvb_file *dvb_file);
284 
299 struct dvb_file *dvb_read_file_format(const char *fname,
300  uint32_t delsys,
301  enum dvb_file_formats format);
302 
318 int dvb_write_file_format(const char *fname,
319  struct dvb_file *dvb_file,
320  uint32_t delsys,
321  enum dvb_file_formats format);
322 
323 
340 int dvb_store_entry_prop(struct dvb_entry *entry,
341  uint32_t cmd, uint32_t value);
342 
358 int dvb_retrieve_entry_prop(struct dvb_entry *entry,
359  uint32_t cmd, uint32_t *value);
360 
398 int dvb_store_channel(struct dvb_file **dvb_file,
399  struct dvb_v5_fe_parms *parms,
401  int get_detected, int get_nit);
402 
421 int dvb_parse_delsys(const char *name);
422 
433 enum dvb_file_formats dvb_parse_format(const char *name);
434 
435 /*
436  * Routines to read a non-libdvbv5 format. They're called by
437  * dvb_read_file_format() or dvb_write_file_format()
438  */
439 
440 #ifndef _DOXYGEN
441 struct dvb_file *dvb_parse_format_oneline(const char *fname,
442  uint32_t delsys,
443  const struct dvb_parse_file *parse_file);
444 int dvb_write_format_oneline(const char *fname,
445  struct dvb_file *dvb_file,
446  uint32_t delsys,
447  const struct dvb_parse_file *parse_file);
448 #endif
449 
450 #ifdef __cplusplus
451 }
452 #endif
453 
454 #endif // _DVB_FILE_H
dvb_file_formats
Known file formats.
Definition: dvb-file.h:201
unsigned video_pid_len
Definition: dvb-file.h:99
char * channel
Definition: dvb-file.h:100
int n_entries
Definition: dvb-file.h:121
Describes an entire file format.
Definition: dvb-file.h:181
int dvb_store_entry_prop(struct dvb_entry *entry, uint32_t cmd, uint32_t value)
Stores a key/value pair on a DVB file entry.
char * delimiter
Definition: dvb-file.h:183
Describes an entire DVB file opened.
Definition: dvb-file.h:119
Describes the format to parse an specific delivery system.
Definition: dvb-file.h:163
struct dvb_elementary_pid * other_el_pid
Definition: dvb-file.h:98
int has_default_value
Definition: dvb-file.h:150
uint16_t * audio_pid
Definition: dvb-file.h:97
char * vchannel
Definition: dvb-file.h:101
const struct dvb_parse_table * table
Definition: dvb-file.h:166
char * lnb
Definition: dvb-file.h:108
const char ** table
Definition: dvb-file.h:147
unsigned other_el_pid_len
Definition: dvb-file.h:99
unsigned int n_props
Definition: dvb-file.h:94
uint16_t service_id
Definition: dvb-file.h:96
struct dvb_parse_struct formats[]
Definition: dvb-file.h:184
unsigned int size
Definition: dvb-file.h:167
int sat_number
Definition: dvb-file.h:105
unsigned int size
Definition: dvb-file.h:148
struct dvb_file * dvb_read_file(const char *fname)
Read a file at libdvbv5 format.
const struct dvb_parse_file channel_file_format
File format definitions for dvb-apps channel format.
unsigned int prop
Definition: dvb-file.h:146
struct dvb_entry * next
Definition: dvb-file.h:95
struct dvb_entry * first_entry
Definition: dvb-file.h:122
Keeps data needed to handle the DVB frontend.
Definition: dvb-fe.h:113
char * fname
Definition: dvb-file.h:120
struct dtv_property props[DTV_MAX_COMMAND]
Definition: dvb-file.h:93
unsigned audio_pid_len
Definition: dvb-file.h:99
unsigned diseqc_wait
Definition: dvb-file.h:107
int has_delsys_id
Definition: dvb-file.h:182
int dvb_write_file_format(const char *fname, struct dvb_file *dvb_file, uint32_t delsys, enum dvb_file_formats format)
uint16_t * video_pid
Definition: dvb-file.h:97
const struct dvb_parse_file channel_file_zap_format
File format definitions for dvb-apps zap format.
int dvb_retrieve_entry_prop(struct dvb_entry *entry, uint32_t cmd, uint32_t *value)
Retrieves the value associated witha key on a DVB file entry.
Describes the fields to parse on a file.
Definition: dvb-file.h:145
unsigned freq_bpf
Definition: dvb-file.h:106
Linked list containing the several descriptors found on a MPEG-TS table.
Definition: descriptors.h:93
struct dvb_file * dvb_read_file_format(const char *fname, uint32_t delsys, enum dvb_file_formats format)
Read a file on any format natively supported by the library.
associates an elementary stream type with its PID
Definition: dvb-file.h:53
char * location
Definition: dvb-file.h:103
Represents one entry on a DTV file.
Definition: dvb-file.h:92
uint32_t delsys
Definition: dvb-file.h:165
Contains the descriptors needed to scan the Service ID and other relevant info at a MPEG-TS Digital T...
Definition: dvb-scan.h:74
uint16_t pid
Definition: dvb-file.h:55
Provides interfaces to deal with DVB frontend.
int dvb_parse_delsys(const char *name)
Ancillary function that seeks for a delivery system.
static void dvb_file_free(struct dvb_file *dvb_file)
Deallocates memory associated with a struct dvb_file.
Definition: dvb-file.h:223
int dvb_write_file(const char *fname, struct dvb_file *dvb_file)
Write a file at libdvbv5 format.
int dvb_store_channel(struct dvb_file **dvb_file, struct dvb_v5_fe_parms *parms, struct dvb_v5_descriptors *dvb_desc, int get_detected, int get_nit)
stored a new scanned channel into a dvb_file struct
enum dvb_file_formats dvb_parse_format(const char *name)
Ancillary function that parses the name of a file format.