gstdiscoverer.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. #ifndef _GST_DISCOVERER_H_
  21. #define _GST_DISCOVERER_H_
  22. #include <gst/gst.h>
  23. G_BEGIN_DECLS
  24. #define GST_TYPE_DISCOVERER_STREAM_INFO \
  25. (gst_discoverer_stream_info_get_type ())
  26. #define GST_DISCOVERER_STREAM_INFO(obj) \
  27. (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_STREAM_INFO, GstDiscovererStreamInfo))
  28. #define GST_IS_DISCOVERER_STREAM_INFO(obj) \
  29. (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_STREAM_INFO))
  30. typedef struct _GstDiscovererStreamInfo GstDiscovererStreamInfo;
  31. typedef GObjectClass GstDiscovererStreamInfoClass;
  32. GType gst_discoverer_stream_info_get_type (void);
  33. /**
  34. * GstDiscovererStreamInfo:
  35. *
  36. * Base structure for information concerning a media stream. Depending on the
  37. * stream type, one can find more media-specific information in
  38. * #GstDiscovererAudioInfo, #GstDiscovererVideoInfo, and
  39. * #GstDiscovererContainerInfo.
  40. *
  41. * The #GstDiscovererStreamInfo represents the topology of the stream. Siblings
  42. * can be iterated over with gst_discoverer_stream_info_get_next() and
  43. * gst_discoverer_stream_info_get_previous(). Children (sub-streams) of a
  44. * stream can be accessed using the #GstDiscovererContainerInfo API.
  45. *
  46. * As a simple example, if you run #GstDiscoverer on an AVI file with one audio
  47. * and one video stream, you will get a #GstDiscovererContainerInfo
  48. * corresponding to the AVI container, which in turn will have a
  49. * #GstDiscovererAudioInfo sub-stream and a #GstDiscovererVideoInfo sub-stream
  50. * for the audio and video streams respectively.
  51. */
  52. #define gst_discoverer_stream_info_ref(info) ((GstDiscovererStreamInfo*) g_object_ref((GObject*) info))
  53. #define gst_discoverer_stream_info_unref(info) (g_object_unref((GObject*) info))
  54. GstDiscovererStreamInfo* gst_discoverer_stream_info_get_previous(GstDiscovererStreamInfo* info);
  55. GstDiscovererStreamInfo* gst_discoverer_stream_info_get_next(GstDiscovererStreamInfo* info);
  56. GstCaps* gst_discoverer_stream_info_get_caps(GstDiscovererStreamInfo* info);
  57. const GstTagList* gst_discoverer_stream_info_get_tags(GstDiscovererStreamInfo* info);
  58. const GstToc* gst_discoverer_stream_info_get_toc(GstDiscovererStreamInfo* info);
  59. const gchar* gst_discoverer_stream_info_get_stream_id(GstDiscovererStreamInfo* info);
  60. const GstStructure* gst_discoverer_stream_info_get_misc(GstDiscovererStreamInfo* info);
  61. const gchar * gst_discoverer_stream_info_get_stream_type_nick(GstDiscovererStreamInfo* info);
  62. /**
  63. * GstDiscovererContainerInfo:
  64. *
  65. * #GstDiscovererStreamInfo specific to container streams.
  66. */
  67. #define GST_TYPE_DISCOVERER_CONTAINER_INFO \
  68. (gst_discoverer_container_info_get_type ())
  69. #define GST_DISCOVERER_CONTAINER_INFO(obj) \
  70. (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_CONTAINER_INFO, GstDiscovererContainerInfo))
  71. #define GST_IS_DISCOVERER_CONTAINER_INFO(obj) \
  72. (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_CONTAINER_INFO))
  73. typedef struct _GstDiscovererContainerInfo GstDiscovererContainerInfo;
  74. typedef GObjectClass GstDiscovererContainerInfoClass;
  75. GType gst_discoverer_container_info_get_type (void);
  76. GList *gst_discoverer_container_info_get_streams(GstDiscovererContainerInfo *info);
  77. /**
  78. * GstDiscovererAudioInfo:
  79. *
  80. * #GstDiscovererStreamInfo specific to audio streams.
  81. */
  82. #define GST_TYPE_DISCOVERER_AUDIO_INFO \
  83. (gst_discoverer_audio_info_get_type ())
  84. #define GST_DISCOVERER_AUDIO_INFO(obj) \
  85. (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_AUDIO_INFO, GstDiscovererAudioInfo))
  86. #define GST_IS_DISCOVERER_AUDIO_INFO(obj) \
  87. (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_AUDIO_INFO))
  88. typedef struct _GstDiscovererAudioInfo GstDiscovererAudioInfo;
  89. typedef GObjectClass GstDiscovererAudioInfoClass;
  90. GType gst_discoverer_audio_info_get_type (void);
  91. guint gst_discoverer_audio_info_get_channels(const GstDiscovererAudioInfo* info);
  92. guint gst_discoverer_audio_info_get_sample_rate(const GstDiscovererAudioInfo* info);
  93. guint gst_discoverer_audio_info_get_depth(const GstDiscovererAudioInfo* info);
  94. guint gst_discoverer_audio_info_get_bitrate(const GstDiscovererAudioInfo* info);
  95. guint gst_discoverer_audio_info_get_max_bitrate(const GstDiscovererAudioInfo* info);
  96. const gchar * gst_discoverer_audio_info_get_language(const GstDiscovererAudioInfo* info);
  97. /**
  98. * GstDiscovererVideoInfo:
  99. *
  100. * #GstDiscovererStreamInfo specific to video streams (this includes images).
  101. */
  102. #define GST_TYPE_DISCOVERER_VIDEO_INFO \
  103. (gst_discoverer_video_info_get_type ())
  104. #define GST_DISCOVERER_VIDEO_INFO(obj) \
  105. (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_VIDEO_INFO, GstDiscovererVideoInfo))
  106. #define GST_IS_DISCOVERER_VIDEO_INFO(obj) \
  107. (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_VIDEO_INFO))
  108. typedef struct _GstDiscovererVideoInfo GstDiscovererVideoInfo;
  109. typedef GObjectClass GstDiscovererVideoInfoClass;
  110. GType gst_discoverer_video_info_get_type (void);
  111. guint gst_discoverer_video_info_get_width(const GstDiscovererVideoInfo* info);
  112. guint gst_discoverer_video_info_get_height(const GstDiscovererVideoInfo* info);
  113. guint gst_discoverer_video_info_get_depth(const GstDiscovererVideoInfo* info);
  114. guint gst_discoverer_video_info_get_framerate_num(const GstDiscovererVideoInfo* info);
  115. guint gst_discoverer_video_info_get_framerate_denom(const GstDiscovererVideoInfo* info);
  116. guint gst_discoverer_video_info_get_par_num(const GstDiscovererVideoInfo* info);
  117. guint gst_discoverer_video_info_get_par_denom(const GstDiscovererVideoInfo* info);
  118. gboolean gst_discoverer_video_info_is_interlaced(const GstDiscovererVideoInfo* info);
  119. guint gst_discoverer_video_info_get_bitrate(const GstDiscovererVideoInfo* info);
  120. guint gst_discoverer_video_info_get_max_bitrate(const GstDiscovererVideoInfo* info);
  121. gboolean gst_discoverer_video_info_is_image(const GstDiscovererVideoInfo* info);
  122. /**
  123. * GstDiscovererSubtitleInfo:
  124. *
  125. * #GstDiscovererStreamInfo specific to subtitle streams (this includes text and
  126. * image based ones).
  127. */
  128. #define GST_TYPE_DISCOVERER_SUBTITLE_INFO \
  129. (gst_discoverer_subtitle_info_get_type ())
  130. #define GST_DISCOVERER_SUBTITLE_INFO(obj) \
  131. (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_SUBTITLE_INFO, GstDiscovererSubtitleInfo))
  132. #define GST_IS_DISCOVERER_SUBTITLE_INFO(obj) \
  133. (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_SUBTITLE_INFO))
  134. typedef struct _GstDiscovererSubtitleInfo GstDiscovererSubtitleInfo;
  135. typedef GObjectClass GstDiscovererSubtitleInfoClass;
  136. GType gst_discoverer_subtitle_info_get_type (void);
  137. const gchar * gst_discoverer_subtitle_info_get_language(const GstDiscovererSubtitleInfo* info);
  138. /**
  139. * GstDiscovererResult:
  140. * @GST_DISCOVERER_OK: The discovery was successful
  141. * @GST_DISCOVERER_URI_INVALID: the URI is invalid
  142. * @GST_DISCOVERER_ERROR: an error happened and the GError is set
  143. * @GST_DISCOVERER_TIMEOUT: the discovery timed-out
  144. * @GST_DISCOVERER_BUSY: the discoverer was already discovering a file
  145. * @GST_DISCOVERER_MISSING_PLUGINS: Some plugins are missing for full discovery
  146. *
  147. * Result values for the discovery process.
  148. */
  149. typedef enum {
  150. GST_DISCOVERER_OK = 0,
  151. GST_DISCOVERER_URI_INVALID = 1,
  152. GST_DISCOVERER_ERROR = 2,
  153. GST_DISCOVERER_TIMEOUT = 3,
  154. GST_DISCOVERER_BUSY = 4,
  155. GST_DISCOVERER_MISSING_PLUGINS = 5
  156. } GstDiscovererResult;
  157. /**
  158. * GstDiscovererSerializeFlags:
  159. * @GST_DISCOVERER_SERIALIZE_BASIC: Serialize only basic information, excluding
  160. * caps, tags and miscellaneous information
  161. * @GST_DISCOVERER_SERIALIZE_CAPS: Serialize the caps for each stream
  162. * @GST_DISCOVERER_SERIALIZE_TAGS: Serialize the tags for each stream
  163. * @GST_DISCOVERER_SERIALIZE_MISC: Serialize miscellaneous information for each stream
  164. * @GST_DISCOVERER_SERIALIZE_ALL: Serialize all the available info, including
  165. * caps, tags and miscellaneous information
  166. *
  167. * You can use these flags to control what is serialized by
  168. * gst_discoverer_info_to_variant()
  169. *
  170. * Since: 1.6
  171. */
  172. typedef enum {
  173. GST_DISCOVERER_SERIALIZE_BASIC = 0,
  174. GST_DISCOVERER_SERIALIZE_CAPS = 1 << 0,
  175. GST_DISCOVERER_SERIALIZE_TAGS = 1 << 1,
  176. GST_DISCOVERER_SERIALIZE_MISC = 1 << 2,
  177. GST_DISCOVERER_SERIALIZE_ALL = GST_DISCOVERER_SERIALIZE_CAPS | GST_DISCOVERER_SERIALIZE_TAGS | GST_DISCOVERER_SERIALIZE_MISC
  178. } GstDiscovererSerializeFlags;
  179. /**
  180. * GstDiscovererInfo:
  181. *
  182. * Structure containing the information of a URI analyzed by #GstDiscoverer.
  183. */
  184. typedef struct _GstDiscovererInfo GstDiscovererInfo;
  185. #define GST_TYPE_DISCOVERER_INFO \
  186. (gst_discoverer_info_get_type ())
  187. #define GST_DISCOVERER_INFO(obj) \
  188. (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_INFO, GstDiscovererInfo))
  189. #define GST_IS_DISCOVERER_INFO(obj) \
  190. (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_INFO))
  191. typedef GObjectClass GstDiscovererInfoClass;
  192. GType gst_discoverer_info_get_type (void);
  193. #define gst_discoverer_info_unref(info) (g_object_unref((GObject*)info))
  194. #define gst_discoverer_info_ref(info) (g_object_ref((GObject*)info))
  195. GstDiscovererInfo* gst_discoverer_info_copy (GstDiscovererInfo * ptr);
  196. const gchar* gst_discoverer_info_get_uri(const GstDiscovererInfo* info);
  197. GstDiscovererResult gst_discoverer_info_get_result(const GstDiscovererInfo* info);
  198. GstDiscovererStreamInfo* gst_discoverer_info_get_stream_info(GstDiscovererInfo* info);
  199. GList* gst_discoverer_info_get_stream_list(GstDiscovererInfo* info);
  200. GstClockTime gst_discoverer_info_get_duration(const GstDiscovererInfo* info);
  201. gboolean gst_discoverer_info_get_seekable(const GstDiscovererInfo* info);
  202. const GstStructure* gst_discoverer_info_get_misc(const GstDiscovererInfo* info);
  203. const GstTagList* gst_discoverer_info_get_tags(const GstDiscovererInfo* info);
  204. const GstToc* gst_discoverer_info_get_toc(const GstDiscovererInfo* info);
  205. const gchar** gst_discoverer_info_get_missing_elements_installer_details(const GstDiscovererInfo* info);
  206. GList * gst_discoverer_info_get_streams (GstDiscovererInfo *info,
  207. GType streamtype);
  208. GList * gst_discoverer_info_get_audio_streams (GstDiscovererInfo *info);
  209. GList * gst_discoverer_info_get_video_streams (GstDiscovererInfo *info);
  210. GList * gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo *info);
  211. GList * gst_discoverer_info_get_container_streams (GstDiscovererInfo *info);
  212. GVariant * gst_discoverer_info_to_variant (GstDiscovererInfo *info,
  213. GstDiscovererSerializeFlags flags);
  214. GstDiscovererInfo * gst_discoverer_info_from_variant (GVariant *variant);
  215. void gst_discoverer_stream_info_list_free (GList *infos);
  216. #define GST_TYPE_DISCOVERER \
  217. (gst_discoverer_get_type())
  218. #define GST_DISCOVERER(obj) \
  219. (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER,GstDiscoverer))
  220. #define GST_DISCOVERER_CLASS(klass) \
  221. (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DISCOVERER,GstDiscovererClass))
  222. #define GST_IS_DISCOVERER(obj) \
  223. (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER))
  224. #define GST_IS_DISCOVERER_CLASS(klass) \
  225. (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DISCOVERER))
  226. typedef struct _GstDiscoverer GstDiscoverer;
  227. typedef struct _GstDiscovererClass GstDiscovererClass;
  228. typedef struct _GstDiscovererPrivate GstDiscovererPrivate;
  229. /**
  230. * GstDiscoverer:
  231. *
  232. * The #GstDiscoverer structure.
  233. **/
  234. struct _GstDiscoverer {
  235. GObject parent;
  236. /*< private >*/
  237. GstDiscovererPrivate *priv;
  238. gpointer _reserved[GST_PADDING];
  239. };
  240. struct _GstDiscovererClass {
  241. GObjectClass parentclass;
  242. /* signals */
  243. void (*finished) (GstDiscoverer *discoverer);
  244. void (*starting) (GstDiscoverer *discoverer);
  245. void (*discovered) (GstDiscoverer *discoverer,
  246. GstDiscovererInfo *info,
  247. const GError *err);
  248. void (*source_setup) (GstDiscoverer *discoverer,
  249. GstElement *source);
  250. gpointer _reserved[GST_PADDING];
  251. };
  252. GType gst_discoverer_get_type (void);
  253. GstDiscoverer *gst_discoverer_new (GstClockTime timeout, GError **err);
  254. /* Asynchronous API */
  255. void gst_discoverer_start (GstDiscoverer *discoverer);
  256. void gst_discoverer_stop (GstDiscoverer *discoverer);
  257. gboolean gst_discoverer_discover_uri_async (GstDiscoverer *discoverer,
  258. const gchar *uri);
  259. /* Synchronous API */
  260. GstDiscovererInfo *
  261. gst_discoverer_discover_uri (GstDiscoverer * discoverer,
  262. const gchar * uri,
  263. GError ** err);
  264. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  265. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscoverer, gst_object_unref)
  266. #endif
  267. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  268. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererAudioInfo, gst_object_unref)
  269. #endif
  270. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  271. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererContainerInfo, gst_object_unref)
  272. #endif
  273. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  274. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererInfo, gst_object_unref)
  275. #endif
  276. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  277. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererStreamInfo, gst_object_unref)
  278. #endif
  279. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  280. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererSubtitleInfo, gst_object_unref)
  281. #endif
  282. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  283. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererVideoInfo, gst_object_unref)
  284. #endif
  285. G_END_DECLS
  286. #endif /* _GST_DISCOVERER_H */