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.
|
|
|
|
*
|
2004-11-20 11:34:04 +01:00
|
|
|
* $Id: player.c 1.8 2004/11/20 11:33:08 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;
|
|
|
|
}
|
|
|
|
|
2002-11-03 11:53:58 +01:00
|
|
|
void cPlayer::PlayAudio(const uchar *Data, int Length)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
2002-11-03 11:53:58 +01:00
|
|
|
if (device) {
|
|
|
|
device->PlayAudio(Data, Length);
|
|
|
|
return;
|
|
|
|
}
|
2002-06-16 12:57:31 +02:00
|
|
|
esyslog("ERROR: attempt to use cPlayer::PlayAudio() without attaching to a cDevice!");
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("Channel locked (recording)!"));
|
2002-06-23 11:23:34 +02:00
|
|
|
Shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cControl::Shutdown(void)
|
|
|
|
{
|
2004-11-20 11:34:04 +01:00
|
|
|
cControl *c = control; // avoids recursions
|
2002-06-23 11:23:34 +02:00
|
|
|
control = NULL;
|
2004-11-20 11:34:04 +01:00
|
|
|
delete c;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|