Ginga  0.13.6.2086-83aa
The iTV middleware.
Player.h
1 /* Copyright (C) 2006-2018 PUC-Rio/Laboratorio TeleMidia
2 
3 This file is part of Ginga (Ginga-NCL).
4 
5 Ginga is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9 
10 Ginga is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
13 License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with Ginga. If not, see <https://www.gnu.org/licenses/>. */
17 
18 #ifndef PLAYER_H
19 #define PLAYER_H
20 
21 #include "Formatter.h"
22 #include "PlayerAnimator.h"
23 
24 GINGA_NAMESPACE_BEGIN
25 
26 class Formatter;
27 class Media;
28 class Player
29 {
30 public:
31  enum State
32  {
33  SLEEPING = 1, // stopped
34  OCCURRING, // playing
35  PAUSED, // paused
36  };
37 
38  enum Property // known properties
39  {
40  PROP_UNKNOWN = 0,
41  PROP_BACKGROUND,
42  PROP_BALANCE,
43  PROP_BASS,
44  PROP_BOTTOM,
45  PROP_BOUNDS,
46  PROP_DEBUG,
47  PROP_DURATION,
48  PROP_EXPLICIT_DUR,
49  PROP_FOCUS_INDEX,
50  PROP_FONT_BG_COLOR,
51  PROP_FONT_COLOR,
52  PROP_FONT_FAMILY,
53  PROP_FONT_SIZE,
54  PROP_FONT_STYLE,
55  PROP_FONT_VARIANT,
56  PROP_FONT_WEIGHT,
57  PROP_FREEZE,
58  PROP_FREQ,
59  PROP_HEIGHT,
60  PROP_HORZ_ALIGN,
61  PROP_LEFT,
62  PROP_LOCATION,
63  PROP_MUTE,
64  PROP_RIGHT,
65  PROP_SIZE,
66  PROP_SPEED,
67  PROP_TIME,
68  PROP_TOP,
69  PROP_TRANSPARENCY,
70  PROP_TREBLE,
71  PROP_TYPE,
72  PROP_URI,
73  PROP_VERT_ALIGN,
74  PROP_VISIBLE,
75  PROP_VOLUME,
76  PROP_WAVE,
77  PROP_WIDTH,
78  PROP_Z_INDEX,
79  PROP_Z_ORDER,
80  };
81 
82  Player (Formatter *, Media *);
83  virtual ~Player ();
84 
85  State getState ();
86  void getZ (int *, int *);
87  bool isFocused ();
88 
89  Time getTime ();
90  void incTime (Time);
91 
92  Time getDuration ();
93  void setDuration (Time);
94 
95  bool getEOS ();
96  void setEOS (bool);
97 
98  virtual void start ();
99  virtual void stop ();
100  virtual void pause ();
101  virtual void resume ();
102 
103  virtual string getProperty (const string &);
104  virtual void setProperty (const string &, const string &);
105  void resetProperties ();
106  void resetProperties (set<string> *);
107  void schedulePropertyAnimation (const string &, const string &,
108  const string &, Time);
109  virtual void reload ();
110  virtual void redraw (cairo_t *);
111 
112  virtual void sendKeyEvent (const string &, bool);
113 
114  // For now, only for the lua player (which reimplements it).
115  virtual void
116  sendPresentationEvent (const string &, const string &)
117  {
118  }
119 
120  // Static.
121  static string getCurrentFocus ();
122  static void setCurrentFocus (const string &);
123  static Property getPlayerProperty (const string &, string *);
124  static Player *createPlayer (Formatter *, Media *, const string &,
125  const string &type = "");
126 
127 protected:
128  Formatter *_formatter; // formatter handle
129  Media *_media; // associated media object
130  string _id; // id of the associated media object
131  State _state; // current state
132  Time _time; // playback time
133  bool _eos; // true if content was exhausted
134  cairo_surface_t *_surface; // player surface
135  bool _opengl; // true if OpenGL is used
136  guint _gltexture; // OpenGL texture (if OpenGL is used)
137  bool _dirty; // true if surface should be reloaded
138  PlayerAnimator *_animator; // associated animator
139  list<int> _crop; // polygon for cropping effect
140 
141  map<string, string> _properties; // property table
142  struct
143  {
144  Color bgColor; // background color
145  Rect rect; // x, y, w, h in pixels
146  Time duration; // explicit duration
147  bool debug; // true if debugging mode is on
148  bool visible; // true if visible
149  guint8 alpha; // alpha
150  int z; // z-index
151  int zorder; // z-order
152  string focusIndex; // focus index
153  string type; // content mime-type
154  string uri; // content URI
155  } _prop;
156 
157 protected:
158  virtual bool doSetProperty (Property, const string &, const string &);
159 
160 private:
161  void redrawDebuggingInfo (cairo_t *);
162 
163  // Static.
164  static string _currentFocus; // current (global) focus index
165 };
166 
167 GINGA_NAMESPACE_END
168 
169 #endif // PLAYER_H
Definition: PlayerAnimator.h:91
Interface between libginga and the external world.
Definition: Formatter.h:37
Definition: Media.h:26
Definition: Player.h:28