gsturi.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* GStreamer
  2. * Copyright (C) 1999,2000 Erik Walthinsen <[email protected]>
  3. * 2000 Wim Taymans <[email protected]>
  4. *
  5. * gsturi.h: Header for uri to element mappings
  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. #ifndef __GST_URI_H__
  23. #define __GST_URI_H__
  24. #include <glib.h>
  25. #include <gst/gstelement.h>
  26. G_BEGIN_DECLS
  27. GQuark gst_uri_error_quark (void);
  28. /**
  29. * GST_URI_ERROR:
  30. *
  31. * Get access to the error quark of the uri subsystem.
  32. */
  33. #define GST_URI_ERROR gst_uri_error_quark ()
  34. /**
  35. * GstURIError:
  36. * @GST_URI_ERROR_UNSUPPORTED_PROTOCOL: The protocol is not supported
  37. * @GST_URI_ERROR_BAD_URI: There was a problem with the URI
  38. * @GST_URI_ERROR_BAD_STATE: Could not set or change the URI because the
  39. * URI handler was in a state where that is not possible or not permitted
  40. * @GST_URI_ERROR_BAD_REFERENCE: There was a problem with the entity that
  41. * the URI references
  42. *
  43. * Different URI-related errors that can occur.
  44. */
  45. typedef enum
  46. {
  47. GST_URI_ERROR_UNSUPPORTED_PROTOCOL,
  48. GST_URI_ERROR_BAD_URI,
  49. GST_URI_ERROR_BAD_STATE,
  50. GST_URI_ERROR_BAD_REFERENCE
  51. } GstURIError;
  52. /**
  53. * GstURIType:
  54. * @GST_URI_UNKNOWN: The URI direction is unknown
  55. * @GST_URI_SINK: The URI is a consumer.
  56. * @GST_URI_SRC: The URI is a producer.
  57. *
  58. * The different types of URI direction.
  59. */
  60. typedef enum {
  61. GST_URI_UNKNOWN,
  62. GST_URI_SINK,
  63. GST_URI_SRC
  64. } GstURIType;
  65. /**
  66. * GST_URI_TYPE_IS_VALID:
  67. * @type: A #GstURIType
  68. *
  69. * Tests if the type direction is valid.
  70. */
  71. #define GST_URI_TYPE_IS_VALID(type) ((type) == GST_URI_SRC || (type) == GST_URI_SINK)
  72. /* uri handler functions */
  73. #define GST_TYPE_URI_HANDLER (gst_uri_handler_get_type ())
  74. #define GST_URI_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_URI_HANDLER, GstURIHandler))
  75. #define GST_IS_URI_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_URI_HANDLER))
  76. #define GST_URI_HANDLER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_URI_HANDLER, GstURIHandlerInterface))
  77. /**
  78. * GstURIHandler:
  79. *
  80. * Opaque #GstURIHandler structure.
  81. */
  82. typedef struct _GstURIHandler GstURIHandler;
  83. typedef struct _GstURIHandlerInterface GstURIHandlerInterface;
  84. /**
  85. * GstURIHandlerInterface:
  86. * @parent: The parent interface type
  87. * @get_type: Method to tell whether the element handles source or sink URI.
  88. * @get_protocols: Method to return the list of protocols handled by the element.
  89. * @get_uri: Method to return the URI currently handled by the element.
  90. * @set_uri: Method to set a new URI.
  91. *
  92. * Any #GstElement using this interface should implement these methods.
  93. */
  94. struct _GstURIHandlerInterface {
  95. GTypeInterface parent;
  96. /* vtable */
  97. /*< public >*/
  98. /* querying capabilities */
  99. GstURIType (* get_type) (GType type);
  100. const gchar * const * (* get_protocols) (GType type);
  101. /* using the interface */
  102. gchar * (* get_uri) (GstURIHandler * handler);
  103. gboolean (* set_uri) (GstURIHandler * handler,
  104. const gchar * uri,
  105. GError ** error);
  106. };
  107. /* general URI functions */
  108. gboolean gst_uri_protocol_is_valid (const gchar * protocol);
  109. gboolean gst_uri_protocol_is_supported (const GstURIType type,
  110. const gchar *protocol);
  111. gboolean gst_uri_is_valid (const gchar * uri);
  112. gchar * gst_uri_get_protocol (const gchar * uri) G_GNUC_MALLOC;
  113. gboolean gst_uri_has_protocol (const gchar * uri,
  114. const gchar * protocol);
  115. gchar * gst_uri_get_location (const gchar * uri) G_GNUC_MALLOC;
  116. gchar * gst_uri_construct (const gchar * protocol,
  117. const gchar * location) G_GNUC_MALLOC;
  118. gchar * gst_filename_to_uri (const gchar * filename,
  119. GError ** error) G_GNUC_MALLOC;
  120. GstElement * gst_element_make_from_uri (const GstURIType type,
  121. const gchar * uri,
  122. const gchar * elementname,
  123. GError ** error) G_GNUC_MALLOC;
  124. /* accessing the interface */
  125. GType gst_uri_handler_get_type (void);
  126. GstURIType gst_uri_handler_get_uri_type (GstURIHandler * handler);
  127. const gchar * const * gst_uri_handler_get_protocols (GstURIHandler * handler);
  128. gchar * gst_uri_handler_get_uri (GstURIHandler * handler) G_GNUC_MALLOC;
  129. gboolean gst_uri_handler_set_uri (GstURIHandler * handler,
  130. const gchar * uri,
  131. GError ** error);
  132. G_END_DECLS
  133. #endif /* __GST_URI_H__ */