Mercurial > mplayer.hg
annotate libmpdemux/dvbin.c @ 13121:93774d4a0c1d
id3edit updated
author | diego |
---|---|
date | Tue, 24 Aug 2004 19:29:17 +0000 |
parents | 168238f8c715 |
children | fd40ef23053b |
rev | line source |
---|---|
9610 | 1 /* |
2 | |
3 dvbstream | |
4 (C) Dave Chapman <dave@dchapman.com> 2001, 2002. | |
5 | |
6 The latest version can be found at http://www.linuxstb.org/dvbstream | |
7 | |
8 Copyright notice: | |
9 | |
10 This program is free software; you can redistribute it and/or modify | |
11 it under the terms of the GNU General Public License as published by | |
12 the Free Software Foundation; either version 2 of the License, or | |
13 (at your option) any later version. | |
14 | |
15 This program is distributed in the hope that it will be useful, | |
16 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 GNU General Public License for more details. | |
19 | |
20 You should have received a copy of the GNU General Public License | |
21 along with this program; if not, write to the Free Software | |
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
24 */ | |
25 | |
10560 | 26 #include "config.h" |
9610 | 27 #include <stdio.h> |
28 #include <stdlib.h> | |
29 #include <string.h> | |
30 #include <ctype.h> | |
31 #include <sys/ioctl.h> | |
32 #include <sys/time.h> | |
33 #include <sys/poll.h> | |
10560 | 34 #include <unistd.h> |
9610 | 35 #include <fcntl.h> |
36 #include <string.h> | |
37 #include <errno.h> | |
38 #include <fcntl.h> | |
39 | |
40 #include "stream.h" | |
41 #include "demuxer.h" | |
10560 | 42 #include "help_mp.h" |
43 #include "../m_option.h" | |
44 #include "../m_struct.h" | |
9610 | 45 |
46 #include "dvbin.h" | |
47 | |
48 | |
49 #define MAX_CHANNELS 8 | |
10560 | 50 #define CHANNEL_LINE_LEN 256 |
9610 | 51 #define min(a, b) ((a) <= (b) ? (a) : (b)) |
52 | |
10560 | 53 |
54 //TODO: CAMBIARE list_ptr e da globale a per_priv | |
55 | |
56 | |
57 static struct stream_priv_s | |
58 { | |
59 char *prog; | |
60 int card; | |
61 char *type; | |
62 int vid, aid; | |
63 char *file; | |
64 } | |
65 stream_defaults = | |
66 { | |
12108
06c4780332bc
disallow non-sense type parameter; added support for absolute file path; prefer channels.conf.{sat,ter,cbl} over channels.conf if the file is available
nicodvb
parents:
12047
diff
changeset
|
67 "", 1, "", 0, 0, NULL |
10560 | 68 }; |
69 | |
70 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s, f) | |
9610 | 71 |
10560 | 72 /// URL definition |
73 static m_option_t stream_params[] = { | |
74 {"prog", ST_OFF(prog), CONF_TYPE_STRING, 0, 0 ,0, NULL}, | |
75 {"card", ST_OFF(card), CONF_TYPE_INT, M_OPT_RANGE, 1, 4, NULL}, | |
76 {"type", ST_OFF(type), CONF_TYPE_STRING, 0, 0 ,0, NULL}, | |
77 {"vid", ST_OFF(vid), CONF_TYPE_INT, 0, 0 ,0, NULL}, | |
78 {"aid", ST_OFF(aid), CONF_TYPE_INT, 0, 0 ,0, NULL}, | |
79 {"file", ST_OFF(file), CONF_TYPE_STRING, 0, 0 ,0, NULL}, | |
80 | |
81 {"hostname", ST_OFF(prog), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
82 {"username", ST_OFF(card), CONF_TYPE_INT, M_OPT_RANGE, 1, 4, NULL}, |
10560 | 83 {NULL, NULL, 0, 0, 0, 0, NULL} |
84 }; | |
85 | |
86 static struct m_struct_st stream_opts = { | |
87 "dvbin", | |
88 sizeof(struct stream_priv_s), | |
89 &stream_defaults, | |
90 stream_params | |
9610 | 91 }; |
92 | |
93 | |
10560 | 94 |
95 m_option_t dvbin_opts_conf[] = { | |
96 {"prog", &stream_defaults.prog, CONF_TYPE_STRING, 0, 0 ,0, NULL}, | |
97 {"card", &stream_defaults.card, CONF_TYPE_INT, M_OPT_RANGE, 1, 4, NULL}, | |
12108
06c4780332bc
disallow non-sense type parameter; added support for absolute file path; prefer channels.conf.{sat,ter,cbl} over channels.conf if the file is available
nicodvb
parents:
12047
diff
changeset
|
98 {"type", "DVB card type is autodetected and can't be overridden\n", CONF_TYPE_PRINT, CONF_NOCFG, 0 ,0, NULL}, |
10560 | 99 {"vid", &stream_defaults.vid, CONF_TYPE_INT, 0, 0 ,0, NULL}, |
100 {"aid", &stream_defaults.aid, CONF_TYPE_INT, 0, 0 ,0, NULL}, | |
101 {"file", &stream_defaults.file, CONF_TYPE_STRING, 0, 0 ,0, NULL}, | |
9610 | 102 |
10560 | 103 {NULL, NULL, 0, 0, 0, 0, NULL} |
104 }; | |
105 | |
106 | |
107 | |
108 | |
109 extern int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype); | |
110 extern int dvb_demux_stop(int fd); | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
111 extern int dvb_get_tuner_type(int fd); |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
112 int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt, int *pids); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
113 int dvb_fix_demuxes(dvb_priv_t *priv, int cnt, int *pids); |
10560 | 114 |
9610 | 115 extern int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone, |
116 fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval, | |
117 fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate); | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
118 extern char *dvb_dvrdev[4], *dvb_demuxdev[4], *dvb_frontenddev[4]; |
10560 | 119 |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
120 static dvb_config_t *dvb_config = NULL; |
9610 | 121 |
122 | |
10560 | 123 static dvb_channels_list *dvb_get_channels(char *filename, int type) |
9610 | 124 { |
125 dvb_channels_list *list; | |
126 FILE *f; | |
10560 | 127 uint8_t line[CHANNEL_LINE_LEN]; |
128 | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
129 int fields, cnt, pcnt; |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
130 dvb_channel_t *ptr, *tmp, chn; |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
131 char *tmp_lcr, *tmp_hier, *inv, *bw, *cr, *mod, *transm, *gi, *vpid_str, *apid_str; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
132 const char *cbl_conf = "%a[^:]:%d:%a[^:]:%d:%a[^:]:%a[^:]:%a[^:]:%a[^:]\n"; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
133 const char *sat_conf = "%a[^:]:%d:%c:%d:%d:%a[^:]:%a[^:]\n"; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
134 const char *ter_conf = "%a[^:]:%d:%a[^:]:%a[^:]:%a[^:]:%a[^:]:%a[^:]:%a[^:]:%a[^:]:%a[^:]:%a[^:]:%a[^:]\n"; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
135 |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
136 mp_msg(MSGT_DEMUX, MSGL_V, "CONFIG_READ FILE: %s, type: %d\n", filename, type); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
137 if((f=fopen(filename, "r"))==NULL) |
10560 | 138 { |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
139 mp_msg(MSGT_DEMUX, MSGL_FATAL, "CAN'T READ CONFIG FILE %s\n", filename); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
140 return NULL; |
10560 | 141 } |
142 | |
9610 | 143 list = malloc(sizeof(dvb_channels_list)); |
144 if(list == NULL) | |
145 { | |
146 mp_msg(MSGT_DEMUX, MSGL_V, "DVB_GET_CHANNELS: couldn't malloc enough memory\n"); | |
147 return NULL; | |
148 } | |
149 | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
150 ptr = &chn; |
9610 | 151 list->NUM_CHANNELS = 0; |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
152 list->channels = NULL; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
153 while(! feof(f)) |
9610 | 154 { |
10708 | 155 if( fgets(line, CHANNEL_LINE_LEN, f) == NULL ) |
156 continue; | |
9610 | 157 |
10708 | 158 if((line[0] == '#') || (strlen(line) == 0)) |
10560 | 159 continue; |
9610 | 160 |
161 | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
162 apid_str = vpid_str = NULL; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
163 ptr->pids_cnt = 0; |
10560 | 164 if(type == TUNER_TER) |
9610 | 165 { |
166 fields = sscanf(line, ter_conf, | |
10560 | 167 &ptr->name, &ptr->freq, &inv, &bw, &cr, &tmp_lcr, &mod, |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
168 &transm, &gi, &tmp_hier, &vpid_str, &apid_str); |
10708 | 169 mp_msg(MSGT_DEMUX, MSGL_V, |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
170 "TER, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d", |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
171 list->NUM_CHANNELS, fields, ptr->name, ptr->freq); |
10560 | 172 } |
173 else if(type == TUNER_CBL) | |
174 { | |
175 fields = sscanf(line, cbl_conf, | |
176 &ptr->name, &ptr->freq, &inv, &ptr->srate, | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
177 &cr, &mod, &vpid_str, &apid_str); |
10708 | 178 mp_msg(MSGT_DEMUX, MSGL_V, |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
179 "CBL, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d", |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
180 list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate); |
10560 | 181 } |
182 else //SATELLITE | |
183 { | |
184 fields = sscanf(line, sat_conf, | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
185 &ptr->name, &ptr->freq, &ptr->pol, &ptr->diseqc, &ptr->srate, &vpid_str, &apid_str); |
10560 | 186 ptr->pol = toupper(ptr->pol); |
187 ptr->freq *= 1000UL; | |
188 ptr->srate *= 1000UL; | |
189 ptr->tone = -1; | |
12047
6fbcdac049c6
added missing tuning parameters (inversion and coderate) and changed debug level in dvb_streaming_read()
nicodvb
parents:
11872
diff
changeset
|
190 ptr->inv = INVERSION_AUTO; |
6fbcdac049c6
added missing tuning parameters (inversion and coderate) and changed debug level in dvb_streaming_read()
nicodvb
parents:
11872
diff
changeset
|
191 ptr->cr = FEC_AUTO; |
12116 | 192 if((ptr->diseqc > 4) || (ptr->diseqc < 0)) |
12047
6fbcdac049c6
added missing tuning parameters (inversion and coderate) and changed debug level in dvb_streaming_read()
nicodvb
parents:
11872
diff
changeset
|
193 continue; |
12116 | 194 if(ptr->diseqc > 0) |
195 ptr->diseqc--; | |
10560 | 196 mp_msg(MSGT_DEMUX, MSGL_V, |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
197 "SAT, NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d, POL: %c, DISEQC: %d", |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
198 list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate, ptr->pol, ptr->diseqc); |
10560 | 199 } |
9610 | 200 |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
201 if(vpid_str != NULL) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
202 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
203 pcnt = sscanf(vpid_str, "%d+%d+%d+%d+%d+%d+%d", &ptr->pids[0], &ptr->pids[1], &ptr->pids[2], &ptr->pids[3], |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
204 &ptr->pids[4], &ptr->pids[5], &ptr->pids[6]); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
205 if(pcnt > 0) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
206 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
207 ptr->pids_cnt = pcnt; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
208 fields++; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
209 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
210 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
211 |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
212 if(apid_str != NULL) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
213 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
214 cnt = ptr->pids_cnt; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
215 pcnt = sscanf(apid_str, "%d+%d+%d+%d+%d+%d+%d+%d", &ptr->pids[cnt], &ptr->pids[cnt+1], &ptr->pids[cnt+2], |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
216 &ptr->pids[cnt+3], &ptr->pids[cnt+4], &ptr->pids[cnt+5], &ptr->pids[cnt+6], &ptr->pids[cnt+7]); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
217 if(pcnt > 0) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
218 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
219 ptr->pids_cnt += pcnt; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
220 fields++; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
221 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
222 } |
10560 | 223 |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
224 if((fields < 3) || (ptr->pids_cnt <= 0) || (ptr->freq == 0) || (strlen(ptr->name) == 0)) |
10708 | 225 continue; |
226 | |
227 | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
228 ptr->pids[ptr->pids_cnt] = 0; //PID 0 is the PAT |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
229 ptr->pids_cnt++; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
230 mp_msg(MSGT_DEMUX, MSGL_V, " PIDS: "); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
231 for(cnt = 0; cnt < ptr->pids_cnt; cnt++) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
232 mp_msg(MSGT_DEMUX, MSGL_V, " %d ", ptr->pids[cnt]); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
233 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
234 |
10560 | 235 if((type == TUNER_TER) || (type == TUNER_CBL)) |
236 { | |
9610 | 237 if(! strcmp(inv, "INVERSION_ON")) |
238 ptr->inv = INVERSION_ON; | |
239 else if(! strcmp(inv, "INVERSION_OFF")) | |
240 ptr->inv = INVERSION_OFF; | |
241 else | |
242 ptr->inv = INVERSION_AUTO; | |
243 | |
244 | |
245 if(! strcmp(cr, "FEC_1_2")) | |
246 ptr->cr =FEC_1_2; | |
247 else if(! strcmp(cr, "FEC_2_3")) | |
248 ptr->cr =FEC_2_3; | |
249 else if(! strcmp(cr, "FEC_3_4")) | |
250 ptr->cr =FEC_3_4; | |
251 #ifdef HAVE_DVB_HEAD | |
252 else if(! strcmp(cr, "FEC_4_5")) | |
253 ptr->cr =FEC_4_5; | |
254 else if(! strcmp(cr, "FEC_6_7")) | |
255 ptr->cr =FEC_6_7; | |
256 else if(! strcmp(cr, "FEC_8_9")) | |
257 ptr->cr =FEC_8_9; | |
258 #endif | |
259 else if(! strcmp(cr, "FEC_5_6")) | |
260 ptr->cr =FEC_5_6; | |
261 else if(! strcmp(cr, "FEC_7_8")) | |
262 ptr->cr =FEC_7_8; | |
263 else if(! strcmp(cr, "FEC_NONE")) | |
264 ptr->cr =FEC_NONE; | |
265 else ptr->cr =FEC_AUTO; | |
266 | |
267 if(! strcmp(mod, "QAM_128")) | |
268 ptr->mod = QAM_128; | |
269 else if(! strcmp(mod, "QAM_256")) | |
270 ptr->mod = QAM_256; | |
271 else if(! strcmp(mod, "QAM_64")) | |
272 ptr->mod = QAM_64; | |
273 else if(! strcmp(mod, "QAM_32")) | |
274 ptr->mod = QAM_32; | |
275 else if(! strcmp(mod, "QAM_16")) | |
276 ptr->mod = QAM_16; | |
10560 | 277 //else ptr->mod = QPSK; |
278 } | |
279 | |
280 | |
281 if(type == TUNER_TER) | |
282 { | |
283 if(! strcmp(bw, "BANDWIDTH_6_MHZ")) | |
284 ptr->bw = BANDWIDTH_6_MHZ; | |
285 else if(! strcmp(bw, "BANDWIDTH_7_MHZ")) | |
286 ptr->bw = BANDWIDTH_7_MHZ; | |
287 else if(! strcmp(bw, "BANDWIDTH_8_MHZ")) | |
288 ptr->bw = BANDWIDTH_8_MHZ; | |
9610 | 289 |
290 | |
291 if(! strcmp(transm, "TRANSMISSION_MODE_2K")) | |
292 ptr->trans = TRANSMISSION_MODE_2K; | |
293 else if(! strcmp(transm, "TRANSMISSION_MODE_8K")) | |
294 ptr->trans = TRANSMISSION_MODE_8K; | |
295 | |
10560 | 296 |
9610 | 297 if(! strcmp(gi, "GUARD_INTERVAL_1_32")) |
298 ptr->gi = GUARD_INTERVAL_1_32; | |
299 else if(! strcmp(gi, "GUARD_INTERVAL_1_16")) | |
300 ptr->gi = GUARD_INTERVAL_1_16; | |
301 else if(! strcmp(gi, "GUARD_INTERVAL_1_8")) | |
302 ptr->gi = GUARD_INTERVAL_1_8; | |
303 else ptr->gi = GUARD_INTERVAL_1_4; | |
304 } | |
305 | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
306 tmp = (dvb_channel_t*)realloc(list->channels, sizeof(dvb_channel_t) * (list->NUM_CHANNELS + 1)); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
307 if(tmp == NULL) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
308 break; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
309 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
310 list->channels = tmp; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
311 memcpy(&(list->channels[list->NUM_CHANNELS]), ptr, sizeof(dvb_channel_t)); |
9610 | 312 list->NUM_CHANNELS++; |
313 } | |
314 | |
315 fclose(f); | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
316 if(list->NUM_CHANNELS == 0) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
317 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
318 if(list->channels != NULL) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
319 free(list->channels); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
320 free(list); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
321 return NULL; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
322 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
323 |
10560 | 324 list->current = 0; |
9610 | 325 return list; |
326 } | |
327 | |
328 | |
329 | |
10560 | 330 static int dvb_streaming_read(stream_t *stream, char *buffer, int size) |
9610 | 331 { |
332 struct pollfd pfds[1]; | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
333 int pos=0, tries, rk, fd; |
10560 | 334 dvb_priv_t *priv = (dvb_priv_t *) stream->priv; |
9610 | 335 |
12047
6fbcdac049c6
added missing tuning parameters (inversion and coderate) and changed debug level in dvb_streaming_read()
nicodvb
parents:
11872
diff
changeset
|
336 mp_msg(MSGT_DEMUX, MSGL_DBG3, "dvb_streaming_read(%d)\n", size); |
9610 | 337 |
11352 | 338 tries = priv->retry + 1; |
339 | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
340 fd = stream->fd; |
9610 | 341 while(pos < size) |
342 { | |
10560 | 343 pfds[0].fd = fd; |
344 pfds[0].events = POLLIN | POLLPRI; | |
9610 | 345 |
10560 | 346 poll(pfds, 1, 500); |
347 rk = size - pos; | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
348 if((rk = read(fd, &buffer[pos], rk)) > 0) |
10560 | 349 { |
350 pos += rk; | |
12047
6fbcdac049c6
added missing tuning parameters (inversion and coderate) and changed debug level in dvb_streaming_read()
nicodvb
parents:
11872
diff
changeset
|
351 mp_msg(MSGT_DEMUX, MSGL_DBG3, "ret (%d) bytes\n", pos); |
10560 | 352 } |
353 else | |
354 { | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
355 errno = 0; |
10560 | 356 mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_streaming_read, attempt N. %d failed with errno %d when reading %d bytes\n", tries, errno, size-pos); |
357 if(--tries > 0) | |
358 continue; | |
359 else | |
360 break; | |
361 } | |
362 } | |
9610 | 363 |
10560 | 364 if(! pos) |
365 mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_streaming_read, return %d bytes\n", pos); | |
9610 | 366 |
367 return pos; | |
368 } | |
369 | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
370 static void dvbin_close(stream_t *stream); |
10560 | 371 |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
372 int dvb_set_channel(dvb_priv_t *priv, int card, int n) |
10560 | 373 { |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
374 dvb_channels_list *new_list; |
10560 | 375 dvb_channel_t *channel; |
376 int do_tuning; | |
377 stream_t *stream = (stream_t*) priv->stream; | |
378 char buf[4096]; | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
379 dvb_config_t *conf = (dvb_config_t *) priv->config; |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
380 int devno; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
381 int i; |
9610 | 382 |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
383 if((card < 0) || (card > conf->count)) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
384 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
385 mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_set_channel: INVALID CARD NUMBER: %d vs %d, abort\n", card, conf->count); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
386 return 0; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
387 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
388 |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
389 devno = conf->cards[card].devno; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
390 new_list = conf->cards[card].list; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
391 if((n > new_list->NUM_CHANNELS) || (n < 0)) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
392 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
393 mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_set_channel: INVALID CHANNEL NUMBER: %d, for card %d, abort\n", n, card); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
394 return 0; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
395 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
396 channel = &(new_list->channels[n]); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
397 |
10560 | 398 if(priv->is_on) //the fds are already open and we have to stop the demuxers |
399 { | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
400 for(i = 0; i < priv->demux_fds_cnt; i++) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
401 dvb_demux_stop(priv->demux_fds[i]); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
402 |
10560 | 403 priv->retry = 0; |
11352 | 404 while(dvb_streaming_read(stream, buf, 4096) > 0); //empty both the stream's and driver's buffer |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
405 if(priv->card != card) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
406 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
407 dvbin_close(stream); |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
408 if(! dvb_open_devices(priv, devno, channel->pids_cnt, channel->pids)) |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
409 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
410 mp_msg(MSGT_DEMUX, MSGL_ERR, "DVB_SET_CHANNEL, COULDN'T OPEN DEVICES OF CARD: %d, EXIT\n", card); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
411 return 0; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
412 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
413 strcpy(priv->prev_tuning, ""); |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
414 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
415 else //close all demux_fds with pos > pids required for the new channel or open other demux_fds if we have too few |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
416 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
417 if(! dvb_fix_demuxes(priv, channel->pids_cnt, channel->pids)) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
418 return 0; |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
419 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
420 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
421 else |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
422 { |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
423 if(! dvb_open_devices(priv, devno, channel->pids_cnt, channel->pids)) |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
424 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
425 mp_msg(MSGT_DEMUX, MSGL_ERR, "DVB_SET_CHANNEL2, COULDN'T OPEN DEVICES OF CARD: %d, EXIT\n", card); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
426 return 0; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
427 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
428 strcpy(priv->prev_tuning, ""); |
10560 | 429 } |
430 | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
431 dvb_config->priv = priv; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
432 priv->card = card; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
433 priv->list = new_list; |
11352 | 434 priv->retry = 5; |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
435 new_list->current = n; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
436 stream->fd = priv->dvr_fd; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
437 mp_msg(MSGT_DEMUX, MSGL_V, "DVB_SET_CHANNEL: new channel name=%s, card: %d, channel %d\n", channel->name, card, n); |
10560 | 438 |
439 switch(priv->tuner_type) | |
440 { | |
441 case TUNER_SAT: | |
442 sprintf(priv->new_tuning, "%d|%09d|%09d|%d|%c", priv->card, channel->freq, channel->srate, channel->diseqc, channel->pol); | |
443 break; | |
9610 | 444 |
10560 | 445 case TUNER_TER: |
446 sprintf(priv->new_tuning, "%d|%09d|%d|%d|%d|%d|%d|%d", priv->card, channel->freq, channel->inv, | |
447 channel->bw, channel->cr, channel->mod, channel->trans, channel->gi); | |
448 break; | |
449 | |
450 case TUNER_CBL: | |
451 sprintf(priv->new_tuning, "%d|%09d|%d|%d|%d|%d", priv->card, channel->freq, channel->inv, channel->srate, | |
452 channel->cr, channel->mod); | |
453 break; | |
454 } | |
455 | |
456 | |
9610 | 457 |
10560 | 458 if(strcmp(priv->prev_tuning, priv->new_tuning)) |
459 { | |
460 mp_msg(MSGT_DEMUX, MSGL_V, "DIFFERENT TUNING THAN THE PREVIOUS: %s -> %s\n", priv->prev_tuning, priv->new_tuning); | |
461 strcpy(priv->prev_tuning, priv->new_tuning); | |
462 do_tuning = 1; | |
463 } | |
464 else | |
465 { | |
11352 | 466 mp_msg(MSGT_DEMUX, MSGL_V, "SAME TUNING PARAMETERS, NO TUNING\n"); |
10560 | 467 do_tuning = 0; |
468 } | |
469 | |
470 stream->eof=1; | |
471 stream_reset(stream); | |
472 | |
9610 | 473 |
10560 | 474 if(do_tuning) |
475 if (! dvb_tune(priv, channel->freq, channel->pol, channel->srate, channel->diseqc, channel->tone, | |
476 channel->inv, channel->mod, channel->gi, channel->trans, channel->bw, channel->cr)) | |
477 return 0; | |
478 | |
479 | |
480 priv->is_on = 1; | |
481 | |
482 //sets demux filters and restart the stream | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
483 for(i = 0; i < channel->pids_cnt; i++) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
484 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
485 if(! dvb_set_ts_filt(priv->demux_fds[i], channel->pids[i], DMX_PES_OTHER)) |
10560 | 486 return 0; |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
487 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
488 |
10560 | 489 return 1; |
490 } | |
491 | |
492 | |
9610 | 493 |
10560 | 494 int dvb_step_channel(dvb_priv_t *priv, int dir) |
495 { | |
496 int new_current; | |
497 dvb_channels_list *list; | |
498 | |
499 mp_msg(MSGT_DEMUX, MSGL_V, "DVB_STEP_CHANNEL dir %d\n", dir); | |
9610 | 500 |
10560 | 501 if(priv == NULL) |
502 { | |
503 mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_step_channel: NULL priv_ptr, quit\n"); | |
504 return 0; | |
505 } | |
9610 | 506 |
10560 | 507 list = priv->list; |
508 if(list == NULL) | |
509 { | |
510 mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_step_channel: NULL list_ptr, quit\n"); | |
511 return 0; | |
512 } | |
9610 | 513 |
10560 | 514 |
515 if(dir == DVB_CHANNEL_HIGHER) | |
516 { | |
517 if(list->current == list->NUM_CHANNELS-1) | |
518 return 0; | |
9610 | 519 |
10560 | 520 new_current = list->current + 1; |
521 } | |
522 else | |
523 { | |
524 if(list->current == 0) | |
525 return 0; | |
9610 | 526 |
10560 | 527 new_current = list->current - 1; |
528 } | |
529 | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
530 return dvb_set_channel(priv, priv->card, new_current); |
9610 | 531 } |
532 | |
533 | |
10560 | 534 |
535 | |
9610 | 536 extern char *get_path(char *); |
537 | |
10560 | 538 static void dvbin_close(stream_t *stream) |
9610 | 539 { |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
540 int i; |
10560 | 541 dvb_priv_t *priv = (dvb_priv_t *) stream->priv; |
9610 | 542 |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
543 for(i = priv->demux_fds_cnt-1; i >= 0; i--) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
544 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
545 priv->demux_fds_cnt--; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
546 mp_msg(MSGT_DEMUX, MSGL_V, "DVBIN_CLOSE, close(%d), fd=%d, COUNT=%d\n", i, priv->demux_fds[i], priv->demux_fds_cnt); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
547 close(priv->demux_fds[i]); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
548 } |
10560 | 549 close(priv->dvr_fd); |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
550 |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
551 close(priv->fe_fd); |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
552 #ifdef HAVE_DVB |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
553 close(priv->sec_fd); |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
554 #endif |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
555 |
10560 | 556 priv->is_on = 0; |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
557 dvb_config->priv = NULL; |
10560 | 558 } |
9610 | 559 |
560 | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
561 static int dvb_streaming_start(dvb_priv_t *priv, struct stream_priv_s *opts, int tuner_type, char *progname) |
10560 | 562 { |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
563 int i; |
10560 | 564 dvb_channel_t *channel = NULL; |
565 stream_t *stream = (stream_t*) priv->stream; | |
9610 | 566 |
567 | |
568 mp_msg(MSGT_DEMUX, MSGL_INFO, "code taken from dvbstream for mplayer v0.4pre1 - (C) Dave Chapman 2001\n"); | |
569 mp_msg(MSGT_DEMUX, MSGL_INFO, "Released under the GPL.\n"); | |
570 mp_msg(MSGT_DEMUX, MSGL_INFO, "Latest version available from http://www.linuxstb.org/\n"); | |
10560 | 571 mp_msg(MSGT_DEMUX, MSGL_V, "PROG: %s, CARD: %d, VID: %d, AID: %d, TYPE: %s, FILE: %s\n", |
572 opts->prog, opts->card, opts->vid, opts->aid, opts->type, opts->file); | |
9610 | 573 |
10560 | 574 priv->is_on = 0; |
9610 | 575 |
10560 | 576 i = 0; |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
577 while((channel == NULL) && i < priv->list->NUM_CHANNELS) |
10560 | 578 { |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
579 if(! strcmp(priv->list->channels[i].name, progname)) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
580 channel = &(priv->list->channels[i]); |
9610 | 581 |
10560 | 582 i++; |
583 } | |
9610 | 584 |
10560 | 585 if(channel != NULL) |
586 { | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
587 priv->list->current = i-1; |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12307
diff
changeset
|
588 mp_msg(MSGT_DEMUX, MSGL_V, "PROGRAM NUMBER %d: name=%s, freq=%u\n", i-1, channel->name, channel->freq); |
10560 | 589 } |
590 else | |
591 { | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
592 mp_msg(MSGT_DEMUX, MSGL_ERR, "\n\nDVBIN: no such channel \"%s\"\n\n", progname); |
10560 | 593 return 0; |
9610 | 594 } |
595 | |
596 | |
10560 | 597 strcpy(priv->prev_tuning, ""); |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
598 if(!dvb_set_channel(priv, priv->card, priv->list->current)) |
10560 | 599 { |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
600 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR, COULDN'T SET CHANNEL %i: ", priv->list->current); |
10560 | 601 dvbin_close(stream); |
602 return 0; | |
603 } | |
604 | |
605 mp_msg(MSGT_DEMUX, MSGL_V, "SUCCESSFUL EXIT from dvb_streaming_start\n"); | |
9610 | 606 |
607 return 1; | |
608 } | |
609 | |
610 | |
10560 | 611 |
612 | |
613 static int dvb_open(stream_t *stream, int mode, void *opts, int *file_format) | |
9610 | 614 { |
10560 | 615 // I don't force the file format bacause, although it's almost always TS, |
616 // there are some providers that stream an IP multicast with M$ Mpeg4 inside | |
617 struct stream_priv_s* p = (struct stream_priv_s*)opts; | |
618 dvb_priv_t *priv; | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
619 char *progname; |
11352 | 620 int tuner_type = 0; |
10560 | 621 |
622 | |
623 if(mode != STREAM_READ) | |
624 return STREAM_UNSUPORTED; | |
625 | |
626 stream->priv = (dvb_priv_t*) malloc(sizeof(dvb_priv_t)); | |
627 if(stream->priv == NULL) | |
628 return STREAM_ERROR; | |
629 | |
630 priv = (dvb_priv_t *)stream->priv; | |
631 priv->stream = stream; | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
632 dvb_config = dvb_get_config(); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
633 if(dvb_config == NULL) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
634 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
635 free(priv); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
636 mp_msg(MSGT_DEMUX, MSGL_ERR, "DVB CONFIGURATION IS EMPTY, exit\n"); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
637 return STREAM_ERROR; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
638 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
639 dvb_config->priv = priv; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
640 priv->config = dvb_config; |
10560 | 641 |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
642 if(p->card < 1 || p->card > priv->config->count) |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
643 { |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
644 free(priv); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
645 mp_msg(MSGT_DEMUX, MSGL_ERR, "NO CONFIGURATION FOUND FOR CARD N. %d, exit\n", p->card); |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
646 return STREAM_ERROR; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
647 } |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
648 priv->card = p->card - 1; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
649 |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
650 tuner_type = priv->config->cards[priv->card].type; |
10560 | 651 |
11352 | 652 if(tuner_type == 0) |
653 { | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
654 free(priv); |
11352 | 655 mp_msg(MSGT_DEMUX, MSGL_V, "OPEN_DVB: UNKNOWN OR UNDETECTABLE TUNER TYPE, EXIT\n"); |
656 return STREAM_ERROR; | |
657 } | |
658 | |
659 | |
10560 | 660 priv->tuner_type = tuner_type; |
661 | |
12108
06c4780332bc
disallow non-sense type parameter; added support for absolute file path; prefer channels.conf.{sat,ter,cbl} over channels.conf if the file is available
nicodvb
parents:
12047
diff
changeset
|
662 mp_msg(MSGT_DEMUX, MSGL_V, "OPEN_DVB: prog=%s, card=%d, type=%d, vid=%d, aid=%d\n", |
06c4780332bc
disallow non-sense type parameter; added support for absolute file path; prefer channels.conf.{sat,ter,cbl} over channels.conf if the file is available
nicodvb
parents:
12047
diff
changeset
|
663 p->prog, priv->card+1, priv->tuner_type, p->vid, p->aid); |
10560 | 664 |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
665 priv->list = priv->config->cards[priv->card].list; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
666 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
667 if((! strcmp(p->prog, "")) && (priv->list != NULL)) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
668 progname = priv->list->channels[0].name; |
10560 | 669 else |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
670 progname = p->prog; |
10560 | 671 |
672 | |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
673 if(! dvb_streaming_start(priv, p, tuner_type, progname)) |
10560 | 674 { |
675 free(stream->priv); | |
676 stream->priv = NULL; | |
677 return STREAM_ERROR; | |
678 } | |
679 | |
680 stream->type = STREAMTYPE_DVB; | |
681 stream->fill_buffer = dvb_streaming_read; | |
682 stream->close = dvbin_close; | |
683 m_struct_free(&stream_opts, opts); | |
684 | |
685 return STREAM_OK; | |
9610 | 686 } |
10560 | 687 |
12307
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
688 #define MAX_CARDS 4 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
689 dvb_config_t *dvb_get_config() |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
690 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
691 int i, fd, type, size; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
692 char filename[30], *conf_file, *name; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
693 dvb_channels_list *list; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
694 dvb_card_config_t *cards = NULL; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
695 dvb_config_t *conf = NULL; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
696 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
697 if(dvb_config != NULL) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
698 return dvb_config; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
699 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
700 conf = (dvb_config_t*) malloc(sizeof(dvb_config_t)); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
701 if(conf == NULL) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
702 return NULL; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
703 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
704 conf->priv = NULL; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
705 conf->count = 0; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
706 conf->cards = NULL; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
707 for(i=0; i<MAX_CARDS; i++) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
708 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
709 sprintf(filename, "/dev/dvb/adapter%d/frontend0", i); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
710 fd = open(filename, O_RDWR | O_NONBLOCK); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
711 if(fd < 0) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
712 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
713 mp_msg(MSGT_DEMUX, MSGL_V, "DVB_CONFIG, can't open device %s, skipping\n", filename); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
714 continue; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
715 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
716 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
717 type = dvb_get_tuner_type(fd); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
718 close(fd); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
719 if(type != TUNER_SAT && type != TUNER_TER && type != TUNER_CBL) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
720 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
721 mp_msg(MSGT_DEMUX, MSGL_V, "DVB_CONFIG, can't detect tuner type of card %d, skipping\n", i); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
722 continue; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
723 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
724 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
725 switch(type) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
726 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
727 case TUNER_TER: |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
728 conf_file = get_path("channels.conf.ter"); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
729 break; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
730 case TUNER_CBL: |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
731 conf_file = get_path("channels.conf.cbl"); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
732 break; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
733 case TUNER_SAT: |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
734 conf_file = get_path("channels.conf.sat"); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
735 break; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
736 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
737 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
738 if((access(conf_file, F_OK | R_OK) != 0)) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
739 conf_file = get_path("channels.conf"); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
740 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
741 list = dvb_get_channels(conf_file, type); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
742 if(list == NULL) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
743 continue; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
744 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
745 size = sizeof(dvb_card_config_t) * (conf->count + 1); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
746 cards = realloc(conf->cards, size); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
747 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
748 if(cards == NULL) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
749 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
750 fprintf(stderr, "DVB_CONFIG, can't realloc %d bytes, skipping\n", size); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
751 continue; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
752 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
753 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
754 name = (char*) malloc(20); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
755 if(name==NULL) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
756 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
757 fprintf(stderr, "DVB_CONFIG, can't realloc 20 bytes, skipping\n"); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
758 continue; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
759 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
760 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
761 conf->cards = cards; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
762 conf->cards[conf->count].devno = i; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
763 conf->cards[conf->count].list = list; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
764 conf->cards[conf->count].type = type; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
765 sprintf(name, "DVB-%c card n. %d", type==TUNER_TER ? 'T' : (type==TUNER_CBL ? 'C' : 'S'), conf->count+1); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
766 conf->cards[conf->count].name = name; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
767 conf->count++; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
768 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
769 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
770 if(conf->count == 0) |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
771 { |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
772 free(conf); |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
773 conf = NULL; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
774 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
775 |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
776 dvb_config = conf; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
777 return conf; |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
778 } |
44152bfdc002
new configuration structure, dvb_set_channel takes 2 parameters, 1000l memleak fix
nicodvb
parents:
12116
diff
changeset
|
779 |
10560 | 780 |
781 | |
782 stream_info_t stream_info_dvb = { | |
783 "Dvb Input", | |
784 "dvbin", | |
785 "Nico", | |
786 "based on the code from ??? (probably Arpi)", | |
787 dvb_open, | |
788 { "dvb", NULL }, | |
789 &stream_opts, | |
790 1 // Urls are an option string | |
791 }; | |
792 | |
793 | |
794 | |
795 |