1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD 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 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = gstreamer-GstUriHandler.html 27 * outPack = gstreamer 28 * outFile = UriHandlerT 29 * strct = GstURIHandler 30 * realStrct= 31 * ctorStrct= 32 * clss = UriHandlerT 33 * interf = UriHandlerIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - gst_uri_protocol_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.ErrorG 49 * - glib.GException 50 * - gstreamer.Element 51 * structWrap: 52 * - GstElement* -> Element 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module gstreamer.UriHandlerT; 59 60 public import gstreamerc.gstreamertypes; 61 62 public import gstreamerc.gstreamer; 63 public import glib.ConstructionException; 64 public import gobject.ObjectG; 65 66 public import glib.Str; 67 public import glib.ErrorG; 68 public import glib.GException; 69 public import gstreamer.Element; 70 71 72 73 /** 74 * The URIHandler is an interface that is implemented by Source and Sink 75 * GstElement to simplify then handling of URI. 76 * 77 * An application can use the following functions to quickly get an element 78 * that handles the given URI for reading or writing 79 * (gst_element_make_from_uri()). 80 * 81 * Source and Sink plugins should implement this interface when possible. 82 * 83 * Last reviewed on 2005-11-09 (0.9.4) 84 */ 85 public template UriHandlerT(TStruct) 86 { 87 88 /** the main Gtk struct */ 89 protected GstURIHandler* gstURIHandler; 90 91 92 /** Get the main Gtk struct */ 93 public GstURIHandler* getUriHandlerTStruct() 94 { 95 return cast(GstURIHandler*)getStruct(); 96 } 97 98 99 /** 100 */ 101 102 /** 103 */ 104 public static GQuark gstUriErrorQuark() 105 { 106 // GQuark gst_uri_error_quark (void); 107 return gst_uri_error_quark(); 108 } 109 110 /** 111 * Tests if the given string is a valid protocol identifier. Protocols 112 * must consist of alphanumeric characters, '+', '-' and '.' and must 113 * start with a alphabetic character. See RFC 3986 Section 3.1. 114 * Params: 115 * protocol = A string 116 * Returns: TRUE if the string is a valid protocol identifier, FALSE otherwise. 117 */ 118 public static int isValid(string protocol) 119 { 120 // gboolean gst_uri_protocol_is_valid (const gchar *protocol); 121 return gst_uri_protocol_is_valid(Str.toStringz(protocol)); 122 } 123 124 /** 125 * Checks if an element exists that supports the given URI protocol. Note 126 * that a positive return value does not imply that a subsequent call to 127 * gst_element_make_from_uri() is guaranteed to work. 128 * Params: 129 * type = Whether to check for a source or a sink 130 * protocol = Protocol that should be checked for (e.g. "http" or "smb") 131 * Returns: TRUE 132 */ 133 public static int isSupported(GstURIType type, string protocol) 134 { 135 // gboolean gst_uri_protocol_is_supported (const GstURIType type, const gchar *protocol); 136 return gst_uri_protocol_is_supported(type, Str.toStringz(protocol)); 137 } 138 139 /** 140 * Tests if the given string is a valid URI identifier. URIs start with a valid 141 * scheme followed by ":" and maybe a string identifying the location. 142 * Params: 143 * uri = A URI string 144 * Returns: TRUE if the string is a valid URI 145 */ 146 public static int gstUriIsValid(string uri) 147 { 148 // gboolean gst_uri_is_valid (const gchar *uri); 149 return gst_uri_is_valid(Str.toStringz(uri)); 150 } 151 152 /** 153 * Checks if the protocol of a given valid URI matches protocol. 154 * Params: 155 * uri = a URI string 156 * protocol = a protocol string (e.g. "http") 157 * Returns: TRUE if the protocol matches. 158 */ 159 public static int gstUriHasProtocol(string uri, string protocol) 160 { 161 // gboolean gst_uri_has_protocol (const gchar *uri, const gchar *protocol); 162 return gst_uri_has_protocol(Str.toStringz(uri), Str.toStringz(protocol)); 163 } 164 165 /** 166 * Extracts the protocol out of a given valid URI. The returned string must be 167 * freed using g_free(). 168 * Params: 169 * uri = A URI string 170 * Returns: The protocol for this URI. 171 */ 172 public static string gstUriGetProtocol(string uri) 173 { 174 // gchar * gst_uri_get_protocol (const gchar *uri); 175 return Str.toString(gst_uri_get_protocol(Str.toStringz(uri))); 176 } 177 178 /** 179 * Extracts the location out of a given valid URI, ie. the protocol and "://" 180 * are stripped from the URI, which means that the location returned includes 181 * the hostname if one is specified. The returned string must be freed using 182 * g_free(). 183 * Free-function: g_free 184 * Params: 185 * uri = A URI string 186 * Returns: the location for this URI. Returns NULL if the URI isn't valid. If the URI does not contain a location, an empty string is returned. [transfer full] 187 */ 188 public static string gstUriGetLocation(string uri) 189 { 190 // gchar * gst_uri_get_location (const gchar *uri); 191 return Str.toString(gst_uri_get_location(Str.toStringz(uri))); 192 } 193 194 /** 195 * Constructs a URI for a given valid protocol and location. 196 * Free-function: g_free 197 * Params: 198 * protocol = Protocol for URI 199 * location = Location for URI. [transfer none] 200 * Returns: a new string for this URI. Returns NULL if the given URI protocol is not valid, or the given location is NULL. [transfer full] 201 */ 202 public static string gstUriConstruct(string protocol, string location) 203 { 204 // gchar * gst_uri_construct (const gchar *protocol, const gchar *location); 205 return Str.toString(gst_uri_construct(Str.toStringz(protocol), Str.toStringz(location))); 206 } 207 208 /** 209 * Similar to g_filename_to_uri(), but attempts to handle relative file paths 210 * as well. Before converting filename into an URI, it will be prefixed by 211 * the current working directory if it is a relative path, and then the path 212 * will be canonicalised so that it doesn't contain any './' or '../' segments. 213 * On Windows filename should be in UTF-8 encoding. 214 * Params: 215 * filename = absolute or relative file name path 216 * Throws: GException on failure. 217 */ 218 public static string gstFilenameToUri(string filename) 219 { 220 // gchar * gst_filename_to_uri (const gchar *filename, GError **error); 221 GError* err = null; 222 223 auto p = gst_filename_to_uri(Str.toStringz(filename), &err); 224 225 if (err !is null) 226 { 227 throw new GException( new ErrorG(err) ); 228 } 229 230 return Str.toString(p); 231 } 232 233 /** 234 * Creates an element for handling the given URI. 235 * Params: 236 * type = Whether to create a source or a sink 237 * uri = URI to create an element for 238 * elementname = Name of created element, can be NULL. [allow-none] 239 * Returns: a new element or NULL if none could be created. [transfer floating] 240 * Throws: GException on failure. 241 */ 242 public static Element gstElementMakeFromUri(GstURIType type, string uri, string elementname) 243 { 244 // GstElement * gst_element_make_from_uri (const GstURIType type, const gchar *uri, const gchar *elementname, GError **error); 245 GError* err = null; 246 247 auto p = gst_element_make_from_uri(type, Str.toStringz(uri), Str.toStringz(elementname), &err); 248 249 if (err !is null) 250 { 251 throw new GException( new ErrorG(err) ); 252 } 253 254 255 if(p is null) 256 { 257 return null; 258 } 259 260 return ObjectG.getDObject!(Element)(cast(GstElement*) p); 261 } 262 263 /** 264 * Gets the type of the given URI handler 265 * Returns: the GstURIType of the URI handler. Returns GST_URI_UNKNOWN if the handler isn't implemented correctly. 266 */ 267 public GstURIType gstUriHandlerGetUriType() 268 { 269 // GstURIType gst_uri_handler_get_uri_type (GstURIHandler *handler); 270 return gst_uri_handler_get_uri_type(getUriHandlerTStruct()); 271 } 272 273 /** 274 * Gets the list of protocols supported by handler. This list may not be 275 * modified. 276 * Returns: the supported protocols. Returns NULL if the handler isn't implemented properly, or the handler doesn't support any protocols. [transfer none][element-type utf8] 277 */ 278 public string[] gstUriHandlerGetProtocols() 279 { 280 // const gchar * const * gst_uri_handler_get_protocols (GstURIHandler *handler); 281 return Str.toStringArray(gst_uri_handler_get_protocols(getUriHandlerTStruct())); 282 } 283 284 /** 285 * Gets the currently handled URI. 286 * Returns: the URI currently handled by the handler. Returns NULL if there are no URI currently handled. The returned string must be freed with g_free() when no longer needed. [transfer full] 287 */ 288 public string gstUriHandlerGetUri() 289 { 290 // gchar * gst_uri_handler_get_uri (GstURIHandler *handler); 291 return Str.toString(gst_uri_handler_get_uri(getUriHandlerTStruct())); 292 } 293 294 /** 295 * Tries to set the URI of the given handler. 296 * Params: 297 * uri = URI to set 298 * Returns: TRUE if the URI was set successfully, else FALSE. 299 * Throws: GException on failure. 300 */ 301 public int gstUriHandlerSetUri(string uri) 302 { 303 // gboolean gst_uri_handler_set_uri (GstURIHandler *handler, const gchar *uri, GError **error); 304 GError* err = null; 305 306 auto p = gst_uri_handler_set_uri(getUriHandlerTStruct(), Str.toStringz(uri), &err); 307 308 if (err !is null) 309 { 310 throw new GException( new ErrorG(err) ); 311 } 312 313 return p; 314 } 315 }