Statistics
| Branch: | Tag: | Revision:

dvbd / src / connection.h @ 59be6a47

History | View | Annotate | Download (2.37 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 __CONNECTION_H
21
#define __CONNECTION_H
22

    
23
#include "source.h"
24
#include "tunermanager.h"
25
#include "stringrep.h"
26

    
27
#include <string>
28

    
29
class InputBuffer;
30
class OutputBuffer;
31
class Scheduler;
32

    
33
class Connection : public Sink, public Selectable, public StringRep {
34
public:
35
  Connection(TunerManager *tm, int dataFD);
36
  virtual ~Connection();
37

    
38
  virtual void addSelectFDs(Select &) const;
39
  virtual bool isReady(const Select &) const;
40

    
41
  virtual bool processReady(const Select &s);
42

    
43
  virtual void receiveData(unsigned char *data, unsigned size);
44

    
45
  virtual void notifyUnsubscribe(Source *s);
46
  virtual int getPriority() const;
47
  virtual void setPriority(int p);
48

    
49
  void setStopTime(time_t);
50
  time_t getStopTime() const;
51

    
52
  bool canTune(const std::string &newType, const std::string &newChannel, int p) const;
53
  bool tune(const std::string &newType, const std::string &newChannel, bool convertToPS, int p);
54

    
55
  bool getInterrupted() const;
56

    
57
private:
58
  bool doSubscribe();
59
  void doUnsubscribe();
60

    
61
protected:
62
  bool isValidType(const std::string &type) const;
63
  bool isValidChannel(const std::string &type, const std::string &channel) const;
64
  void getTunableChannels(const std::string &type, int priority, StringList &channels) const;
65

    
66
  bool isRetuning() const;
67
  bool numDemuxers() const;
68

    
69
  void setRemoveMe(bool status);
70

    
71
  time_t getCurrentTime() const;
72

    
73
  virtual std::ostream& printOn(std::ostream &) const;
74

    
75
private:
76
  int dataFD;
77
  int priority;
78
  bool tuned;
79
  bool retuning;
80
  TunerManager *tm;
81
  std::string channel, type;
82
  OutputBuffer *dataOutput;
83
  SourceList demuxers;
84
  bool removeMe;
85
  time_t stopTime;
86
  bool interrupted;
87
};
88

    
89

    
90
#endif // __CONNECTION_H