dvbd / src / dvbstuneparams.cpp @ a24dbbce
History | View | Annotate | Download (2.65 KB)
1 |
/*
|
---|---|
2 |
Copyright 2004 Tobias Eckert
|
3 |
Copyright 2003 John Knottenbelt
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
7 |
the Free Software Foundation; either version 2 of the License, or
|
8 |
(at your option) any later version.
|
9 |
|
10 |
This program is distributed in the hope that it will be useful,
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
GNU General Public License for more details.
|
14 |
|
15 |
You should have received a copy of the GNU General Public License
|
16 |
along with this program; if not, write to the Free Software
|
17 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
18 |
*/
|
19 |
|
20 |
#include "config.h" |
21 |
#include "tuneparams.h" |
22 |
#include "stringutil.h" |
23 |
|
24 |
#include <map> |
25 |
#include <iostream> |
26 |
#include <cstdlib> |
27 |
#include "tune.h" |
28 |
|
29 |
// DVB-S Tuning Parameters
|
30 |
|
31 |
DVBSTuneParams::DVBSTuneParams(const std::string &name, int apid, int vpid) |
32 |
: TuneParams(name, apid, vpid), |
33 |
freq(0),
|
34 |
sr(0),
|
35 |
sat_no(0),
|
36 |
pol(0)
|
37 |
{ |
38 |
} |
39 |
|
40 |
DVBSTuneParams::~DVBSTuneParams() |
41 |
{ |
42 |
} |
43 |
|
44 |
DVBSTuneParams *DVBSTuneParams::createFromSZAP(const std::string &line) |
45 |
{ |
46 |
// It is assumed that the line is a valid SZAP conf line
|
47 |
// (not a comment)
|
48 |
|
49 |
std::vector<std::string> v;
|
50 |
splitString(line, ':', v);
|
51 |
|
52 |
std::string newName = v[0]; |
53 |
int vpid = toUnsignedLong(v[5]); |
54 |
int apid = toUnsignedLong(v[6]); |
55 |
|
56 |
DVBSTuneParams *p = new DVBSTuneParams(newName, vpid, apid);
|
57 |
p->freq = toUnsignedLong(v[1]) * 1000; |
58 |
p->pol = ((v[2] == "h") ? 0 : 1); |
59 |
p->sat_no = toUnsignedLong(v[3]);
|
60 |
p->sr = toUnsignedLong(v[4]) * 1000; |
61 |
|
62 |
return p;
|
63 |
} |
64 |
|
65 |
bool DVBSTuneParams::tune(int frontendFD) const |
66 |
{ |
67 |
char polarity;
|
68 |
polarity = ((pol == 0) ? 'h' : 'v'); |
69 |
|
70 |
// Give it three goes at least!
|
71 |
for (int i = 0; i < 3; i++) { |
72 |
int rc = tune_it(frontendFD,
|
73 |
freq, // frequency to tune to
|
74 |
sr, // Symbol Rate for DVB-C or DVB-S
|
75 |
polarity, // Polarity
|
76 |
-1, // Tone |
77 |
fe_spectral_inversion_t(0),
|
78 |
0, // diseqc |
79 |
fe_modulation_t(0),
|
80 |
fe_code_rate_t(0),
|
81 |
fe_transmit_mode_t(0),
|
82 |
fe_guard_interval_t(0),
|
83 |
fe_bandwidth_t(0),
|
84 |
fe_code_rate_t(0),
|
85 |
fe_hierarchy_t(0)
|
86 |
); |
87 |
if (rc >= 0) |
88 |
return true; |
89 |
} |
90 |
|
91 |
std::cerr << "Fatal error: failed to tune channel " << name << "\n"; |
92 |
return false; |
93 |
} |
94 |
|
95 |
bool DVBSTuneParams::sameAsExceptPIDs(const TuneParams &other) const |
96 |
{ |
97 |
const DVBSTuneParams &x = dynamic_cast<const DVBSTuneParams&>(other); |
98 |
|
99 |
if (&x == NULL) |
100 |
return false; |
101 |
|
102 |
return (freq == x.freq &&
|
103 |
pol == x.pol && |
104 |
sat_no == x.sat_no && |
105 |
sr == x.sr |
106 |
); |
107 |
} |