Statistics
| Branch: | Tag: | Revision:

dvbd / src / dvbstuneparams.cpp @ 904d298f

History | View | Annotate | Download (2.62 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
                     0,                // old fd_sec 
74
                     freq,       // frequency to tune to
75
                     sr,        // Symbol Rate for DVB-C or DVB-S 
76
                     polarity,        // Polarity 
77
                     -1,        // Tone  
78
                     fe_spectral_inversion_t(0), 
79
                     0,                // diseqc
80
                     fe_modulation_t(0),
81
                     fe_code_rate_t(0), 
82
                     fe_transmit_mode_t(0),
83
                     fe_guard_interval_t(0), 
84
                     fe_bandwidth_t(0)
85
    );
86
    if (rc >= 0)
87
      return true;
88
  }
89

    
90
  std::cerr << "Fatal error: failed to tune channel " << name << "\n";
91
  return false;
92
}
93

    
94
bool DVBSTuneParams::sameAsExceptPIDs(const TuneParams &other) const
95
{
96
  const DVBSTuneParams &x = dynamic_cast<const DVBSTuneParams&>(other);
97

    
98
  if (&x == NULL)
99
    return false;
100
 
101
  return (freq == x.freq &&
102
          pol  == x.pol &&
103
          sat_no == x.sat_no &&
104
          sr == x.sr
105
  );
106
}