libgpac
Documentation of the core library of GPAC
Bitstream Interface Reference

import"core.idl";

Public Member Functions

 Bitstream ()
 
 Bitstream (ArrayBuffer buffer, optional boolean write_mode=false)
 
 Bitstream (File file, optional boolean write_mode=false)
 
unsigned long get_u8 ()
 
unsigned long get_s8 ()
 
unsigned long get_u16 ()
 
unsigned long get_u16_le ()
 
unsigned long get_s16 ()
 
unsigned long get_u24 ()
 
unsigned long get_u32 ()
 
unsigned long get_u32_le ()
 
unsigned long get_s32 ()
 
unsigned long get_u64 ()
 
unsigned long get_u64_le ()
 
unsigned long get_s64 ()
 
unsigned long get_bits (unsigned long nb_bits)
 
double get_float ()
 
double get_double ()
 
unsigned long get_data (ArrayBuffer buffer, optional unsigned long nb_bytes=0)
 
DOMString get_string ()
 
DOMString get_4cc ()
 
void put_u8 (unsigned long value)
 
void put_s8 (signed long value)
 
void put_u16 (unsigned long value)
 
void put_u16_le (unsigned long value)
 
void put_s16 (signed long value)
 
void put_u24 (unsigned long value)
 
void put_u32 (unsigned long value)
 
void put_u32_le (unsigned long value)
 
void put_s32 (signed long value)
 
void put_u64 (unsigned long long value)
 
void put_u64_le (unsigned long long value)
 
void put_s64 (signed long long value)
 
void put_bits (unsigned long long value, unsigned long nb_bits)
 
void put_float (double value)
 
void put_double (double value)
 
unsigned long put_data (ArrayBuffer buffer, optional unsigned long nb_bytes=0)
 
void put_4cc (DOMString fcc)
 
void put_string (DOMString str)
 
void insert_data (ArrayBuffer buffer, optional unsigned long nb_bytes=0, optional unsigned long offset=0)
 
boolean is_align ()
 
void align ()
 
void truncate ()
 
ArrayBuffer get_content ()
 
void transfer (Bitstream *src_bs, optional boolean keep_src=false)
 
unsigned long peek (unsigned long nb_bits, optional unsigned long byte_offset=0)
 
void skip (unsigned long nb_bytes)
 
void flush ()
 
void epb_mode (boolean enable)
 

Data Fields

attribute unsigned long long pos
 
attribute readonly unsigned long long available
 
attribute readonly unsigned long long size
 
attribute readonly unsigned long bit_offset
 
attribute readonly unsigned long bit_position
 
attribute readonly unsigned long bits_available
 
attribute readonly unsigned long long refreshed_size
 
attribute readonly boolean overflow
 

Detailed Description

Bitstream object

Constructor & Destructor Documentation

◆ Bitstream() [1/3]

Bitstream::Bitstream ( )

constructor for a dynamic allocated write bitstream

◆ Bitstream() [2/3]

Bitstream::Bitstream ( ArrayBuffer  buffer,
optional boolean  write_mode = false 
)

constructor for a static allocated bitstream

Parameters
bufferthe array buffer to use for bitstream operations
write_modeif set to true, the bitstream is created in write mode, otherwise in read mode

◆ Bitstream() [3/3]

Bitstream::Bitstream ( File  file,
optional boolean  write_mode = false 
)

constructor for a bitstream wrapping a file - see gf_bs_from_file

Parameters
filethe File object to use for bitstream operations
write_modeif set to true, the bitstream is created in write mode, otherwise in read mode. This mode shall be compatible with the file open mode

Member Function Documentation

◆ get_u8()

unsigned long Bitstream::get_u8 ( )

get 8-bits unsigned integer, byte-aligned

Returns
value read

◆ get_s8()

unsigned long Bitstream::get_s8 ( )

get 8-bits signed integer, byte-aligned

Returns
value read

◆ get_u16()

unsigned long Bitstream::get_u16 ( )

get 16-bits unsigned integer, byte-aligned, big-endian

Returns
value read

◆ get_u16_le()

unsigned long Bitstream::get_u16_le ( )

