mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
- Completely switched to the new CVS HEAD version of the linux-dvb driver. The NEWSTRUCT compile time switch is now obsolete. The required driver is now the CVS HEAD version dated 2002-11-01 or later. - Adjusted the INSTALL file to the 1.1.x version. - Only accepting key presses from the current remote control when learning (thanks to Oliver Endriss). - Fixed the EPG scanner, which broke 'Transfer Mode' as soon as it kicked in (thanks to Oliver Endriss for reporting this one). - Fixed handling audio tracks in cDvbDevice. - Updated channels.conf.terr (thanks to Uwe Scheffler). - Fixed displaying the group separators in the channel display (thanks to Martin Hammerschmid for pointing out this one). - The Makefile now includes the file Make.config (if present in the VDR source directory), which allows the user to overwrite several settings with individual values (suggested by Andreas Schultz). The VDR distribution archive does not contain this file in order to not overwrite a user defined file. There is a Make.config.template which contains the default values of the macros the user can overwrite. - Since there have been changes to the 'newplugin' script authors of plugins may want to newly create their plugins' Makefiles with the new version of this script, and adapt them to their individual needs (make sure you don't overwrite your existing plugin directory - make a backup copy first!). - Fixed reading EPG data via the SVDRP command PUTE (it changed the current service ID). - Fixed closing all dup'ed file descriptors in cPipe. - Implemented a plugin interface for additional audio processing (see PLUGINS.html under "Dolby Digital"). The functionality of the '-a' command line option has been reactivated. Since the author doesn't have any Dolby Digital equipment this may or may not work as expected. There may still be some places where a call to cAudios::Clear() or cAudios::Mute() is necessary. Those with Dolby Digital equipment should please take a look at this and maybe send patches. Replaying Dolby Digital in ways other than through VDR's '-a' option will have to be implemented as plugins. Those who have written patches for VDR version 1.0.x should convert their work into the proper plugins for version 1.1.x. Note to authors of cPlayer derived plugins: please read the modified comments in device.h regarding the member functions cDevice::Clear(), cDevice::Mute() and cDevice::PlayAudio(). Derived classes must call these base class member functions to make sure all registered cAudio objects are properly handled. Also note that the return type of cDevice::PlayAudio() has been changed to 'void', since this function always has to accept the entire data block immediately and there is nothing that could be reasonably done in case an error occurs in one of the cAudio objects. - Now checking the driver's DVB_API_VERSION in dvbdevice.h. Since VDR now requires a driver dated 2002-11-01 or later the MIN_DVB_DRIVER_VERSION_FOR_TIMESHIFT and DVB_DRIVER_VERSION stuff has been replaced with DO_REC_AND_PLAY_ON_PRIMARY_DEVICE, which can be used to disable simultaneous recording and replaying on the primary DVB device in case there are problems with this.
190 lines
5.0 KiB
C
190 lines
5.0 KiB
C
/*
|
|
* transfer.c: Transfer mode
|
|
*
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
* how to reach the author.
|
|
*
|
|
* $Id: transfer.c 1.7 2002/11/03 11:24:02 kls Exp $
|
|
*/
|
|
|
|
#include "transfer.h"
|
|
|
|
//XXX+ also used in recorder.c - find a better place???
|
|
// The size of the array used to buffer video data:
|
|
// (must be larger than MINVIDEODATA - see remux.h)
|
|
#define VIDEOBUFSIZE MEGABYTE(1)
|
|
|
|
// --- cTransfer -------------------------------------------------------------
|
|
|
|
cTransfer::cTransfer(int VPid, int APid1, int APid2, int DPid1, int DPid2)
|
|
:cReceiver(0, -1, 5, VPid, APid1, APid2, DPid1, DPid2)
|
|
{
|
|
ringBuffer = new cRingBufferLinear(VIDEOBUFSIZE, true);
|
|
remux = new cRemux(VPid, APid1, APid2, DPid1, DPid2);
|
|
canToggleAudioTrack = false;
|
|
audioTrack = 0xC0;
|
|
gotBufferReserve = false;
|
|
active = false;
|
|
}
|
|
|
|
cTransfer::~cTransfer()
|
|
{
|
|
cReceiver::Detach();
|
|
cPlayer::Detach();
|
|
delete remux;
|
|
delete ringBuffer;
|
|
}
|
|
|
|
void cTransfer::Activate(bool On)
|
|
{
|
|
if (On) {
|
|
if (!active)
|
|
Start();
|
|
}
|
|
else if (active) {
|
|
active = false;
|
|
Cancel(3);
|
|
}
|
|
}
|
|
|
|
void cTransfer::Receive(uchar *Data, int Length)
|
|
{
|
|
if (IsAttached()) {
|
|
int p = ringBuffer->Put(Data, Length);
|
|
if (p != Length && active)
|
|
esyslog("ERROR: ring buffer overflow (%d bytes dropped)", Length - p);
|
|
}
|
|
}
|
|
|
|
void cTransfer::Action(void)
|
|
{
|
|
dsyslog("transfer thread started (pid=%d)", getpid());
|
|
|
|
uchar b[MINVIDEODATA];
|
|
int r = 0;
|
|
active = true;
|
|
while (active) {
|
|
|
|
//XXX+ Maybe we need this to avoid "buffer empty" log messages from the driver.
|
|
//XXX+ But then again, it appears to play just fine without this...
|
|
/*
|
|
if (!gotBufferReserve) {
|
|
if (ringBuffer->Available() < 4 * MAXFRAMESIZE) {
|
|
usleep(100000); // allow the buffer to collect some reserve
|
|
continue;
|
|
}
|
|
else
|
|
gotBufferReserve = true;
|
|
}
|
|
*/
|
|
|
|
// Get data from the buffer:
|
|
|
|
int g = ringBuffer->Get(b + r, sizeof(b) - r);
|
|
if (g > 0)
|
|
r += g;
|
|
|
|
// Play the data:
|
|
|
|
if (r > 0) {
|
|
int Count = r, Result;
|
|
uchar *p = remux->Process(b, Count, Result);
|
|
if (p) {
|
|
StripAudioPackets(p, Result, audioTrack);
|
|
while (Result > 0 && active) {
|
|
int w = PlayVideo(p, Result);
|
|
if (w > 0) {
|
|
p += w;
|
|
Result -= w;
|
|
}
|
|
else if (w < 0 && FATALERRNO) {
|
|
LOG_ERROR;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (Count > 0) {
|
|
r -= Count;
|
|
if (r > 0)
|
|
memmove(b, b + Count, r);
|
|
}
|
|
}
|
|
}
|
|
|
|
dsyslog("transfer thread ended (pid=%d)", getpid());
|
|
}
|
|
|
|
void cTransfer::StripAudioPackets(uchar *b, int Length, uchar Except)
|
|
{
|
|
for (int i = 0; i < Length - 6; i++) {
|
|
if (b[i] == 0x00 && b[i + 1] == 0x00 && b[i + 2] == 0x01) {
|
|
uchar c = b[i + 3];
|
|
int l = b[i + 4] * 256 + b[i + 5] + 6;
|
|
switch (c) {
|
|
case 0xBD: // dolby
|
|
if (Except)
|
|
PlayAudio(&b[i], l);
|
|
// continue with deleting the data - otherwise it disturbs DVB replay
|
|
case 0xC0 ... 0xC1: // audio
|
|
if (c == 0xC1)
|
|
canToggleAudioTrack = true;
|
|
if (!Except || c != Except) {
|
|
int n = l;
|
|
for (int j = i; j < Length && n--; j++)
|
|
b[j] = 0x00;
|
|
}
|
|
break;
|
|
case 0xE0 ... 0xEF: // video
|
|
break;
|
|
default:
|
|
//esyslog("ERROR: unexpected packet id %02X", c);
|
|
l = 0;
|
|
}
|
|
if (l)
|
|
i += l - 1; // the loop increments, too!
|
|
}
|
|
/*XXX
|
|
else
|
|
esyslog("ERROR: broken packet header");
|
|
XXX*/
|
|
}
|
|
}
|
|
|
|
int cTransfer::NumAudioTracks(void) const
|
|
{
|
|
return canToggleAudioTrack ? 2 : 1;
|
|
}
|
|
|
|
const char **cTransfer::GetAudioTracks(int *CurrentTrack) const
|
|
{
|
|
if (NumAudioTracks()) {
|
|
if (CurrentTrack)
|
|
*CurrentTrack = (audioTrack == 0xC0) ? 0 : 1;
|
|
static const char *audioTracks1[] = { "Audio 1", NULL };
|
|
static const char *audioTracks2[] = { "Audio 1", "Audio 2", NULL };
|
|
return NumAudioTracks() > 1 ? audioTracks2 : audioTracks1;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void cTransfer::SetAudioTrack(int Index)
|
|
{
|
|
if ((audioTrack == 0xC0) != (Index == 0)) {
|
|
audioTrack = (Index == 1) ? 0xC1 : 0xC0;
|
|
DeviceClear();
|
|
}
|
|
}
|
|
|
|
// --- cTransferControl ------------------------------------------------------
|
|
|
|
cTransferControl::cTransferControl(cDevice *ReceiverDevice, int VPid, int APid1, int APid2, int DPid1, int DPid2)
|
|
:cControl(transfer = new cTransfer(VPid, APid1, APid2, DPid1, DPid2), true)
|
|
{
|
|
ReceiverDevice->AttachReceiver(transfer);
|
|
}
|
|
|
|
cTransferControl::~cTransferControl()
|
|
{
|
|
delete transfer;
|
|
}
|