1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
|
/*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gst.base.BitReader;
private import glib.ConstructionException;
private import gobject.ObjectG;
private import gst.base.c.functions;
public import gst.base.c.types;
private import gtkd.Loader;
/**
* #GstBitReader provides a bit reader that can read any number of bits
* from a memory buffer. It provides functions for reading any number of bits
* into 8, 16, 32 and 64 bit variables.
*/
public class BitReader
{
/** the main Gtk struct */
protected GstBitReader* gstBitReader;
protected bool ownedRef;
/** Get the main Gtk struct */
public GstBitReader* getBitReaderStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gstBitReader;
}
/** the main Gtk struct as a void* */
protected void* getStruct()
{
return cast(void*)gstBitReader;
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GstBitReader* gstBitReader, bool ownedRef = false)
{
this.gstBitReader = gstBitReader;
this.ownedRef = ownedRef;
}
~this ()
{
if ( Linker.isLoaded(LIBRARY_GSTBASE) && ownedRef )
gst_bit_reader_free(gstBitReader);
}
/**
* Frees a #GstBitReader instance, which was previously allocated by
* gst_bit_reader_new().
*/
public void free()
{
gst_bit_reader_free(gstBitReader);
ownedRef = false;
}
/**
* Read @nbits bits into @val and update the current position.
*
* Params:
* val = Pointer to a #guint16 to store the result
* nbits = number of bits to read
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
public bool getBitsUint16(out ushort val, uint nbits)
{
return gst_bit_reader_get_bits_uint16(gstBitReader, &val, nbits) != 0;
}
/**
* Read @nbits bits into @val and update the current position.
*
* Params:
* val = Pointer to a #guint32 to store the result
* nbits = number of bits to read
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
public bool getBitsUint32(out uint val, uint nbits)
{
return gst_bit_reader_get_bits_uint32(gstBitReader, &val, nbits) != 0;
}
/**
* Read @nbits bits into @val and update the current position.
*
* Params:
* val = Pointer to a #guint64 to store the result
* nbits = number of bits to read
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
public bool getBitsUint64(out ulong val, uint nbits)
{
return gst_bit_reader_get_bits_uint64(gstBitReader, &val, nbits) != 0;
}
/**
* Read @nbits bits into @val and update the current position.
*
* Params:
* val = Pointer to a #guint8 to store the result
* nbits = number of bits to read
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
public bool getBitsUint8(out ubyte val, uint nbits)
{
return gst_bit_reader_get_bits_uint8(gstBitReader, &val, nbits) != 0;
}
/**
* Returns the current position of a #GstBitReader instance in bits.
*
* Returns: The current position of @reader in bits.
*/
public uint getPos()
{
return gst_bit_reader_get_pos(gstBitReader);
}
/**
* Returns the remaining number of bits of a #GstBitReader instance.
*
* Returns: The remaining number of bits of @reader instance.
*/
public uint getRemaining()
{
return gst_bit_reader_get_remaining(gstBitReader);
}
/**
* Returns the total number of bits of a #GstBitReader instance.
*
* Returns: The total number of bits of @reader instance.
*/
public uint getSize()
{
return gst_bit_reader_get_size(gstBitReader);
}
/**
* Initializes a #GstBitReader instance to read from @data. This function
* can be called on already initialized instances.
*
* Params:
* data = data from which the bit reader should read
*/
public void init(ubyte[] data)
{
gst_bit_reader_init(gstBitReader, data.ptr, cast(uint)data.length);
}
/**
* Read @nbits bits into @val but keep the current position.
*
* Params:
* val = Pointer to a #guint16 to store the result
* nbits = number of bits to read
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
public bool peekBitsUint16(out ushort val, uint nbits)
{
return gst_bit_reader_peek_bits_uint16(gstBitReader, &val, nbits) != 0;
}
/**
* Read @nbits bits into @val but keep the current position.
*
* Params:
* val = Pointer to a #guint32 to store the result
* nbits = number of bits to read
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
public bool peekBitsUint32(out uint val, uint nbits)
{
return gst_bit_reader_peek_bits_uint32(gstBitReader, &val, nbits) != 0;
}
/**
* Read @nbits bits into @val but keep the current position.
*
* Params:
* val = Pointer to a #guint64 to store the result
* nbits = number of bits to read
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
public bool peekBitsUint64(out ulong val, uint nbits)
{
return gst_bit_reader_peek_bits_uint64(gstBitReader, &val, nbits) != 0;
}
/**
* Read @nbits bits into @val but keep the current position.
*
* Params:
* val = Pointer to a #guint8 to store the result
* nbits = number of bits to read
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
public bool peekBitsUint8(out ubyte val, uint nbits)
{
return gst_bit_reader_peek_bits_uint8(gstBitReader, &val, nbits) != 0;
}
/**
* Sets the new position of a #GstBitReader instance to @pos in bits.
*
* Params:
* pos = The new position in bits
*
* Returns: %TRUE if the position could be set successfully, %FALSE
* otherwise.
*/
public bool setPos(uint pos)
{
return gst_bit_reader_set_pos(gstBitReader, pos) != 0;
}
/**
* Skips @nbits bits of the #GstBitReader instance.
*
* Params:
* nbits = the number of bits to skip
*
* Returns: %TRUE if @nbits bits could be skipped, %FALSE otherwise.
*/
public bool skip(uint nbits)
{
return gst_bit_reader_skip(gstBitReader, nbits) != 0;
}
/**
* Skips until the next byte.
*
* Returns: %TRUE if successful, %FALSE otherwise.
*/
public bool skipToByte()
{
return gst_bit_reader_skip_to_byte(gstBitReader) != 0;
}
/**
* Create a new #GstBitReader instance, which will read from @data.
*
* Free-function: gst_bit_reader_free
*
* Params:
* data = Data from which the #GstBitReader
* should read
*
* Returns: a new #GstBitReader instance
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this(ubyte[] data)
{
auto p = gst_bit_reader_new(data.ptr, cast(uint)data.length);
if(p is null)
{
throw new ConstructionException("null returned by new");
}
this(cast(GstBitReader*) p);
}
}
|