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.StreamCollection;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.ParamSpec;
31 private import gobject.Signals;
32 private import gstreamer.ObjectGst;
33 private import gstreamer.Stream;
34 private import gstreamer.c.functions;
35 public  import gstreamer.c.types;
36 public  import gstreamerc.gstreamertypes;
37 private import std.algorithm;
38 
39 
40 /**
41  * A collection of #GstStream that are available.
42  * 
43  * A #GstStreamCollection will be provided by elements that can make those
44  * streams available. Applications can use the collection to show the user
45  * what streams are available by using %gst_stream_collection_get_stream()
46  * 
47  * Once posted, a #GstStreamCollection is immutable. Updates are made by sending
48  * a new #GstStreamCollection message, which may or may not share some of
49  * the #GstStream objects from the collection it replaces. The receiver can check
50  * the sender of a stream collection message to know which collection is
51  * obsoleted.
52  * 
53  * Several elements in a pipeline can provide #GstStreamCollection.
54  * 
55  * Applications can activate streams from a collection by using the
56  * #GST_EVENT_SELECT_STREAMS event on a pipeline, bin or element.
57  *
58  * Since: 1.10
59  */
60 public class StreamCollection : ObjectGst
61 {
62 	/** the main Gtk struct */
63 	protected GstStreamCollection* gstStreamCollection;
64 
65 	/** Get the main Gtk struct */
66 	public GstStreamCollection* getStreamCollectionStruct(bool transferOwnership = false)
67 	{
68 		if (transferOwnership)
69 			ownedRef = false;
70 		return gstStreamCollection;
71 	}
72 
73 	/** the main Gtk struct as a void* */
74 	protected override void* getStruct()
75 	{
76 		return cast(void*)gstStreamCollection;
77 	}
78 
79 	/**
80 	 * Sets our main struct and passes it to the parent class.
81 	 */
82 	public this (GstStreamCollection* gstStreamCollection, bool ownedRef = false)
83 	{
84 		this.gstStreamCollection = gstStreamCollection;
85 		super(cast(GstObject*)gstStreamCollection, ownedRef);
86 	}
87 
88 
89 	/** */
90 	public static GType getType()
91 	{
92 		return gst_stream_collection_get_type();
93 	}
94 
95 	/**
96 	 * Create a new #GstStreamCollection.
97 	 *
98 	 * Params:
99 	 *     upstreamId = The stream id of the parent stream
100 	 *
101 	 * Returns: The new #GstStreamCollection.
102 	 *
103 	 * Since: 1.10
104 	 *
105 	 * Throws: ConstructionException GTK+ fails to create the object.
106 	 */
107 	public this(string upstreamId)
108 	{
109 		auto p = gst_stream_collection_new(Str.toStringz(upstreamId));
110 
111 		if(p is null)
112 		{
113 			throw new ConstructionException("null returned by new");
114 		}
115 
116 		this(cast(GstStreamCollection*) p, true);
117 	}
118 
119 	/**
120 	 * Add the given @stream to the @collection.
121 	 *
122 	 * Params:
123 	 *     stream = the #GstStream to add
124 	 *
125 	 * Returns: %TRUE if the @stream was properly added, else %FALSE
126 	 *
127 	 * Since: 1.10
128 	 */
129 	public bool addStream(Stream stream)
130 	{
131 		return gst_stream_collection_add_stream(gstStreamCollection, (stream is null) ? null : stream.getStreamStruct()) != 0;
132 	}
133 
134 	/**
135 	 * Get the number of streams this collection contains
136 	 *
137 	 * Returns: The number of streams that @collection contains
138 	 *
139 	 * Since: 1.10
140 	 */
141 	public uint getSize()
142 	{
143 		return gst_stream_collection_get_size(gstStreamCollection);
144 	}
145 
146 	/**
147 	 * Retrieve the #GstStream with index @index from the collection.
148 	 *
149 	 * The caller should not modify the returned #GstStream
150 	 *
151 	 * Params:
152 	 *     index = Index of the stream to retrieve
153 	 *
154 	 * Returns: A #GstStream
155 	 *
156 	 * Since: 1.10
157 	 */
158 	public Stream getStream(uint index)
159 	{
160 		auto p = gst_stream_collection_get_stream(gstStreamCollection, index);
161 
162 		if(p is null)
163 		{
164 			return null;
165 		}
166 
167 		return ObjectG.getDObject!(Stream)(cast(GstStream*) p);
168 	}
169 
170 	/**
171 	 * Returns the upstream id of the @collection.
172 	 *
173 	 * Returns: The upstream id
174 	 *
175 	 * Since: 1.10
176 	 */
177 	public string getUpstreamId()
178 	{
179 		return Str.toString(gst_stream_collection_get_upstream_id(gstStreamCollection));
180 	}
181 
182 	/** */
183 	gulong addOnStreamNotify(void delegate(Stream, ParamSpec, StreamCollection) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
184 	{
185 		return Signals.connect(this, "stream-notify", dlg, connectFlags ^ ConnectFlags.SWAPPED);
186 	}
187 }