2002-06-16 12:57:31 +02:00
|
|
|
/*
|
|
|
|
* player.c: The basic player interface
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2002-08-15 11:16:34 +02:00
|
|
|
* $Id: player.c 1.5 2002/08/15 10:29:17 kls Exp $
|
2002-06-16 12:57:31 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "player.h"
|
2002-06-23 11:23:34 +02:00
|
|
|
#include "i18n.h"
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
// --- cPlayer ---------------------------------------------------------------
|
|
|
|
|
2002-08-15 11:16:34 +02:00
|
|
|
cPlayer::cPlayer(ePlayMode PlayMode)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
|
|
|
device = NULL;
|
2002-08-15 11:16:34 +02:00
|
|
|
playMode = PlayMode;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cPlayer::~cPlayer()
|
|
|
|
{
|
|
|
|
Detach();
|
|
|
|
}
|
|
|
|
|
|
|
|
int cPlayer::PlayVideo(const uchar *Data, int Length)
|
|
|
|
{
|
|
|
|
if (device)
|
|
|
|
return device->PlayVideo(Data, Length);
|
|
|
|
esyslog("ERROR: attempt to use cPlayer::PlayVideo() without attaching to a cDevice!");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cPlayer::PlayAudio(const uchar *Data, int Length)
|
|
|
|
{
|
|
|
|
if (device)
|
|
|
|
return device->PlayAudio(Data, Length);
|
|
|
|
esyslog("ERROR: attempt to use cPlayer::PlayAudio() without attaching to a cDevice!");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cPlayer::Detach(void)
|
|
|
|
{
|
|
|
|
if (device)
|
|
|
|
device->Detach(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cControl --------------------------------------------------------------
|
|
|
|
|
2002-06-23 11:23:34 +02:00
|
|
|
cControl *cControl::control = NULL;
|
|
|
|
|
2002-06-23 12:59:58 +02:00
|
|
|
cControl::cControl(cPlayer *Player, bool Hidden)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
2002-06-23 11:23:34 +02:00
|
|
|
attached = false;
|
2002-06-23 12:59:58 +02:00
|
|
|
hidden = Hidden;
|
2002-06-23 11:23:34 +02:00
|
|
|
player = Player;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cControl::~cControl()
|
|
|
|
{
|
2002-06-23 11:23:34 +02:00
|
|
|
if (this == control)
|
|
|
|
control = NULL;
|
|
|
|
}
|
|
|
|
|
2002-06-23 12:59:58 +02:00
|
|
|
cControl *cControl::Control(void)
|
|
|
|
{
|
|
|
|
return (control && !control->hidden) ? control : NULL;
|
|
|
|
}
|
|
|
|
|
2002-06-23 11:23:34 +02:00
|
|
|
void cControl::Launch(cControl *Control)
|
|
|
|
{
|
|
|
|
delete control;
|
|
|
|
control = Control;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cControl::Attach(void)
|
|
|
|
{
|
|
|
|
if (control && !control->attached && control->player && !control->player->IsAttached()) {
|
|
|
|
if (cDevice::PrimaryDevice()->AttachPlayer(control->player))
|
|
|
|
control->attached = true;
|
|
|
|
else {
|
|
|
|
Interface->Error(tr("Channel locked (recording)!"));
|
|
|
|
Shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cControl::Shutdown(void)
|
|
|
|
{
|
|
|
|
delete control;
|
|
|
|
control = NULL;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|