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 * Conversion parameters: 26 * inFile = gstreamer-GstPoll.html 27 * outPack = gstreamer 28 * outFile = Poll 29 * strct = GstPoll 30 * realStrct= 31 * ctorStrct= 32 * clss = Poll 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_poll_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * structWrap: 47 * module aliases: 48 * local aliases: 49 * overrides: 50 */ 51 52 module gstreamer.Poll; 53 54 public import gstreamerc.gstreamertypes; 55 56 private import gstreamerc.gstreamer; 57 private import glib.ConstructionException; 58 private import gobject.ObjectG; 59 60 61 62 63 64 65 /** 66 * A GstPoll keeps track of file descriptors much like fd_set (used with 67 * select()) or a struct pollfd array (used with poll()). Once created with 68 * gst_poll_new(), the set can be used to wait for file descriptors to be 69 * readable and/or writable. It is possible to make this wait be controlled 70 * by specifying TRUE for the controllable flag when creating the set (or 71 * later calling gst_poll_set_controllable()). 72 * 73 * New file descriptors are added to the set using gst_poll_add_fd(), and 74 * removed using gst_poll_remove_fd(). Controlling which file descriptors 75 * should be waited for to become readable and/or writable are done using 76 * gst_poll_fd_ctl_read() and gst_poll_fd_ctl_write(). 77 * 78 * Use gst_poll_wait() to wait for the file descriptors to actually become 79 * readable and/or writable, or to timeout if no file descriptor is available 80 * in time. The wait can be controlled by calling gst_poll_restart() and 81 * gst_poll_set_flushing(). 82 * 83 * Once the file descriptor set has been waited for, one can use 84 * gst_poll_fd_has_closed() to see if the file descriptor has been closed, 85 * gst_poll_fd_has_error() to see if it has generated an error, 86 * gst_poll_fd_can_read() to see if it is possible to read from the file 87 * descriptor, and gst_poll_fd_can_write() to see if it is possible to 88 * write to it. 89 */ 90 public class Poll 91 { 92 93 /** the main Gtk struct */ 94 protected GstPoll* gstPoll; 95 96 97 public GstPoll* getPollStruct() 98 { 99 return gstPoll; 100 } 101 102 103 /** the main Gtk struct as a void* */ 104 protected void* getStruct() 105 { 106 return cast(void*)gstPoll; 107 } 108 109 /** 110 * Sets our main struct and passes it to the parent class 111 */ 112 public this (GstPoll* gstPoll) 113 { 114 this.gstPoll = gstPoll; 115 } 116 117 /** 118 */ 119 120 /** 121 * Add a file descriptor to the file descriptor set. 122 * Params: 123 * fd = a file descriptor. 124 * Returns: TRUE if the file descriptor was successfully added to the set. 125 */ 126 public int addFd(GstPollFD* fd) 127 { 128 // gboolean gst_poll_add_fd (GstPoll *set, GstPollFD *fd); 129 return gst_poll_add_fd(gstPoll, fd); 130 } 131 132 /** 133 * Check if fd in set has data to be read. 134 * Params: 135 * fd = a file descriptor. 136 * Returns: TRUE if the descriptor has data to be read. 137 */ 138 public int fdCanRead(GstPollFD* fd) 139 { 140 // gboolean gst_poll_fd_can_read (const GstPoll *set, GstPollFD *fd); 141 return gst_poll_fd_can_read(gstPoll, fd); 142 } 143 144 /** 145 * Check if fd in set can be used for writing. 146 * Params: 147 * fd = a file descriptor. 148 * Returns: TRUE if the descriptor can be used for writing. 149 */ 150 public int fdCanWrite(GstPollFD* fd) 151 { 152 // gboolean gst_poll_fd_can_write (const GstPoll *set, GstPollFD *fd); 153 return gst_poll_fd_can_write(gstPoll, fd); 154 } 155 156 /** 157 * Control whether the descriptor fd in set will be monitored for 158 * readability. 159 * Params: 160 * fd = a file descriptor. 161 * active = a new status. 162 * Returns: TRUE if the descriptor was successfully updated. 163 */ 164 public int fdCtlRead(GstPollFD* fd, int active) 165 { 166 // gboolean gst_poll_fd_ctl_read (GstPoll *set, GstPollFD *fd, gboolean active); 167 return gst_poll_fd_ctl_read(gstPoll, fd, active); 168 } 169 170 /** 171 * Control whether the descriptor fd in set will be monitored for 172 * writability. 173 * Params: 174 * fd = a file descriptor. 175 * active = a new status. 176 * Returns: TRUE if the descriptor was successfully updated. 177 */ 178 public int fdCtlWrite(GstPollFD* fd, int active) 179 { 180 // gboolean gst_poll_fd_ctl_write (GstPoll *set, GstPollFD *fd, gboolean active); 181 return gst_poll_fd_ctl_write(gstPoll, fd, active); 182 } 183 184 /** 185 * Check if fd in set has closed the connection. 186 * Params: 187 * fd = a file descriptor. 188 * Returns: TRUE if the connection was closed. 189 */ 190 public int fdHasClosed(GstPollFD* fd) 191 { 192 // gboolean gst_poll_fd_has_closed (const GstPoll *set, GstPollFD *fd); 193 return gst_poll_fd_has_closed(gstPoll, fd); 194 } 195 196 /** 197 * Check if fd in set has an error. 198 * Params: 199 * fd = a file descriptor. 200 * Returns: TRUE if the descriptor has an error. 201 */ 202 public int fdHasError(GstPollFD* fd) 203 { 204 // gboolean gst_poll_fd_has_error (const GstPoll *set, GstPollFD *fd); 205 return gst_poll_fd_has_error(gstPoll, fd); 206 } 207 208 /** 209 * Mark fd as ignored so that the next call to gst_poll_wait() will yield 210 * the same result for fd as last time. This function must be called if no 211 * operation (read/write/recv/send/etc.) will be performed on fd before 212 * the next call to gst_poll_wait(). 213 * The reason why this is needed is because the underlying implementation 214 * might not allow querying the fd more than once between calls to one of 215 * the re-enabling operations. 216 * Params: 217 * fd = a file descriptor. 218 */ 219 public void fdIgnored(GstPollFD* fd) 220 { 221 // void gst_poll_fd_ignored (GstPoll *set, GstPollFD *fd); 222 gst_poll_fd_ignored(gstPoll, fd); 223 } 224 225 /** 226 * Initializes fd. Alternatively you can initialize it with 227 * GST_POLL_FD_INIT. 228 * Params: 229 * fd = a GstPollFD 230 */ 231 public static void fdInit(GstPollFD* fd) 232 { 233 // void gst_poll_fd_init (GstPollFD *fd); 234 gst_poll_fd_init(fd); 235 } 236 237 /** 238 * Free a file descriptor set. 239 */ 240 public void free() 241 { 242 // void gst_poll_free (GstPoll *set); 243 gst_poll_free(gstPoll); 244 } 245 246 /** 247 * Create a new file descriptor set. If controllable, it 248 * is possible to restart or flush a call to gst_poll_wait() with 249 * gst_poll_restart() and gst_poll_set_flushing() respectively. 250 * Free-function: gst_poll_free 251 * Params: 252 * controllable = whether it should be possible to control a wait. 253 * Throws: ConstructionException GTK+ fails to create the object. 254 */ 255 public this (int controllable) 256 { 257 // GstPoll * gst_poll_new (gboolean controllable); 258 auto p = gst_poll_new(controllable); 259 if(p is null) 260 { 261 throw new ConstructionException("null returned by gst_poll_new(controllable)"); 262 } 263 this(cast(GstPoll*) p); 264 } 265 266 /** 267 * Create a new poll object that can be used for scheduling cancellable 268 * timeouts. 269 * A timeout is performed with gst_poll_wait(). Multiple timeouts can be 270 * performed from different threads. 271 * Free-function: gst_poll_free 272 * Throws: ConstructionException GTK+ fails to create the object. 273 */ 274 public this () 275 { 276 // GstPoll * gst_poll_new_timer (void); 277 auto p = gst_poll_new_timer(); 278 if(p is null) 279 { 280 throw new ConstructionException("null returned by gst_poll_new_timer()"); 281 } 282 this(cast(GstPoll*) p); 283 } 284 285 /** 286 * Get a GPollFD for the reading part of the control socket. This is useful when 287 * integrating with a GSource and GMainLoop. 288 * Params: 289 * fd = a GPollFD 290 */ 291 public void getReadGpollfd(GPollFD* fd) 292 { 293 // void gst_poll_get_read_gpollfd (GstPoll *set, GPollFD *fd); 294 gst_poll_get_read_gpollfd(gstPoll, fd); 295 } 296 297 /** 298 * Remove a file descriptor from the file descriptor set. 299 * Params: 300 * fd = a file descriptor. 301 * Returns: TRUE if the file descriptor was successfully removed from the set. 302 */ 303 public int removeFd(GstPollFD* fd) 304 { 305 // gboolean gst_poll_remove_fd (GstPoll *set, GstPollFD *fd); 306 return gst_poll_remove_fd(gstPoll, fd); 307 } 308 309 /** 310 * Restart any gst_poll_wait() that is in progress. This function is typically 311 * used after adding or removing descriptors to set. 312 * If set is not controllable, then this call will have no effect. 313 */ 314 public void restart() 315 { 316 // void gst_poll_restart (GstPoll *set); 317 gst_poll_restart(gstPoll); 318 } 319 320 /** 321 * When controllable is TRUE, this function ensures that future calls to 322 * gst_poll_wait() will be affected by gst_poll_restart() and 323 * gst_poll_set_flushing(). 324 * Params: 325 * set = a GstPoll. 326 * controllable = new controllable state. 327 * Returns: TRUE if the controllability of set could be updated. 328 */ 329 public int setControllable(int controllable) 330 { 331 // gboolean gst_poll_set_controllable (GstPoll *set, gboolean controllable); 332 return gst_poll_set_controllable(gstPoll, controllable); 333 } 334 335 /** 336 * When flushing is TRUE, this function ensures that current and future calls 337 * to gst_poll_wait() will return -1, with errno set to EBUSY. 338 * Unsetting the flushing state will restore normal operation of set. 339 * Params: 340 * set = a GstPoll. 341 * flushing = new flushing state. 342 */ 343 public void setFlushing(int flushing) 344 { 345 // void gst_poll_set_flushing (GstPoll *set, gboolean flushing); 346 gst_poll_set_flushing(gstPoll, flushing); 347 } 348 349 /** 350 * Wait for activity on the file descriptors in set. This function waits up to 351 * the specified timeout. A timeout of GST_CLOCK_TIME_NONE waits forever. 352 * For GstPoll objects created with gst_poll_new(), this function can only be 353 * called from a single thread at a time. If called from multiple threads, 354 * -1 will be returned with errno set to EPERM. 355 * This is not true for timer GstPoll objects created with 356 * gst_poll_new_timer(), where it is allowed to have multiple threads waiting 357 * simultaneously. 358 * Params: 359 * timeout = a timeout in nanoseconds. 360 * Returns: The number of GstPollFD in set that have activity or 0 when no activity was detected after timeout. If an error occurs, -1 is returned and errno is set. 361 */ 362 public int wait(GstClockTime timeout) 363 { 364 // gint gst_poll_wait (GstPoll *set, GstClockTime timeout); 365 return gst_poll_wait(gstPoll, timeout); 366 } 367 368 /** 369 * Read a byte from the control socket of the controllable set. 370 * This function is mostly useful for timer GstPoll objects created with 371 * gst_poll_new_timer(). 372 * Returns: TRUE on success. FALSE when set is not controllable or when there was no byte to read. 373 */ 374 public int readControl() 375 { 376 // gboolean gst_poll_read_control (GstPoll *set); 377 return gst_poll_read_control(gstPoll); 378 } 379 380 /** 381 * Write a byte to the control socket of the controllable set. 382 * This function is mostly useful for timer GstPoll objects created with 383 * gst_poll_new_timer(). 384 * It will make any current and future gst_poll_wait() function return with 385 * 1, meaning the control socket is set. After an equal amount of calls to 386 * gst_poll_read_control() have been performed, calls to gst_poll_wait() will 387 * block again until their timeout expired. 388 * Returns: TRUE on success. FALSE when set is not controllable or when the byte could not be written. 389 */ 390 public int writeControl() 391 { 392 // gboolean gst_poll_write_control (GstPoll *set); 393 return gst_poll_write_control(gstPoll); 394 } 395 }