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 public static GType getType() 84 { 85 return gst_device_get_type(); 86 } 87 88 /** 89 * Creates the element with all of the required paramaters set to use 90 * this device. 91 * 92 * Params: 93 * name = name of new element, or %NULL to automatically 94 * create a unique name. 95 * 96 * Return: a new #GstElement configured to use this device 97 * 98 * Since: 1.4 99 */ 100 public Element createElement(string name) 101 { 102 auto p = gst_device_create_element(gstDevice, Str.toStringz(name)); 103 104 if(p is null) 105 { 106 return null; 107 } 108 109 return ObjectG.getDObject!(Element)(cast(GstElement*) p, true); 110 } 111 112 /** 113 * Getter for the #GstCaps that this device supports. 114 * 115 * Return: The #GstCaps supported by this device. Unref with 116 * gst_caps_unref() when done. 117 * 118 * Since: 1.4 119 */ 120 public Caps getCaps() 121 { 122 auto p = gst_device_get_caps(gstDevice); 123 124 if(p is null) 125 { 126 return null; 127 } 128 129 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 130 } 131 132 /** 133 * Gets the "class" of a device. This is a "/" separated list of 134 * classes that represent this device. They are a subset of the 135 * classes of the #GstDeviceProvider that produced this device. 136 * 137 * Return: The device class. Free with g_free() after use. 138 * 139 * Since: 1.4 140 */ 141 public string getDeviceClass() 142 { 143 return Str.toString(gst_device_get_device_class(gstDevice)); 144 } 145 146 /** 147 * Gets the user-friendly name of the device. 148 * 149 * Return: The device name. Free with g_free() after use. 150 * 151 * Since: 1.4 152 */ 153 public string getDisplayName() 154 { 155 return Str.toString(gst_device_get_display_name(gstDevice)); 156 } 157 158 /** 159 * Gets the extra properties of a device. 160 * 161 * Return: The extra properties or %NULL when there are none. 162 * Free with gst_structure_free() after use. 163 * 164 * Since: 1.6 165 */ 166 public Structure getProperties() 167 { 168 auto p = gst_device_get_properties(gstDevice); 169 170 if(p is null) 171 { 172 return null; 173 } 174 175 return ObjectG.getDObject!(Structure)(cast(GstStructure*) p); 176 } 177 178 /** 179 * Check if @device matches all of the given classes 180 * 181 * Params: 182 * classes = a "/" separate list of device classes to match, only match if 183 * all classes are matched 184 * 185 * Return: %TRUE if @device matches. 186 * 187 * Since: 1.4 188 */ 189 public bool hasClasses(string classes) 190 { 191 return gst_device_has_classes(gstDevice, Str.toStringz(classes)) != 0; 192 } 193 194 /** 195 * Check if @factory matches all of the given classes 196 * 197 * Params: 198 * classes = a %NULL terminated array of classes to match, only match if all 199 * classes are matched 200 * 201 * Return: %TRUE if @device matches. 202 * 203 * Since: 1.4 204 */ 205 public bool hasClassesv(string[] classes) 206 { 207 return gst_device_has_classesv(gstDevice, Str.toStringzArray(classes)) != 0; 208 } 209 210 /** 211 * Tries to reconfigure an existing element to use the device. If this 212 * function fails, then one must destroy the element and create a new one 213 * using gst_device_create_element(). 214 * 215 * Note: This should only be implemented for elements can change their 216 * device in the PLAYING state. 217 * 218 * Params: 219 * element = a #GstElement 220 * 221 * Return: %TRUE if the element could be reconfigured to use this device, 222 * %FALSE otherwise. 223 * 224 * Since: 1.4 225 */ 226 public bool reconfigureElement(Element element) 227 { 228 return gst_device_reconfigure_element(gstDevice, (element is null) ? null : element.getElementStruct()) != 0; 229 } 230 231 int[string] connectedSignals; 232 233 void delegate(Device)[] onRemovedListeners; 234 /** */ 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 }