A library to read & write resource interchange file format (RIFF) files. Common uses of the RIFF format are multimedia containers such as AVI and WAV files.
The library is focused on reading & writing RIFF chunks. It does not provide any interpretation of what the chunks represent. E.g. it provides no additional functionality for the AVI hdrl chunk.
Similar to the .NET Class Library I/O classes, the library is broken into separate read & write portions.
Call Riff.Read.Reader.Read
.
- This will return a chunk descriptor, which encapsulates all chunks in the source stream.
- Use LINQ to search & extract individual chunks
- Chunk descriptors are immutable
Chunk data can be loaded immediately or lazily, as determined by the caller: pass the appropriate IChunkFactory
to Riff.Read.Reader.Read
.
Write chunks can be created in 2 ways:
- Directly by creating an instance of the appropriate chunk class. E.g.
ByteArrayChunk
- Indirectly from a chunk descriptor generated by reading a file:
ChunkDescriptorBase.CreateWriteChunk()
.- The resulting chunk is immutable, but children can be added or removed.
- This allows reading a file, making edits, whilst lazily loading source data in a memory efficient manner
To write the chunk (and it's child chunks), call Write(BinaryWriter)
The library is extensible via derivation if you need to add semantics to chunk types:
- (optional) Add a write chunk class
- Add a read chunk descriptor class
- Implement
IChunkFactory
to create instances of your chunk descriptor- Or derive from
BasicChunkFactory, LazyBasicChunkFactory
- Or derive from