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())
29 : cReceiver(channel->Ca(), 0, channel->Vpid(), channel->Apids(), channel->Dpids(), channel->Spids())
32 logger = Log::getInstance();
36 // logger->log("MVPReceiver", Log::DEBUG, "Channel has VPID %i APID %i", channel->Vpid(), channel->Apid(0));
38 if (!processed.init(1000000)) return;
39 pthread_mutex_init(&processedRingLock, NULL);
44 device->SwitchChannel(channel, false);
45 device->AttachReceiver(this);
48 int MVPReceiver::init()
53 MVPReceiver::~MVPReceiver()
58 void MVPReceiver::Activate(bool on)
61 if (on) logger->log("MVPReceiver", Log::DEBUG, "VDR active");
62 else logger->log("MVPReceiver", Log::DEBUG, "VDR inactive");
65 bool MVPReceiver::isVdrActivated()
70 void MVPReceiver::Receive(UCHAR* data, int length)
72 pthread_mutex_lock(&processedRingLock);
73 processed.put(data, length);
74 pthread_mutex_unlock(&processedRingLock);
77 unsigned long MVPReceiver::getBlock(unsigned char* buffer, unsigned long amount)
79 pthread_mutex_lock(&processedRingLock);
83 while ((unsigned long)processed.getContent() < amount)
85 pthread_mutex_unlock(&processedRingLock);
86 if (++numTries == 30) // 15s
88 logger->log("MVPReceiver", Log::DEBUG, "getBlock timeout");
92 pthread_mutex_lock(&processedRingLock);
95 unsigned long amountReceived = processed.get(buffer, amount);
96 pthread_mutex_unlock(&processedRingLock);
97 return amountReceived;