1 | /* GStreamer |
2 | * |
3 | * Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com> |
4 | * Copyright (C) 2019-2020 Stephan Hesse <stephan@emliri.com> |
5 | * Copyright (C) 2020 Philippe Normand <philn@igalia.com> |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. |
11 | * |
12 | * This library is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Library General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Library General Public |
18 | * License along with this library; if not, write to the |
19 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
20 | * Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef __GST_PLAY_H__ |
24 | #define __GST_PLAY_H__ |
25 | |
26 | #include <gst/gst.h> |
27 | #include <gst/video/video.h> |
28 | #include <gst/play/play-prelude.h> |
29 | #include <gst/play/gstplay-types.h> |
30 | #include <gst/play/gstplay-video-renderer.h> |
31 | #include <gst/play/gstplay-media-info.h> |
32 | |
33 | G_BEGIN_DECLS |
34 | |
35 | GST_PLAY_API |
36 | GType gst_play_state_get_type (void); |
37 | |
38 | /** |
39 | * GST_TYPE_PLAY_STATE: |
40 | * Since: 1.20 |
41 | */ |
42 | #define GST_TYPE_PLAY_STATE (gst_play_state_get_type ()) |
43 | |
44 | GST_PLAY_API |
45 | GType gst_play_message_get_type (void); |
46 | |
47 | /** |
48 | * GST_TYPE_PLAY_MESSAGE: |
49 | * Since: 1.20 |
50 | */ |
51 | #define GST_TYPE_PLAY_MESSAGE (gst_play_message_get_type ()) |
52 | |
53 | /** |
54 | * GstPlayState: |
55 | * @GST_PLAY_STATE_STOPPED: the play is stopped. |
56 | * @GST_PLAY_STATE_BUFFERING: the play is buffering. |
57 | * @GST_PLAY_STATE_PAUSED: the play is paused. |
58 | * @GST_PLAY_STATE_PLAYING: the play is currently playing a |
59 | * stream. |
60 | * |
61 | * Since: 1.20 |
62 | */ |
63 | typedef enum |
64 | { |
65 | GST_PLAY_STATE_STOPPED, |
66 | GST_PLAY_STATE_BUFFERING, |
67 | GST_PLAY_STATE_PAUSED, |
68 | GST_PLAY_STATE_PLAYING |
69 | } GstPlayState; |
70 | |
71 | /** |
72 | * GstPlayMessage: |
73 | * @GST_PLAY_MESSAGE_URI_LOADED: Source element was initalized for set URI |
74 | * @GST_PLAY_MESSAGE_POSITION_UPDATED: Sink position changed |
75 | * @GST_PLAY_MESSAGE_DURATION_CHANGED: Duration of stream changed |
76 | * @GST_PLAY_MESSAGE_STATE_CHANGED: State changed, see #GstPlayState |
77 | * @GST_PLAY_MESSAGE_BUFFERING: Pipeline is in buffering state, message contains the percentage value of the decoding buffer |
78 | * @GST_PLAY_MESSAGE_END_OF_STREAM: Sink has received EOS |
79 | * @GST_PLAY_MESSAGE_ERROR: Message contains an error |
80 | * @GST_PLAY_MESSAGE_WARNING: Message contains an error |
81 | * @GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED: Video sink received format in different dimensions than before |
82 | * @GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED: A media-info property has changed, message contains current #GstPlayMediaInfo |
83 | * @GST_PLAY_MESSAGE_VOLUME_CHANGED: The volume of the audio ouput has changed |
84 | * @GST_PLAY_MESSAGE_MUTE_CHANGED: Audio muting flag has been toggled |
85 | * @GST_PLAY_MESSAGE_SEEK_DONE: Any pending seeking operation has been completed |
86 | * |
87 | * Since: 1.20 |
88 | * |
89 | * Types of messages that will be posted on the play API bus. |
90 | * |
91 | * See also #gst_play_get_message_bus() |
92 | * |
93 | */ |
94 | typedef enum |
95 | { |
96 | GST_PLAY_MESSAGE_URI_LOADED, |
97 | GST_PLAY_MESSAGE_POSITION_UPDATED, |
98 | GST_PLAY_MESSAGE_DURATION_CHANGED, |
99 | GST_PLAY_MESSAGE_STATE_CHANGED, |
100 | GST_PLAY_MESSAGE_BUFFERING, |
101 | GST_PLAY_MESSAGE_END_OF_STREAM, |
102 | GST_PLAY_MESSAGE_ERROR, |
103 | GST_PLAY_MESSAGE_WARNING, |
104 | GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED, |
105 | GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED, |
106 | GST_PLAY_MESSAGE_VOLUME_CHANGED, |
107 | GST_PLAY_MESSAGE_MUTE_CHANGED, |
108 | GST_PLAY_MESSAGE_SEEK_DONE |
109 | } GstPlayMessage; |
110 | |
111 | GST_PLAY_API |
112 | const gchar *gst_play_state_get_name (GstPlayState state); |
113 | |
114 | GST_PLAY_API |
115 | const gchar *gst_play_message_get_name (GstPlayMessage message_type); |
116 | |
117 | GST_PLAY_API |
118 | GQuark gst_play_error_quark (void); |
119 | |
120 | GST_PLAY_API |
121 | GType gst_play_error_get_type (void); |
122 | |
123 | /** |
124 | * GST_PLAY_ERROR: |
125 | * |
126 | * Since: 1.20 |
127 | */ |
128 | #define GST_PLAY_ERROR (gst_play_error_quark ()) |
129 | |
130 | /** |
131 | * GST_TYPE_PLAY_ERROR: |
132 | * |
133 | * Since: 1.20 |
134 | */ |
135 | #define GST_TYPE_PLAY_ERROR (gst_play_error_get_type ()) |
136 | |
137 | /** |
138 | * GstPlayError: |
139 | * @GST_PLAY_ERROR_FAILED: generic error. |
140 | * |
141 | * Since: 1.20 |
142 | */ |
143 | typedef enum { |
144 | GST_PLAY_ERROR_FAILED = 0 |
145 | } GstPlayError; |
146 | |
147 | GST_PLAY_API |
148 | const gchar *gst_play_error_get_name (GstPlayError error); |
149 | |
150 | GST_PLAY_API |
151 | GType gst_play_color_balance_type_get_type (void); |
152 | |
153 | /** |
154 | * GST_TYPE_PLAY_COLOR_BALANCE_TYPE: |
155 | * |
156 | * Since: 1.20 |
157 | */ |
158 | #define GST_TYPE_PLAY_COLOR_BALANCE_TYPE (gst_play_color_balance_type_get_type ()) |
159 | |
160 | /** |
161 | * GstPlayColorBalanceType: |
162 | * @GST_PLAY_COLOR_BALANCE_BRIGHTNESS: brightness or black level. |
163 | * @GST_PLAY_COLOR_BALANCE_CONTRAST: contrast or luma gain. |
164 | * @GST_PLAY_COLOR_BALANCE_SATURATION: color saturation or chroma |
165 | * gain. |
166 | * @GST_PLAY_COLOR_BALANCE_HUE: hue or color balance. |
167 | * |
168 | * Since: 1.20 |
169 | */ |
170 | typedef enum |
171 | { |
172 | GST_PLAY_COLOR_BALANCE_BRIGHTNESS, |
173 | GST_PLAY_COLOR_BALANCE_CONTRAST, |
174 | GST_PLAY_COLOR_BALANCE_SATURATION, |
175 | GST_PLAY_COLOR_BALANCE_HUE, |
176 | } GstPlayColorBalanceType; |
177 | |
178 | GST_PLAY_API |
179 | const gchar *gst_play_color_balance_type_get_name (GstPlayColorBalanceType type); |
180 | |
181 | #define GST_TYPE_PLAY (gst_play_get_type ()) |
182 | #define GST_IS_PLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAY)) |
183 | #define GST_IS_PLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAY)) |
184 | #define GST_PLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAY, GstPlayClass)) |
185 | #define GST_PLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAY, GstPlay)) |
186 | #define GST_PLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAY, GstPlayClass)) |
187 | |
188 | /** |
189 | * GST_PLAY_CAST: |
190 | * Since: 1.20 |
191 | */ |
192 | #define GST_PLAY_CAST(obj) ((GstPlay*)(obj)) |
193 | |
194 | #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC |
195 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstPlay, gst_object_unref) |
196 | #endif |
197 | |
198 | GST_PLAY_API |
199 | GType gst_play_get_type (void); |
200 | |
201 | GST_PLAY_API |
202 | GstPlay * gst_play_new (GstPlayVideoRenderer * video_renderer); |
203 | |
204 | GST_PLAY_API |
205 | GstBus * gst_play_get_message_bus (GstPlay * play); |
206 | |
207 | GST_PLAY_API |
208 | void gst_play_play (GstPlay * play); |
209 | |
210 | GST_PLAY_API |
211 | void gst_play_pause (GstPlay * play); |
212 | |
213 | GST_PLAY_API |
214 | void gst_play_stop (GstPlay * play); |
215 | |
216 | GST_PLAY_API |
217 | void gst_play_seek (GstPlay * play, |
218 | GstClockTime position); |
219 | |
220 | GST_PLAY_API |
221 | void gst_play_set_rate (GstPlay * play, |
222 | gdouble rate); |
223 | |
224 | GST_PLAY_API |
225 | gdouble gst_play_get_rate (GstPlay * play); |
226 | |
227 | GST_PLAY_API |
228 | gchar * gst_play_get_uri (GstPlay * play); |
229 | |
230 | GST_PLAY_API |
231 | void gst_play_set_uri (GstPlay * play, |
232 | const gchar * uri); |
233 | |
234 | GST_PLAY_API |
235 | gchar * gst_play_get_subtitle_uri (GstPlay * play); |
236 | |
237 | GST_PLAY_API |
238 | void gst_play_set_subtitle_uri (GstPlay * play, |
239 | const gchar *uri); |
240 | |
241 | GST_PLAY_API |
242 | GstClockTime gst_play_get_position (GstPlay * play); |
243 | |
244 | GST_PLAY_API |
245 | GstClockTime gst_play_get_duration (GstPlay * play); |
246 | |
247 | GST_PLAY_API |
248 | gdouble gst_play_get_volume (GstPlay * play); |
249 | |
250 | GST_PLAY_API |
251 | void gst_play_set_volume (GstPlay * play, |
252 | gdouble val); |
253 | |
254 | GST_PLAY_API |
255 | gboolean gst_play_get_mute (GstPlay * play); |
256 | |
257 | GST_PLAY_API |
258 | void gst_play_set_mute (GstPlay * play, |
259 | gboolean val); |
260 | |
261 | GST_PLAY_API |
262 | GstElement * gst_play_get_pipeline (GstPlay * play); |
263 | |
264 | GST_PLAY_API |
265 | void gst_play_set_video_track_enabled (GstPlay * play, |
266 | gboolean enabled); |
267 | |
268 | GST_PLAY_API |
269 | void gst_play_set_audio_track_enabled (GstPlay * play, |
270 | gboolean enabled); |
271 | |
272 | GST_PLAY_API |
273 | void gst_play_set_subtitle_track_enabled (GstPlay * play, |
274 | gboolean enabled); |
275 | |
276 | GST_PLAY_API |
277 | gboolean gst_play_set_audio_track (GstPlay *play, |
278 | gint stream_index); |
279 | |
280 | GST_PLAY_API |
281 | gboolean gst_play_set_video_track (GstPlay *play, |
282 | gint stream_index); |
283 | |
284 | GST_PLAY_API |
285 | gboolean gst_play_set_subtitle_track (GstPlay *play, |
286 | gint stream_index); |
287 | |
288 | GST_PLAY_API |
289 | GstPlayMediaInfo * gst_play_get_media_info (GstPlay * play); |
290 | |
291 | GST_PLAY_API |
292 | GstPlayAudioInfo * gst_play_get_current_audio_track (GstPlay * play); |
293 | |
294 | GST_PLAY_API |
295 | GstPlayVideoInfo * gst_play_get_current_video_track (GstPlay * play); |
296 | |
297 | GST_PLAY_API |
298 | GstPlaySubtitleInfo * gst_play_get_current_subtitle_track (GstPlay * play); |
299 | |
300 | GST_PLAY_API |
301 | gboolean gst_play_set_visualization (GstPlay * play, |
302 | const gchar *name); |
303 | |
304 | GST_PLAY_API |
305 | void gst_play_set_visualization_enabled (GstPlay * play, |
306 | gboolean enabled); |
307 | |
308 | GST_PLAY_API |
309 | gchar * gst_play_get_current_visualization (GstPlay * play); |
310 | |
311 | GST_PLAY_API |
312 | gboolean gst_play_has_color_balance (GstPlay * play); |
313 | |
314 | GST_PLAY_API |
315 | void gst_play_set_color_balance (GstPlay * play, |
316 | GstPlayColorBalanceType type, |
317 | gdouble value); |
318 | |
319 | GST_PLAY_API |
320 | gdouble gst_play_get_color_balance (GstPlay * play, |
321 | GstPlayColorBalanceType type); |
322 | |
323 | |
324 | GST_PLAY_API |
325 | GstVideoMultiviewFramePacking gst_play_get_multiview_mode (GstPlay * play); |
326 | |
327 | GST_PLAY_API |
328 | void gst_play_set_multiview_mode (GstPlay * play, |
329 | GstVideoMultiviewFramePacking mode); |
330 | |
331 | GST_PLAY_API |
332 | GstVideoMultiviewFlags gst_play_get_multiview_flags (GstPlay * play); |
333 | |
334 | GST_PLAY_API |
335 | void gst_play_set_multiview_flags (GstPlay * play, |
336 | GstVideoMultiviewFlags flags); |
337 | |
338 | GST_PLAY_API |
339 | gint64 gst_play_get_audio_video_offset (GstPlay * play); |
340 | |
341 | GST_PLAY_API |
342 | void gst_play_set_audio_video_offset (GstPlay * play, |
343 | gint64 offset); |
344 | |
345 | GST_PLAY_API |
346 | gint64 gst_play_get_subtitle_video_offset (GstPlay * play); |
347 | |
348 | GST_PLAY_API |
349 | void gst_play_set_subtitle_video_offset (GstPlay * play, |
350 | gint64 offset); |
351 | |
352 | GST_PLAY_API |
353 | gboolean gst_play_set_config (GstPlay * play, |
354 | GstStructure * config); |
355 | |
356 | GST_PLAY_API |
357 | GstStructure * gst_play_get_config (GstPlay * play); |
358 | |
359 | /* helpers for configuring the config structure */ |
360 | |
361 | GST_PLAY_API |
362 | void gst_play_config_set_user_agent (GstStructure * config, |
363 | const gchar * agent); |
364 | |
365 | GST_PLAY_API |
366 | gchar * gst_play_config_get_user_agent (const GstStructure * config); |
367 | |
368 | GST_PLAY_API |
369 | void gst_play_config_set_position_update_interval (GstStructure * config, |
370 | guint interval); |
371 | |
372 | GST_PLAY_API |
373 | guint gst_play_config_get_position_update_interval (const GstStructure * config); |
374 | |
375 | GST_PLAY_API |
376 | void gst_play_config_set_seek_accurate (GstStructure * config, gboolean accurate); |
377 | |
378 | GST_PLAY_API |
379 | gboolean gst_play_config_get_seek_accurate (const GstStructure * config); |
380 | |
381 | /** |
382 | * GstPlaySnapshotFormat: |
383 | * @GST_PLAY_THUMBNAIL_RAW_NATIVE: raw native format. |
384 | * @GST_PLAY_THUMBNAIL_RAW_xRGB: raw xRGB format. |
385 | * @GST_PLAY_THUMBNAIL_RAW_BGRx: raw BGRx format. |
386 | * @GST_PLAY_THUMBNAIL_JPG: jpeg format. |
387 | * @GST_PLAY_THUMBNAIL_PNG: png format. |
388 | * |
389 | * Since: 1.20 |
390 | */ |
391 | typedef enum |
392 | { |
393 | GST_PLAY_THUMBNAIL_RAW_NATIVE = 0, |
394 | GST_PLAY_THUMBNAIL_RAW_xRGB, |
395 | GST_PLAY_THUMBNAIL_RAW_BGRx, |
396 | GST_PLAY_THUMBNAIL_JPG, |
397 | GST_PLAY_THUMBNAIL_PNG |
398 | } GstPlaySnapshotFormat; |
399 | |
400 | GST_PLAY_API |
401 | GstSample * gst_play_get_video_snapshot (GstPlay * play, |
402 | GstPlaySnapshotFormat format, const GstStructure * config); |
403 | |
404 | GST_PLAY_API |
405 | gboolean gst_play_is_play_message (GstMessage *msg); |
406 | |
407 | GST_PLAY_API |
408 | void gst_play_message_parse_type (GstMessage *msg, GstPlayMessage *type); |
409 | |
410 | GST_PLAY_API |
411 | void gst_play_message_parse_duration_updated (GstMessage *msg, GstClockTime *duration); |
412 | |
413 | GST_PLAY_API |
414 | void gst_play_message_parse_position_updated (GstMessage *msg, GstClockTime *position); |
415 | |
416 | GST_PLAY_API |
417 | void gst_play_message_parse_state_changed (GstMessage *msg, GstPlayState *state); |
418 | |
419 | GST_PLAY_API |
420 | void gst_play_message_parse_buffering_percent (GstMessage *msg, guint *percent); |
421 | |
422 | GST_PLAY_API |
423 | void gst_play_message_parse_error (GstMessage *msg, GError **error, GstStructure **details); |
424 | |
425 | GST_PLAY_API |
426 | void gst_play_message_parse_warning (GstMessage *msg, GError **error, GstStructure **details); |
427 | |
428 | GST_PLAY_API |
429 | void gst_play_message_parse_video_dimensions_changed (GstMessage *msg, guint *width, guint *height); |
430 | |
431 | GST_PLAY_API |
432 | void gst_play_message_parse_media_info_updated (GstMessage *msg, GstPlayMediaInfo **info); |
433 | |
434 | GST_PLAY_API |
435 | void gst_play_message_parse_volume_changed (GstMessage *msg, gdouble *volume); |
436 | |
437 | GST_PLAY_API |
438 | void gst_play_message_parse_muted_changed (GstMessage *msg, gboolean *muted); |
439 | |
440 | G_END_DECLS |
441 | |
442 | #endif /* __GST_PLAY_H__ */ |
443 | |