summaryrefslogtreecommitdiff
path: root/gst-libs/gst/play/gstplay.h
blob: ce0d6c5239fc9c0575e69f2f6a4dcb8a2b2291b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
/* GStreamer
 *
 * Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
 * Copyright (C) 2019-2020 Stephan Hesse <stephan@emliri.com>
 * Copyright (C) 2020 Philippe Normand <philn@igalia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef __GST_PLAY_H__
#define __GST_PLAY_H__

#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/play/play-prelude.h>
#include <gst/play/gstplay-types.h>
#include <gst/play/gstplay-video-renderer.h>
#include <gst/play/gstplay-media-info.h>

G_BEGIN_DECLS

GST_PLAY_API
GType        gst_play_state_get_type                (void);

/**
 * GST_TYPE_PLAY_STATE:
 * Since: 1.20
 */
#define      GST_TYPE_PLAY_STATE                    (gst_play_state_get_type ())

GST_PLAY_API
GType        gst_play_message_get_type              (void);

/**
 * GST_TYPE_PLAY_MESSAGE:
 * Since: 1.20
 */
#define      GST_TYPE_PLAY_MESSAGE                  (gst_play_message_get_type ())

/**
 * GstPlayState:
 * @GST_PLAY_STATE_STOPPED: the play is stopped.
 * @GST_PLAY_STATE_BUFFERING: the play is buffering.
 * @GST_PLAY_STATE_PAUSED: the play is paused.
 * @GST_PLAY_STATE_PLAYING: the play is currently playing a
 * stream.
 *
 * Since: 1.20
 */
typedef enum
{
  GST_PLAY_STATE_STOPPED,
  GST_PLAY_STATE_BUFFERING,
  GST_PLAY_STATE_PAUSED,
  GST_PLAY_STATE_PLAYING
} GstPlayState;

/**
 * GstPlayMessage:
 * @GST_PLAY_MESSAGE_URI_LOADED: Source element was initalized for set URI
 * @GST_PLAY_MESSAGE_POSITION_UPDATED: Sink position changed
 * @GST_PLAY_MESSAGE_DURATION_CHANGED: Duration of stream changed
 * @GST_PLAY_MESSAGE_STATE_CHANGED: State changed, see #GstPlayState
 * @GST_PLAY_MESSAGE_BUFFERING: Pipeline is in buffering state, message contains the percentage value of the decoding buffer
 * @GST_PLAY_MESSAGE_END_OF_STREAM: Sink has received EOS
 * @GST_PLAY_MESSAGE_ERROR: Message contains an error
 * @GST_PLAY_MESSAGE_WARNING: Message contains an error
 * @GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED: Video sink received format in different dimensions than before
 * @GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED: A media-info property has changed, message contains current #GstPlayMediaInfo
 * @GST_PLAY_MESSAGE_VOLUME_CHANGED: The volume of the audio ouput has changed
 * @GST_PLAY_MESSAGE_MUTE_CHANGED: Audio muting flag has been toggled
 * @GST_PLAY_MESSAGE_SEEK_DONE: Any pending seeking operation has been completed
 *
 * Since: 1.20
 *
 * Types of messages that will be posted on the play API bus.
 *
 * See also #gst_play_get_message_bus()
 *
 */
typedef enum
{
  GST_PLAY_MESSAGE_URI_LOADED,
  GST_PLAY_MESSAGE_POSITION_UPDATED,
  GST_PLAY_MESSAGE_DURATION_CHANGED,
  GST_PLAY_MESSAGE_STATE_CHANGED,
  GST_PLAY_MESSAGE_BUFFERING,
  GST_PLAY_MESSAGE_END_OF_STREAM,
  GST_PLAY_MESSAGE_ERROR,
  GST_PLAY_MESSAGE_WARNING,
  GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED,
  GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED,
  GST_PLAY_MESSAGE_VOLUME_CHANGED,
  GST_PLAY_MESSAGE_MUTE_CHANGED,
  GST_PLAY_MESSAGE_SEEK_DONE
} GstPlayMessage;

GST_PLAY_API
const gchar *gst_play_state_get_name                (GstPlayState state);

GST_PLAY_API
const gchar *gst_play_message_get_name              (GstPlayMessage message_type);

GST_PLAY_API
GQuark       gst_play_error_quark                   (void);

GST_PLAY_API
GType        gst_play_error_get_type                (void);

/**
 * GST_PLAY_ERROR:
 *
 * Since: 1.20
 */
#define      GST_PLAY_ERROR                         (gst_play_error_quark ())

/**
 * GST_TYPE_PLAY_ERROR:
 *
 * Since: 1.20
 */
#define      GST_TYPE_PLAY_ERROR                    (gst_play_error_get_type ())

/**
 * GstPlayError:
 * @GST_PLAY_ERROR_FAILED: generic error.
 *
 * Since: 1.20
 */
typedef enum {
  GST_PLAY_ERROR_FAILED = 0
} GstPlayError;

GST_PLAY_API
const gchar *gst_play_error_get_name                (GstPlayError error);

GST_PLAY_API
GType gst_play_color_balance_type_get_type          (void);

