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