Statistics
| Branch: | Tag: | Revision:

dvbd / src / tuner.h @ 2cecea08

History | View | Annotate | Download (2.3 KB)

1 bfdb7446 jak
// -*- c++ -*-
2
/*
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
#if !defined __TUNER_H
21
#define __TUNER_H
22
23
#include "source.h"
24
#include "select.h"
25
#include "demuxer.h"
26
27
#include <string>
28
#include <map>
29
30
class TuneParams;
31
class Demuxer;
32
33
class Tuner : public Source, public Selectable {
34
public:
35
  Tuner( const std::string &frontendDevice );
36
  virtual ~Tuner();
37
38
  const TuneParams *getTuneParams() const { return tuneParams; };
39
  void setTuneParams(const TuneParams *tuneParams);
40
41
  // Returns the corresponding demuxer device
42
  // to the frontendDevice
43
  std::string getDemuxerDevice() const { return demuxDevice; };
44
45
  virtual void addSelectFDs(Select &) const;
46
  virtual bool isReady(const Select &) const;
47
48 2cecea08 jak
  Demuxer *getDemuxer(int pid, bool convertToPS, Demuxer::PESType pesType) const;
49 bfdb7446 jak
50
  int getMaxNumSubscribers() const { return 8; }
51
  virtual bool subscribe(Sink *s);
52
  virtual void unsubscribe(Sink *s);
53
54
  // Process the data from the dvr device
55
  void process();
56
57
protected:
58 2cecea08 jak
  virtual Demuxer *makeNewDemuxer(int pid, bool convertToPS, Demuxer::PESType pesType) const;
59 bfdb7446 jak
  virtual bool openFrontend();
60
  virtual void closeFrontend();
61
  virtual bool openDvr();
62
  virtual void closeDvr();
63
  virtual bool tune();
64
65
private:
66
  int numReaders;
67
  int frontendFD, dvrFD;
68
  const TuneParams *tuneParams;
69
  std::string frontendDevice, demuxDevice, dvrDevice;
70
  
71
  // Keep a track of all the demuxers ever created.
72
  // The Tuner owns the demuxers.
73
74
  typedef std::map <int, Demuxer *> PIDMap;
75
  typedef std::map <const TuneParams *, PIDMap> DemuxerMap;
76
77 2cecea08 jak
  // demuxerMap[0] for TS
78
  // demuxerMap[1] for PS
79
  mutable DemuxerMap demuxerMap[2];
80 bfdb7446 jak
};
81
82
#endif // __TUNER_H