/**
 * GST_TYPE_PLAY_COLOR_BALANCE_TYPE:
 *
 * Since: 1.20
 */
#define GST_TYPE_PLAY_COLOR_BALANCE_TYPE            (gst_play_color_balance_type_get_type ())

/**
 * GstPlayColorBalanceType:
 * @GST_PLAY_COLOR_BALANCE_BRIGHTNESS: brightness or black level.
 * @GST_PLAY_COLOR_BALANCE_CONTRAST: contrast or luma gain.
 * @GST_PLAY_COLOR_BALANCE_SATURATION: color saturation or chroma
 * gain.
 * @GST_PLAY_COLOR_BALANCE_HUE: hue or color balance.
 *
 * Since: 1.20
 */
typedef enum
{
  GST_PLAY_COLOR_BALANCE_BRIGHTNESS,
  GST_PLAY_COLOR_BALANCE_CONTRAST,
  GST_PLAY_COLOR_BALANCE_SATURATION,
  GST_PLAY_COLOR_BALANCE_HUE,
} GstPlayColorBalanceType;

GST_PLAY_API
const gchar *gst_play_color_balance_type_get_name   (GstPlayColorBalanceType type);

#define GST_TYPE_PLAY             (gst_play_get_type ())
#define GST_IS_PLAY(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAY))
#define GST_IS_PLAY_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAY))
#define GST_PLAY_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAY, GstPlayClass))
#define GST_PLAY(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAY, GstPlay))
#define GST_PLAY_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAY, GstPlayClass))

/**
 * GST_PLAY_CAST:
 * Since: 1.20
 */
#define GST_PLAY_CAST(obj)        ((GstPlay*)(obj))

#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstPlay, gst_object_unref)
#endif

GST_PLAY_API
GType        gst_play_get_type                      (void);

GST_PLAY_API
GstPlay *    gst_play_new                           (GstPlayVideoRenderer * video_renderer);

GST_PLAY_API
GstBus *     gst_play_get_message_bus               (GstPlay    * play);

GST_PLAY_API
void         gst_play_play                          (GstPlay    * play);

GST_PLAY_API
void         gst_play_pause                         (GstPlay    * play);

GST_PLAY_API
void         gst_play_stop                          (GstPlay    * play);

GST_PLAY_API
void         gst_play_seek                          (GstPlay    * play,
                                                     GstClockTime   position);

GST_PLAY_API
void         gst_play_set_rate                      (GstPlay    * play,
                                                     gdouble        rate);

GST_PLAY_API
gdouble      gst_play_get_rate                      (GstPlay    * play);

GST_PLAY_API
gchar *      gst_play_get_uri                       (GstPlay    * play);

GST_PLAY_API
void         gst_play_set_uri                       (GstPlay    * play,
                                                     const gchar  * uri);

GST_PLAY_API
gchar *      gst_play_get_subtitle_uri              (GstPlay    * play);

GST_PLAY_API
void         gst_play_set_subtitle_uri              (GstPlay    * play,
                                                     const gchar *uri);

GST_PLAY_API
GstClockTime gst_play_get_position                  (GstPlay    * play);

GST_PLAY_API
GstClockTime gst_play_get_duration                  (GstPlay    * play);

GST_PLAY_API
gdouble      gst_play_get_volume                    (GstPlay    * play);

GST_PLAY_API
void         gst_play_set_volume                    (GstPlay    * play,
                                                     gdouble        val);

GST_PLAY_API
gboolean     gst_play_get_mute                      (GstPlay    * play);

GST_PLAY_API
void         gst_play_set_mute                      (GstPlay    * play,
                                                     gboolean       val);

GST_PLAY_API
GstElement * gst_play_get_pipeline                  (GstPlay    * play);

GST_PLAY_API
void         gst_play_set_video_track_enabled       (GstPlay    * play,
                                                     gboolean enabled);

GST_PLAY_API
void         gst_play_set_audio_track_enabled       (GstPlay    * play,
                                                     gboolean enabled);

GST_PLAY_API
void         gst_play_set_subtitle_track_enabled    (GstPlay    * play,
                                                     gboolean enabled);

GST_PLAY_API
gboolean     gst_play_set_audio_track               (GstPlay    *play,
                                                     gint stream_index);

GST_PLAY_API
gboolean     gst_play_set_video_track               (GstPlay    *play,
                                                     gint stream_index);

GST_PLAY_API
gboolean     gst_play_set_subtitle_track            (GstPlay    *play,
                                                     gint stream_index);

GST_PLAY_API
GstPlayMediaInfo *    gst_play_get_media_info     (GstPlay * play);

GST_PLAY_API
GstPlayAudioInfo *    gst_play_get_current_audio_track (GstPlay * play);

GST_PLAY_API
GstPlayVideoInfo *    gst_play_get_current_video_track (GstPlay * play);

GST_PLAY_API
GstPlaySubtitleInfo * gst_play_get_current_subtitle_track (GstPlay * play);

GST_PLAY_API
gboolean     gst_play_set_visualization             (GstPlay    * play,
                                                     const gchar *name);

