Statistics
| Branch: | Tag: | Revision:

dvbd / src / dvbctuneparams.cpp @ a24dbbce

History | View | Annotate | Download (2.7 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
                     freq, 
74
                     sr,               // Symbol Rate for DVB-C or DVB-S 
75
                     0,                // Polarity 
76
                     -1,        // Tone  
77
                     fe_spectral_inversion_t(inv), 
78
                     0,                // diseqc 
79
                     fe_modulation_t(qam),
80
                     fe_code_rate_t(fec),
81
                     TRANSMISSION_MODE_DEFAULT,
82
                     GUARD_INTERVAL_DEFAULT,
83
                     BANDWIDTH_DEFAULT,
84
                     LP_CODERATE_DEFAULT,
85
                     HIERARCHY_DEFAULT);
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 DVBCTuneParams::sameAsExceptPIDs(const TuneParams &other) const
96
{
97
  const DVBCTuneParams &x = dynamic_cast<const DVBCTuneParams&>(other);
98

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