]> git.vomp.tv Git - vompserver.git/blob - mvpreceiver.h
Replacement transceiver and use of new thread class (from client!)
[vompserver.git] / mvpreceiver.h
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #ifndef MVPRECEIVER_H
22 #define MVPRECEIVER_H
23
24 #include <vdr/channels.h>
25 #include <vdr/device.h>
26 #include <vdr/receiver.h>
27 #include <vdr/ringbuffer.h>
28
29 #include "tsremux.h"
30 #include "ts2es.h"
31 #include "ts2ps.h"
32
33 #include "log.h"
34 #include "thread.h"
35 #include "ringbuffer.h"
36
37 class MVPReceiver : public cReceiver, public Thread
38 {
39   public:
40     static MVPReceiver* create(cChannel*);
41     virtual ~MVPReceiver();
42     int init();
43     unsigned long getBlock(unsigned char* buffer, unsigned long amount);
44     bool isVdrActivated();
45
46   private:
47     MVPReceiver(cChannel* channel, cDevice* device);
48     void threadMethod();
49
50     Log* logger;
51     bool vdrActivated;
52     int inittedOK;
53     cTSRemux* remuxer;
54     cRingBufferLinear* unprocessed; // A VDR ring buffer used for the unprocessed data
55                                     // it doesn't delete until told and does its own locking
56     Ringbuffer processed;    // A simpler deleting ringbuffer for processed data
57     pthread_mutex_t processedRingLock; // needs outside locking
58
59     // cReciever stuff
60     void Activate(bool On);
61     void Receive(UCHAR *Data, int Length);
62 };
63
64 #endif
65
66
67 /*
68     cReceiver docs from the header file
69
70     void Activate(bool On);
71       // This function is called just before the cReceiver gets attached to
72       // (On == true) or detached from (On == false) a cDevice. It can be used
73       // to do things like starting/stopping a thread.
74       // It is guaranteed that Receive() will not be called before Activate(true).
75     void Receive(uchar *Data, int Length);
76       // This function is called from the cDevice we are attached to, and
77       // delivers one TS packet from the set of PIDs the cReceiver has requested.
78       // The data packet must be accepted immediately, and the call must return
79       // as soon as possible, without any unnecessary delay. Each TS packet
80       // will be delivered only ONCE, so the cReceiver must make sure that
81       // it will be able to buffer the data if necessary.
82
83 */
84
85 /*
86
87   cDevice docs
88
89   static cDevice *GetDevice(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL);
90      ///< Returns a device that is able to receive the given Channel at the
91      ///< given Priority.
92      ///< See ProvidesChannel() for more information on how
93      ///< priorities are handled, and the meaning of NeedsDetachReceivers.
94
95 */