vdr  2.4.1
player.c
Go to the documentation of this file.
1 /*
2  * player.c: The basic player interface
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: player.c 4.0 2012/04/28 11:52:50 kls Exp $
8  */
9 
10 #include "player.h"
11 #include "i18n.h"
12 
13 // --- cPlayer ---------------------------------------------------------------
14 
16 {
17  device = NULL;
18  playMode = PlayMode;
19 }
20 
22 {
23  Detach();
24 }
25 
26 int cPlayer::PlayPes(const uchar *Data, int Length, bool VideoOnly)
27 {
28  if (device)
29  return device->PlayPes(Data, Length, VideoOnly);
30  esyslog("ERROR: attempt to use cPlayer::PlayPes() without attaching to a cDevice!");
31  return -1;
32 }
33 
34 void cPlayer::Detach(void)
35 {
36  if (device)
37  device->Detach(this);
38 }
39 
40 // --- cControl --------------------------------------------------------------
41 
44 
45 cControl::cControl(cPlayer *Player, bool Hidden)
46 {
47  attached = false;
48  hidden = Hidden;
49  player = Player;
50 }
51 
53 {
54  if (this == control)
55  control = NULL;
56 }
57 
59 {
60  return NULL;
61 }
62 
64 {
65  return NULL;
66 }
67 
69 {
70  return "";
71 }
72 
74 {
75  cMutexLock MutexLock(&mutex);
76  return (control && (!control->hidden || Hidden)) ? control : NULL;
77 }
78 
79 void cControl::Launch(cControl *Control)
80 {
81  cMutexLock MutexLock(&mutex);
82  cControl *c = control; // keeps control from pointing to uninitialized memory
83  control = Control;
84  delete c;
85 }
86 
87 void cControl::Attach(void)
88 {
89  cMutexLock MutexLock(&mutex);
91  if (cDevice::PrimaryDevice()->AttachPlayer(control->player))
92  control->attached = true;
93  else {
94  Skins.Message(mtError, tr("Channel locked (recording)!"));
95  Shutdown();
96  }
97  }
98 }
99 
101 {
102  cMutexLock MutexLock(&mutex);
103  cControl *c = control; // avoids recursions
104  control = NULL;
105  delete c;
106 }
cPlayer::Detach
void Detach(void)
Definition: player.c:34
cControl::~cControl
virtual ~cControl()
Definition: player.c:52
cSkins::Message
eKeys Message(eMessageType Type, const char *s, int Seconds=0)
Displays the given message, either through a currently visible display object that is capable of doin...
Definition: skins.c:250
tr
#define tr(s)
Definition: i18n.h:85
cControl::attached
bool attached
Definition: player.h:84
cControl
Definition: player.h:80
cOsdObject
Definition: osdbase.h:69
cMutexLock
Definition: thread.h:141
cMutex
Definition: thread.h:67
cDevice::Detach
void Detach(cFilter *Filter)
Detaches the given filter from this device.
Definition: device.c:699
cControl::player
cPlayer * player
Definition: player.h:87
cControl::Launch
static void Launch(cControl *Control)
Definition: player.c:79
i18n.h
uchar
unsigned char uchar
Definition: tools.h:31
cPlayer::cPlayer
cPlayer(ePlayMode PlayMode=pmAudioVideo)
Definition: player.c:15
cControl::hidden
bool hidden
Definition: player.h:85
cPlayer
Definition: player.h:16
cRecording
Definition: recording.h:98
ePlayMode
ePlayMode
Definition: device.h:39
cControl::GetRecording
virtual const cRecording * GetRecording(void)
Returns the cRecording that is currently being replayed, or NULL if this player is not playing a cRec...
Definition: player.c:63
cPlayer::playMode
ePlayMode playMode
Definition: player.h:20
cString
Definition: tools.h:176
cControl::cControl
cControl(cPlayer *Player, bool Hidden=false)
Definition: player.c:45
player.h
cPlayer::~cPlayer
virtual ~cPlayer()
Definition: player.c:21
Skins
cSkins Skins
Definition: skins.c:219
cControl::control
static cControl * control
Definition: player.h:82
cPlayer::IsAttached
bool IsAttached(void)
Definition: player.h:54
mtError
@ mtError
Definition: skins.h:37
cPlayer::PlayPes
int PlayPes(const uchar *Data, int Length, bool VideoOnly=false)
Definition: player.c:26
cPlayer::device
cDevice * device
Definition: player.h:19
cControl::GetHeader
virtual cString GetHeader(void)
This can be used by players that don't play a cRecording, but rather do something completely differen...
Definition: player.c:68
cDevice::PlayPes
virtual int PlayPes(const uchar *Data, int Length, bool VideoOnly=false)
Plays all valid PES packets in Data with the given Length.
Definition: device.c:1491
cControl::mutex
static cMutex mutex
Definition: player.h:83
cControl::GetInfo
virtual cOsdObject * GetInfo(void)
Returns an OSD object that displays information about the currently played programme.
Definition: player.c:58
esyslog
#define esyslog(a...)
Definition: tools.h:35
cControl::Control
static cControl * Control(bool Hidden=false)
Returns the current replay control (if any) in case it is currently visible.
Definition: player.c:73
cControl::Attach
static void Attach(void)
Definition: player.c:87
cControl::Shutdown
static void Shutdown(void)
Definition: player.c:100