SASC
DVBSoftCAM

player.h

Go to the documentation of this file.
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 1.19 2006/01/06 11:29:27 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 DevicePoll(cPoller &Poller, int TimeoutMs = 0) { return device ? device->Poll(Poller, TimeoutMs) : false; }
00026   bool DeviceFlush(int TimeoutMs = 0) { return device ? device->Flush(TimeoutMs) : true; }
00027   void DeviceTrickSpeed(int Speed) { if (device) device->TrickSpeed(Speed); }
00028   void DeviceClear(void) { if (device) device->Clear(); }
00029   void DevicePlay(void) { if (device) device->Play(); }
00030   void DeviceFreeze(void) { if (device) device->Freeze(); }
00031   void DeviceMute(void) { if (device) device->Mute(); }
00032   void DeviceSetVideoDisplayFormat(eVideoDisplayFormat VideoDisplayFormat) { if (device) device->SetVideoDisplayFormat(VideoDisplayFormat); }
00033   void DeviceStillPicture(const uchar *Data, int Length) { if (device) device->StillPicture(Data, Length); }
00034   void Detach(void);
00035   virtual void Activate(bool On) {}
00036        // This function is called right after the cPlayer has been attached to
00037        // (On == true) or before it gets detached from (On == false) a cDevice.
00038        // It can be used to do things like starting/stopping a thread.
00039   int PlayPes(const uchar *Data, int Length, bool VideoOnly = false);
00040        // Sends the given PES Data to the device and returns the number of
00041        // bytes that have actually been accepted by the device (or a
00042        // negative value in case of an error).
00043 public:
00044   cPlayer(ePlayMode PlayMode = pmAudioVideo);
00045   virtual ~cPlayer();
00046   bool IsAttached(void) { return device != NULL; }
00047   virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false) { return false; }
00048        // Returns the current and total frame index, optionally snapped to the
00049        // nearest I-frame.
00050   virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed) { return false; }
00051        // Returns the current replay mode (if applicable).
00052        // 'Play' tells whether we are playing or pausing, 'Forward' tells whether
00053        // we are going forward or backward and 'Speed' is -1 if this is normal
00054        // play/pause mode, 0 if it is single speed fast/slow forward/back mode
00055        // and >0 if this is multi speed mode.
00056   virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId) {}
00057        // Sets the current audio track to the given value.
00058        // This is just a virtual hook for players that need to do special things
00059        // in order to switch audio tracks.
00060   };
00061 
00062 class cControl : public cOsdObject {
00063 private:
00064   static cControl *control;
00065   static cMutex mutex;
00066   bool attached;
00067   bool hidden;
00068 protected:
00069   cPlayer *player;
00070 public:
00071   cControl(cPlayer *Player, bool Hidden = false);
00072   virtual ~cControl();
00073   virtual void Hide(void) = 0;
00074   virtual cOsdObject *GetInfo(void);
00075   bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false) { return player->GetIndex(Current, Total, SnapToIFrame); }
00076   bool GetReplayMode(bool &Play, bool &Forward, int &Speed) { return player->GetReplayMode(Play, Forward, Speed); }
00077   static void Launch(cControl *Control);
00078   static void Attach(void);
00079   static void Shutdown(void);
00080   static cControl *Control(void);
00081   };
00082 
00083 #endif //__PLAYER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines