Top | ![]() |
![]() |
![]() |
![]() |
enum | IpatchRiffStatus |
enum | IpatchRiffMode |
enum | IpatchRiffChunkType |
struct | IpatchRiffChunk |
#define | IPATCH_RIFF_ERROR |
enum | IpatchRiffError |
#define | IPATCH_FOURCC_RIFX |
#define | IPATCH_FOURCC_LIST |
#define | IPATCH_RIFF_HEADER_SIZE |
#define | IPATCH_RIFF_FOURCC_SIZE |
#define | IPATCH_RIFF_LIST_HEADER_SIZE |
#define | IPATCH_RIFF_WAVE_FMT_PCM |
#define | IPATCH_RIFF_WAVE_FMT_FLOAT |
GObject ╰── IpatchRiff ├── IpatchDLSReader ├── IpatchDLSWriter ├── IpatchSF2Reader ╰── IpatchSF2Writer
#define IPATCH_RIFF_NEED_SWAP(riff) IPATCH_FILE_NEED_SWAP (riff->handle->file)
#define IPATCH_RIFF_BIG_ENDIAN(riff) IPATCH_FILE_BIG_ENDIAN (riff->handle->file)
IpatchRiff *
ipatch_riff_new (IpatchFileHandle *handle
);
Create a new RIFF file riff/composer object
void ipatch_riff_set_file_handle (IpatchRiff *riff
,IpatchFileHandle *handle
);
Set the file object handle of a RIFF object. The handle is taken over by the riff object and will be closed when finalized.
int
ipatch_riff_get_chunk_level (IpatchRiff *riff
);
Gets the current chunk level count (number of embedded chunks) currently being processed in a RIFF file.
IpatchRiffChunk * ipatch_riff_get_chunk_array (IpatchRiff *riff
,int *count
);
Gets the array of open chunk info structures.
riff |
RIFF object |
|
count |
Location to store the number of elements in the returned array. |
[out] |
Array of IpatchRiffChunk
structures or NULL
if no chunks being processed (processing hasn't started).
The returned array is internal and should not be modified or freed. Also note that the
array is valid only while the chunk state is unchanged (riff object or file
operations). The number of elements in the array is stored in count
.
[array length=count][transfer none]
IpatchRiffChunk * ipatch_riff_get_chunk (IpatchRiff *riff
,int level
);
Get the chunk at the specified level
from a RIFF riff
chunk state
array.
guint32
ipatch_riff_get_total_size (IpatchRiff *riff
);
Get total size of toplevel chunk. This is a convenience function that just adds the size of the toplevel chunk and its header, the actual file object size is not checked.
guint32
ipatch_riff_get_position (IpatchRiff *riff
);
Get current position in the toplevel RIFF chunk (including header, i.e., the file position).
void
ipatch_riff_push_state (IpatchRiff *riff
);
Pushes the current file position and chunk state onto the state stack. This state can be later restored to return to the same position in a RIFF file.
gboolean ipatch_riff_pop_state (IpatchRiff *riff
,GError **err
);
Pops the most recent state pushed onto the state stack. This causes the position in the RIFF file stored by the state to be restored.
IpatchRiffChunk * ipatch_riff_start_read (IpatchRiff *riff
,GError **err
);
Start parsing the riff
file object as if it were at the
beginning of a RIFF file. Clears any current chunk state,
loads a chunk and ensures that it has the "RIFF" or "RIFX" ID. If this call
is sucessful there will be one chunk on the chunk stack with the
secondary ID of the RIFF chunk. If it is desirable to process a
chunk that is not the beginning of a RIFF file,
ipatch_riff_start_read_chunk()
can be used. This function will also
automatically enable byte order swapping if needed.
IpatchRiffChunk * ipatch_riff_start_read_chunk (IpatchRiff *riff
,GError **err
);
Start parsing the riff
file object at an arbitrary chunk.
Clears any current chunk state and loads a chunk. If this
call is sucessful there will be one chunk on the chunk stack. If it
is desirable to start processing from the beginning of a RIFF file
ipatch_riff_start_read()
should be used instead. An end of file
condition is considered an error. Note that it is up to the caller to
ensure byte order swapping is enabled, if needed.
IpatchRiffChunk * ipatch_riff_read_chunk_verify (IpatchRiff *riff
,IpatchRiffChunkType type
,guint32 id
,GError **err
);
Like ipatch_riff_read_chunk()
but ensures that the new chunk matches a
specific type and ID. If the chunk is not the expected chunk or no more
chunks in current list chunk, it is considered an error.
ipatch_riff_close_chunk()
should be called when finished parsing the
opened chunk.
IpatchRiffChunk * ipatch_riff_read_chunk (IpatchRiff *riff
,GError **err
);
Parse next RIFF chunk header. The ipatch_riff_close_chunk()
function should be called at the end of parsing a chunk, otherwise this
function will return NULL if the current chunk has ended. When
the first RIFF chunk is read the IPATCH_RIFF_FLAG_BIG_ENDIAN flag
is cleared or set depending on if its RIFF or RIFX respectively,
endian swapping is also enabled if the file uses non-native endian
format to the host.
gboolean ipatch_riff_write_chunk (IpatchRiff *riff
,IpatchRiffChunkType type
,guint32 id
,GError **err
);
Opens a new chunk and writes a chunk header to the file object in riff
.
The size field of the chunk is set to 0 and will be filled in when the
chunk is closed (see ipatch_riff_close_chunk()
).
gboolean ipatch_riff_close_chunk (IpatchRiff *riff
,int level
,GError **err
);
Closes the chunk specified by level
and all its children (if any).
In write mode the chunk size is filled in for chunks that get closed and
therefore the file object of riff
must be seekable (anyone need
non-seekable RIFF writing?). The chunk size is padded to an even
number if necessary (by writing a NULL byte).
Upon successful completion the file position will be where it was prior to
the call (write mode) or at the beginning of the next chunk (read mode).
There will be level
open chunks (or previous chunk count - 1 if
level
== -1). In read mode the status will be
IPATCH_RIFF_STATUS_NORMAL if open chunks remain or
IPATCH_RIFF_STATUS_FINISHED if toplevel chunk was closed. The status is
not modified in write mode.
gboolean ipatch_riff_skip_chunks (IpatchRiff *riff
,guint count
,GError **err
);
Skips RIFF chunks at the current chunk level (children of the current chunk).
gboolean ipatch_riff_get_error (IpatchRiff *riff
,GError **err
);
Gets error information from a RIFF object.
FALSE
if status is a IPATCH_RIFF_STATUS_FAIL condition and info
can be found in err
, TRUE
if no error has occured.
char * ipatch_riff_message_detail (IpatchRiff *riff
,int level
,const char *format
,...
);
Generates a detailed message, including current position in RIFF file and a chunk trace back. Useful for debugging purposes.
struct IpatchRiffChunk { IpatchRiffChunkType type; /* type of chunk */ guint32 id; /* chunk ID in integer format for easy comparison */ char idstr[4]; /* four character chunk ID string */ gint32 position; /* current position in chunk (read or write mode) */ guint32 size; /* size of chunk (read mode only) */ guint32 filepos; /* Position in file object of chunk data */ };
#define IPATCH_RIFF_HEADER_SIZE 8 /* size of RIFF chunk headers (ID + size) */