Tawara
0.1.0
|
The BlockGroup is the standard block. More...
#include <tawara/block_group.h>
Public Member Functions | |
BlockGroup (uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE, uint64_t duration=0, uint64_t ref_priority=0) | |
Create a new BlockGroup. More... | |
BlockAdditions & | additions () |
Access the block additions property. More... | |
uint64_t | duration () const |
Get the block's duration. More... | |
void | duration (uint64_t duration) |
Set the block's duration. More... | |
uint64_t | ref_priority () const |
Get the block's reference priority. More... | |
void | ref_priority (uint64_t ref_priority) |
Set the block's reference priority. More... | |
std::vector< int16_t > & | ref_blocks () |
Get the reference block timecode array. More... | |
std::vector< char > | codec_state () const |
Get the codec state for this block. More... | |
void | codec_state (std::vector< char > const &codec_state) |
Set the codec state for this block. More... | |
virtual uint64_t | track_number () const |
The block's track number. More... | |
virtual void | track_number (uint64_t track_number) |
Set the block's track number. More... | |
virtual int16_t | timecode () const |
The timecode of this block. More... | |
virtual void | timecode (int16_t timecode) |
Set the block's timecode. More... | |
virtual bool | invisible () const |
If this block is invisible. More... | |
virtual void | invisible (bool invisible) |
Set if this block is invisible. More... | |
virtual LacingType | lacing () const |
Get the lacing type in use. More... | |
virtual void | lacing (LacingType lacing) |
Set the lacing type in use. More... | |
virtual value_type & | at (size_type pos) |
Get the frame at the given position, with bounds checking. More... | |
virtual value_type const & | at (size_type pos) const |
Get the frame at the given position, with bounds checking. More... | |
virtual value_type & | operator[] (size_type pos) |
Get a reference to a frame. More... | |
virtual value_type const & | operator[] (size_type pos) const |
Get a reference to a frame. More... | |
virtual iterator | begin () |
Get an iterator to the first frame. More... | |
virtual const_iterator | begin () const |
Get an iterator to the first frame. More... | |
virtual iterator | end () |
Get an iterator to the position past the last frame. More... | |
virtual const_iterator | end () const |
Get an iterator to the position past the last frame. More... | |
virtual reverse_iterator | rbegin () |
Get a reverse iterator to the last frame. More... | |
virtual const_reverse_iterator | rbegin () const |
Get a reverse iterator to the last frame. More... | |
virtual reverse_iterator | rend () |
Get a reverse iterator to the position before the first frame. More... | |
virtual const_reverse_iterator | rend () const |
Get a reverse iterator to the position before the first frame. More... | |
virtual bool | empty () const |
Check if there are no frames. More... | |
virtual size_type | count () const |
Get the number of frames. More... | |
virtual size_type | max_count () const |
Get the maximum number of frames. More... | |
virtual void | clear () |
Remove all frames. More... | |
virtual void | erase (iterator position) |
Erase the frame at the specified iterator. More... | |
virtual void | erase (iterator first, iterator last) |
Erase a range of frames. More... | |
virtual void | push_back (value_type const &value) |
Add a frame to this block. More... | |
virtual void | resize (size_type count) |
Resizes the frames storage. More... | |
virtual void | swap (BlockGroup &other) |
Swaps the contents of this block with another. More... | |
![]() | |
BlockElement (tawara::ids::ID id, uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE) | |
![]() | |
Element (tawara::ids::ID id) | |
Create a new Element. More... | |
virtual | ~Element () |
Destructor. More... | |
uint32_t | id () const |
Get the element's ID. More... | |
std::streampos | offset () const |
Get the element's offset in the byte stream. More... | |
virtual std::streamsize | size () const |
Get the total size of the element. More... | |
virtual std::streamsize | write (std::ostream &output) |
Element writing. More... | |
virtual std::streamsize | read (std::istream &input) |
Element reading. More... | |
![]() | |
Block (uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE) | |
Constructor. More... | |
virtual | ~Block ()=0 |
Desctructor. More... | |
virtual void | swap (Block &other) |
Swaps the contents of this block with another. More... | |
Protected Member Functions | |
virtual std::streamsize | body_size () const |
Get the size of the body of this element. More... | |
virtual std::streamsize | read_body (std::istream &input, std::streamsize size) |
Element body loading. More... | |
virtual std::streamsize | write_body (std::ostream &output) |
Element body writing. More... | |
void | reset () |
Reset all values to their defaults. More... | |
![]() | |
std::streamsize | write_id (std::ostream &output) |
Element ID writing. More... | |
virtual std::streamsize | write_size (std::ostream &output) |
Element size writing. More... | |
Protected Attributes | |
BlockAdditions | additions_ |
UIntElement | duration_ |
UIntElement | ref_priority_ |
std::vector< int16_t > | ref_blocks_ |
BinaryElement | codec_state_ |
BlockImpl | block_ |
![]() | |
tawara::ids::ID | id_ |
std::streampos | offset_ |
Friends | |
bool | operator== (BlockGroup const &lhs, BlockGroup const &rhs) |
Equality operator. More... | |
Additional Inherited Members | |
![]() | |
typedef boost::shared_ptr < BlockElement > | Ptr |
![]() | |
enum | LacingType { LACING_NONE, LACING_EBML, LACING_FIXED } |
Lacing types. More... | |
typedef boost::shared_ptr< Block > | Ptr |
Pointer to a block. More... | |
typedef boost::shared_ptr < Block const > | ConstPtr |
Constant pointer to a block. More... | |
typedef std::vector< char > | Frame |
The type of a single frame of data. More... | |
typedef boost::shared_ptr< Frame > | FramePtr |
A pointer to a frame of data. More... | |
typedef std::vector< FramePtr > ::value_type | value_type |
The value type of this container. More... | |
typedef std::vector< FramePtr > ::size_type | size_type |
The size type of this container. More... | |
typedef std::vector< FramePtr > ::reference | reference |
The reference type. More... | |
typedef std::vector< FramePtr > ::const_reference | const_reference |
The constant reference type. More... | |
typedef std::vector< FramePtr > ::iterator | iterator |
The random access iterator type. More... | |
typedef std::vector< FramePtr > ::const_iterator | const_iterator |
The constant random access iterator type. More... | |
typedef std::vector< FramePtr > ::reverse_iterator | reverse_iterator |
The reversed random access iterator type. More... | |
typedef std::vector< FramePtr > ::const_reverse_iterator | const_reverse_iterator |
The constant reversed random access iterator type. More... | |
The BlockGroup is the standard block.
The BlockGroup contains a Block itself as well as meta-data and extra data for that block, such as reference blocks and private codec data for the block.
Despite its name, the BlockGroup only stores a single Block. It implements the Block interface, and so can be treated as a Block, similar to the SimpleBlock element.
Definition at line 66 of file block_group.h.
tawara::BlockGroup::BlockGroup | ( | uint64_t | track_number, |
int16_t | timecode, | ||
LacingType | lacing = LACING_NONE , |
||
uint64_t | duration = 0 , |
||
uint64_t | ref_priority = 0 |
||
) |
Create a new BlockGroup.
[in] | track_number | The track number this block belongs to. |
[in] | timecode | The timecode of this block. |
[in] | lacing | The type of lacing to use. |
[in] | duration | The duration of the block. |
[in] | ref_priority | The reference priority for this block. |
|
inline |
Access the block additions property.
Definition at line 83 of file block_group.h.
|
inlinevirtual |
Get the frame at the given position, with bounds checking.
std::out_of_range | if the position is invalid. |
Implements tawara::Block.
Definition at line 190 of file block_group.h.
|
inlinevirtual |
Get the frame at the given position, with bounds checking.
std::out_of_range | if the position is invalid. |
Implements tawara::Block.
Definition at line 197 of file block_group.h.
|
inlinevirtual |
Get an iterator to the first frame.
Implements tawara::Block.
Definition at line 218 of file block_group.h.
|
inlinevirtual |
Get an iterator to the first frame.
Implements tawara::Block.
Definition at line 220 of file block_group.h.
|
protectedvirtual |
Get the size of the body of this element.
Implements tawara::Element.
|
inlinevirtual |
|
inline |
Get the codec state for this block.
Sometimes a block may reset the codec state to a new value. This property stores the new state as a binary blob. Understanding the data stored in the blob is codec-specific.
Definition at line 127 of file block_group.h.
|
inline |
Set the codec state for this block.
Definition at line 130 of file block_group.h.
|
inlinevirtual |
|
inline |
Get the block's duration.
The duration of this block may come from one of three sources:
The units are the TimecodeScale of the segment.
Definition at line 98 of file block_group.h.
|
inline |
Set the block's duration.
Definition at line 100 of file block_group.h.
|
inlinevirtual |
Check if there are no frames.
Empty blocks cannot be written. If this returns true, an error will occur when write() is called.
Implements tawara::Block.
Definition at line 245 of file block_group.h.
|
inlinevirtual |
Get an iterator to the position past the last frame.
Implements tawara::Block.
Definition at line 222 of file block_group.h.
|
inlinevirtual |
Get an iterator to the position past the last frame.
Implements tawara::Block.
Definition at line 224 of file block_group.h.
|
inlinevirtual |
Erase the frame at the specified iterator.
[in] | position | The position to erase at. |
Implements tawara::Block.
Definition at line 264 of file block_group.h.
Erase a range of frames.
[in] | first | The start of the range. |
[in] | last | The end of the range. |
Implements tawara::Block.
Definition at line 270 of file block_group.h.
|
inlinevirtual |
If this block is invisible.
Invisible blocks should be decoded by the codec (thus updating codec state) but not used for playback.
Implements tawara::Block.
Definition at line 165 of file block_group.h.
|
inlinevirtual |
Set if this block is invisible.
Implements tawara::Block.
Definition at line 167 of file block_group.h.
|
inlinevirtual |
Get the lacing type in use.
The data in a block is typically a single frame, but sometimes multiple frames may be stored. This is called "lacing," and is usually used to reduce overhead when the size of the data itself is small. However, lacing also reduces seekability of the file, so laces should usually be kept small. A common number is up to three frames in a lace.
Implements tawara::Block.
Definition at line 179 of file block_group.h.
|
inlinevirtual |
|
inlinevirtual |
Get the maximum number of frames.
If lacing is not enabled, this will always return 1.
If lacing is enabled, this will be the maximum number of frames that can be stored in a lace within a single block.
Implements tawara::Block.
Definition at line 255 of file block_group.h.
|
inlinevirtual |
Get a reference to a frame.
No bounds checking is performed.
Implements tawara::Block.
Definition at line 206 of file block_group.h.
|
inlinevirtual |
Get a reference to a frame.
No bounds checking is performed.
Implements tawara::Block.
Definition at line 214 of file block_group.h.
|
inlinevirtual |
Add a frame to this block.
When lacing is enabled, this will append an additional frame to the block to be stored.
When lacing is not enabled, the value of frame_count() must be zero or an error will occur.
MaxLaceSizeExceeded | if the new size is incompatible with the lacing type. |
EmptyFrame | if the frame data is empty. |
Implements tawara::Block.
Definition at line 285 of file block_group.h.
|
inlinevirtual |
Get a reverse iterator to the last frame.
Implements tawara::Block.
Definition at line 226 of file block_group.h.
|
inlinevirtual |
Get a reverse iterator to the last frame.
Implements tawara::Block.
Definition at line 228 of file block_group.h.
|
protectedvirtual |
Element body loading.
Implements tawara::Element.
|
inline |
Get the reference block timecode array.
These timecodes, specified as relative to the cluster's timecode, locate the reference blocks used to understand this block.
Definition at line 119 of file block_group.h.
|
inline |
Get the block's reference priority.
If this block is referenced and cached, then only another block of higher priority should replace it in the cache. A value of 0 means the block is not referenced.
Definition at line 108 of file block_group.h.
|
inline |
Set the block's reference priority.
Definition at line 110 of file block_group.h.
|
inlinevirtual |
Get a reverse iterator to the position before the first frame.
Implements tawara::Block.
Definition at line 233 of file block_group.h.
|
inlinevirtual |
Get a reverse iterator to the position before the first frame.
Implements tawara::Block.
Definition at line 237 of file block_group.h.
|
protected |
Reset all values to their defaults.
|
inlinevirtual |
Resizes the frames storage.
When lacing is not enabled, the new size must be 1 or an error will occur.
If the current size is less than the new size, additional empty frames will be added. These should be filled with data before calling write() or an error will occur.
If the current size is greater than the new size, frames past the new end will be dropped.
MaxLaceSizeExceeded | if the new size is incompatible with the lacing type. |
Implements tawara::Block.
Definition at line 303 of file block_group.h.
|
virtual |
Swaps the contents of this block with another.
[in] | other | The other block to swap with. |
|
inlinevirtual |
The timecode of this block.
Each block has a timecode relative to its containing cluster. It is measured in the units specified by the containing segment's TimecodeScale, and is a 16-bit signed integer.
Implements tawara::Block.
Definition at line 155 of file block_group.h.
|
inlinevirtual |
|
inlinevirtual |
The block's track number.
This property specifies the track that this block belongs to. The data stored in the block should be interpreted by the codec for its track.
Implements tawara::Block.
Definition at line 143 of file block_group.h.
|
inlinevirtual |
Set the block's track number.
Implements tawara::Block.
Definition at line 146 of file block_group.h.
|
protectedvirtual |
Element body writing.
Implements tawara::Element.
|
friend |
Equality operator.
|
protected |
Definition at line 316 of file block_group.h.
|
protected |
Definition at line 321 of file block_group.h.
|
protected |
Definition at line 320 of file block_group.h.
|
protected |
Definition at line 317 of file block_group.h.
|
protected |
Definition at line 319 of file block_group.h.
|
protected |
Definition at line 318 of file block_group.h.