GST_PLAY_API
void         gst_play_set_visualization_enabled     (GstPlay    * play,
                                                     gboolean enabled);

GST_PLAY_API
gchar *      gst_play_get_current_visualization     (GstPlay    * play);

GST_PLAY_API
gboolean     gst_play_has_color_balance             (GstPlay    * play);

GST_PLAY_API
void         gst_play_set_color_balance             (GstPlay    * play,
                                                     GstPlayColorBalanceType type,
                                                     gdouble value);

GST_PLAY_API
gdouble      gst_play_get_color_balance             (GstPlay    * play,
                                                     GstPlayColorBalanceType type);


GST_PLAY_API
GstVideoMultiviewFramePacking gst_play_get_multiview_mode (GstPlay    * play);

GST_PLAY_API
void                     gst_play_set_multiview_mode (GstPlay    * play,
                                                      GstVideoMultiviewFramePacking mode);

GST_PLAY_API
GstVideoMultiviewFlags  gst_play_get_multiview_flags  (GstPlay  * play);

GST_PLAY_API
void                    gst_play_set_multiview_flags  (GstPlay  * play,
                                                       GstVideoMultiviewFlags flags);

GST_PLAY_API
gint64       gst_play_get_audio_video_offset        (GstPlay    * play);

GST_PLAY_API
void         gst_play_set_audio_video_offset        (GstPlay    * play,
                                                     gint64 offset);

GST_PLAY_API
gint64       gst_play_get_subtitle_video_offset        (GstPlay    * play);

GST_PLAY_API
void         gst_play_set_subtitle_video_offset        (GstPlay    * play,
                                                        gint64 offset);

GST_PLAY_API
gboolean       gst_play_set_config                  (GstPlay * play,
                                                     GstStructure * config);

GST_PLAY_API
GstStructure * gst_play_get_config                  (GstPlay * play);

/* helpers for configuring the config structure */

GST_PLAY_API
void           gst_play_config_set_user_agent       (GstStructure * config,
                                                     const gchar * agent);

GST_PLAY_API
gchar *        gst_play_config_get_user_agent       (const GstStructure * config);

GST_PLAY_API
void           gst_play_config_set_position_update_interval  (GstStructure * config,
                                                              guint          interval);

GST_PLAY_API
guint          gst_play_config_get_position_update_interval  (const GstStructure * config);

GST_PLAY_API
void           gst_play_config_set_seek_accurate (GstStructure * config, gboolean accurate);

GST_PLAY_API
gboolean       gst_play_config_get_seek_accurate (const GstStructure * config);

/**
 * GstPlaySnapshotFormat:
 * @GST_PLAY_THUMBNAIL_RAW_NATIVE: raw native format.
 * @GST_PLAY_THUMBNAIL_RAW_xRGB: raw xRGB format.
 * @GST_PLAY_THUMBNAIL_RAW_BGRx: raw BGRx format.
 * @GST_PLAY_THUMBNAIL_JPG: jpeg format.
 * @GST_PLAY_THUMBNAIL_PNG: png format.
 *
 * Since: 1.20
 */
typedef enum
{
  GST_PLAY_THUMBNAIL_RAW_NATIVE = 0,
  GST_PLAY_THUMBNAIL_RAW_xRGB,
  GST_PLAY_THUMBNAIL_RAW_BGRx,
  GST_PLAY_THUMBNAIL_JPG,
  GST_PLAY_THUMBNAIL_PNG
} GstPlaySnapshotFormat;

GST_PLAY_API
GstSample * gst_play_get_video_snapshot (GstPlay * play,
    GstPlaySnapshotFormat format, const GstStructure * config);

GST_PLAY_API
gboolean       gst_play_is_play_message                        (GstMessage *msg);

GST_PLAY_API
void           gst_play_message_parse_type                       (GstMessage *msg, GstPlayMessage *type);

GST_PLAY_API
void           gst_play_message_parse_duration_updated           (GstMessage *msg, GstClockTime *duration);

GST_PLAY_API
void           gst_play_message_parse_position_updated           (GstMessage *msg, GstClockTime *position);

GST_PLAY_API
void           gst_play_message_parse_state_changed              (GstMessage *msg, GstPlayState *state);

GST_PLAY_API
void           gst_play_message_parse_buffering_percent          (GstMessage *msg, guint *percent);

GST_PLAY_API
void           gst_play_message_parse_error                      (GstMessage *msg, GError *error, GstStructure **details);

GST_PLAY_API
void           gst_play_message_parse_warning                    (GstMessage *msg, GError *error, GstStructure **details);

GST_PLAY_API
void           gst_play_message_parse_video_dimensions_changed   (GstMessage *msg, guint *width, guint *height);

GST_PLAY_API
void           gst_play_message_parse_media_info_updated         (GstMessage *msg, GstPlayMediaInfo **info);

GST_PLAY_API
void           gst_play_message_parse_volume_changed             (GstMessage *msg, gdouble *volume);

GST_PLAY_API
void           gst_play_message_parse_muted_changed              (GstMessage *msg, gboolean *muted);

G_END_DECLS

#endif /* __GST_PLAY_H__ */