vdr
1.7.27
|
00001 /* 00002 * player.h: The basic player interface 00003 * 00004 * See the main source file 'vdr.c' for copyright information and 00005 * how to reach the author. 00006 * 00007 * $Id: player.h 2.4 2009/03/08 12:29:10 kls Exp $ 00008 */ 00009 00010 #ifndef __PLAYER_H 00011 #define __PLAYER_H 00012 00013 #include "device.h" 00014 #include "osdbase.h" 00015 00016 class cPlayer { 00017 friend class cDevice; 00018 private: 00019 cDevice *device; 00020 ePlayMode playMode; 00021 protected: 00022 void DeviceClrAvailableTracks(bool DescriptionsOnly = false) { if (device) device->ClrAvailableTracks(DescriptionsOnly); } 00023 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; } 00024 bool DeviceSetCurrentAudioTrack(eTrackType Type) { return device ? device->SetCurrentAudioTrack(Type) : false; } 00025 bool DeviceSetCurrentSubtitleTrack(eTrackType Type) { return device ? device->SetCurrentSubtitleTrack(Type) : false; } 00026 bool DevicePoll(cPoller &Poller, int TimeoutMs = 0) { return device ? device->Poll(Poller, TimeoutMs) : false; } 00027 bool DeviceFlush(int TimeoutMs = 0) { return device ? device->Flush(TimeoutMs) : true; } 00028 bool DeviceHasIBPTrickSpeed(void) { return device ? device->HasIBPTrickSpeed() : false; } 00029 bool DeviceIsPlayingVideo(void) { return device ? device->IsPlayingVideo() : false; } 00030 void DeviceTrickSpeed(int Speed) { if (device) device->TrickSpeed(Speed); } 00031 void DeviceClear(void) { if (device) device->Clear(); } 00032 void DevicePlay(void) { if (device) device->Play(); } 00033 void DeviceFreeze(void) { if (device) device->Freeze(); } 00034 void DeviceMute(void) { if (device) device->Mute(); } 00035 void DeviceSetVideoDisplayFormat(eVideoDisplayFormat VideoDisplayFormat) { if (device) device->SetVideoDisplayFormat(VideoDisplayFormat); } 00036 void DeviceStillPicture(const uchar *Data, int Length) { if (device) device->StillPicture(Data, Length); } 00037 uint64_t DeviceGetSTC(void) { return device ? device->GetSTC() : -1; } 00038 void Detach(void); 00039 virtual void Activate(bool On) {} 00040 // This function is called right after the cPlayer has been attached to 00041 // (On == true) or before it gets detached from (On == false) a cDevice. 00042 // It can be used to do things like starting/stopping a thread. 00043 int PlayPes(const uchar *Data, int Length, bool VideoOnly = false); 00044 // Sends the given PES Data to the device and returns the number of 00045 // bytes that have actually been accepted by the device (or a 00046 // negative value in case of an error). 00047 int PlayTs(const uchar *Data, int Length, bool VideoOnly = false) { return device ? device->PlayTs(Data, Length, VideoOnly) : -1; } 00048 // Sends the given TS packet to the device and returns a positive number 00049 // if the packet has been accepted by the device, or a negative value in 00050 // case of an error. 00051 public: 00052 cPlayer(ePlayMode PlayMode = pmAudioVideo); 00053 virtual ~cPlayer(); 00054 bool IsAttached(void) { return device != NULL; } 00055 virtual double FramesPerSecond(void) { return DEFAULTFRAMESPERSECOND; } 00056 // Returns the number of frames per second of the currently played material. 00057 virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false) { return false; } 00058 // Returns the current and total frame index, optionally snapped to the 00059 // nearest I-frame. 00060 virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed) { return false; } 00061 // Returns the current replay mode (if applicable). 00062 // 'Play' tells whether we are playing or pausing, 'Forward' tells whether 00063 // we are going forward or backward and 'Speed' is -1 if this is normal 00064 // play/pause mode, 0 if it is single speed fast/slow forward/back mode 00065 // and >0 if this is multi speed mode. 00066 virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId) {} 00067 // Sets the current audio track to the given value. 00068 // This is just a virtual hook for players that need to do special things 00069 // in order to switch audio tracks. 00070 virtual void SetSubtitleTrack(eTrackType Type, const tTrackId *TrackId) {} 00071 // Sets the current subtitle track to the given value. 00072 // This is just a virtual hook for players that need to do special things 00073 // in order to switch subtitle tracks. 00074 }; 00075 00076 class cControl : public cOsdObject { 00077 private: 00078 static cControl *control; 00079 static cMutex mutex; 00080 bool attached; 00081 bool hidden; 00082 protected: 00083 cPlayer *player; 00084 public: 00085 cControl(cPlayer *Player, bool Hidden = false); 00086 virtual ~cControl(); 00087 virtual void Hide(void) = 0; 00088 virtual cOsdObject *GetInfo(void); 00089 double FramesPerSecond(void) { return player->FramesPerSecond(); } 00090 bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false) { return player->GetIndex(Current, Total, SnapToIFrame); } 00091 bool GetReplayMode(bool &Play, bool &Forward, int &Speed) { return player->GetReplayMode(Play, Forward, Speed); } 00092 static void Launch(cControl *Control); 00093 static void Attach(void); 00094 static void Shutdown(void); 00095 static cControl *Control(void); 00096 }; 00097 00098 #endif //__PLAYER_H