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 gstreamerc.gstreamer; 35 public import gstreamerc.gstreamertypes; 36 private import std.algorithm; 37 38 39 /** 40 * A collection of #GstStream that are available. 41 * 42 * A #GstStreamCollection will be provided by elements that can make those 43 * streams available. Applications can use the collection to show the user 44 * what streams are available by using %gst_stream_collection_get_stream() 45 * 46 * Once posted, a #GstStreamCollection is immutable. Updates are made by sending 47 * a new #GstStreamCollection message, which may or may not share some of 48 * the #GstStream objects from the collection it replaces. The receiver can check 49 * the sender of a stream collection message to know which collection is 50 * obsoleted. 51 * 52 * Several elements in a pipeline can provide #GstStreamCollection. 53 * 54 * Applications can activate streams from a collection by using the 55 * #GST_EVENT_SELECT_STREAMS event on a pipeline, bin or element. 56 * 57 * Since: 1.10 58 */ 59 public class StreamCollection : ObjectGst 60 { 61 /** the main Gtk struct */ 62 protected GstStreamCollection* gstStreamCollection; 63 64 /** Get the main Gtk struct */ 65 public GstStreamCollection* getStreamCollectionStruct(bool transferOwnership = false) 66 { 67 if (transferOwnership) 68 ownedRef = false; 69 return gstStreamCollection; 70 } 71 72 /** the main Gtk struct as a void* */ 73 protected override void* getStruct() 74 { 75 return cast(void*)gstStreamCollection; 76 } 77 78 protected override void setStruct(GObject* obj) 79 { 80 gstStreamCollection = cast(GstStreamCollection*)obj; 81 super.setStruct(obj); 82 } 83 84 /** 85 * Sets our main struct and passes it to the parent class. 86 */ 87 public this (GstStreamCollection* gstStreamCollection, bool ownedRef = false) 88 { 89 this.gstStreamCollection = gstStreamCollection; 90 super(cast(GstObject*)gstStreamCollection, ownedRef); 91 } 92 93 94 /** */ 95 public static GType getType() 96 { 97 return gst_stream_collection_get_type(); 98 } 99 100 /** 101 * Create a new #GstStreamCollection. 102 * 103 * Params: 104 * upstreamId = The stream id of the parent stream 105 * 106 * Returns: The new #GstStreamCollection. 107 * 108 * Since: 1.10 109 * 110 * Throws: ConstructionException GTK+ fails to create the object. 111 */ 112 public this(string upstreamId) 113 { 114 auto p = gst_stream_collection_new(Str.toStringz(upstreamId)); 115 116 if(p is null) 117 { 118 throw new ConstructionException("null returned by new"); 119 } 120 121 this(cast(GstStreamCollection*) p); 122 } 123 124 /** 125 * Add the given @stream to the @collection. 126 * 127 * Params: 128 * stream = the #GstStream to add 129 * 130 * Returns: %TRUE if the @stream was properly added, else %FALSE 131 * 132 * Since: 1.10 133 */ 134 public bool addStream(Stream stream) 135 { 136 return gst_stream_collection_add_stream(gstStreamCollection, (stream is null) ? null : stream.getStreamStruct()) != 0; 137 } 138 139 /** 140 * Get the number of streams this collection contains 141 * 142 * Returns: The number of streams that @collection contains 143 * 144 * Since: 1.10 145 */ 146 public uint getSize() 147 { 148 return gst_stream_collection_get_size(gstStreamCollection); 149 } 150 151 /** 152 * Retrieve the #GstStream with index @index from the collection. 153 * 154 * The caller should not modify the returned #GstStream 155 * 156 * Params: 157 * index = Index of the stream to retrieve 158 * 159 * Returns: A #GstStream 160 * 161 * Since: 1.10 162 */ 163 public Stream getStream(uint index) 164 { 165 auto p = gst_stream_collection_get_stream(gstStreamCollection, index); 166 167 if(p is null) 168 { 169 return null; 170 } 171 172 return ObjectG.getDObject!(Stream)(cast(GstStream*) p); 173 } 174 175 /** 176 * Returns the upstream id of the @collection. 177 * 178 * Returns: The upstream id 179 * 180 * Since: 1.10 181 */ 182 public string getUpstreamId() 183 { 184 return Str.toString(gst_stream_collection_get_upstream_id(gstStreamCollection)); 185 } 186 187 protected class OnStreamNotifyDelegateWrapper 188 { 189 static OnStreamNotifyDelegateWrapper[] listeners; 190 void delegate(Stream, ParamSpec, StreamCollection) dlg; 191 gulong handlerId; 192 193 this(void delegate(Stream, ParamSpec, StreamCollection) dlg) 194 { 195 this.dlg = dlg; 196 this.listeners ~= this; 197 } 198 199 void remove(OnStreamNotifyDelegateWrapper source) 200 { 201 foreach(index, wrapper; listeners) 202 { 203 if (wrapper.handlerId == source.handlerId) 204 { 205 listeners[index] = null; 206 listeners = std.algorithm.remove(listeners, index); 207 break; 208 } 209 } 210 } 211 } 212 213 /** */ 214 gulong addOnStreamNotify(void delegate(Stream, ParamSpec, StreamCollection) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 215 { 216 auto wrapper = new OnStreamNotifyDelegateWrapper(dlg); 217 wrapper.handlerId = Signals.connectData( 218 this, 219 "stream-notify", 220 cast(GCallback)&callBackStreamNotify, 221 cast(void*)wrapper, 222 cast(GClosureNotify)&callBackStreamNotifyDestroy, 223 connectFlags); 224 return wrapper.handlerId; 225 } 226 227 extern(C) static void callBackStreamNotify(GstStreamCollection* streamcollectionStruct, GstStream* object, GParamSpec* p0, OnStreamNotifyDelegateWrapper wrapper) 228 { 229 wrapper.dlg(ObjectG.getDObject!(Stream)(object), ObjectG.getDObject!(ParamSpec)(p0), wrapper.outer); 230 } 231 232 extern(C) static void callBackStreamNotifyDestroy(OnStreamNotifyDelegateWrapper wrapper, GClosure* closure) 233 { 234 wrapper.remove(wrapper); 235 } 236 }