blob: 4a29af77d5cd4a45e0e86aa3d40a5fef3662c99c [file] [log] [blame]
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +00001/*
2 * parsechannels.c -
3 * Copyright (C) 2008 Zaheer Abbas Merali
4 *
5 * Authors:
6 * Zaheer Abbas Merali <zaheerabbas at merali dot org>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
Tim-Philipp Müller9e1b75f2012-11-03 20:38:00 +000020 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000022 */
23
Tim-Philipp Müller3bacb632013-04-21 14:04:11 +010024#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000028#include <glib.h>
29#include <glib-object.h>
30#include <stdlib.h>
31#include <string.h>
32#include <gst/gst.h>
33
Tim-Philipp Müllerbd504e32013-04-21 18:28:52 +010034#include <gst/gst-i18n-plugin.h>
35
Benjamin Ottef96e4f12010-03-21 21:39:18 +010036#include "parsechannels.h"
37
Tim-Philipp Müllerfc2b5592013-04-21 14:13:45 +010038GST_DEBUG_CATEGORY_EXTERN (dvb_base_bin_debug);
39#define GST_CAT_DEFAULT dvb_base_bin_debug
40
Edward Herveyd7ad4ce2012-06-19 10:35:48 +020041/* TODO:
42 * Store the channels hash table around instead of constantly parsing it
43 * Detect when the file changed on disk
44 */
45
46/* this will do zap style channels.conf only for the moment */
Edward Hervey068598e2012-06-19 10:22:50 +020047static GHashTable *
Tim-Philipp Müllerbd504e32013-04-21 18:28:52 +010048parse_channels_conf_from_file (GstElement * dvbbasebin, const gchar * filename,
49 GError ** error)
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000050{
51 gchar *contents;
52 gchar **lines;
53 gchar *line;
54 gchar **fields;
Benjamin Otte33c2f5f2010-03-22 13:16:33 +010055 const gchar *terrestrial[] = { "inversion", "bandwidth",
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000056 "code-rate-hp", "code-rate-lp", "modulation", "transmission-mode",
57 "guard", "hierarchy"
58 };
Benjamin Otte33c2f5f2010-03-22 13:16:33 +010059 const gchar *satellite[] = { "polarity", "diseqc-source",
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000060 "symbol-rate"
61 };
Benjamin Otte33c2f5f2010-03-22 13:16:33 +010062 const gchar *cable[] = { "inversion", "symbol-rate", "code-rate-hp",
Zaheer Abbas Merali8be7f452008-03-01 12:49:13 +000063 "modulation"
64 };
Edward Herveyd7ad4ce2012-06-19 10:35:48 +020065 int i, parsedchannels = 0;
Edward Hervey068598e2012-06-19 10:22:50 +020066 GHashTable *res;
67 GError *err = NULL;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000068
Tim-Philipp Müller3bacb632013-04-21 14:04:11 +010069 GST_INFO_OBJECT (dvbbasebin, "parsing '%s'", filename);
70
Edward Hervey068598e2012-06-19 10:22:50 +020071 if (!g_file_get_contents (filename, &contents, NULL, &err))
72 goto open_fail;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000073
Edward Hervey068598e2012-06-19 10:22:50 +020074 lines = g_strsplit (contents, "\n", 0);
75 res = g_hash_table_new (g_str_hash, g_str_equal);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000076
Edward Hervey068598e2012-06-19 10:22:50 +020077 i = 0;
78 line = lines[0];
79 while (line != NULL) {
80 if (line[0] != '#') {
81 int numfields;
82 gboolean parsed = FALSE;
83 GHashTable *params = g_hash_table_new_full (g_str_hash, g_str_equal,
84 g_free, g_free);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000085
Edward Hervey068598e2012-06-19 10:22:50 +020086 fields = g_strsplit (line, ":", 0);
87 numfields = g_strv_length (fields);
88 if (numfields == 8) {
89 /* satellite */
90 int j;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000091
Edward Hervey068598e2012-06-19 10:22:50 +020092 g_hash_table_insert (params, g_strdup ("type"), g_strdup ("satellite"));
93 for (j = 2; j <= 4; j++) {
94 g_hash_table_insert (params, g_strdup (satellite[j - 2]),
95 g_strdup (fields[j]));
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +000096 }
Edward Hervey068598e2012-06-19 10:22:50 +020097 g_hash_table_insert (params, g_strdup ("frequency"),
98 g_strdup_printf ("%d", atoi (fields[1]) * 1000));
99 parsed = TRUE;
100 } else if (numfields == 13) {
101 /* terrestrial */
102 int j;
103
104 g_hash_table_insert (params, g_strdup ("type"),
105 g_strdup ("terrestrial"));
106 for (j = 2; j <= 9; j++) {
107 g_hash_table_insert (params, g_strdup (terrestrial[j - 2]),
108 g_strdup (fields[j]));
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000109 }
Edward Hervey068598e2012-06-19 10:22:50 +0200110 g_hash_table_insert (params, g_strdup ("frequency"),
111 g_strdup (fields[1]));
112 parsed = TRUE;
113 } else if (numfields == 9) {
114 /* cable */
115 int j;
116
117 g_hash_table_insert (params, g_strdup ("type"), g_strdup ("cable"));
118 for (j = 2; j <= 5; j++) {
119 g_hash_table_insert (params, g_strdup (cable[j - 2]),
120 g_strdup (fields[j]));
121 }
122 g_hash_table_insert (params, g_strdup ("frequency"),
123 g_strdup (fields[1]));
124 parsed = TRUE;
125 } else if (numfields == 6) {
126 /* atsc (vsb/qam) */
127 g_hash_table_insert (params, g_strdup ("type"), g_strdup ("atsc"));
128 g_hash_table_insert (params, g_strdup ("modulation"),
129 g_strdup (fields[2]));
130
131 g_hash_table_insert (params, g_strdup ("frequency"),
132 g_strdup (fields[1]));
133 parsed = TRUE;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000134 }
Edward Hervey068598e2012-06-19 10:22:50 +0200135 if (parsed) {
136 g_hash_table_insert (params, g_strdup ("sid"),
137 g_strdup (fields[numfields - 1]));
138 g_hash_table_insert (res, g_strdup (fields[0]), params);
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200139 parsedchannels++;
Edward Hervey068598e2012-06-19 10:22:50 +0200140 }
141 g_strfreev (fields);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000142 }
Edward Hervey068598e2012-06-19 10:22:50 +0200143 line = lines[++i];
144 }
145 g_strfreev (lines);
146 g_free (contents);
147
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200148 if (parsedchannels == 0)
149 goto no_channels;
150
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000151 return res;
Edward Hervey068598e2012-06-19 10:22:50 +0200152
153open_fail:
154 {
Tim-Philipp Müllerbd504e32013-04-21 18:28:52 +0100155 if (err->code == G_FILE_ERROR_NOENT) {
156 g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_NOT_FOUND,
157 _("Couldn't find DVB channel configuration file"));
158 } else {
159 g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_READ,
160 _("Couldn't load DVB channel configuration file: %s"), err->message);
161 }
Edward Hervey068598e2012-06-19 10:22:50 +0200162 g_clear_error (&err);
163 return NULL;
164 }
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200165
166no_channels:
167 {
Tim-Philipp Müllerbd504e32013-04-21 18:28:52 +0100168 g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
169 _("DVB channel configuration file doesn't contain any channels"));
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200170 g_hash_table_unref (res);
171 return NULL;
172 }
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000173}
174
175static gboolean
176remove_channel_from_hash (gpointer key, gpointer value, gpointer user_data)
177{
178 if (key)
179 g_free (key);
180 if (value)
181 g_hash_table_destroy ((GHashTable *) value);
182 return TRUE;
183}
184
185static void
186destroy_channels_hash (GHashTable * channels)
187{
188 g_hash_table_foreach_remove (channels, remove_channel_from_hash, NULL);
189}
190
191gboolean
Tim-Philipp Müllerbd504e32013-04-21 18:28:52 +0100192set_properties_for_channel (GstElement * dvbbasebin,
193 const gchar * channel_name, GError ** error)
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000194{
195 gboolean ret = FALSE;
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200196 GHashTable *channels, *params;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000197 gchar *filename;
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200198 gchar *type;
199 const gchar *adapter;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000200
201 filename = g_strdup (g_getenv ("GST_DVB_CHANNELS_CONF"));
202 if (filename == NULL) {
Tim-Philipp Müller3bacb632013-04-21 14:04:11 +0100203 filename = g_build_filename (g_get_user_config_dir (),
204 "gstreamer-" GST_API_VERSION, "dvb-channels.conf", NULL);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000205 }
Tim-Philipp Müllerbd504e32013-04-21 18:28:52 +0100206 channels = parse_channels_conf_from_file (dvbbasebin, filename, error);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000207 g_free (filename);
208
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200209 if (!channels)
210 goto beach;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000211
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200212 params = g_hash_table_lookup (channels, channel_name);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000213
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200214 if (!params)
215 goto unknown_channel;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000216
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200217 g_object_set (dvbbasebin, "program-numbers",
218 g_hash_table_lookup (params, "sid"), NULL);
219 /* check if it is terrestrial or satellite */
220 adapter = g_getenv ("GST_DVB_ADAPTER");
221 if (adapter)
222 g_object_set (dvbbasebin, "adapter", atoi (adapter), NULL);
223 g_object_set (dvbbasebin, "frequency",
224 atoi (g_hash_table_lookup (params, "frequency")), NULL);
225 type = g_hash_table_lookup (params, "type");
226 if (strcmp (type, "terrestrial") == 0) {
227 gchar *val;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000228
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200229 val = g_hash_table_lookup (params, "inversion");
230 if (strcmp (val, "INVERSION_OFF") == 0)
231 g_object_set (dvbbasebin, "inversion", 0, NULL);
232 else if (strcmp (val, "INVERSION_ON") == 0)
233 g_object_set (dvbbasebin, "inversion", 1, NULL);
234 else
235 g_object_set (dvbbasebin, "inversion", 2, NULL);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000236
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200237 val = g_hash_table_lookup (params, "bandwidth");
238 if (strcmp (val, "BANDWIDTH_8_MHZ") == 0)
239 g_object_set (dvbbasebin, "bandwidth", 0, NULL);
240 else if (strcmp (val, "BANDWIDTH_7_MHZ") == 0)
241 g_object_set (dvbbasebin, "bandwidth", 1, NULL);
242 else if (strcmp (val, "BANDWIDTH_6_MHZ") == 0)
243 g_object_set (dvbbasebin, "bandwidth", 2, NULL);
244 else
245 g_object_set (dvbbasebin, "bandwidth", 3, NULL);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000246
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200247 val = g_hash_table_lookup (params, "code-rate-hp");
248 if (strcmp (val, "FEC_NONE") == 0)
249 g_object_set (dvbbasebin, "code-rate-hp", 0, NULL);
250 else if (strcmp (val, "FEC_1_2") == 0)
251 g_object_set (dvbbasebin, "code-rate-hp", 1, NULL);
252 else if (strcmp (val, "FEC_2_3") == 0)
253 g_object_set (dvbbasebin, "code-rate-hp", 2, NULL);
254 else if (strcmp (val, "FEC_3_4") == 0)
255 g_object_set (dvbbasebin, "code-rate-hp", 3, NULL);
256 else if (strcmp (val, "FEC_4_5") == 0)
257 g_object_set (dvbbasebin, "code-rate-hp", 4, NULL);
258 else if (strcmp (val, "FEC_5_6") == 0)
259 g_object_set (dvbbasebin, "code-rate-hp", 5, NULL);
260 else if (strcmp (val, "FEC_6_7") == 0)
261 g_object_set (dvbbasebin, "code-rate-hp", 6, NULL);
262 else if (strcmp (val, "FEC_7_8") == 0)
263 g_object_set (dvbbasebin, "code-rate-hp", 7, NULL);
264 else if (strcmp (val, "FEC_8_9") == 0)
265 g_object_set (dvbbasebin, "code-rate-hp", 8, NULL);
266 else
267 g_object_set (dvbbasebin, "code-rate-hp", 9, NULL);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000268
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200269 val = g_hash_table_lookup (params, "code-rate-lp");
270 if (strcmp (val, "FEC_NONE") == 0)
271 g_object_set (dvbbasebin, "code-rate-lp", 0, NULL);
272 else if (strcmp (val, "FEC_1_2") == 0)
273 g_object_set (dvbbasebin, "code-rate-lp", 1, NULL);
274 else if (strcmp (val, "FEC_2_3") == 0)
275 g_object_set (dvbbasebin, "code-rate-lp", 2, NULL);
276 else if (strcmp (val, "FEC_3_4") == 0)
277 g_object_set (dvbbasebin, "code-rate-lp", 3, NULL);
278 else if (strcmp (val, "FEC_4_5") == 0)
279 g_object_set (dvbbasebin, "code-rate-lp", 4, NULL);
280 else if (strcmp (val, "FEC_5_6") == 0)
281 g_object_set (dvbbasebin, "code-rate-lp", 5, NULL);
282 else if (strcmp (val, "FEC_6_7") == 0)
283 g_object_set (dvbbasebin, "code-rate-lp", 6, NULL);
284 else if (strcmp (val, "FEC_7_8") == 0)
285 g_object_set (dvbbasebin, "code-rate-lp", 7, NULL);
286 else if (strcmp (val, "FEC_8_9") == 0)
287 g_object_set (dvbbasebin, "code-rate-lp", 8, NULL);
288 else
289 g_object_set (dvbbasebin, "code-rate-lp", 9, NULL);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000290
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200291 val = g_hash_table_lookup (params, "modulation");
292 if (strcmp (val, "QPSK") == 0)
293 g_object_set (dvbbasebin, "modulation", 0, NULL);
294 else if (strcmp (val, "QAM_16") == 0)
295 g_object_set (dvbbasebin, "modulation", 1, NULL);
296 else if (strcmp (val, "QAM_32") == 0)
297 g_object_set (dvbbasebin, "modulation", 2, NULL);
298 else if (strcmp (val, "QAM_64") == 0)
299 g_object_set (dvbbasebin, "modulation", 3, NULL);
300 else if (strcmp (val, "QAM_128") == 0)
301 g_object_set (dvbbasebin, "modulation", 4, NULL);
302 else if (strcmp (val, "QAM_256") == 0)
303 g_object_set (dvbbasebin, "modulation", 5, NULL);
304 else
305 g_object_set (dvbbasebin, "modulation", 6, NULL);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000306
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200307 val = g_hash_table_lookup (params, "transmission-mode");
308 if (strcmp (val, "TRANSMISSION_MODE_2K") == 0)
309 g_object_set (dvbbasebin, "trans-mode", 0, NULL);
310 else if (strcmp (val, "TRANSMISSION_MODE_8K") == 0)
311 g_object_set (dvbbasebin, "trans-mode", 1, NULL);
312 else
313 g_object_set (dvbbasebin, "trans-mode", 2, NULL);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000314
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200315 val = g_hash_table_lookup (params, "guard");
316 if (strcmp (val, "GUARD_INTERVAL_1_32") == 0)
317 g_object_set (dvbbasebin, "guard", 0, NULL);
318 else if (strcmp (val, "GUARD_INTERVAL_1_16") == 0)
319 g_object_set (dvbbasebin, "guard", 1, NULL);
320 else if (strcmp (val, "GUARD_INTERVAL_1_8") == 0)
321 g_object_set (dvbbasebin, "guard", 2, NULL);
322 else if (strcmp (val, "GUARD_INTERVAL_1_4") == 0)
323 g_object_set (dvbbasebin, "guard", 3, NULL);
324 else
325 g_object_set (dvbbasebin, "guard", 4, NULL);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000326
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200327 val = g_hash_table_lookup (params, "hierarchy");
328 if (strcmp (val, "HIERARCHY_NONE") == 0)
329 g_object_set (dvbbasebin, "hierarchy", 0, NULL);
330 else if (strcmp (val, "HIERARCHY_1") == 0)
331 g_object_set (dvbbasebin, "hierarchy", 1, NULL);
332 else if (strcmp (val, "HIERARCHY_2") == 0)
333 g_object_set (dvbbasebin, "hierarchy", 2, NULL);
334 else if (strcmp (val, "HIERARCHY_4") == 0)
335 g_object_set (dvbbasebin, "hierarchy", 3, NULL);
336 else
337 g_object_set (dvbbasebin, "hierarchy", 4, NULL);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000338
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200339 ret = TRUE;
340 } else if (strcmp (type, "satellite") == 0) {
341 gchar *val;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000342
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200343 ret = TRUE;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000344
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200345 val = g_hash_table_lookup (params, "polarity");
346 if (val)
347 g_object_set (dvbbasebin, "polarity", val, NULL);
348 else
349 ret = FALSE;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000350
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200351 val = g_hash_table_lookup (params, "diseqc-source");
352 if (val)
353 g_object_set (dvbbasebin, "diseqc-source", atoi (val), NULL);
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000354
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200355 val = g_hash_table_lookup (params, "symbol-rate");
356 if (val)
357 g_object_set (dvbbasebin, "symbol-rate", atoi (val), NULL);
358 else
359 ret = FALSE;
360 } else if (strcmp (type, "cable") == 0) {
361 gchar *val;
Michael Krufkye2c08fe2008-08-18 11:13:07 +0000362
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200363 ret = TRUE;
364 val = g_hash_table_lookup (params, "symbol-rate");
365 if (val)
366 g_object_set (dvbbasebin, "symbol-rate", atoi (val) / 1000, NULL);
367 val = g_hash_table_lookup (params, "modulation");
368 if (strcmp (val, "QPSK") == 0)
369 g_object_set (dvbbasebin, "modulation", 0, NULL);
370 else if (strcmp (val, "QAM_16") == 0)
371 g_object_set (dvbbasebin, "modulation", 1, NULL);
372 else if (strcmp (val, "QAM_32") == 0)
373 g_object_set (dvbbasebin, "modulation", 2, NULL);
374 else if (strcmp (val, "QAM_64") == 0)
375 g_object_set (dvbbasebin, "modulation", 3, NULL);
376 else if (strcmp (val, "QAM_128") == 0)
377 g_object_set (dvbbasebin, "modulation", 4, NULL);
378 else if (strcmp (val, "QAM_256") == 0)
379 g_object_set (dvbbasebin, "modulation", 5, NULL);
380 else
381 g_object_set (dvbbasebin, "modulation", 6, NULL);
382 val = g_hash_table_lookup (params, "code-rate-hp");
383 if (strcmp (val, "FEC_NONE") == 0)
384 g_object_set (dvbbasebin, "code-rate-hp", 0, NULL);
385 else if (strcmp (val, "FEC_1_2") == 0)
386 g_object_set (dvbbasebin, "code-rate-hp", 1, NULL);
387 else if (strcmp (val, "FEC_2_3") == 0)
388 g_object_set (dvbbasebin, "code-rate-hp", 2, NULL);
389 else if (strcmp (val, "FEC_3_4") == 0)
390 g_object_set (dvbbasebin, "code-rate-hp", 3, NULL);
391 else if (strcmp (val, "FEC_4_5") == 0)
392 g_object_set (dvbbasebin, "code-rate-hp", 4, NULL);
393 else if (strcmp (val, "FEC_5_6") == 0)
394 g_object_set (dvbbasebin, "code-rate-hp", 5, NULL);
395 else if (strcmp (val, "FEC_6_7") == 0)
396 g_object_set (dvbbasebin, "code-rate-hp", 6, NULL);
397 else if (strcmp (val, "FEC_7_8") == 0)
398 g_object_set (dvbbasebin, "code-rate-hp", 7, NULL);
399 else if (strcmp (val, "FEC_8_9") == 0)
400 g_object_set (dvbbasebin, "code-rate-hp", 8, NULL);
401 else
402 g_object_set (dvbbasebin, "code-rate-hp", 9, NULL);
403 val = g_hash_table_lookup (params, "inversion");
404 if (strcmp (val, "INVERSION_OFF") == 0)
405 g_object_set (dvbbasebin, "inversion", 0, NULL);
406 else if (strcmp (val, "INVERSION_ON") == 0)
407 g_object_set (dvbbasebin, "inversion", 1, NULL);
408 else
409 g_object_set (dvbbasebin, "inversion", 2, NULL);
410 } else if (strcmp (type, "atsc") == 0) {
411 gchar *val;
Michael Krufkye2c08fe2008-08-18 11:13:07 +0000412
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200413 ret = TRUE;
414
415 val = g_hash_table_lookup (params, "modulation");
416 if (strcmp (val, "QAM_64") == 0)
417 g_object_set (dvbbasebin, "modulation", 3, NULL);
418 else if (strcmp (val, "QAM_256") == 0)
419 g_object_set (dvbbasebin, "modulation", 5, NULL);
420 else if (strcmp (val, "8VSB") == 0)
421 g_object_set (dvbbasebin, "modulation", 7, NULL);
422 else if (strcmp (val, "16VSB") == 0)
423 g_object_set (dvbbasebin, "modulation", 8, NULL);
424 else
425 ret = FALSE;
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000426 }
427
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200428 destroy_channels_hash (channels);
429
430beach:
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000431 return ret;
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200432
433unknown_channel:
434 {
Tim-Philipp Müllerbd504e32013-04-21 18:28:52 +0100435 /* FIXME: is channel name guaranteed to be ASCII or UTF-8? */
436 g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_NOT_FOUND,
437 _("Couldn't find details for DVB channel %s"), channel_name);
Edward Herveyd7ad4ce2012-06-19 10:35:48 +0200438 destroy_channels_hash (channels);
439 return FALSE;
440 }
Zaheer Abbas Merali1316ad42008-02-08 18:22:08 +0000441}