]> git.vomp.tv Git - vompserver.git/blob - mvpreceiver.h
Live TV teletext mods
[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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 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
28 #include "log.h"
29 #include "thread.h"
30 #include "ringbuffer.h"
31 #include "tcp.h"
32 #include "thread.h"
33
34 class MVPReceiver : public cReceiver, public Thread
35 {
36   public:
37     static MVPReceiver* create(cChannel*, int priority);
38     virtual ~MVPReceiver();
39     int init(TCP* tcp, ULONG streamID);
40     bool isVdrActivated();
41
42   private:
43     MVPReceiver(cChannel* channel, cDevice* device);
44
45     Log* logger;
46     bool vdrActivated;
47     int inittedOK;
48     Ringbuffer processed;    // A simpler deleting ringbuffer for processed data
49     pthread_mutex_t processedRingLock; // needs outside locking
50
51     TCP* tcp;
52     ULONG streamID;
53     ULONG streamDataCollected;
54     int streamChunkSize;
55
56     // cReciever stuff
57     void Activate(bool On);
58     void Receive(UCHAR *Data, int Length);
59     void sendStreamEnd();
60
61     static int numMVPReceivers;
62     
63   protected:
64     void threadMethod();
65     int *mergeSpidsTpid(const int *spids,int tpid);
66     int  mergedSpidsTpid[MAXSPIDS+2];
67 };
68
69 #endif
70
71
72 /*
73     cReceiver docs from the header file
74
75     void Activate(bool On);
76       // This function is called just before the cReceiver gets attached to
77       // (On == true) or detached from (On == false) a cDevice. It can be used
78       // to do things like starting/stopping a thread.
79       // It is guaranteed that Receive() will not be called before Activate(true).
80     void Receive(uchar *Data, int Length);
81       // This function is called from the cDevice we are attached to, and
82       // delivers one TS packet from the set of PIDs the cReceiver has requested.
83       // The data packet must be accepted immediately, and the call must return
84       // as soon as possible, without any unnecessary delay. Each TS packet
85       // will be delivered only ONCE, so the cReceiver must make sure that
86       // it will be able to buffer the data if necessary.
87
88 */
89
90 /*
91
92   cDevice docs
93
94 (VDR 1.4)
95   static cDevice *GetDevice(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL);
96      ///< Returns a device that is able to receive the given Channel at the
97      ///< given Priority.
98      ///< See ProvidesChannel() for more information on how
99      ///< priorities are handled, and the meaning of NeedsDetachReceivers.
100
101 (VDR >1.5)
102   static cDevice *GetDevice(const cChannel *Channel, int Priority, bool LiveView);
103      ///< Returns a device that is able to receive the given Channel at the
104      ///< given Priority, with the least impact on active recordings and
105      ///< live viewing. The LiveView parameter tells whether the device will
106      ///< be used for live viewing or a recording.
107      ///< If the Channel is encrypted, a CAM slot that claims to be able to
108      ///< decrypt the channel is automatically selected and assigned to the
109      ///< returned device. Whether or not this combination of device and CAM
110      ///< slot is actually able to decrypt the channel can only be determined
111      ///< by checking the "scrambling control" bits of the received TS packets.
112      ///< The Action() function automatically does this and takes care that
113      ///< after detaching any receivers because the channel can't be decrypted,
114      ///< this device/CAM combination will be skipped in the next call to
115      ///< GetDevice().
116      ///< See also ProvidesChannel().
117
118 */