Statistics
| Branch: | Tag: | Revision:

dvbd / src / tuner.h @ a24dbbce

History | View | Annotate | Download (2.45 KB)

1
// -*- 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
#include "timer.h"
27

    
28
#include <string>
29
#include <map>
30

    
31
class TuneParams;
32
class Demuxer;
33
class PSFilter;
34

    
35
class Tuner : public Source, public Selectable {
36
public:
37
  Tuner( const std::string &frontendDevice );
38
  virtual ~Tuner();
39

    
40
  const TuneParams *getTuneParams() const { return tuneParams; };
41
  void setTuneParams(const TuneParams *tuneParams);
42

    
43
  // Returns the corresponding demuxer device
44
  // to the frontendDevice
45
  std::string getDemuxerDevice() const { return demuxDevice; };
46

    
47
  virtual void addSelectFDs(Select &) const;
48
  virtual bool isReady(const Select &) const;
49

    
50
  Source *getDemuxer(int pid, bool convertToPS, Demuxer::PESType pesType) const;
51

    
52
  int getMaxNumSubscribers() const { return 8; }
53
  virtual bool subscribe(Sink *s);
54
  virtual void unsubscribe(Sink *s);
55

    
56
  // Process the data from the dvr device
57
  void process();
58

    
59
protected:
60
  virtual Demuxer *makeNewDemuxer(int pid, Demuxer::PESType pesType) const;
61
  virtual bool openFrontend();
62
  virtual void closeFrontend();
63
  virtual bool openDvr();
64
  virtual void closeDvr();
65
  virtual bool tune();
66

    
67
private:
68
  static void reallyCloseFrontendCallback(void *);
69

    
70
private:
71
  int numReaders;
72
  int frontendFD, dvrFD;
73
  const TuneParams *tuneParams, *oldTuneParams;
74
  std::string frontendDevice, demuxDevice, dvrDevice;
75

    
76
  Timer closeTimer;
77
  
78
  // Keep a track of all the demuxers ever created.
79
  // The Tuner owns the demuxers.
80

    
81
  typedef std::map <int, Demuxer *> PIDMap;
82
  typedef std::map <const TuneParams *, PIDMap> DemuxerMap;
83
  typedef std::map <Demuxer *, PSFilter *> PSFilterMap;
84

    
85
  mutable DemuxerMap demuxerMap;
86
  mutable PSFilterMap psfilterMap;
87

    
88
};
89

    
90
#endif // __TUNER_H