get 16-bits unsigned integer, byte-aligned, little-endian

Returns
value read

◆ get_s16()

unsigned long Bitstream::get_s16 ( )

get 16-bits signed integer, byte-aligned, big-endian

Returns
value read

◆ get_u24()

unsigned long Bitstream::get_u24 ( )

get 24-bits unsigned integer, byte-aligned, big-endian

Returns
value read

◆ get_u32()

unsigned long Bitstream::get_u32 ( )

get 32-bits unsigned integer, byte-aligned, big-endian

Returns
value read

◆ get_u32_le()

unsigned long Bitstream::get_u32_le ( )

get 32-bits unsigned integer, byte-aligned, little-endian

Returns
value read

◆ get_s32()

unsigned long Bitstream::get_s32 ( )

get 32-bits signed integer, byte-aligned, big-endian

Returns
value read

◆ get_u64()

unsigned long Bitstream::get_u64 ( )

get 64-bits unsigned integer, byte-aligned, big-endian

Returns
value read

◆ get_u64_le()

unsigned long Bitstream::get_u64_le ( )

get 64-bits unsigned integer, byte-aligned, little-endian

Returns
value read

◆ get_s64()

unsigned long Bitstream::get_s64 ( )

get 64-bits signed integer, byte-aligned, big-endian

Returns
value read

◆ get_bits()

unsigned long Bitstream::get_bits ( unsigned long  nb_bits)

get n-bits unsigned integer, big-endian

Parameters
nb_bitsnumber of bits to read
Returns
value read

◆ get_float()

double Bitstream::get_float ( )

get float 32 bits value

Returns
value read

◆ get_double()

double Bitstream::get_double ( )

get float 64 bits value

Returns
value read

◆ get_data()

unsigned long Bitstream::get_data ( ArrayBuffer  buffer,
optional unsigned long  nb_bytes = 0 
)

reads bytes in an array buffer

Parameters
buffertarget read buffer
nb_bytesnumber of bytes to read - if 0, uses array buffer size. If more than array buffer size, truncated to array buffer size
Returns
number of bytes read

◆ get_string()

DOMString Bitstream::get_string ( )

get utf8 string

Returns
value read

◆ get_4cc()

DOMString Bitstream::get_4cc ( )

reads 4CC

Returns
four-character code read

◆ put_u8()

void Bitstream::put_u8 ( unsigned long  value)

write 8-bit unsigned value

Parameters
valuevalue to write

◆ put_s8()

void Bitstream::put_s8 ( signed long  value)

write 8-bit signed value

Parameters
valuevalue to write

◆ put_u16()

void Bitstream::put_u16 ( unsigned long  value)

write 16-bit unsigned value, big-endian

Parameters
valuevalue to write

◆ put_u16_le()

void Bitstream::put_u16_le ( unsigned long  value)

write 8-bit unsigned value, little-endian

Parameters
valuevalue to write

◆ put_s16()

void Bitstream::put_s16 ( signed long  value)

write 16-bit signed value, big-endian

Parameters
valuevalue to write

◆ put_u24()

void Bitstream::put_u24 ( unsigned long  value)

write 24-bit unsigned value

Parameters
valuevalue to write

◆ put_u32()

void Bitstream::put_u32 ( unsigned long  value)

write 32-bit unsigned value, big-endian

Parameters
valuevalue to write

◆ put_u32_le()

void Bitstream::put_u32_le ( unsigned long  value)

write 32-bit unsigned value, little-endian

Parameters
valuevalue to write

◆ put_s32()

void Bitstream::put_s32 ( signed long  value)

write 32-bit signed value, big-endian

Parameters
valuevalue to write

◆ put_u64()

void Bitstream::put_u64 ( unsigned long long  value)

write 64-bit unsigned value, big-endian

Parameters
valuevalue to write

◆ put_u64_le()

void Bitstream::put_u64_le ( unsigned long long  value)

write 64-bit unsigned value, little-endian

Parameters
valuevalue to write

◆ put_s64()

void Bitstream::put_s64 ( signed long long  value)

write 64-bit signed value, big-endian

Parameters
valuevalue to write

