vdr  1.7.31
include/vdr/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 2.6 2012/04/28 13:04:17 kls Exp $
8  */
9 
10 #ifndef __PLAYER_H
11 #define __PLAYER_H
12 
13 #include "device.h"
14 #include "osdbase.h"
15 
16 class cPlayer {
17  friend class cDevice;
18 private:
21 protected:
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; }
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) { if (device) device->TrickSpeed(Speed); }
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  uint64_t DeviceGetSTC(void) { return device ? device->GetSTC() : -1; }
38  void Detach(void);
39  virtual void Activate(bool On) {}
40  // This function is called right after the cPlayer has been attached to
41  // (On == true) or before it gets detached from (On == false) a cDevice.
42  // It can be used to do things like starting/stopping a thread.
43  int PlayPes(const uchar *Data, int Length, bool VideoOnly = false);
44  // Sends the given PES Data to the device and returns the number of
45  // bytes that have actually been accepted by the device (or a
46  // negative value in case of an error).
47  int PlayTs(const uchar *Data, int Length, bool VideoOnly = false) { return device ? device->PlayTs(Data, Length, VideoOnly) : -1; }
48  // Sends the given TS packet to the device and returns a positive number
49  // if the packet has been accepted by the device, or a negative value in
50  // case of an error.
51 public:
52  cPlayer(ePlayMode PlayMode = pmAudioVideo);
53  virtual ~cPlayer();
54  bool IsAttached(void) { return device != NULL; }
55  virtual double FramesPerSecond(void) { return DEFAULTFRAMESPERSECOND; }
56  // Returns the number of frames per second of the currently played material.
57  virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false) { return false; }
58  // Returns the current and total frame index, optionally snapped to the
59  // nearest I-frame.
60  virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed) { return false; }
61  // Returns the current replay mode (if applicable).
62  // 'Play' tells whether we are playing or pausing, 'Forward' tells whether
63  // we are going forward or backward and 'Speed' is -1 if this is normal
64  // play/pause mode, 0 if it is single speed fast/slow forward/back mode
65  // and >0 if this is multi speed mode.
66  virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId) {}
67  // Sets the current audio track to the given value.
68  // This is just a virtual hook for players that need to do special things
69  // in order to switch audio tracks.
70  virtual void SetSubtitleTrack(eTrackType Type, const tTrackId *TrackId) {}
71  // Sets the current subtitle track to the given value.
72  // This is just a virtual hook for players that need to do special things
73  // in order to switch subtitle tracks.
74  };
75 
76 class cControl : public cOsdObject {
77 private:
78  static cControl *control;
79  static cMutex mutex;
80  bool attached;
81  bool hidden;
82 protected:
84 public:
85  cControl(cPlayer *Player, bool Hidden = false);
86  virtual ~cControl();
87  virtual void Hide(void) = 0;
88  virtual cOsdObject *GetInfo(void);
92  virtual const cRecording *GetRecording(void);
95  virtual cString GetHeader(void);
101  double FramesPerSecond(void) { return player->FramesPerSecond(); }
102  bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false) { return player->GetIndex(Current, Total, SnapToIFrame); }
103  bool GetReplayMode(bool &Play, bool &Forward, int &Speed) { return player->GetReplayMode(Play, Forward, Speed); }
104  static void Launch(cControl *Control);
105  static void Attach(void);
106  static void Shutdown(void);
107  static cControl *Control(bool Hidden = false);
111  };
112 
113 #endif //__PLAYER_H