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