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