Skip to content

bindings.decoder

Melchor Garau Madrigal edited this page Aug 4, 2016 · 1 revision

Contains all the functions and objects for FLAC/stream_decoder interface. Don't think this documentation is a full replacement of the FLAC's one. Only tells all available functions, and the relation to the FLAC API, with a short description.

Functions

Buffer? new()

FLAC__stream_decoder_new()

Creates an instance of a FLAC decoder. If return null, then an error has occurred, probably with memory.

delete(Buffer dec)

FLAC__stream_decoder_delete()

Deletes an instance of a FLAC decoder freeing all the native resources.

Boolean set_ogg_serial_number(Buffer dec, Number serialNumber)

FLAC__stream_decoder_set_ogg_serial_number()

Sets the serial number of an ogg stream. Only useful if the stream will be an ogg one.

Boolean set_md5_checking(Buffer dec, Boolean md5Checking)

FLAC__stream_decoder_set_md5_checking()

Set the MD5 signature check flag.

Boolean set_metadata_respond(Buffer dec, Number metadataType)

FLAC__stream_decoder_set_metadata_respond()

Tells the decoder to pass all metadata blocks of this type to the metadata callback. See bindings.format.MetadataType for values accepted in metadataType argument.

Boolean set_metadata_respond_application(Buffer dec, [Number] id)

FLAC__stream_decoder_set_metadata_respond_application()

Tells the decoder to pass all APPLICATION metadata blocks that matches the id to the metadata callback. id has to be an array of characters, that is, ['f'.charCodeAt(0), 'l'.charCodeAt(0), 'a'.charCodeAt(0), 'c'.charCodeAt(0)] as an example.

Boolean set_metadata_respond_all(Buffer dec)

FLAC__stream_decoder_set_metadata_respond_all()

Tells the decoder to pass all metadata blocks to the metadatata callback.

Boolean set_metadata_ignore(Buffer dec, Number metadataType)

FLAC__stream_decoder_set_metadata_ignore()

Tells the decoder to ignore all metadata blocks that matches metadataType type. See bindings.type.MetadataType for all valid values.

Boolean set_metadata_ignore_application(Buffer dec, [Number] id)

FLAC__stream_decoder_set_metadata_ignore_application()

Tells the decoder to ignore all APPLICATION metadata blocks that matches the given id. The format of id is the same as in set_metadata_respond_application.

Boolean set_metadata_ignore_all(Buffer dec)

FLAC__stream_decoder_set_metadata_ignore_all()

Tells the decoder to ignore all metadata blocks.

Number get_state(Buffer dec)

FLAC__stream_decoder_get_state()

Gets the current decoder status. See bindings.decoder.State and bindings.decoder.StateString.

String get_resolved_state_string(Buffer dec)

FLAC__stream_decoder_get_resolved_state_string()

Gets a string representation of the decoder status.

Boolean get_md5_checking(Buffer dec)

FLAC__stream_decoder_get_md5_checking()

Gets if md5 checking is enabled or not.

Number get_total_sample(Buffer dec)

FLAC__stream_decoder_get_total_samples()

Gets the total number of samples. Will return 0 if is undefined. Will return a valid value only after the decoder read the STREAMINFO block.

This value can be truncated due to Number precision. This function returns a value of 64 bits but Number has only 48 bits.

Number get_channels(Buffer dec)

FLAC__stream_decoder_get_channels()

Gets the number of channels from the last decoded frame. Will return a valid value only after the decoder had decoded at least one frame.

Number get_channel_assignment(Buffer dec)

FLAC__stream_decoder_get_channel_assignment()

Gets the channel assignment from the last decoded frame. Will return a valid value only after the decoder had decoded at least one frame. Return values are from bindings.format.ChannelAssignment.

Number get_bits_per_sample(Buffer dec)

FLAC__stream_decoder_get_bits_per_sample()

Gets the bits per sample from the last decoded frame. Will return a valid value only after the decoder had decoded at least one frame.

Number get_sample_rate(Buffer dec)

FLAC__stream_decoder_get_sample_rate()

