vdr  2.0.4
transfer.c
Go to the documentation of this file.
1 /*
2  * transfer.c: Transfer mode
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: transfer.c 2.8.1.1 2013/08/22 12:37:02 kls Exp $
8  */
9 
10 #include "transfer.h"
11 
12 // --- cTransfer -------------------------------------------------------------
13 
15 :cReceiver(Channel, TRANSFERPRIORITY)
16 {
17  patPmtGenerator.SetChannel(Channel);
18 }
19 
21 {
24 }
25 
26 void cTransfer::Activate(bool On)
27 {
28  if (On) {
30  int Index = 0;
31  while (uchar *pmt = patPmtGenerator.GetPmt(Index))
32  PlayTs(pmt, TS_SIZE);
33  }
34  else
36 }
37 
38 #define MAXRETRIES 20 // max. number of retries for a single TS packet
39 #define RETRYWAIT 5 // time (in ms) between two retries
40 
41 void cTransfer::Receive(uchar *Data, int Length)
42 {
43  if (cPlayer::IsAttached()) {
44  // Transfer Mode means "live tv", so there's no point in doing any additional
45  // buffering here. The TS packets *must* get through here! However, every
46  // now and then there may be conditions where the packet just can't be
47  // handled when offered the first time, so that's why we try several times:
48  for (int i = 0; i < MAXRETRIES; i++) {
49  if (PlayTs(Data, Length) > 0)
50  return;
52  }
53  DeviceClear();
54  esyslog("ERROR: TS packet not accepted in Transfer Mode");
55  }
56 }
57 
58 // --- cTransferControl ------------------------------------------------------
59 
61 
62 cTransferControl::cTransferControl(cDevice *ReceiverDevice, const cChannel *Channel)
63 :cControl(transfer = new cTransfer(Channel), true)
64 {
65  ReceiverDevice->AttachReceiver(transfer);
67 }
68 
70 {
71  receiverDevice = NULL;
72  delete transfer;
73 }
74