1 /* GStreamer
2  *
3  * Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef __GST_PLAYER_H__
22 #define __GST_PLAYER_H__
23 
24 #include <gst/gst.h>
25 #include <gst/video/video.h>
26 #include <gst/player/player-prelude.h>
27 #include <gst/player/gstplayer-types.h>
28 #include <gst/player/gstplayer-signal-dispatcher.h>
29 #include <gst/player/gstplayer-video-renderer.h>
30 #include <gst/player/gstplayer-media-info.h>
31 
32 G_BEGIN_DECLS
33 
34 GST_PLAYER_API
35 GType        gst_player_state_get_type                (void);
36 #define      GST_TYPE_PLAYER_STATE                    (gst_player_state_get_type ())
37 
38 /**
39  * GstPlayerState:
40  * @GST_PLAYER_STATE_STOPPED: the player is stopped.
41  * @GST_PLAYER_STATE_BUFFERING: the player is buffering.
42  * @GST_PLAYER_STATE_PAUSED: the player is paused.
43  * @GST_PLAYER_STATE_PLAYING: the player is currently playing a
44  * stream.
45  */
46 typedef enum
47 {
48   GST_PLAYER_STATE_STOPPED,
49   GST_PLAYER_STATE_BUFFERING,
50   GST_PLAYER_STATE_PAUSED,
51   GST_PLAYER_STATE_PLAYING
52 } GstPlayerState;
53 
54 GST_PLAYER_API
55 const gchar *gst_player_state_get_name                (GstPlayerState state);
56 
57 GST_PLAYER_API
58 GQuark       gst_player_error_quark                   (void);
59 
60 GST_PLAYER_API
61 GType        gst_player_error_get_type                (void);
62 #define      GST_PLAYER_ERROR                         (gst_player_error_quark ())
63 #define      GST_TYPE_PLAYER_ERROR                    (gst_player_error_get_type ())
64 
65 /**
66  * GstPlayerError:
67  * @GST_PLAYER_ERROR_FAILED: generic error.
68  */
69 typedef enum {
70   GST_PLAYER_ERROR_FAILED = 0
71 } GstPlayerError;
72 
73 GST_PLAYER_API
74 const gchar *gst_player_error_get_name                (GstPlayerError error);
75 
76 GST_PLAYER_API
77 GType gst_player_color_balance_type_get_type          (void);
78 #define GST_TYPE_PLAYER_COLOR_BALANCE_TYPE            (gst_player_color_balance_type_get_type ())
79 
80 /**
81  * GstPlayerColorBalanceType:
82  * @GST_PLAYER_COLOR_BALANCE_BRIGHTNESS: brightness or black level.
83  * @GST_PLAYER_COLOR_BALANCE_CONTRAST: contrast or luma gain.
84  * @GST_PLAYER_COLOR_BALANCE_SATURATION: color saturation or chroma
85  * gain.
86  * @GST_PLAYER_COLOR_BALANCE_HUE: hue or color balance.
87  */
88 typedef enum
89 {
90   GST_PLAYER_COLOR_BALANCE_BRIGHTNESS,
91   GST_PLAYER_COLOR_BALANCE_CONTRAST,
92   GST_PLAYER_COLOR_BALANCE_SATURATION,
93   GST_PLAYER_COLOR_BALANCE_HUE,
94 } GstPlayerColorBalanceType;
95 
96 GST_PLAYER_API
97 const gchar *gst_player_color_balance_type_get_name   (GstPlayerColorBalanceType type);
98 
99 #define GST_TYPE_PLAYER             (gst_player_get_type ())
100 #define GST_IS_PLAYER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER))
101 #define GST_IS_PLAYER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAYER))
102 #define GST_PLAYER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAYER, GstPlayerClass))
103 #define GST_PLAYER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER, GstPlayer))
104 #define GST_PLAYER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAYER, GstPlayerClass))
105 #define GST_PLAYER_CAST(obj)        ((GstPlayer*)(obj))
106 
107 
108 GST_PLAYER_API
109 GType        gst_player_get_type                      (void);
110 
111 GST_PLAYER_API
112 GstPlayer *  gst_player_new                           (GstPlayerVideoRenderer * video_renderer, GstPlayerSignalDispatcher * signal_dispatcher);
113 
114 GST_PLAYER_API
115 void         gst_player_play                          (GstPlayer    * player);
116 
117 GST_PLAYER_API
118 void         gst_player_pause                         (GstPlayer    * player);
119 
120 GST_PLAYER_API
121 void         gst_player_stop                          (GstPlayer    * player);
122 
123 GST_PLAYER_API
124 void         gst_player_seek                          (GstPlayer    * player,
125                                                        GstClockTime   position);
126 
127 GST_PLAYER_API
128 void         gst_player_set_rate                      (GstPlayer    * player,
129                                                        gdouble        rate);
130 
131 GST_PLAYER_API
132 gdouble      gst_player_get_rate                      (GstPlayer    * player);
133 
134 GST_PLAYER_API
135 gchar *      gst_player_get_uri                       (GstPlayer    * player);
136 
137 GST_PLAYER_API
138 void         gst_player_set_uri                       (GstPlayer    * player,
139                                                        const gchar  * uri);
140 
141 GST_PLAYER_API
142 gchar *      gst_player_get_subtitle_uri              (GstPlayer    * player);
143 
144 GST_PLAYER_API
145 void         gst_player_set_subtitle_uri              (GstPlayer    * player,
146                                                        const gchar *uri);
147 
148 GST_PLAYER_API
149 GstClockTime gst_player_get_position                  (GstPlayer    * player);
150 
151 GST_PLAYER_API
152 GstClockTime gst_player_get_duration                  (GstPlayer    * player);
153 
154 GST_PLAYER_API
155 gdouble      gst_player_get_volume                    (GstPlayer    * player);
156 
157 GST_PLAYER_API
158 void         gst_player_set_volume                    (GstPlayer    * player,
159                                                        gdouble        val);
160 
161 GST_PLAYER_API
162 gboolean     gst_player_get_mute                      (GstPlayer    * player);
163 
164 GST_PLAYER_API
165 void         gst_player_set_mute                      (GstPlayer    * player,
166                                                        gboolean       val);
167 
168 GST_PLAYER_API
169 GstElement * gst_player_get_pipeline                  (GstPlayer    * player);
170 
171 GST_PLAYER_API
172 void         gst_player_set_video_track_enabled       (GstPlayer    * player,
173                                                        gboolean enabled);
174 
175 GST_PLAYER_API
176 void         gst_player_set_audio_track_enabled       (GstPlayer    * player,
177                                                        gboolean enabled);
178 
179 GST_PLAYER_API
180 void         gst_player_set_subtitle_track_enabled    (GstPlayer    * player,
181                                                        gboolean enabled);
182 
183 GST_PLAYER_API
184 gboolean     gst_player_set_audio_track               (GstPlayer    *player,
185                                                        gint stream_index);
186 
187 GST_PLAYER_API
188 gboolean     gst_player_set_video_track               (GstPlayer    *player,
189                                                        gint stream_index);
190 
191 GST_PLAYER_API
192 gboolean     gst_player_set_subtitle_track            (GstPlayer    *player,
193                                                        gint stream_index);
194 
195 GST_PLAYER_API
196 GstPlayerMediaInfo *    gst_player_get_media_info     (GstPlayer * player);
197 
198 GST_PLAYER_API
199 GstPlayerAudioInfo *    gst_player_get_current_audio_track (GstPlayer * player);
200 
201 GST_PLAYER_API
202 GstPlayerVideoInfo *    gst_player_get_current_video_track (GstPlayer * player);
203 
204 GST_PLAYER_API
205 GstPlayerSubtitleInfo * gst_player_get_current_subtitle_track (GstPlayer * player);
206 
207 GST_PLAYER_API
208 gboolean     gst_player_set_visualization             (GstPlayer    * player,
209                                                        const gchar *name);
210 
211 GST_PLAYER_API
212 void         gst_player_set_visualization_enabled     (GstPlayer    * player,
213                                                        gboolean enabled);
214 
215 GST_PLAYER_API
216 gchar *      gst_player_get_current_visualization     (GstPlayer    * player);
217 
218 GST_PLAYER_API
219 gboolean     gst_player_has_color_balance             (GstPlayer    * player);
220 
221 GST_PLAYER_API
222 void         gst_player_set_color_balance             (GstPlayer    * player,
223                                                        GstPlayerColorBalanceType type,
224                                                        gdouble value);
225 
226 GST_PLAYER_API
227 gdouble      gst_player_get_color_balance             (GstPlayer    * player,
228                                                        GstPlayerColorBalanceType type);
229 
230 
231 GST_PLAYER_API
232 GstVideoMultiviewFramePacking gst_player_get_multiview_mode (GstPlayer    * player);
233 
234 GST_PLAYER_API
235 void                     gst_player_set_multiview_mode (GstPlayer    * player,
236                                                         GstVideoMultiviewFramePacking mode);
237 
238 GST_PLAYER_API
239 GstVideoMultiviewFlags  gst_player_get_multiview_flags  (GstPlayer  * player);
240 
241 GST_PLAYER_API
242 void                    gst_player_set_multiview_flags  (GstPlayer  * player,
243                                                          GstVideoMultiviewFlags flags);
244 
245 GST_PLAYER_API
246 gint64       gst_player_get_audio_video_offset        (GstPlayer    * player);
247 
248 GST_PLAYER_API
249 void         gst_player_set_audio_video_offset        (GstPlayer    * player,
250                                                        gint64 offset);
251 
252 GST_PLAYER_API
253 gint64       gst_player_get_subtitle_video_offset        (GstPlayer    * player);
254 
255 GST_PLAYER_API
256 void         gst_player_set_subtitle_video_offset        (GstPlayer    * player,
257                                                           gint64 offset);
258 
259 GST_PLAYER_API
260 gboolean       gst_player_set_config                  (GstPlayer * player,
261                                                        GstStructure * config);
262 
263 GST_PLAYER_API
264 GstStructure * gst_player_get_config                  (GstPlayer * player);
265 
266 /* helpers for configuring the config structure */
267 
268 GST_PLAYER_API
269 void           gst_player_config_set_user_agent       (GstStructure * config,
270                                                        const gchar * agent);
271 
272 GST_PLAYER_API
273 gchar *        gst_player_config_get_user_agent       (const GstStructure * config);
274 
275 GST_PLAYER_API
276 void           gst_player_config_set_position_update_interval  (GstStructure * config,
277                                                                 guint          interval);
278 
279 GST_PLAYER_API
280 guint          gst_player_config_get_position_update_interval  (const GstStructure * config);
281 
282 GST_PLAYER_API
283 void           gst_player_config_set_seek_accurate (GstStructure * config, gboolean accurate);
284 
285 GST_PLAYER_API
286 gboolean       gst_player_config_get_seek_accurate (const GstStructure * config);
287 
288 typedef enum
289 {
290   GST_PLAYER_THUMBNAIL_RAW_NATIVE = 0,
291   GST_PLAYER_THUMBNAIL_RAW_xRGB,
292   GST_PLAYER_THUMBNAIL_RAW_BGRx,
293   GST_PLAYER_THUMBNAIL_JPG,
294   GST_PLAYER_THUMBNAIL_PNG
295 } GstPlayerSnapshotFormat;
296 
297 GST_PLAYER_API
298 GstSample * gst_player_get_video_snapshot (GstPlayer * player,
299     GstPlayerSnapshotFormat format, const GstStructure * config);
300 
301 G_END_DECLS
302 
303 #endif /* __GST_PLAYER_H__ */
304