Gets the sample rate from the last decoded frame in Hz. Will return a valid value only after the decoder had decoded at least one frame.

Number get_blocksize(Buffer dec)

FLAC__stream_decoder_get_blocksize()

Gets the current block size of the stream. Will return a valid value only after the decoder had decoded at least one frame.

Number get_decode_position(Buffer dec)

FLAC__stream_decoder_get_decode_position()

Returns the current byte offset from the start of the stream.

This value can be truncated due to Number bits precision. This function returns a 64 bit integer, but Number only stores 48 bits or less.

Number init_stream(Buffer dec, Function readCbk, Function? seekCbk, Function? tellCbk, Function? lengthCbk, Function? eofCbk, Function writeCbk, Function? metadataCbk, Function errorCbk)

FLAC__stream_decoder_init_stream()

Initializes the decoder and prepares to start decoding. Returned values are of type bindings.decoder.InitStatus. client_data is not needed.

Number init_ogg_stream(Buffer dec, Function readCbk, Function? seekCbk, Function? tellCbk, Function? lengthCbk, Function? eofCbk, Function writeCbk, Function? metadataCbk, Function errorCbk)

FLAC__stream_decoder_init_ogg_stream()

Initializes the decoder and prepares to start decoding an OGG stream. Returned values are of type bindings.decoder.InitStatus. client_data is not needed.

Both are functions that are imposible to implement on node.js because require a FILE* form the C API.

Number init_file(Buffer dec, String filename, Function writeCbk, Function? metadataCbk, Function error Cbk)

FLAC__stream_decoder_init_file()

Initializes the decoder and prepares to start decoding the file. Returned values are of type bindings.decoder.InitStatus. client_data is not needed.

Number init_ogg_file(Buffer dec, String filename, Function writeCbk, Function? metadataCbk, Function error Cbk)

FLAC__stream_decoder_init_ogg_file()

Initializes the decoder and prepares to start decoding the OGG file. Returned values are of type bindings.decoder.InitStatus. client_data is not needed.

Boolean finish(Buffer dec)

FLAC__stream_decoder_finish()

Finish the decoder process, flushing the decoding buffer, releasing some resources and setting the decoder to initial state.

Boolean flush(Buffer dec)

FLAC__stream_decoder_flush()

Flushes decoder's buffers. This will deactivate md5 checking if was enabled.

Boolean reset(Buffer dec)

FLAC__stream_decoder_reset()

Resets the decoding process to the beginning.

Boolean process_single(Buffer dec)

FLAC__stream_decoder_process_single()

Process one metadata block or audio frame.

Boolean process_until_end_of_metadata(Buffer dec)

FLAC__stream_decoder_process_until_end_of_metadata()

Process all metadata blocks, and stops when there's no more metadata blocks.

Boolean process_until_end_of_stream(Buffer dec)

FLAC__stream_decoder_process_until_end_of_stream()

Process all the metadata blocks and audio frames from the current position until the end of stream.

Boolean skip_single_frame(Buffer dec)

FLAC__stream_decoder_skip_single_frame()

Skip one audio frame.

Boolean seek_absolute(Buffer dec)

FLAC__stream_decoder_seek_absolute()

Seek to the absolute sample given and continues decoding from there.

Enums

get Number State[]

FLAC__StreamDecoderState

Represents the above enum as a associative array. For example bindings.decoder.State.ABORTED will return a Number that represents this enum value. An invalid enum value will return undefined.

get Number InitStatus[]

FLAC__StreamDecoderInitStatus

Represents the above enum as a associative array. For example bindings.decoder.InitStatus.OK will return a Number that represents this enum value. An invalid enum value will return undefined.

get Number ReadStatus[]

FLAC__StreamDecoderReadStatus

Represents the above enum as a associative array. For example bindings.decoder.ReadStatus.CONTINUE will return a Number that represents this enum value. An invalid enum value will return undefined.

get Number SeekStatus[]

FLAC__StreamDecoderSeekStatus

Represents the above enum as a associative array. For example bindings.decoder.SeekStatus.OK will return a Number that represents this enum value. An invalid enum value will return undefined.

get Number TellStatus[]

