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.Device; 26 27 private import glib.Str; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gstreamer.Caps; 31 private import gstreamer.Element; 32 private import gstreamer.ObjectGst; 33 private import gstreamer.Structure; 34 private import gstreamerc.gstreamer; 35 public import gstreamerc.gstreamertypes; 36 public import gtkc.gdktypes; 37 38 39 /** 40 * #GstDevice are objects representing a device, they contain 41 * relevant metadata about the device, such as its class and the #GstCaps 42 * representing the media types it can produce or handle. 43 * 44 * #GstDevice are created by #GstDeviceProvider objects which can be 45 * aggregated by #GstDeviceMonitor objects. 46 * 47 * Since: 1.4 48 */ 49 public class Device : ObjectGst 50 { 51 /** the main Gtk struct */ 52 protected GstDevice* gstDevice; 53 54 /** Get the main Gtk struct */ 55 public GstDevice* getDeviceStruct() 56 { 57 return gstDevice; 58 } 59 60 /** the main Gtk struct as a void* */ 61 protected override void* getStruct() 62 { 63 return cast(void*)gstDevice; 64 } 65 66 protected override void setStruct(GObject* obj) 67 { 68 gstDevice = cast(GstDevice*)obj; 69 super.setStruct(obj); 70 } 71 72 /** 73 * Sets our main struct and passes it to the parent class. 74 */ 75 public this (GstDevice* gstDevice, bool ownedRef = false) 76 { 77 this.gstDevice = gstDevice; 78 super(cast(GstObject*)gstDevice, ownedRef); 79 } 80 81 /** 82 */ 83 84 public static GType getType() 85 { 86 return gst_device_get_type(); 87 } 88 89 /** 90 * Creates the element with all of the required paramaters set to use 91 * this device. 92 * 93 * Params: 94 * name = name of new element, or %NULL to automatically 95 * create a unique name. 96 * 97 * Return: a new #GstElement configured to use this device 98 * 99 * Since: 1.4 100 */ 101 public Element createElement(string name) 102 { 103 auto p = gst_device_create_element(gstDevice, Str.toStringz(name)); 104 105 if(p is null) 106 { 107 return null; 108 } 109 110 return ObjectG.getDObject!(Element)(cast(GstElement*) p, true); 111 } 112 113 /** 114 * Getter for the #GstCaps that this device supports. 115 * 116 * Return: The #GstCaps supported by this device. Unref with 117 * gst_caps_unref() when done. 118 * 119 * Since: 1.4 120 */ 121 public Caps getCaps() 122 { 123 auto p = gst_device_get_caps(gstDevice); 124 125 if(p is null) 126 { 127 return null; 128 } 129 130 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 131 } 132 133 /** 134 * Gets the "class" of a device. This is a "/" separated list of 135 * classes that represent this device. They are a subset of the 136 * classes of the #GstDeviceProvider that produced this device. 137 * 138 * Return: The device class. Free with g_free() after use. 139 * 140 * Since: 1.4 141 */ 142 public string getDeviceClass() 143 { 144 return Str.toString(gst_device_get_device_class(gstDevice)); 145 } 146 147 /** 148 * Gets the user-friendly name of the device. 149 * 150 * Return: The device name. Free with g_free() after use. 151 * 152 * Since: 1.4 153 */ 154 public string getDisplayName() 155 { 156 return Str.toString(gst_device_get_display_name(gstDevice)); 157 } 158 159 /** 160 * Gets the extra properties of a device. 161 * 162 * Return: The extra properties or %NULL when there are none. 163 * Free with gst_structure_free() after use. 164 * 165 * Since: 1.6 166 */ 167 public Structure getProperties() 168 { 169 auto p = gst_device_get_properties(gstDevice); 170 171 if(p is null) 172 { 173 return null; 174 } 175 176 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p); 177 } 178 179 /** 180 * Check if @device matches all of the given classes 181 * 182 * Params: 183 * classes = a "/" separate list of device classes to match, only match if 184 * all classes are matched 185 * 186 * Return: %TRUE if @device matches. 187 * 188 * Since: 1.4 189 */ 190 public bool hasClasses(string classes) 191 { 192 return gst_device_has_classes(gstDevice, Str.toStringz(classes)) != 0; 193 } 194 195 /** 196 * Check if @factory matches all of the given classes 197 * 198 * Params: 199 * classes = a %NULL terminated array of classes to match, only match if all 200 * classes are matched 201 * 202 * Return: %TRUE if @device matches. 203 * 204 * Since: 1.4 205 */ 206 public bool hasClassesv(string[] classes) 207 { 208 return gst_device_has_classesv(gstDevice, Str.toStringzArray(classes)) != 0; 209 } 210 211 /** 212 * Tries to reconfigure an existing element to use the device. If this 213 * function fails, then one must destroy the element and create a new one 214 * using gst_device_create_element(). 215 * 216 * Note: This should only be implemented for elements can change their 217 * device in the PLAYING state. 218 * 219 * Params: 220 * element = a #GstElement 221 * 222 * Return: %TRUE if the element could be reconfigured to use this device, 223 * %FALSE otherwise. 224 * 225 * Since: 1.4 226 */ 227 public bool reconfigureElement(Element element) 228 { 229 return gst_device_reconfigure_element(gstDevice, (element is null) ? null : element.getElementStruct()) != 0; 230 } 231 232 int[string] connectedSignals; 233 234 void delegate(Device)[] onRemovedListeners; 235 void addOnRemoved(void delegate(Device) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 236 { 237 if ( "removed" !in connectedSignals ) 238 { 239 Signals.connectData( 240 this, 241 "removed", 242 cast(GCallback)&callBackRemoved, 243 cast(void*)this, 244 null, 245 connectFlags); 246 connectedSignals["removed"] = 1; 247 } 248 onRemovedListeners ~= dlg; 249 } 250 extern(C) static void callBackRemoved(GstDevice* deviceStruct, Device _device) 251 { 252 foreach ( void delegate(Device) dlg; _device.onRemovedListeners ) 253 { 254 dlg(_device); 255 } 256 } 257 }