1 #include "mvpreceiver.h"
3 MVPReceiver* MVPReceiver::create(cChannel* channel, int priority)
5 bool NeedsDetachReceivers;
6 cDevice* device = cDevice::GetDevice(channel, priority, &NeedsDetachReceivers);
10 Log::getInstance()->log("MVPReceiver", Log::DEBUG, "No device found to receive this channel at this priority");
14 if (NeedsDetachReceivers)
16 Log::getInstance()->log("MVPReceiver", Log::DEBUG, "Needs detach receivers");
18 // Need to detach other receivers or VDR will shut down??
21 MVPReceiver* m = new MVPReceiver(channel, device);
25 MVPReceiver::MVPReceiver(cChannel* channel, cDevice* device)
26 #if VDRVERSNUM < 10300
27 : cReceiver(channel->Ca(), 0, 7, channel->Vpid(), channel->Ppid(), channel->Apid1(), channel->Apid2(), channel->Dpid1(), channel->Dpid2(), channel->Tpid())
28 #elif VDRVERSNUM < 10500
29 : cReceiver(channel->Ca(), 0, channel->Vpid(), channel->Apids(), channel->Dpids(), channel->Spids())
31 : cReceiver(channel->GetChannelID(), 0, channel->Vpid(), channel->Apids(), channel->Dpids(), channel->Spids())
34 logger = Log::getInstance();
38 // logger->log("MVPReceiver", Log::DEBUG, "Channel has VPID %i APID %i", channel->Vpid(), channel->Apid(0));
40 if (!processed.init(1000000)) return;
41 pthread_mutex_init(&processedRingLock, NULL);
46 device->SwitchChannel(channel, false);
47 device->AttachReceiver(this);
50 int MVPReceiver::init()
55 MVPReceiver::~MVPReceiver()
60 void MVPReceiver::Activate(bool on)
63 if (on) logger->log("MVPReceiver", Log::DEBUG, "VDR active");
64 else logger->log("MVPReceiver", Log::DEBUG, "VDR inactive");
67 bool MVPReceiver::isVdrActivated()
72 void MVPReceiver::Receive(UCHAR* data, int length)
74 pthread_mutex_lock(&processedRingLock);
75 processed.put(data, length);
76 pthread_mutex_unlock(&processedRingLock);
79 unsigned long MVPReceiver::getBlock(unsigned char* buffer, unsigned long amount)
81 pthread_mutex_lock(&processedRingLock);
85 while ((unsigned long)processed.getContent() < amount)
87 pthread_mutex_unlock(&processedRingLock);
88 if (++numTries == 30) // 15s
90 logger->log("MVPReceiver", Log::DEBUG, "getBlock timeout");
94 pthread_mutex_lock(&processedRingLock);
97 unsigned long amountReceived = processed.get(buffer, amount);
98 pthread_mutex_unlock(&processedRingLock);
99 return amountReceived;