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