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 67 public import glib.Str; 68 public import glib.ErrorG; 69 public import glib.GException; 70 public import gstreamer.Element; 71 72 73 74 75 /** 76 * The URIHandler is an interface that is implemented by Source and Sink 77 * GstElement to simplify then handling of URI. 78 * 79 * An application can use the following functions to quickly get an element 80 * that handles the given URI for reading or writing 81 * (gst_element_make_from_uri()). 82 * 83 * Source and Sink plugins should implement this interface when possible. 84 * 85 * Last reviewed on 2005-11-09 (0.9.4) 86 */ 87 public template UriHandlerT(TStruct) 88 { 89 90 /** the main Gtk struct */ 91 protected GstURIHandler* gstURIHandler; 92 93 94 public GstURIHandler* getUriHandlerTStruct() 95 { 96 return cast(GstURIHandler*)getStruct(); 97 } 98 99 100 /** 101 */ 102 103 /** 104 */ 105 public static GQuark gstUriErrorQuark() 106 { 107 // GQuark gst_uri_error_quark (void); 108 return gst_uri_error_quark(); 109 } 110 111 /** 112 * Tests if the given string is a valid protocol identifier. Protocols 113 * must consist of alphanumeric characters, '+', '-' and '.' and must 114 * start with a alphabetic character. See RFC 3986 Section 3.1. 115 * Params: 116 * protocol = A string 117 * Returns: TRUE if the string is a valid protocol identifier, FALSE otherwise. 118 */ 119 public static int isValid(string protocol) 120 { 121 // gboolean gst_uri_protocol_is_valid (const gchar *protocol); 122 return gst_uri_protocol_is_valid(Str.toStringz(protocol)); 123 } 124 125 /** 126 * Checks if an element exists that supports the given URI protocol. Note 127 * that a positive return value does not imply that a subsequent call to 128 * gst_element_make_from_uri() is guaranteed to work. 129 * Params: 130 * type = Whether to check for a source or a sink 131 * protocol = Protocol that should be checked for (e.g. "http" or "smb") 132 * Returns: TRUE 133 */ 134 public static int isSupported(GstURIType type, string protocol) 135 { 136 // gboolean gst_uri_protocol_is_supported (const GstURIType type, const gchar *protocol); 137 return gst_uri_protocol_is_supported(type, Str.toStringz(protocol)); 138 } 139 140 /** 141 * Tests if the given string is a valid URI identifier. URIs start with a valid 142 * scheme followed by ":" and maybe a string identifying the location. 143 * Params: 144 * uri = A URI string 145 * Returns: TRUE if the string is a valid URI 146 */ 147 public static int gstUriIsValid(string uri) 148 { 149 // gboolean gst_uri_is_valid (const gchar *uri); 150 return gst_uri_is_valid(Str.toStringz(uri)); 151 } 152 153 /** 154 * Checks if the protocol of a given valid URI matches protocol. 155 * Params: 156 * uri = a URI string 157 * protocol = a protocol string (e.g. "http") 158 * Returns: TRUE if the protocol matches. 159 */ 160 public static int gstUriHasProtocol(string uri, string protocol) 161 { 162 // gboolean gst_uri_has_protocol (const gchar *uri, const gchar *protocol); 163 return gst_uri_has_protocol(Str.toStringz(uri), Str.toStringz(protocol)); 164 } 165 166 /** 167 * Extracts the protocol out of a given valid URI. The returned string must be 168 * freed using g_free(). 169 * Params: 170 * uri = A URI string 171 * Returns: The protocol for this URI. 172 */ 173 public static string gstUriGetProtocol(string uri) 174 { 175 // gchar * gst_uri_get_protocol (const gchar *uri); 176 return Str.toString(gst_uri_get_protocol(Str.toStringz(uri))); 177 } 178 179 /** 180 * Extracts the location out of a given valid URI, ie. the protocol and "://" 181 * are stripped from the URI, which means that the location returned includes 182 * the hostname if one is specified. The returned string must be freed using 183 * g_free(). 184 * Free-function: g_free 185 * Params: 186 * uri = A URI string 187 * 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] 188 */ 189 public static string gstUriGetLocation(string uri) 190 { 191 // gchar * gst_uri_get_location (const gchar *uri); 192 return Str.toString(gst_uri_get_location(Str.toStringz(uri))); 193 } 194 195 /** 196 * Constructs a URI for a given valid protocol and location. 197 * Free-function: g_free 198 * Params: 199 * protocol = Protocol for URI 200 * location = Location for URI. [transfer none] 201 * 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] 202 */ 203 public static string gstUriConstruct(string protocol, string location) 204 { 205 // gchar * gst_uri_construct (const gchar *protocol, const gchar *location); 206 return Str.toString(gst_uri_construct(Str.toStringz(protocol), Str.toStringz(location))); 207 } 208 209 /** 210 * Similar to g_filename_to_uri(), but attempts to handle relative file paths 211 * as well. Before converting filename into an URI, it will be prefixed by 212 * the current working directory if it is a relative path, and then the path 213 * will be canonicalised so that it doesn't contain any './' or '../' segments. 214 * On Windows filename should be in UTF-8 encoding. 215 * Params: 216 * filename = absolute or relative file name path 217 * Throws: GException on failure. 218 */ 219 public static string gstFilenameToUri(string filename) 220 { 221 // gchar * gst_filename_to_uri (const gchar *filename, GError **error); 222 GError* err = null; 223 224 auto p = gst_filename_to_uri(Str.toStringz(filename), &err); 225 226 if (err !is null) 227 { 228 throw new GException( new ErrorG(err) ); 229 } 230 231 return Str.toString(p); 232 } 233 234 /** 235 * Creates an element for handling the given URI. 236 * Params: 237 * type = Whether to create a source or a sink 238 * uri = URI to create an element for 239 * elementname = Name of created element, can be NULL. [allow-none] 240 * Returns: a new element or NULL if none could be created. [transfer floating] 241 * Throws: GException on failure. 242 */ 243 public static Element gstElementMakeFromUri(GstURIType type, string uri, string elementname) 244 { 245 // GstElement * gst_element_make_from_uri (const GstURIType type, const gchar *uri, const gchar *elementname, GError **error); 246 GError* err = null; 247 248 auto p = gst_element_make_from_uri(type, Str.toStringz(uri), Str.toStringz(elementname), &err); 249 250 if (err !is null) 251 { 252 throw new GException( new ErrorG(err) ); 253 } 254 255 256 if(p is null) 257 { 258 return null; 259 } 260 261 return ObjectG.getDObject!(Element)(cast(GstElement*) p); 262 } 263 264 /** 265 * Gets the type of the given URI handler 266 * Returns: the GstURIType of the URI handler. Returns GST_URI_UNKNOWN if the handler isn't implemented correctly. 267 */ 268 public GstURIType gstUriHandlerGetUriType() 269 { 270 // GstURIType gst_uri_handler_get_uri_type (GstURIHandler *handler); 271 return gst_uri_handler_get_uri_type(getUriHandlerTStruct()); 272 } 273 274 /** 275 * Gets the list of protocols supported by handler. This list may not be 276 * modified. 277 * 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] 278 */ 279 public string[] gstUriHandlerGetProtocols() 280 { 281 // const gchar * const * gst_uri_handler_get_protocols (GstURIHandler *handler); 282 return Str.toStringArray(gst_uri_handler_get_protocols(getUriHandlerTStruct())); 283 } 284 285 /** 286 * Gets the currently handled URI. 287 * 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] 288 */ 289 public string gstUriHandlerGetUri() 290 { 291 // gchar * gst_uri_handler_get_uri (GstURIHandler *handler); 292 return Str.toString(gst_uri_handler_get_uri(getUriHandlerTStruct())); 293 } 294 295 /** 296 * Tries to set the URI of the given handler. 297 * Params: 298 * uri = URI to set 299 * Returns: TRUE if the URI was set successfully, else FALSE. 300 * Throws: GException on failure. 301 */ 302 public int gstUriHandlerSetUri(string uri) 303 { 304 // gboolean gst_uri_handler_set_uri (GstURIHandler *handler, const gchar *uri, GError **error); 305 GError* err = null; 306 307 auto p = gst_uri_handler_set_uri(getUriHandlerTStruct(), Str.toStringz(uri), &err); 308 309 if (err !is null) 310 { 311 throw new GException( new ErrorG(err) ); 312 } 313 314 return p; 315 } 316 }