◆ put_bits()

void Bitstream::put_bits ( unsigned long long  value,
unsigned long  nb_bits 
)

write n-bit unsigned value

Parameters
valuevalue to write
nb_bitsnumber of bits to use when writing

◆ put_float()

void Bitstream::put_float ( double  value)

write 32-bit float value

Parameters
valuevalue to write

◆ put_double()

void Bitstream::put_double ( double  value)

write 64-bit float value

Parameters
valuevalue to write

◆ put_data()

unsigned long Bitstream::put_data ( ArrayBuffer  buffer,
optional unsigned long  nb_bytes = 0 
)

write data

Parameters
buffersource of data to write
nb_bytesnumber of bytes to write - if 0, uses array buffer size. If more than array buffer size, truncated to array buffer size
Returns
number of bytes written

◆ put_4cc()

void Bitstream::put_4cc ( DOMString  fcc)

write 4CC

Parameters
fccfour-character code to write

◆ put_string()

void Bitstream::put_string ( DOMString  str)

write UTF-8 string

Parameters
strstring to write

◆ insert_data()

void Bitstream::insert_data ( ArrayBuffer  buffer,
optional unsigned long  nb_bytes = 0,
optional unsigned long  offset = 0 
)

write 64-bit float value

Parameters
bufferbuffer to write
nb_bytesnumber of bytes to write - if 0, uses array buffer size. If more than array buffer size, truncated to array buffer size
offsetbyte offset at which data must be inserted

◆ is_align()

boolean Bitstream::is_align ( )

check if bitsream is byte-aligned - see gf_bs_is_align

Returns
true if aligned

◆ align()

void Bitstream::align ( )

set bitsream byte-aligned - see gf_bs_align

◆ truncate()

void Bitstream::truncate ( )

truncate bitsream - see gf_bs_truncate

◆ get_content()

ArrayBuffer Bitstream::get_content ( )

get content of the bitstream - see gf_bs_get_content

Returns
ArrayBuffer containing the bitstream content

◆ transfer()

void Bitstream::transfer ( Bitstream src_bs,
optional boolean  keep_src = false 
)

transfer bitstream into another - see gf_bs_transfer

Parameters
src_bssource bitstream for bytes to transfer
keep_srcif true, the source bitstream will not be reset

◆ peek()

unsigned long Bitstream::peek ( unsigned long  nb_bits,
optional unsigned long  byte_offset = 0 
)

peek bits without changing bitstream state - see gf_bs_peek_bits

Parameters
nb_bitsthe number of bits to peek
byte_offsetthe position of the first byte after the current position to start peek
Returns
value peeked

◆ skip()

void Bitstream::skip ( unsigned long  nb_bytes)

skips given amount of bytes

Parameters
nb_bytesnumber of bytes to skip

◆ flush()

void Bitstream::flush ( )

flush underlying file object if any

◆ epb_mode()

void Bitstream::epb_mode ( boolean  enable)

enable emulation preventio byte removal - see gf_bs_enable_emulation_byte_removal

Parameters
enableif true, EPB is removed in read operations

Field Documentation

◆ pos

attribute unsigned long long Bitstream::pos

position of bitstream - see gf_bs_get_position and gf_bs_seek

◆ available

attribute readonly unsigned long long Bitstream::available

check if bytes are available for read/write - see gf_bs_available

◆ size

attribute readonly unsigned long long Bitstream::size

size of bitstream - see gf_bs_get_size

◆ bit_offset

attribute readonly unsigned long Bitstream::bit_offset

bit offset in bitstream - see gf_bs_get_bit_offset

◆ bit_position

attribute readonly unsigned long Bitstream::bit_position

bit position in bitstream - see gf_bs_get_bit_position

◆ bits_available

attribute readonly unsigned long Bitstream::bits_available

bit available till end of byte - see gf_bs_bits_available

◆ refreshed_size

attribute readonly unsigned long long Bitstream::refreshed_size

gets refreshed size of bitstream - see gf_bs_get_refreshed_size

◆ overflow

attribute readonly boolean Bitstream::overflow

checks if bitstream read has overflown - see gf_bs_is_overflow