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.DeviceProvider; 26 27 private import glib.ListG; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gstreamer.Bus; 31 private import gstreamer.Device; 32 private import gstreamer.DeviceProviderFactory; 33 private import gstreamer.ObjectGst; 34 private import gstreamer.Plugin; 35 private import gstreamerc.gstreamer; 36 public import gstreamerc.gstreamertypes; 37 38 39 /** 40 * A #GstDeviceProvider subclass is provided by a plugin that handles devices 41 * if there is a way to programatically list connected devices. It can also 42 * optionally provide updates to the list of connected devices. 43 * 44 * Each #GstDeviceProvider subclass is a singleton, a plugin should 45 * normally provide a single subclass for all devices. 46 * 47 * Applications would normally use a #GstDeviceMonitor to monitor devices 48 * from all relevant providers. 49 * 50 * Since: 1.4 51 */ 52 public class DeviceProvider : ObjectGst 53 { 54 /** the main Gtk struct */ 55 protected GstDeviceProvider* gstDeviceProvider; 56 57 /** Get the main Gtk struct */ 58 public GstDeviceProvider* getDeviceProviderStruct() 59 { 60 return gstDeviceProvider; 61 } 62 63 /** the main Gtk struct as a void* */ 64 protected override void* getStruct() 65 { 66 return cast(void*)gstDeviceProvider; 67 } 68 69 protected override void setStruct(GObject* obj) 70 { 71 gstDeviceProvider = cast(GstDeviceProvider*)obj; 72 super.setStruct(obj); 73 } 74 75 /** 76 * Sets our main struct and passes it to the parent class. 77 */ 78 public this (GstDeviceProvider* gstDeviceProvider, bool ownedRef = false) 79 { 80 this.gstDeviceProvider = gstDeviceProvider; 81 super(cast(GstObject*)gstDeviceProvider, ownedRef); 82 } 83 84 /** 85 */ 86 87 public static GType getType() 88 { 89 return gst_device_provider_get_type(); 90 } 91 92 /** 93 * Create a new device providerfactory capable of instantiating objects of the 94 * @type and add the factory to @plugin. 95 * 96 * Params: 97 * plugin = #GstPlugin to register the device provider with, or %NULL for 98 * a static device provider. 99 * name = name of device providers of this type 100 * rank = rank of device provider (higher rank means more importance when autoplugging) 101 * type = GType of device provider to register 102 * 103 * Return: %TRUE, if the registering succeeded, %FALSE on error 104 * 105 * Since: 1.4 106 */ 107 public static bool register(Plugin plugin, string name, uint rank, GType type) 108 { 109 return gst_device_provider_register((plugin is null) ? null : plugin.getPluginStruct(), Str.toStringz(name), rank, type) != 0; 110 } 111 112 public bool canMonitor() 113 { 114 return gst_device_provider_can_monitor(gstDeviceProvider) != 0; 115 } 116 117 /** 118 * Posts a message on the provider's #GstBus to inform applications that 119 * a new device has been added. 120 * 121 * This is for use by subclasses. 122 * 123 * Params: 124 * device = a #GstDevice that has been added 125 * 126 * Since: 1.4 127 */ 128 public void deviceAdd(Device device) 129 { 130 gst_device_provider_device_add(gstDeviceProvider, (device is null) ? null : device.getDeviceStruct()); 131 } 132 133 /** 134 * Posts a message on the provider's #GstBus to inform applications that 135 * a device has been removed. 136 * 137 * This is for use by subclasses. 138 * 139 * Params: 140 * device = a #GstDevice that has been removed 141 * 142 * Since: 1.4 143 */ 144 public void deviceRemove(Device device) 145 { 146 gst_device_provider_device_remove(gstDeviceProvider, (device is null) ? null : device.getDeviceStruct()); 147 } 148 149 /** 150 * Gets the #GstBus of this #GstDeviceProvider 151 * 152 * Return: a #GstBus 153 * 154 * Since: 1.4 155 */ 156 public Bus getBus() 157 { 158 auto p = gst_device_provider_get_bus(gstDeviceProvider); 159 160 if(p is null) 161 { 162 return null; 163 } 164 165 return ObjectG.getDObject!(Bus)(cast(GstBus*) p, true); 166 } 167 168 /** 169 * Gets a list of devices that this provider understands. This may actually 170 * probe the hardware if the provider is not currently started. 171 * 172 * Return: a #GList of 173 * #GstDevice 174 * 175 * Since: 1.4 176 */ 177 public ListG getDevices() 178 { 179 auto p = gst_device_provider_get_devices(gstDeviceProvider); 180 181 if(p is null) 182 { 183 return null; 184 } 185 186 return new ListG(cast(GList*) p); 187 } 188 189 /** 190 * Retrieves the factory that was used to create this device provider. 191 * 192 * Return: the #GstDeviceProviderFactory used for 193 * creating this device provider. no refcounting is needed. 194 * 195 * Since: 1.4 196 */ 197 public DeviceProviderFactory getFactory() 198 { 199 auto p = gst_device_provider_get_factory(gstDeviceProvider); 200 201 if(p is null) 202 { 203 return null; 204 } 205 206 return ObjectG.getDObject!(DeviceProviderFactory)(cast(GstDeviceProviderFactory*) p); 207 } 208 209 /** 210 * Starts providering the devices. This will cause #GST_MESSAGE_DEVICE_ADDED 211 * and #GST_MESSAGE_DEVICE_REMOVED messages to be posted on the provider's bus 212 * when devices are added or removed from the system. 213 * 214 * Since the #GstDeviceProvider is a singleton, 215 * gst_device_provider_start() may already have been called by another 216 * user of the object, gst_device_provider_stop() needs to be called the same 217 * number of times. 218 * 219 * Return: %TRUE if the device providering could be started 220 * 221 * Since: 1.4 222 */ 223 public bool start() 224 { 225 return gst_device_provider_start(gstDeviceProvider) != 0; 226 } 227 228 /** 229 * Decreases the use-count by one. If the use count reaches zero, this 230 * #GstDeviceProvider will stop providering the devices. This needs to be 231 * called the same number of times that gst_device_provider_start() was called. 232 * 233 * Since: 1.4 234 */ 235 public void stop() 236 { 237 gst_device_provider_stop(gstDeviceProvider); 238 } 239 }