FLAC__StreamDecoderTellStatus

Represents the above enum as a associative array. For example bindings.decoder.TellStatus.OK will return a Number that represents this enum value. An invalid enum value will return undefined.

get Number LengthStatus[]

FLAC__StreamDecoderLengthStatus

Represents the above enum as a associative array. For example bindings.decoder.LengthStatus.OK will return a Number that represents this enum value. An invalid enum value will return undefined.

get Number WriteStatus[]

FLAC__StreamDecoderWriteStatus

Represents the above enum as a associative array. For example bindings.decoder.WriteStatus.CONTINUE will return a Number that represents this enum value. An invalid enum value will return undefined.

get Number ErrorStatus[]

FLAC__StreamDecoderErrorStatus

Represents the above enum as a associative array. For example bindings.decoder.ErrorStatus.LOST_SYNC will return a Number that represents this enum value. An invalid enum value will return undefined.

Constants

get String StateString[]

FLAC__StreamDecoderStateString

Represents the above const char* array as a JavaScript array. Returns a String representation for enum bindings.decoder.State.

get String InitStatusString[]

FLAC__StreamDecoderInitStatusString

Represents the above const char* array as a JavaScript array. Returns a String representation for enum bindings.decoder.InitStatus.

get String ReadStatusString[]

FLAC__StreamDecoderReadStatusString

Represents the above const char* array as a JavaScript array. Returns a String representation for enum bindings.decoder.ReadStatus.

get String SeekStatusString[]

FLAC__StreamDecoderSeekStatusString

Represents the above const char* array as a JavaScript array. Returns a String representation for enum bindings.decoder.SeekStatus.

get String TellStatusString[]

FLAC__StreamDecoderTellStatusString

Represents the above const char* array as a JavaScript array. Returns a String representation for enum bindings.decoder.TellStatus.

get String LengthStatusString[]

FLAC__StreamDecoderLengthStatusString

Represents the above const char* array as a JavaScript array. Returns a String representation for enum bindings.decoder.LengthStatus.

get String WriteStatusString[]

FLAC__StreamDecoderWriteStatusString

Represents the above const char* array as a JavaScript array. Returns a String representation for enum bindings.decoder.WriteStatus.

get String ErrorStatusString[]

FLAC__StreamDecoderErrorStatusString

Represents the above const char* array as a JavaScript array. Returns a String representation for enum bindings.decoder.ErrorStatus.

Callbacks

Read callback

Object read_callback(Buffer buffer)

Called when the decoder needs some data. Fill the data into the buffer and return an object with bytes set to the bytes read and a valid return value from bindings.decoder.ReadStatus in returnValue field. {bytes: ..., returnValue: ...}

Seek callback

Number seek_callback(Number offset)

Called when the decoder requests seeking on the stream. The value of offset could be truncated due to Number precision. Return a valid value from bindings.decoder.SeekStatus.

Tell callback

Object tell_callback()

Called when the decoder wants to know the offset in bytes from the beginning of the stream. Return an object with offset value as the offset in bytes and returnValue as the valid return value from bindings.decoder.TellStatus. {offset: ..., returnValue: ...}

Length callback

Object length_callback()

Called when the decoder wants to know the length of the stream. Return an object with length set to the length value and returnValue as a valid return value from bindings.decoder.LengthStatus.

EOF callback

Boolean eof_callback()

Called when the decoder wants to know if the stream has no more data, has arrived to its end of file. Return true if have arrived the EOF, or false otherwise.

Write callback

Number read_callback(Object frame, [Buffer] buffers)

Called when the decoder decoded some data. frame contain a FLAC__Frame representation in JavaScript. buffers are the array of buffers (one per channel). Return a valid value from bindings.decoder.WriteStatus.

Metadata callback

read_callback(Object metadata)

Called when the decoder read a metadata block, and you requested that block to be passed here. metadata is a JavaScript representation of a FLAC__StreamMetadata struct.

Error callback

error_callback(Number error)

Called when the decoder had an error. See bindings.decoder.ErrorStatus and bindings.decoder.ErrorStatusString to know what's going on.

Clone this wiki locally