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 module gstreamer.Uri; 26 27 private import glib.ConstructionException; 28 private import glib.ErrorG; 29 private import glib.GException; 30 private import glib.HashTable; 31 private import glib.ListG; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 private import gstreamerc.gstreamer; 35 public import gstreamerc.gstreamertypes; 36 37 38 /** 39 * A #GstUri object can be used to parse and split a URI string into its 40 * constituant parts. Two #GstUri objects can be joined to make a new #GstUri 41 * using the algorithm described in RFC3986. 42 */ 43 public class Uri 44 { 45 /** the main Gtk struct */ 46 protected GstUri* gstUri; 47 48 /** Get the main Gtk struct */ 49 public GstUri* getUriStruct() 50 { 51 return gstUri; 52 } 53 54 /** the main Gtk struct as a void* */ 55 protected void* getStruct() 56 { 57 return cast(void*)gstUri; 58 } 59 60 /** 61 * Sets our main struct and passes it to the parent class. 62 */ 63 public this (GstUri* gstUri) 64 { 65 this.gstUri = gstUri; 66 } 67 68 69 /** */ 70 public static GType getType() 71 { 72 return gst_uri_get_type(); 73 } 74 75 /** 76 * Creates a new #GstUri object with the given URI parts. The path and query 77 * strings will be broken down into their elements. All strings should not be 78 * escaped except where indicated. 79 * 80 * Params: 81 * scheme = The scheme for the new URI. 82 * userinfo = The user-info for the new URI. 83 * host = The host name for the new URI. 84 * port = The port number for the new URI or %GST_URI_NO_PORT. 85 * path = The path for the new URI with '/' separating path 86 * elements. 87 * query = The query string for the new URI with '&' separating 88 * query elements. Elements containing '&' characters 89 * should encode them as "%26". 90 * fragment = The fragment name for the new URI. 91 * 92 * Return: A new #GstUri object. 93 * 94 * Since: 1.6 95 * 96 * Throws: ConstructionException GTK+ fails to create the object. 97 */ 98 public this(string scheme, string userinfo, string host, uint port, string path, string query, string fragment) 99 { 100 auto p = gst_uri_new(Str.toStringz(scheme), Str.toStringz(userinfo), Str.toStringz(host), port, Str.toStringz(path), Str.toStringz(query), Str.toStringz(fragment)); 101 102 if(p is null) 103 { 104 throw new ConstructionException("null returned by new"); 105 } 106 107 this(cast(GstUri*) p); 108 } 109 110 /** 111 * Append a path onto the end of the path in the URI. The path is not 112 * normalized, call #gst_uri_normalize() to normalize the path. 113 * 114 * Params: 115 * relativePath = Relative path to append to the end of the current path. 116 * 117 * Return: %TRUE if the path was appended successfully. 118 * 119 * Since: 1.6 120 */ 121 public bool appendPath(string relativePath) 122 { 123 return gst_uri_append_path(gstUri, Str.toStringz(relativePath)) != 0; 124 } 125 126 /** 127 * Append a single path segment onto the end of the URI path. 128 * 129 * Params: 130 * pathSegment = The path segment string to append to the URI path. 131 * 132 * Return: %TRUE if the path was appended successfully. 133 * 134 * Since: 1.6 135 */ 136 public bool appendPathSegment(string pathSegment) 137 { 138 return gst_uri_append_path_segment(gstUri, Str.toStringz(pathSegment)) != 0; 139 } 140 141 /** 142 * Compares two #GstUri objects to see if they represent the same normalized 143 * URI. 144 * 145 * Params: 146 * second = Second #GstUri to compare. 147 * 148 * Return: %TRUE if the normalized versions of the two URI's would be equal. 149 * 150 * Since: 1.6 151 */ 152 public bool equal(Uri second) 153 { 154 return gst_uri_equal(gstUri, (second is null) ? null : second.getUriStruct()) != 0; 155 } 156 157 /** 158 * Like gst_uri_from_string() but also joins with a base URI. 159 * 160 * Params: 161 * uri = The URI string to parse. 162 * 163 * Return: A new #GstUri object. 164 * 165 * Since: 1.6 166 */ 167 public Uri fromStringWithBase(string uri) 168 { 169 auto p = gst_uri_from_string_with_base(gstUri, Str.toStringz(uri)); 170 171 if(p is null) 172 { 173 return null; 174 } 175 176 return ObjectG.getDObject!(Uri)(cast(GstUri*) p); 177 } 178 179 /** 180 * Get the fragment name from the URI or %NULL if it doesn't exist. 181 * If @uri is %NULL then returns %NULL. 182 * 183 * Return: The host name from the #GstUri object or %NULL. 184 * 185 * Since: 1.6 186 */ 187 public string getFragment() 188 { 189 return Str.toString(gst_uri_get_fragment(gstUri)); 190 } 191 192 /** 193 * Get the host name from the URI or %NULL if it doesn't exist. 194 * If @uri is %NULL then returns %NULL. 195 * 196 * Return: The host name from the #GstUri object or %NULL. 197 * 198 * Since: 1.6 199 */ 200 public string getHost() 201 { 202 return Str.toString(gst_uri_get_host(gstUri)); 203 } 204 205 /** 206 * Extract the path string from the URI object. 207 * 208 * Return: The path from the URI. Once finished with the 209 * string should be g_free()'d. 210 * 211 * Since: 1.6 212 */ 213 public string getPath() 214 { 215 return Str.toString(gst_uri_get_path(gstUri)); 216 } 217 218 /** 219 * Get a list of path segments from the URI. 220 * 221 * Return: A #GList of path segment 222 * strings or %NULL if no path segments are available. Free the list 223 * when no longer needed with g_list_free_full(list, g_free). 224 * 225 * Since: 1.6 226 */ 227 public ListG getPathSegments() 228 { 229 auto p = gst_uri_get_path_segments(gstUri); 230 231 if(p is null) 232 { 233 return null; 234 } 235 236 return new ListG(cast(GList*) p); 237 } 238 239 /** 240 * Extract the path string from the URI object as a percent encoded URI path. 241 * 242 * Return: The path from the URI. Once finished with the 243 * string should be g_free()'d. 244 * 245 * Since: 1.6 246 */ 247 public string getPathString() 248 { 249 return Str.toString(gst_uri_get_path_string(gstUri)); 250 } 251 252 /** 253 * Get the port number from the URI or %GST_URI_NO_PORT if it doesn't exist. 254 * If @uri is %NULL then returns %GST_URI_NO_PORT. 255 * 256 * Return: The port number from the #GstUri object or %GST_URI_NO_PORT. 257 * 258 * Since: 1.6 259 */ 260 public uint getPort() 261 { 262 return gst_uri_get_port(gstUri); 263 } 264 265 /** 266 * Get a list of the query keys from the URI. 267 * 268 * Return: A list of keys from 269 * the URI query. Free the list with g_list_free(). 270 * 271 * Since: 1.6 272 */ 273 public ListG getQueryKeys() 274 { 275 auto p = gst_uri_get_query_keys(gstUri); 276 277 if(p is null) 278 { 279 return null; 280 } 281 282 return new ListG(cast(GList*) p); 283 } 284 285 /** 286 * Get a percent encoded URI query string from the @uri. 287 * 288 * Return: A percent encoded query string. Use g_free() when 289 * no longer needed. 290 * 291 * Since: 1.6 292 */ 293 public string getQueryString() 294 { 295 return Str.toString(gst_uri_get_query_string(gstUri)); 296 } 297 298 /** 299 * Get the query table from the URI. Keys and values in the table are freed 300 * with g_free when they are deleted. A value may be %NULL to indicate that 301 * the key should appear in the query string in the URI, but does not have a 302 * value. Free the returned #GHashTable with #g_hash_table_unref() when it is 303 * no longer required. Modifying this hash table will modify the query in the 304 * URI. 305 * 306 * Return: The query hash table 307 * from the URI. 308 * 309 * Since: 1.6 310 */ 311 public HashTable getQueryTable() 312 { 313 auto p = gst_uri_get_query_table(gstUri); 314 315 if(p is null) 316 { 317 return null; 318 } 319 320 return new HashTable(cast(GHashTable*) p); 321 } 322 323 /** 324 * Get the value associated with the @query_key key. Will return %NULL if the 325 * key has no value or if the key does not exist in the URI query table. Because 326 * %NULL is returned for both missing keys and keys with no value, you should 327 * use gst_uri_query_has_key() to determine if a key is present in the URI 328 * query. 329 * 330 * Params: 331 * queryKey = The key to lookup. 332 * 333 * Return: The value for the given key, or %NULL if not found. 334 * 335 * Since: 1.6 336 */ 337 public string getQueryValue(string queryKey) 338 { 339 return Str.toString(gst_uri_get_query_value(gstUri, Str.toStringz(queryKey))); 340 } 341 342 /** 343 * Get the scheme name from the URI or %NULL if it doesn't exist. 344 * If @uri is %NULL then returns %NULL. 345 * 346 * Return: The scheme from the #GstUri object or %NULL. 347 */ 348 public string getScheme() 349 { 350 return Str.toString(gst_uri_get_scheme(gstUri)); 351 } 352 353 /** 354 * Get the userinfo (usually in the form "username:password") from the URI 355 * or %NULL if it doesn't exist. If @uri is %NULL then returns %NULL. 356 * 357 * Return: The userinfo from the #GstUri object or %NULL. 358 * 359 * Since: 1.6 360 */ 361 public string getUserinfo() 362 { 363 return Str.toString(gst_uri_get_userinfo(gstUri)); 364 } 365 366 /** 367 * Tests the @uri to see if it is normalized. A %NULL @uri is considered to be 368 * normalized. 369 * 370 * Return: TRUE if the URI is normalized or is %NULL. 371 * 372 * Since: 1.6 373 */ 374 public bool isNormalized() 375 { 376 return gst_uri_is_normalized(gstUri) != 0; 377 } 378 379 /** 380 * Check if it is safe to write to this #GstUri. 381 * 382 * Check if the refcount of @uri is exactly 1, meaning that no other 383 * reference exists to the #GstUri and that the #GstUri is therefore writable. 384 * 385 * Modification of a #GstUri should only be done after verifying that it is 386 * writable. 387 * 388 * Return: %TRUE if it is safe to write to the object. 389 * 390 * Since: 1.6 391 */ 392 public bool isWritable() 393 { 394 return gst_uri_is_writable(gstUri) != 0; 395 } 396 397 /** 398 * Join a reference URI onto a base URI using the method from RFC 3986. 399 * If either URI is %NULL then the other URI will be returned with the ref count 400 * increased. 401 * 402 * Params: 403 * refUri = The reference URI to join onto the 404 * base URI. 405 * 406 * Return: A #GstUri which represents the base with the 407 * reference URI joined on. 408 * 409 * Since: 1.6 410 */ 411 public Uri join(Uri refUri) 412 { 413 auto p = gst_uri_join(gstUri, (refUri is null) ? null : refUri.getUriStruct()); 414 415 if(p is null) 416 { 417 return null; 418 } 419 420 return ObjectG.getDObject!(Uri)(cast(GstUri*) p); 421 } 422 423 /** 424 * Make the #GstUri writable. 425 * 426 * Checks if @uri is writable, and if so the original object is returned. If 427 * not, then a writable copy is made and returned. This gives away the 428 * reference to @uri and returns a reference to the new #GstUri. 429 * If @uri is %NULL then %NULL is returned. 430 * 431 * Return: A writable version of @uri. 432 * 433 * Since: 1.6 434 */ 435 public Uri makeWritable() 436 { 437 auto p = gst_uri_make_writable(gstUri); 438 439 if(p is null) 440 { 441 return null; 442 } 443 444 return ObjectG.getDObject!(Uri)(cast(GstUri*) p); 445 } 446 447 /** 448 * Like gst_uri_new(), but joins the new URI onto a base URI. 449 * 450 * Params: 451 * scheme = The scheme for the new URI. 452 * userinfo = The user-info for the new URI. 453 * host = The host name for the new URI. 454 * port = The port number for the new URI or %GST_URI_NO_PORT. 455 * path = The path for the new URI with '/' separating path 456 * elements. 457 * query = The query string for the new URI with '&' separating 458 * query elements. Elements containing '&' characters 459 * should encode them as "%26". 460 * fragment = The fragment name for the new URI. 461 * 462 * Return: The new URI joined onto @base. 463 * 464 * Since: 1.6 465 */ 466 public Uri newWithBase(string scheme, string userinfo, string host, uint port, string path, string query, string fragment) 467 { 468 auto p = gst_uri_new_with_base(gstUri, Str.toStringz(scheme), Str.toStringz(userinfo), Str.toStringz(host), port, Str.toStringz(path), Str.toStringz(query), Str.toStringz(fragment)); 469 470 if(p is null) 471 { 472 return null; 473 } 474 475 return ObjectG.getDObject!(Uri)(cast(GstUri*) p); 476 } 477 478 /** 479 * Normalization will remove extra path segments ("." and "..") from the URI. It 480 * will also convert the scheme and host name to lower case and any 481 * percent-encoded values to uppercase. 482 * 483 * The #GstUri object must be writable. Check with gst_uri_is_writable() or use 484 * gst_uri_make_writable() first. 485 * 486 * Return: TRUE if the URI was modified. 487 * 488 * Since: 1.6 489 */ 490 public bool normalize() 491 { 492 return gst_uri_normalize(gstUri) != 0; 493 } 494 495 /** 496 * Check if there is a query table entry for the @query_key key. 497 * 498 * Params: 499 * queryKey = The key to lookup. 500 * 501 * Return: %TRUE if @query_key exists in the URI query table. 502 * 503 * Since: 1.6 504 */ 505 public bool queryHasKey(string queryKey) 506 { 507 return gst_uri_query_has_key(gstUri, Str.toStringz(queryKey)) != 0; 508 } 509 510 /** 511 * Remove an entry from the query table by key. 512 * 513 * Params: 514 * queryKey = The key to remove. 515 * 516 * Return: %TRUE if the key existed in the table and was removed. 517 * 518 * Since: 1.6 519 */ 520 public bool removeQueryKey(string queryKey) 521 { 522 return gst_uri_remove_query_key(gstUri, Str.toStringz(queryKey)) != 0; 523 } 524 525 /** 526 * Sets the fragment string in the URI. Use a value of %NULL in @fragment to 527 * unset the fragment string. 528 * 529 * Params: 530 * fragment = The fragment string to set. 531 * 532 * Return: %TRUE if the fragment was set/unset successfully. 533 * 534 * Since: 1.6 535 */ 536 public bool setFragment(string fragment) 537 { 538 return gst_uri_set_fragment(gstUri, Str.toStringz(fragment)) != 0; 539 } 540 541 /** 542 * Set or unset the host for the URI. 543 * 544 * Params: 545 * host = The new host string to set or %NULL to unset. 546 * 547 * Return: %TRUE if the host was set/unset successfully. 548 * 549 * Since: 1.6 550 */ 551 public bool setHost(string host) 552 { 553 return gst_uri_set_host(gstUri, Str.toStringz(host)) != 0; 554 } 555 556 /** 557 * Sets or unsets the path in the URI. 558 * 559 * Params: 560 * path = The new path to set with path segments separated by '/', or use %NULL 561 * to unset the path. 562 * 563 * Return: %TRUE if the path was set successfully. 564 * 565 * Since: 1.6 566 */ 567 public bool setPath(string path) 568 { 569 return gst_uri_set_path(gstUri, Str.toStringz(path)) != 0; 570 } 571 572 /** 573 * Replace the path segments list in the URI. 574 * 575 * Params: 576 * pathSegments = The new 577 * path list to set. 578 * 579 * Return: %TRUE if the path segments were set successfully. 580 * 581 * Since: 1.6 582 */ 583 public bool setPathSegments(ListG pathSegments) 584 { 585 return gst_uri_set_path_segments(gstUri, (pathSegments is null) ? null : pathSegments.getListGStruct()) != 0; 586 } 587 588 /** 589 * Sets or unsets the path in the URI. 590 * 591 * Params: 592 * path = The new percent encoded path to set with path segments separated by 593 * '/', or use %NULL to unset the path. 594 * 595 * Return: %TRUE if the path was set successfully. 596 * 597 * Since: 1.6 598 */ 599 public bool setPathString(string path) 600 { 601 return gst_uri_set_path_string(gstUri, Str.toStringz(path)) != 0; 602 } 603 604 /** 605 * Set or unset the port number for the URI. 606 * 607 * Params: 608 * port = The new port number to set or %GST_URI_NO_PORT to unset. 609 * 610 * Return: %TRUE if the port number was set/unset successfully. 611 * 612 * Since: 1.6 613 */ 614 public bool setPort(uint port) 615 { 616 return gst_uri_set_port(gstUri, port) != 0; 617 } 618 619 /** 620 * Sets or unsets the query table in the URI. 621 * 622 * Params: 623 * query = The new percent encoded query string to use to populate the query 624 * table, or use %NULL to unset the query table. 625 * 626 * Return: %TRUE if the query table was set successfully. 627 * 628 * Since: 1.6 629 */ 630 public bool setQueryString(string query) 631 { 632 return gst_uri_set_query_string(gstUri, Str.toStringz(query)) != 0; 633 } 634 635 /** 636 * Set the query table to use in the URI. The old table is unreferenced and a 637 * reference to the new one is used instead. A value if %NULL for @query_table 638 * will remove the query string from the URI. 639 * 640 * Params: 641 * queryTable = The new 642 * query table to use. 643 * 644 * Return: %TRUE if the new table was sucessfully used for the query table. 645 * 646 * Since: 1.6 647 */ 648 public bool setQueryTable(HashTable queryTable) 649 { 650 return gst_uri_set_query_table(gstUri, (queryTable is null) ? null : queryTable.getHashTableStruct()) != 0; 651 } 652 653 /** 654 * This inserts or replaces a key in the query table. A @query_value of %NULL 655 * indicates that the key has no associated value, but will still be present in 656 * the query string. 657 * 658 * Params: 659 * queryKey = The key for the query entry. 660 * queryValue = The value for the key. 661 * 662 * Return: %TRUE if the query table was sucessfully updated. 663 * 664 * Since: 1.6 665 */ 666 public bool setQueryValue(string queryKey, string queryValue) 667 { 668 return gst_uri_set_query_value(gstUri, Str.toStringz(queryKey), Str.toStringz(queryValue)) != 0; 669 } 670 671 /** 672 * Set or unset the scheme for the URI. 673 * 674 * Params: 675 * scheme = The new scheme to set or %NULL to unset the scheme. 676 * 677 * Return: %TRUE if the scheme was set/unset successfully. 678 * 679 * Since: 1.6 680 */ 681 public bool setScheme(string scheme) 682 { 683 return gst_uri_set_scheme(gstUri, Str.toStringz(scheme)) != 0; 684 } 685 686 /** 687 * Set or unset the user information for the URI. 688 * 689 * Params: 690 * userinfo = The new user-information string to set or %NULL to unset. 691 * 692 * Return: %TRUE if the user information was set/unset successfully. 693 * 694 * Since: 1.6 695 */ 696 public bool setUserinfo(string userinfo) 697 { 698 return gst_uri_set_userinfo(gstUri, Str.toStringz(userinfo)) != 0; 699 } 700 701 /** 702 * Convert the URI to a string. 703 * 704 * Returns the URI as held in this object as a #gchar* nul-terminated string. 705 * The caller should g_free() the string once they are finished with it. 706 * The string is put together as described in RFC 3986. 707 * 708 * Return: The string version of the URI. 709 * 710 * Since: 1.6 711 */ 712 public override string toString() 713 { 714 return Str.toString(gst_uri_to_string(gstUri)); 715 } 716 717 /** 718 * Constructs a URI for a given valid protocol and location. 719 * 720 * Free-function: g_free 721 * 722 * Params: 723 * protocol = Protocol for URI 724 * location = Location for URI 725 * 726 * Return: a new string for this URI. Returns %NULL if the 727 * given URI protocol is not valid, or the given location is %NULL. 728 */ 729 public static string construct(string protocol, string location) 730 { 731 return Str.toString(gst_uri_construct(Str.toStringz(protocol), Str.toStringz(location))); 732 } 733 734 /** 735 * Parses a URI string into a new #GstUri object. Will return NULL if the URI 736 * cannot be parsed. 737 * 738 * Params: 739 * uri = The URI string to parse. 740 * 741 * Return: A new #GstUri object, or NULL. 742 * 743 * Since: 1.6 744 */ 745 public static Uri fromString(string uri) 746 { 747 auto p = gst_uri_from_string(Str.toStringz(uri)); 748 749 if(p is null) 750 { 751 return null; 752 } 753 754 return ObjectG.getDObject!(Uri)(cast(GstUri*) p); 755 } 756 757 /** 758 * Extracts the location out of a given valid URI, ie. the protocol and "://" 759 * are stripped from the URI, which means that the location returned includes 760 * the hostname if one is specified. The returned string must be freed using 761 * g_free(). 762 * 763 * Free-function: g_free 764 * 765 * Params: 766 * uri = A URI string 767 * 768 * Return: the location for this URI. Returns %NULL if the 769 * URI isn't valid. If the URI does not contain a location, an empty 770 * string is returned. 771 */ 772 public static string getLocation(string uri) 773 { 774 return Str.toString(gst_uri_get_location(Str.toStringz(uri))); 775 } 776 777 /** 778 * Extracts the protocol out of a given valid URI. The returned string must be 779 * freed using g_free(). 780 * 781 * Params: 782 * uri = A URI string 783 * 784 * Return: The protocol for this URI. 785 */ 786 public static string getProtocol(string uri) 787 { 788 return Str.toString(gst_uri_get_protocol(Str.toStringz(uri))); 789 } 790 791 /** 792 * Checks if the protocol of a given valid URI matches @protocol. 793 * 794 * Params: 795 * uri = a URI string 796 * protocol = a protocol string (e.g. "http") 797 * 798 * Return: %TRUE if the protocol matches. 799 */ 800 public static bool hasProtocol(string uri, string protocol) 801 { 802 return gst_uri_has_protocol(Str.toStringz(uri), Str.toStringz(protocol)) != 0; 803 } 804 805 /** 806 * Tests if the given string is a valid URI identifier. URIs start with a valid 807 * scheme followed by ":" and maybe a string identifying the location. 808 * 809 * Params: 810 * uri = A URI string 811 * 812 * Return: %TRUE if the string is a valid URI 813 */ 814 public static bool isValid(string uri) 815 { 816 return gst_uri_is_valid(Str.toStringz(uri)) != 0; 817 } 818 819 /** 820 * This is a convenience function to join two URI strings and return the result. 821 * The returned string should be g_free()'d after use. 822 * 823 * Params: 824 * baseUri = The percent-encoded base URI. 825 * refUri = The percent-encoded reference URI to join to the @base_uri. 826 * 827 * Return: A string representing the percent-encoded join of 828 * the two URIs. 829 * 830 * Since: 1.6 831 */ 832 public static string joinStrings(string baseUri, string refUri) 833 { 834 return Str.toString(gst_uri_join_strings(Str.toStringz(baseUri), Str.toStringz(refUri))); 835 } 836 837 /** 838 * Checks if an element exists that supports the given URI protocol. Note 839 * that a positive return value does not imply that a subsequent call to 840 * gst_element_make_from_uri() is guaranteed to work. 841 * 842 * Params: 843 * type = Whether to check for a source or a sink 844 * protocol = Protocol that should be checked for (e.g. "http" or "smb") 845 * 846 * Return: %TRUE 847 */ 848 public static bool protocolIsSupported(GstURIType type, string protocol) 849 { 850 return gst_uri_protocol_is_supported(type, Str.toStringz(protocol)) != 0; 851 } 852 853 /** 854 * Tests if the given string is a valid protocol identifier. Protocols 855 * must consist of alphanumeric characters, '+', '-' and '.' and must 856 * start with a alphabetic character. See RFC 3986 Section 3.1. 857 * 858 * Params: 859 * protocol = A string 860 * 861 * Return: %TRUE if the string is a valid protocol identifier, %FALSE otherwise. 862 */ 863 public static bool protocolIsValid(string protocol) 864 { 865 return gst_uri_protocol_is_valid(Str.toStringz(protocol)) != 0; 866 } 867 868 /** 869 * Similar to g_filename_to_uri(), but attempts to handle relative file paths 870 * as well. Before converting @filename into an URI, it will be prefixed by 871 * the current working directory if it is a relative path, and then the path 872 * will be canonicalised so that it doesn't contain any './' or '../' segments. 873 * 874 * On Windows #filename should be in UTF-8 encoding. 875 * 876 * Params: 877 * filename = absolute or relative file name path 878 * 879 * Return: newly-allocated URI string, or NULL on error. The caller must 880 * free the URI string with g_free() when no longer needed. 881 * 882 * Throws: GException on failure. 883 */ 884 public static string filenameToUri(string filename) 885 { 886 GError* err = null; 887 888 auto p = gst_filename_to_uri(Str.toStringz(filename), &err); 889 890 if (err !is null) 891 { 892 throw new GException( new ErrorG(err) ); 893 } 894 895 return Str.toString(p); 896 } 897 898 /** */ 899 public static GQuark uriErrorQuark() 900 { 901 return gst_uri_error_quark(); 902 } 903 }