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.URIHandlerT;
26 
27 public  import glib.ErrorG;
28 public  import glib.GException;
29 public  import glib.Str;
30 public  import gstreamer.c.functions;
31 public  import gstreamer.c.types;
32 public  import gstreamerc.gstreamertypes;
33 
34 
35 /**
36  * The #GstURIHandler is an interface that is implemented by Source and Sink
37  * #GstElement to unify handling of URI.
38  * 
39  * An application can use the following functions to quickly get an element
40  * that handles the given URI for reading or writing
41  * (gst_element_make_from_uri()).
42  * 
43  * Source and Sink plugins should implement this interface when possible.
44  */
45 public template URIHandlerT(TStruct)
46 {
47 	/** Get the main Gtk struct */
48 	public GstURIHandler* getURIHandlerStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return cast(GstURIHandler*)getStruct();
53 	}
54 
55 
56 	/**
57 	 * Gets the list of protocols supported by @handler. This list may not be
58 	 * modified.
59 	 *
60 	 * Returns: the
61 	 *     supported protocols.  Returns %NULL if the @handler isn't
62 	 *     implemented properly, or the @handler doesn't support any
63 	 *     protocols.
64 	 */
65 	public string[] getProtocols()
66 	{
67 		return Str.toStringArray(gst_uri_handler_get_protocols(getURIHandlerStruct()));
68 	}
69 
70 	/**
71 	 * Gets the currently handled URI.
72 	 *
73 	 * Returns: the URI currently handled by
74 	 *     the @handler.  Returns %NULL if there are no URI currently
75 	 *     handled. The returned string must be freed with g_free() when no
76 	 *     longer needed.
77 	 */
78 	public string getUri()
79 	{
80 		auto retStr = gst_uri_handler_get_uri(getURIHandlerStruct());
81 
82 		scope(exit) Str.freeString(retStr);
83 		return Str.toString(retStr);
84 	}
85 
86 	/**
87 	 * Gets the type of the given URI handler
88 	 *
89 	 * Returns: the #GstURIType of the URI handler.
90 	 *     Returns #GST_URI_UNKNOWN if the @handler isn't implemented correctly.
91 	 */
92 	public GstURIType getUriType()
93 	{
94 		return gst_uri_handler_get_uri_type(getURIHandlerStruct());
95 	}
96 
97 	/**
98 	 * Tries to set the URI of the given handler.
99 	 *
100 	 * Params:
101 	 *     uri = URI to set
102 	 *
103 	 * Returns: %TRUE if the URI was set successfully, else %FALSE.
104 	 *
105 	 * Throws: GException on failure.
106 	 */
107 	public bool setUri(string uri)
108 	{
109 		GError* err = null;
110 
111 		auto p = gst_uri_handler_set_uri(getURIHandlerStruct(), Str.toStringz(uri), &err) != 0;
112 
113 		if (err !is null)
114 		{
115 			throw new GException( new ErrorG(err) );
116 		}
117 
118 		return p;
119 	}
120 }