Statistics
| Branch: | Tag: | Revision:

dvbd / src / dvbctuneparams.cpp @ 23bc8293

History | View | Annotate | Download (2.67 KB)

1
/*
2
  Copyright 2004 John Knottenbelt
3
  
4
  This program is free software; you can redistribute it and/or modify
5
  it under the terms of the GNU General Public License as published by
6
  the Free Software Foundation; either version 2 of the License, or
7
  (at your option) any later version.
8
 
9
  This program is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
 
14
  You should have received a copy of the GNU General Public License
15
  along with this program; if not, write to the Free Software
16
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17
*/
18

    
19
#include "config.h"
20
#include "tuneparams.h"
21
#include "dvbtuneparamscommon.h"
22
#include "stringutil.h"
23

    
24
#include <map>
25
#include <iostream>
26
#include <cstdlib>
27
#include "tune.h"
28

    
29
// DVB-T Tuning Parameters 
30

    
31
DVBCTuneParams::DVBCTuneParams(const std::string &name, int apid, int vpid)
32
  : TuneParams(name, apid, vpid),
33
    freq(0),
34
    inv(INVERSION_OFF),
35
    sr(0),
36
    fec(HP_CODERATE_DEFAULT)
37
{
38
}
39

    
40
DVBCTuneParams::~DVBCTuneParams()
41
{
42
}
43

    
44
DVBCTuneParams *DVBCTuneParams::createFromCZAP(const std::string &line)
45
{
46
  // It is assumed that the line is a valid CZAP 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[6]);
54
  int apid = toUnsignedLong(v[7]);
55

    
56
  DVBCTuneParams *p = new DVBCTuneParams(newName, vpid, apid);
57
  p->freq = toUnsignedLong(v[1]);
58
  p->inv = translateTuneParam(v[2]);
59
  p->sr = toUnsignedLong(v[3]);
60
  p->fec = translateTuneParam(v[4]);
61
  p->qam = translateTuneParam(v[5]);
62
  return p;
63
}
64

    
65
bool DVBCTuneParams::tune(int frontendFD) const
66
{
67
  // Possible todo:
68
  // Change tune_it to observe lower code rate (fec2)
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, 
75
                     sr,               // Symbol Rate for DVB-C or DVB-S 
76
                     0,                // Polarity 
77
                     -1,        // Tone  
78
                     fe_spectral_inversion_t(inv), 
79
                     0,                // diseqc 
80
                     fe_modulation_t(qam),
81
                     fe_code_rate_t(fec),
82
                     TRANSMISSION_MODE_DEFAULT,
83
                     GUARD_INTERVAL_DEFAULT,
84
                     BANDWIDTH_DEFAULT);
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 DVBCTuneParams::sameAsExceptPIDs(const TuneParams &other) const
95
{
96
  const DVBCTuneParams &x = dynamic_cast<const DVBCTuneParams&>(other);
97

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