1 /* GStreamer 2 * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk> 3 * 2009 Nokia Corporation 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_DISCOVERER_H_ 22 #define _GST_DISCOVERER_H_ 23 24 #include <gst/gst.h> 25 #include <gst/pbutils/pbutils-prelude.h> 26 27 G_BEGIN_DECLS 28 29 #define GST_TYPE_DISCOVERER_STREAM_INFO \ 30 (gst_discoverer_stream_info_get_type ()) 31 #define GST_DISCOVERER_STREAM_INFO(obj) \ 32 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_STREAM_INFO, GstDiscovererStreamInfo)) 33 #define GST_IS_DISCOVERER_STREAM_INFO(obj) \ 34 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_STREAM_INFO)) 35 typedef struct _GstDiscovererStreamInfo GstDiscovererStreamInfo; 36 typedef GObjectClass GstDiscovererStreamInfoClass; 37 38 GST_PBUTILS_API 39 GType gst_discoverer_stream_info_get_type (void); 40 41 /** 42 * GstDiscovererStreamInfo: 43 * 44 * Base structure for information concerning a media stream. Depending on the 45 * stream type, one can find more media-specific information in 46 * #GstDiscovererAudioInfo, #GstDiscovererVideoInfo, and 47 * #GstDiscovererContainerInfo. 48 * 49 * The #GstDiscovererStreamInfo represents the topology of the stream. Siblings 50 * can be iterated over with gst_discoverer_stream_info_get_next() and 51 * gst_discoverer_stream_info_get_previous(). Children (sub-streams) of a 52 * stream can be accessed using the #GstDiscovererContainerInfo API. 53 * 54 * As a simple example, if you run #GstDiscoverer on an AVI file with one audio 55 * and one video stream, you will get a #GstDiscovererContainerInfo 56 * corresponding to the AVI container, which in turn will have a 57 * #GstDiscovererAudioInfo sub-stream and a #GstDiscovererVideoInfo sub-stream 58 * for the audio and video streams respectively. 59 */ 60 #define gst_discoverer_stream_info_ref(info) ((GstDiscovererStreamInfo*) g_object_ref((GObject*) info)) 61 #define gst_discoverer_stream_info_unref(info) (g_object_unref((GObject*) info)) 62 63 GST_PBUTILS_API 64 GstDiscovererStreamInfo* gst_discoverer_stream_info_get_previous(GstDiscovererStreamInfo* info); 65 66 GST_PBUTILS_API 67 GstDiscovererStreamInfo* gst_discoverer_stream_info_get_next(GstDiscovererStreamInfo* info); 68 69 GST_PBUTILS_API 70 GstCaps* gst_discoverer_stream_info_get_caps(GstDiscovererStreamInfo* info); 71 72 GST_PBUTILS_API 73 const GstTagList* gst_discoverer_stream_info_get_tags(GstDiscovererStreamInfo* info); 74 75 GST_PBUTILS_API 76 const GstToc* gst_discoverer_stream_info_get_toc(GstDiscovererStreamInfo* info); 77 78 GST_PBUTILS_API 79 const gchar* gst_discoverer_stream_info_get_stream_id(GstDiscovererStreamInfo* info); 80 81 GST_PBUTILS_DEPRECATED_FOR(gst_discoverer_info_get_missing_elements_installer_details) 82 const GstStructure* gst_discoverer_stream_info_get_misc(GstDiscovererStreamInfo* info); 83 84 GST_PBUTILS_API 85 const gchar * gst_discoverer_stream_info_get_stream_type_nick(GstDiscovererStreamInfo* info); 86 87 /** 88 * GstDiscovererContainerInfo: 89 * 90 * #GstDiscovererStreamInfo specific to container streams. 91 */ 92 #define GST_TYPE_DISCOVERER_CONTAINER_INFO \ 93 (gst_discoverer_container_info_get_type ()) 94 #define GST_DISCOVERER_CONTAINER_INFO(obj) \ 95 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_CONTAINER_INFO, GstDiscovererContainerInfo)) 96 #define GST_IS_DISCOVERER_CONTAINER_INFO(obj) \ 97 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_CONTAINER_INFO)) 98 typedef struct _GstDiscovererContainerInfo GstDiscovererContainerInfo; 99 typedef GObjectClass GstDiscovererContainerInfoClass; 100 101 GST_PBUTILS_API 102 GType gst_discoverer_container_info_get_type (void); 103 104 GST_PBUTILS_API 105 GList *gst_discoverer_container_info_get_streams(GstDiscovererContainerInfo *info); 106 107 108 /** 109 * GstDiscovererAudioInfo: 110 * 111 * #GstDiscovererStreamInfo specific to audio streams. 112 */ 113 #define GST_TYPE_DISCOVERER_AUDIO_INFO \ 114 (gst_discoverer_audio_info_get_type ()) 115 #define GST_DISCOVERER_AUDIO_INFO(obj) \ 116 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_AUDIO_INFO, GstDiscovererAudioInfo)) 117 #define GST_IS_DISCOVERER_AUDIO_INFO(obj) \ 118 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_AUDIO_INFO)) 119 typedef struct _GstDiscovererAudioInfo GstDiscovererAudioInfo; 120 typedef GObjectClass GstDiscovererAudioInfoClass; 121 122 GST_PBUTILS_API 123 GType gst_discoverer_audio_info_get_type (void); 124 125 GST_PBUTILS_API 126 guint gst_discoverer_audio_info_get_channels(const GstDiscovererAudioInfo* info); 127 128 GST_PBUTILS_API 129 guint64 gst_discoverer_audio_info_get_channel_mask(const GstDiscovererAudioInfo* info); 130 131 GST_PBUTILS_API 132 guint gst_discoverer_audio_info_get_sample_rate(const GstDiscovererAudioInfo* info); 133 134 GST_PBUTILS_API 135 guint gst_discoverer_audio_info_get_depth(const GstDiscovererAudioInfo* info); 136 137 GST_PBUTILS_API 138 guint gst_discoverer_audio_info_get_bitrate(const GstDiscovererAudioInfo* info); 139 140 GST_PBUTILS_API 141 guint gst_discoverer_audio_info_get_max_bitrate(const GstDiscovererAudioInfo* info); 142 143 GST_PBUTILS_API 144 const gchar * gst_discoverer_audio_info_get_language(const GstDiscovererAudioInfo* info); 145 146 /** 147 * GstDiscovererVideoInfo: 148 * 149 * #GstDiscovererStreamInfo specific to video streams (this includes images). 150 */ 151 #define GST_TYPE_DISCOVERER_VIDEO_INFO \ 152 (gst_discoverer_video_info_get_type ()) 153 #define GST_DISCOVERER_VIDEO_INFO(obj) \ 154 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_VIDEO_INFO, GstDiscovererVideoInfo)) 155 #define GST_IS_DISCOVERER_VIDEO_INFO(obj) \ 156 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_VIDEO_INFO)) 157 typedef struct _GstDiscovererVideoInfo GstDiscovererVideoInfo; 158 typedef GObjectClass GstDiscovererVideoInfoClass; 159 160 GST_PBUTILS_API 161 GType gst_discoverer_video_info_get_type (void); 162 163 GST_PBUTILS_API 164 guint gst_discoverer_video_info_get_width(const GstDiscovererVideoInfo* info); 165 166 GST_PBUTILS_API 167 guint gst_discoverer_video_info_get_height(const GstDiscovererVideoInfo* info); 168 169 GST_PBUTILS_API 170 guint gst_discoverer_video_info_get_depth(const GstDiscovererVideoInfo* info); 171 172 GST_PBUTILS_API 173 guint gst_discoverer_video_info_get_framerate_num(const GstDiscovererVideoInfo* info); 174 175 GST_PBUTILS_API 176 guint gst_discoverer_video_info_get_framerate_denom(const GstDiscovererVideoInfo* info); 177 178 GST_PBUTILS_API 179 guint gst_discoverer_video_info_get_par_num(const GstDiscovererVideoInfo* info); 180 181 GST_PBUTILS_API 182 guint gst_discoverer_video_info_get_par_denom(const GstDiscovererVideoInfo* info); 183 184 GST_PBUTILS_API 185 gboolean gst_discoverer_video_info_is_interlaced(const GstDiscovererVideoInfo* info); 186 187 GST_PBUTILS_API 188 guint gst_discoverer_video_info_get_bitrate(const GstDiscovererVideoInfo* info); 189 190 GST_PBUTILS_API 191 guint gst_discoverer_video_info_get_max_bitrate(const GstDiscovererVideoInfo* info); 192 193 GST_PBUTILS_API 194 gboolean gst_discoverer_video_info_is_image(const GstDiscovererVideoInfo* info); 195 196 /** 197 * GstDiscovererSubtitleInfo: 198 * 199 * #GstDiscovererStreamInfo specific to subtitle streams (this includes text and 200 * image based ones). 201 */ 202 #define GST_TYPE_DISCOVERER_SUBTITLE_INFO \ 203 (gst_discoverer_subtitle_info_get_type ()) 204 #define GST_DISCOVERER_SUBTITLE_INFO(obj) \ 205 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_SUBTITLE_INFO, GstDiscovererSubtitleInfo)) 206 #define GST_IS_DISCOVERER_SUBTITLE_INFO(obj) \ 207 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_SUBTITLE_INFO)) 208 typedef struct _GstDiscovererSubtitleInfo GstDiscovererSubtitleInfo; 209 typedef GObjectClass GstDiscovererSubtitleInfoClass; 210 211 GST_PBUTILS_API 212 GType gst_discoverer_subtitle_info_get_type (void); 213 214 GST_PBUTILS_API 215 const gchar * gst_discoverer_subtitle_info_get_language(const GstDiscovererSubtitleInfo* info); 216 217 /** 218 * GstDiscovererResult: 219 * @GST_DISCOVERER_OK: The discovery was successful 220 * @GST_DISCOVERER_URI_INVALID: the URI is invalid 221 * @GST_DISCOVERER_ERROR: an error happened and the GError is set 222 * @GST_DISCOVERER_TIMEOUT: the discovery timed-out 223 * @GST_DISCOVERER_BUSY: the discoverer was already discovering a file 224 * @GST_DISCOVERER_MISSING_PLUGINS: Some plugins are missing for full discovery 225 * 226 * Result values for the discovery process. 227 */ 228 typedef enum { 229 GST_DISCOVERER_OK = 0, 230 GST_DISCOVERER_URI_INVALID = 1, 231 GST_DISCOVERER_ERROR = 2, 232 GST_DISCOVERER_TIMEOUT = 3, 233 GST_DISCOVERER_BUSY = 4, 234 GST_DISCOVERER_MISSING_PLUGINS = 5 235 } GstDiscovererResult; 236 237 /** 238 * GstDiscovererSerializeFlags: 239 * @GST_DISCOVERER_SERIALIZE_BASIC: Serialize only basic information, excluding 240 * caps, tags and miscellaneous information 241 * @GST_DISCOVERER_SERIALIZE_CAPS: Serialize the caps for each stream 242 * @GST_DISCOVERER_SERIALIZE_TAGS: Serialize the tags for each stream 243 * @GST_DISCOVERER_SERIALIZE_MISC: Serialize miscellaneous information for each stream 244 * @GST_DISCOVERER_SERIALIZE_ALL: Serialize all the available info, including 245 * caps, tags and miscellaneous information 246 * 247 * You can use these flags to control what is serialized by 248 * gst_discoverer_info_to_variant() 249 * 250 * Since: 1.6 251 */ 252 253 typedef enum { 254 GST_DISCOVERER_SERIALIZE_BASIC = 0, 255 GST_DISCOVERER_SERIALIZE_CAPS = 1 << 0, 256 GST_DISCOVERER_SERIALIZE_TAGS = 1 << 1, 257 GST_DISCOVERER_SERIALIZE_MISC = 1 << 2, 258 GST_DISCOVERER_SERIALIZE_ALL = GST_DISCOVERER_SERIALIZE_CAPS | GST_DISCOVERER_SERIALIZE_TAGS | GST_DISCOVERER_SERIALIZE_MISC 259 } GstDiscovererSerializeFlags; 260 261 /** 262 * GstDiscovererInfo: 263 * 264 * Structure containing the information of a URI analyzed by #GstDiscoverer. 265 */ 266 typedef struct _GstDiscovererInfo GstDiscovererInfo; 267 268 #define GST_TYPE_DISCOVERER_INFO \ 269 (gst_discoverer_info_get_type ()) 270 #define GST_DISCOVERER_INFO(obj) \ 271 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_INFO, GstDiscovererInfo)) 272 #define GST_IS_DISCOVERER_INFO(obj) \ 273 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_INFO)) 274 typedef GObjectClass GstDiscovererInfoClass; 275 276 GST_PBUTILS_API 277 GType gst_discoverer_info_get_type (void); 278 279 #define gst_discoverer_info_unref(info) (g_object_unref((GObject*)info)) 280 #define gst_discoverer_info_ref(info) (g_object_ref((GObject*)info)) 281 282 GST_PBUTILS_API 283 GstDiscovererInfo* gst_discoverer_info_copy (GstDiscovererInfo * ptr); 284 285 GST_PBUTILS_API 286 const gchar* gst_discoverer_info_get_uri(const GstDiscovererInfo* info); 287 288 GST_PBUTILS_API 289 GstDiscovererResult gst_discoverer_info_get_result(const GstDiscovererInfo* info); 290 291 GST_PBUTILS_API 292 GstDiscovererStreamInfo* gst_discoverer_info_get_stream_info(GstDiscovererInfo* info); 293 294 GST_PBUTILS_API 295 GList* gst_discoverer_info_get_stream_list(GstDiscovererInfo* info); 296 297 GST_PBUTILS_API 298 GstClockTime gst_discoverer_info_get_duration(const GstDiscovererInfo* info); 299 300 GST_PBUTILS_API 301 gboolean gst_discoverer_info_get_seekable(const GstDiscovererInfo* info); 302 303 GST_PBUTILS_API 304 gboolean gst_discoverer_info_get_live(const GstDiscovererInfo* info); 305 306 GST_PBUTILS_DEPRECATED_FOR(gst_discoverer_info_get_missing_elements_installer_details) 307 const GstStructure* gst_discoverer_info_get_misc(const GstDiscovererInfo* info); 308 309 GST_PBUTILS_API 310 const GstTagList* gst_discoverer_info_get_tags(const GstDiscovererInfo* info); 311 GST_PBUTILS_API 312 const GstToc* gst_discoverer_info_get_toc(const GstDiscovererInfo* info); 313 314 GST_PBUTILS_API 315 const gchar** gst_discoverer_info_get_missing_elements_installer_details(const GstDiscovererInfo* info); 316 317 GST_PBUTILS_API 318 GList * gst_discoverer_info_get_streams (GstDiscovererInfo *info, 319 GType streamtype); 320 321 GST_PBUTILS_API 322 GList * gst_discoverer_info_get_audio_streams (GstDiscovererInfo *info); 323 324 GST_PBUTILS_API 325 GList * gst_discoverer_info_get_video_streams (GstDiscovererInfo *info); 326 327 GST_PBUTILS_API 328 GList * gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo *info); 329 330 GST_PBUTILS_API 331 GList * gst_discoverer_info_get_container_streams (GstDiscovererInfo *info); 332 333 GST_PBUTILS_API 334 GVariant * gst_discoverer_info_to_variant (GstDiscovererInfo *info, 335 GstDiscovererSerializeFlags flags); 336 337 GST_PBUTILS_API 338 GstDiscovererInfo * gst_discoverer_info_from_variant (GVariant *variant); 339 340 GST_PBUTILS_API 341 void gst_discoverer_stream_info_list_free (GList *infos); 342 343 #define GST_TYPE_DISCOVERER \ 344 (gst_discoverer_get_type()) 345 #define GST_DISCOVERER(obj) \ 346 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER,GstDiscoverer)) 347 #define GST_DISCOVERER_CLASS(klass) \ 348 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DISCOVERER,GstDiscovererClass)) 349 #define GST_IS_DISCOVERER(obj) \ 350 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER)) 351 #define GST_IS_DISCOVERER_CLASS(klass) \ 352 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DISCOVERER)) 353 354 typedef struct _GstDiscoverer GstDiscoverer; 355 typedef struct _GstDiscovererClass GstDiscovererClass; 356 typedef struct _GstDiscovererPrivate GstDiscovererPrivate; 357 358 /** 359 * GstDiscoverer: 360 * 361 * The #GstDiscoverer structure. 362 **/ 363 struct _GstDiscoverer { 364 GObject parent; 365 366 /*< private >*/ 367 GstDiscovererPrivate *priv; 368 369 gpointer _reserved[GST_PADDING]; 370 }; 371 372 struct _GstDiscovererClass { 373 GObjectClass parentclass; 374 375 /* signals */ 376 void (*finished) (GstDiscoverer *discoverer); 377 void (*starting) (GstDiscoverer *discoverer); 378 void (*discovered) (GstDiscoverer *discoverer, 379 GstDiscovererInfo *info, 380 const GError *err); 381 void (*source_setup) (GstDiscoverer *discoverer, 382 GstElement *source); 383 384 gpointer _reserved[GST_PADDING]; 385 }; 386 387 GST_PBUTILS_API 388 GType gst_discoverer_get_type (void); 389 390 GST_PBUTILS_API 391 GstDiscoverer *gst_discoverer_new (GstClockTime timeout, GError **err); 392 393 /* Asynchronous API */ 394 395 GST_PBUTILS_API 396 void gst_discoverer_start (GstDiscoverer *discoverer); 397 398 GST_PBUTILS_API 399 void gst_discoverer_stop (GstDiscoverer *discoverer); 400 401 GST_PBUTILS_API 402 gboolean gst_discoverer_discover_uri_async (GstDiscoverer *discoverer, 403 const gchar *uri); 404 405 /* Synchronous API */ 406 407 GST_PBUTILS_API 408 GstDiscovererInfo * 409 gst_discoverer_discover_uri (GstDiscoverer * discoverer, 410 const gchar * uri, 411 GError ** err); 412 413 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC 414 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscoverer, gst_object_unref) 415 #endif 416 417 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC 418 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererAudioInfo, gst_object_unref) 419 #endif 420 421 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC 422 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererContainerInfo, gst_object_unref) 423 #endif 424 425 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC 426 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererInfo, gst_object_unref) 427 #endif 428 429 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC 430 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererStreamInfo, gst_object_unref) 431 #endif 432 433 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC 434 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererSubtitleInfo, gst_object_unref) 435 #endif 436 437 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC 438 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererVideoInfo, gst_object_unref) 439 #endif 440 441 G_END_DECLS 442 443 #endif /* _GST_DISCOVERER_H */ 444