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(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return cast(GstURIHandler*)getStruct();
52 	}
53 
54 
55 	/**
56 	 * Gets the list of protocols supported by @handler. This list may not be
57 	 * modified.
58 	 *
59 	 * Returns: the
60 	 *     supported protocols.  Returns %NULL if the @handler isn't
61 	 *     implemented properly, or the @handler doesn't support any
62 	 *     protocols.
63 	 */
64 	public string[] getProtocols()
65 	{
66 		return Str.toStringArray(gst_uri_handler_get_protocols(getURIHandlerStruct()));
67 	}
68 
69 	/**
70 	 * Gets the currently handled URI.
71 	 *
72 	 * Returns: the URI currently handled by
73 	 *     the @handler.  Returns %NULL if there are no URI currently
74 	 *     handled. The returned string must be freed with g_free() when no
75 	 *     longer needed.
76 	 */
77 	public string getUri()
78 	{
79 		auto retStr = gst_uri_handler_get_uri(getURIHandlerStruct());
80 		
81 		scope(exit) Str.freeString(retStr);
82 		return Str.toString(retStr);
83 	}
84 
85 	/**
86 	 * Gets the type of the given URI handler
87 	 *
88 	 * Returns: the #GstURIType of the URI handler.
89 	 *     Returns #GST_URI_UNKNOWN if the @handler isn't implemented correctly.
90 	 */
91 	public GstURIType getUriType()
92 	{
93 		return gst_uri_handler_get_uri_type(getURIHandlerStruct());
94 	}
95 
96 	/**
97 	 * Tries to set the URI of the given handler.
98 	 *
99 	 * Params:
100 	 *     uri = URI to set
101 	 *
102 	 * Returns: %TRUE if the URI was set successfully, else %FALSE.
103 	 *
104 	 * Throws: GException on failure.
105 	 */
106 	public bool setUri(string uri)
107 	{
108 		GError* err = null;
109 		
110 		auto p = gst_uri_handler_set_uri(getURIHandlerStruct(), Str.toStringz(uri), &err) != 0;
111 		
112 		if (err !is null)
113 		{
114 			throw new GException( new ErrorG(err) );
115 		}
116 		
117 		return p;
118 	}
119 }