vdr 2.7.5
player.h
Go to the documentation of this file.
1/*
2 * player.h: 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.h 5.8 2025/03/28 22:49:17 kls Exp $
8 */
9
10#ifndef __PLAYER_H
11#define __PLAYER_H
12
13#include "device.h"
14#include "osdbase.h"
15
16class cPlayer {
17 friend class cDevice;
18private:
21protected:
22 void DeviceClrAvailableTracks(bool DescriptionsOnly = false) { if (device) device->ClrAvailableTracks(DescriptionsOnly); }
23 bool DeviceSetAvailableTrack(eTrackType Type, int Index, uint16_t Id, const char *Language = NULL, const char *Description = NULL) { return device ? device->SetAvailableTrack(Type, Index, Id, Language, Description) : false; }
24 bool DeviceSetCurrentAudioTrack(eTrackType Type) { return device ? device->SetCurrentAudioTrack(Type) : false; }
25 bool DeviceSetCurrentSubtitleTrack(eTrackType Type) { return device ? device->SetCurrentSubtitleTrack(Type) : false; }
26 bool DevicePoll(cPoller &Poller, int TimeoutMs = 0) { return device ? device->Poll(Poller, TimeoutMs) : false; }
27 bool DeviceFlush(int TimeoutMs = 0) { return device ? device->Flush(TimeoutMs) : true; }
28 bool DeviceHasIBPTrickSpeed(void) { return device ? device->HasIBPTrickSpeed() : false; }
29 bool DeviceIsPlayingVideo(void) { return device ? device->IsPlayingVideo() : false; }
30 void DeviceTrickSpeed(int Speed, bool Forward) { if (device) device->TrickSpeed(Speed, Forward); }
31 void DeviceClear(void) { if (device) device->Clear(); }
32 void DevicePlay(void) { if (device) device->Play(); }
33 void DeviceFreeze(void) { if (device) device->Freeze(); }
34 void DeviceMute(void) { if (device) device->Mute(); }
35 void DeviceSetVideoDisplayFormat(eVideoDisplayFormat VideoDisplayFormat) { if (device) device->SetVideoDisplayFormat(VideoDisplayFormat); }
36 void DeviceStillPicture(const uchar *Data, int Length) { if (device) device->StillPicture(Data, Length); }
37 void DeviceSetTempSubtitles(void) { if (device) device->SetTempSubtitles(); }
38 uint64_t DeviceGetSTC(void) { return device ? device->GetSTC() : -1; }
39 void Detach(void);
40 virtual void Activate(bool On) {}
41 // This function is called right after the cPlayer has been attached to
42 // (On == true) or before it gets detached from (On == false) a cDevice.
43 // It can be used to do things like starting/stopping a thread.
44 int PlayPes(const uchar *Data, int Length, bool VideoOnly = false);
45 // Sends the given PES Data to the device and returns the number of
46 // bytes that have actually been accepted by the device (or a
47 // negative value in case of an error).
48 int PlayTs(const uchar *Data, int Length, bool VideoOnly = false) { return device ? device->PlayTs(Data, Length, VideoOnly) : -1; }
49 // Sends the given TS packet to the device and returns a positive number
50 // if the packet has been accepted by the device, or a negative value in
51 // case of an error.
52public:
53 cPlayer(ePlayMode PlayMode = pmAudioVideo);
54 virtual ~cPlayer();
55 bool IsAttached(void) { return device != NULL; }
56 virtual double FramesPerSecond(void) { return DEFAULTFRAMESPERSECOND; }
57 // Returns the number of frames per second of the currently played material.
58 virtual const cErrors *GetErrors(void) { return NULL; }
59 // Returns the frame indexes of errors in the recording (if any).
60 virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false) { return false; }
61 // Returns the current and total frame index, optionally snapped to the
62 // nearest I-frame.
63 virtual bool GetFrameNumber(int &Current, int &Total) { return false; }
64 // Returns the current and total frame number. In contrast to GetIndex(),
65 // this function respects the chronological order of frames, which is
66 // different from its index for streams containing B frames (e.g. H264)
67 virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed) { return false; }
68 // Returns the current replay mode (if applicable).
69 // 'Play' tells whether we are playing or pausing, 'Forward' tells whether
70 // we are going forward or backward and 'Speed' is -1 if this is normal
71 // play/pause mode, 0 if it is single speed fast/slow forward/back mode
72 // and >0 if this is multi speed mode.
73 virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId) {}
74 // Sets the current audio track to the given value.
75 // This is just a virtual hook for players that need to do special things
76 // in order to switch audio tracks.
77 virtual void SetSubtitleTrack(eTrackType Type, const tTrackId *TrackId) {}
78 // Sets the current subtitle track to the given value.
79 // This is just a virtual hook for players that need to do special things
80 // in order to switch subtitle tracks.
81 };
82
83class cControl : public cOsdObject {
84private:
86 static cMutex mutex;
88 bool hidden;
89protected:
91public:
92 cControl(cPlayer *Player, bool Hidden = false);
93 virtual ~cControl() override;
94 virtual void Hide(void) = 0;
95 virtual cOsdObject *GetInfo(void);
99 virtual const cRecording *GetRecording(void);
102 virtual cString GetHeader(void);
108 virtual void ClearEditingMarks(void) {}
113 void SetPlayer(cPlayer *Player) { player = Player; }
114 double FramesPerSecond(void) const { return player ? player->FramesPerSecond() : DEFAULTFRAMESPERSECOND; }
115 bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false) const { return player ? player->GetIndex(Current, Total, SnapToIFrame) : false; }
116 bool GetFrameNumber(int &Current, int &Total) const { return player ? player->GetFrameNumber(Current, Total) : false; }
117 bool GetReplayMode(bool &Play, bool &Forward, int &Speed) const { return player ? player->GetReplayMode(Play, Forward, Speed) : false; }
118 static void Launch(cControl *Control);
119 static void Attach(void);
120 static void Shutdown(void);
121 static cControl *Control(cMutexLock &MutexLock, bool Hidden = false);
127 };
128
129#endif //__PLAYER_H
static cControl * Control(cMutexLock &MutexLock, bool Hidden=false)
Returns the current replay control (if any) in case it is currently visible.
Definition player.c:73
virtual void ClearEditingMarks(void)
Clears any editing marks this player might be showing.
Definition player.h:108
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
double FramesPerSecond(void) const
Definition player.h:114
bool GetFrameNumber(int &Current, int &Total) const
Definition player.h:116
static void Shutdown(void)
Definition player.c:99
bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false) const
Definition player.h:115
static cControl * control
Definition player.h:85
virtual cOsdObject * GetInfo(void)
Returns an OSD object that displays information about the currently played programme.
Definition player.c:58
static cMutex mutex
Definition player.h:86
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
static void Attach(void)
Definition player.c:86
bool GetReplayMode(bool &Play, bool &Forward, int &Speed) const
Definition player.h:117
void SetPlayer(cPlayer *Player)
Definition player.h:113
bool hidden
Definition player.h:88
virtual ~cControl() override
Definition player.c:52
bool attached
Definition player.h:87
static void Launch(cControl *Control)
Definition player.c:79
cControl(cPlayer *Player, bool Hidden=false)
Definition player.c:45
virtual void Hide(void)=0
cPlayer * player
Definition player.h:90
cOsdObject(bool FastResponse=false)
Definition osdbase.h:77
bool DeviceSetCurrentAudioTrack(eTrackType Type)
Definition player.h:24
void Detach(void)
Definition player.c:34
void DeviceStillPicture(const uchar *Data, int Length)
Definition player.h:36
uint64_t DeviceGetSTC(void)
Definition player.h:38
bool DeviceSetAvailableTrack(eTrackType Type, int Index, uint16_t Id, const char *Language=NULL, const char *Description=NULL)
Definition player.h:23
virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false)
Definition player.h:60
friend class cDevice
Definition player.h:17
virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed)
Definition player.h:67
virtual const cErrors * GetErrors(void)
Definition player.h:58
virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId)
Definition player.h:73
int PlayTs(const uchar *Data, int Length, bool VideoOnly=false)
Definition player.h:48
void DevicePlay(void)
Definition player.h:32
int PlayPes(const uchar *Data, int Length, bool VideoOnly=false)
Definition player.c:26
virtual bool GetFrameNumber(int &Current, int &Total)
Definition player.h:63
bool DevicePoll(cPoller &Poller, int TimeoutMs=0)
Definition player.h:26
void DeviceClrAvailableTracks(bool DescriptionsOnly=false)
Definition player.h:22
void DeviceMute(void)
Definition player.h:34
virtual double FramesPerSecond(void)
Definition player.h:56
bool IsAttached(void)
Definition player.h:55
virtual ~cPlayer()
Definition player.c:21
void DeviceSetVideoDisplayFormat(eVideoDisplayFormat VideoDisplayFormat)
Definition player.h:35
void DeviceFreeze(void)
Definition player.h:33
bool DeviceFlush(int TimeoutMs=0)
Definition player.h:27
void DeviceSetTempSubtitles(void)
Definition player.h:37
bool DeviceHasIBPTrickSpeed(void)
Definition player.h:28
ePlayMode playMode
Definition player.h:20
cPlayer(ePlayMode PlayMode=pmAudioVideo)
Definition player.c:15
bool DeviceSetCurrentSubtitleTrack(eTrackType Type)
Definition player.h:25
virtual void Activate(bool On)
Definition player.h:40
virtual void SetSubtitleTrack(eTrackType Type, const tTrackId *TrackId)
Definition player.h:77
cDevice * device
Definition player.h:19
bool DeviceIsPlayingVideo(void)
Definition player.h:29
void DeviceClear(void)
Definition player.h:31
void DeviceTrickSpeed(int Speed, bool Forward)
Definition player.h:30
eVideoDisplayFormat
Definition device.h:58
ePlayMode
Definition device.h:39
@ pmAudioVideo
Definition device.h:40
eTrackType
Definition device.h:63
#define DEFAULTFRAMESPERSECOND
Definition recording.h:377
unsigned char uchar
Definition tools.h:31