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 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC 108 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstPlayer, gst_object_unref) 109 #endif 110 111 GST_PLAYER_API 112 GType gst_player_get_type (void); 113 114 GST_PLAYER_API 115 GstPlayer * gst_player_new (GstPlayerVideoRenderer * video_renderer, GstPlayerSignalDispatcher * signal_dispatcher); 116 117 GST_PLAYER_API 118 void gst_player_play (GstPlayer * player); 119 120 GST_PLAYER_API 121 void gst_player_pause (GstPlayer * player); 122 123 GST_PLAYER_API 124 void gst_player_stop (GstPlayer * player); 125 126 GST_PLAYER_API 127 void gst_player_seek (GstPlayer * player, 128 GstClockTime position); 129 130 GST_PLAYER_API 131 void gst_player_set_rate (GstPlayer * player, 132 gdouble rate); 133 134 GST_PLAYER_API 135 gdouble gst_player_get_rate (GstPlayer * player); 136 137 GST_PLAYER_API 138 gchar * gst_player_get_uri (GstPlayer * player); 139 140 GST_PLAYER_API 141 void gst_player_set_uri (GstPlayer * player, 142 const gchar * uri); 143 144 GST_PLAYER_API 145 gchar * gst_player_get_subtitle_uri (GstPlayer * player); 146 147 GST_PLAYER_API 148 void gst_player_set_subtitle_uri (GstPlayer * player, 149 const gchar *uri); 150 151 GST_PLAYER_API 152 GstClockTime gst_player_get_position (GstPlayer * player); 153 154 GST_PLAYER_API 155 GstClockTime gst_player_get_duration (GstPlayer * player); 156 157 GST_PLAYER_API 158 gdouble gst_player_get_volume (GstPlayer * player); 159 160 GST_PLAYER_API 161 void gst_player_set_volume (GstPlayer * player, 162 gdouble val); 163 164 GST_PLAYER_API 165 gboolean gst_player_get_mute (GstPlayer * player); 166 167 GST_PLAYER_API 168 void gst_player_set_mute (GstPlayer * player, 169 gboolean val); 170 171 GST_PLAYER_API 172 GstElement * gst_player_get_pipeline (GstPlayer * player); 173 174 GST_PLAYER_API 175 void gst_player_set_video_track_enabled (GstPlayer * player, 176 gboolean enabled); 177 178 GST_PLAYER_API 179 void gst_player_set_audio_track_enabled (GstPlayer * player, 180 gboolean enabled); 181 182 GST_PLAYER_API 183 void gst_player_set_subtitle_track_enabled (GstPlayer * player, 184 gboolean enabled); 185 186 GST_PLAYER_API 187 gboolean gst_player_set_audio_track (GstPlayer *player, 188 gint stream_index); 189 190 GST_PLAYER_API 191 gboolean gst_player_set_video_track (GstPlayer *player, 192 gint stream_index); 193 194 GST_PLAYER_API 195 gboolean gst_player_set_subtitle_track (GstPlayer *player, 196 gint stream_index); 197 198 GST_PLAYER_API 199 GstPlayerMediaInfo * gst_player_get_media_info (GstPlayer * player); 200 201 GST_PLAYER_API 202 GstPlayerAudioInfo * gst_player_get_current_audio_track (GstPlayer * player); 203 204 GST_PLAYER_API 205 GstPlayerVideoInfo * gst_player_get_current_video_track (GstPlayer * player); 206 207 GST_PLAYER_API 208 GstPlayerSubtitleInfo * gst_player_get_current_subtitle_track (GstPlayer * player); 209 210 GST_PLAYER_API 211 gboolean gst_player_set_visualization (GstPlayer * player, 212 const gchar *name); 213 214 GST_PLAYER_API 215 void gst_player_set_visualization_enabled (GstPlayer * player, 216 gboolean enabled); 217 218 GST_PLAYER_API 219 gchar * gst_player_get_current_visualization (GstPlayer * player); 220 221 GST_PLAYER_API 222 gboolean gst_player_has_color_balance (GstPlayer * player); 223 224 GST_PLAYER_API 225 void gst_player_set_color_balance (GstPlayer * player, 226 GstPlayerColorBalanceType type, 227 gdouble value); 228 229 GST_PLAYER_API 230 gdouble gst_player_get_color_balance (GstPlayer * player, 231 GstPlayerColorBalanceType type); 232 233 234 GST_PLAYER_API 235 GstVideoMultiviewFramePacking gst_player_get_multiview_mode (GstPlayer * player); 236 237 GST_PLAYER_API 238 void gst_player_set_multiview_mode (GstPlayer * player, 239 GstVideoMultiviewFramePacking mode); 240 241 GST_PLAYER_API 242 GstVideoMultiviewFlags gst_player_get_multiview_flags (GstPlayer * player); 243 244 GST_PLAYER_API 245 void gst_player_set_multiview_flags (GstPlayer * player, 246 GstVideoMultiviewFlags flags); 247 248 GST_PLAYER_API 249 gint64 gst_player_get_audio_video_offset (GstPlayer * player); 250 251 GST_PLAYER_API 252 void gst_player_set_audio_video_offset (GstPlayer * player, 253 gint64 offset); 254 255 GST_PLAYER_API 256 gint64 gst_player_get_subtitle_video_offset (GstPlayer * player); 257 258 GST_PLAYER_API 259 void gst_player_set_subtitle_video_offset (GstPlayer * player, 260 gint64 offset); 261 262 GST_PLAYER_API 263 gboolean gst_player_set_config (GstPlayer * player, 264 GstStructure * config); 265 266 GST_PLAYER_API 267 GstStructure * gst_player_get_config (GstPlayer * player); 268 269 /* helpers for configuring the config structure */ 270 271 GST_PLAYER_API 272 void gst_player_config_set_user_agent (GstStructure * config, 273 const gchar * agent); 274 275 GST_PLAYER_API 276 gchar * gst_player_config_get_user_agent (const GstStructure * config); 277 278 GST_PLAYER_API 279 void gst_player_config_set_position_update_interval (GstStructure * config, 280 guint interval); 281 282 GST_PLAYER_API 283 guint gst_player_config_get_position_update_interval (const GstStructure * config); 284 285 GST_PLAYER_API 286 void gst_player_config_set_seek_accurate (GstStructure * config, gboolean accurate); 287 288 GST_PLAYER_API 289 gboolean gst_player_config_get_seek_accurate (const GstStructure * config); 290 291 typedef enum 292 { 293 GST_PLAYER_THUMBNAIL_RAW_NATIVE = 0, 294 GST_PLAYER_THUMBNAIL_RAW_xRGB, 295 GST_PLAYER_THUMBNAIL_RAW_BGRx, 296 GST_PLAYER_THUMBNAIL_JPG, 297 GST_PLAYER_THUMBNAIL_PNG 298 } GstPlayerSnapshotFormat; 299 300 GST_PLAYER_API 301 GstSample * gst_player_get_video_snapshot (GstPlayer * player, 302 GstPlayerSnapshotFormat format, const GstStructure * config); 303 304 G_END_DECLS 305 306 #endif /* __GST_PLAYER_H__ */ 307