2002-06-22 13:45:53 +02:00
|
|
|
/*
|
|
|
|
* transfer.c: Transfer mode
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2009-01-23 16:44:46 +01:00
|
|
|
* $Id: transfer.c 2.3 2009/01/23 16:44:29 kls Exp $
|
2002-06-22 13:45:53 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "transfer.h"
|
|
|
|
|
|
|
|
// --- cTransfer -------------------------------------------------------------
|
|
|
|
|
2007-01-07 14:46:14 +01:00
|
|
|
cTransfer::cTransfer(tChannelID ChannelID, int VPid, const int *APids, const int *DPids, const int *SPids)
|
|
|
|
:cReceiver(ChannelID, -1, VPid, APids, Setup.UseDolbyDigital ? DPids : NULL, SPids)
|
2002-06-22 13:45:53 +02:00
|
|
|
{
|
2009-01-23 16:44:46 +01:00
|
|
|
patPmtGenerator.SetChannel(Channels.GetByChannelID(ChannelID));
|
2002-06-22 13:45:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cTransfer::~cTransfer()
|
|
|
|
{
|
|
|
|
cReceiver::Detach();
|
|
|
|
cPlayer::Detach();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cTransfer::Activate(bool On)
|
|
|
|
{
|
2008-08-15 14:49:34 +02:00
|
|
|
if (On) {
|
|
|
|
PlayTs(patPmtGenerator.GetPat(), TS_SIZE);
|
|
|
|
int Index = 0;
|
|
|
|
while (uchar *pmt = patPmtGenerator.GetPmt(Index))
|
|
|
|
PlayTs(pmt, TS_SIZE);
|
2007-01-07 14:46:14 +01:00
|
|
|
}
|
2009-01-16 15:16:08 +01:00
|
|
|
else
|
|
|
|
cPlayer::Detach();
|
2002-06-22 13:45:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cTransfer::Receive(uchar *Data, int Length)
|
|
|
|
{
|
2008-08-15 14:49:34 +02:00
|
|
|
if (cPlayer::IsAttached()) {
|
|
|
|
// Transfer Mode means "live tv", so there's no point in doing any additional
|
|
|
|
// buffering here. The TS packets *must* get through here! However, every
|
|
|
|
// now and then there may be conditions where the packet just can't be
|
|
|
|
// handled when offered the first time, so that's why we try several times:
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
if (PlayTs(Data, Length) > 0)
|
|
|
|
return;
|
|
|
|
fprintf(stderr, "-");//XXX just for testing - remove when stable
|
|
|
|
cCondWait::SleepMs(10);
|
|
|
|
}
|
|
|
|
esyslog("ERROR: TS packet not accepted in Transfer Mode");
|
2002-09-22 09:52:38 +02:00
|
|
|
}
|
2002-06-22 13:45:53 +02:00
|
|
|
}
|
|
|
|
|
2002-06-23 12:59:58 +02:00
|
|
|
// --- cTransferControl ------------------------------------------------------
|
|
|
|
|
2003-05-11 09:01:51 +02:00
|
|
|
cDevice *cTransferControl::receiverDevice = NULL;
|
|
|
|
|
2007-01-07 14:46:14 +01:00
|
|
|
cTransferControl::cTransferControl(cDevice *ReceiverDevice, tChannelID ChannelID, int VPid, const int *APids, const int *DPids, const int *SPids)
|
|
|
|
:cControl(transfer = new cTransfer(ChannelID, VPid, APids, DPids, SPids), true)
|
2002-06-23 12:59:58 +02:00
|
|
|
{
|
|
|
|
ReceiverDevice->AttachReceiver(transfer);
|
2003-05-11 09:01:51 +02:00
|
|
|
receiverDevice = ReceiverDevice;
|
2002-06-23 12:59:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cTransferControl::~cTransferControl()
|
|
|
|
{
|
2003-05-11 09:01:51 +02:00
|
|
|
receiverDevice = NULL;
|
2002-06-23 12:59:58 +02:00
|
|
|
delete transfer;
|
|
|
|
}
|