Tawara  0.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
tawara::BlockGroup Class Reference

The BlockGroup is the standard block. More...

#include <tawara/block_group.h>

Inheritance diagram for tawara::BlockGroup:
Inheritance graph
[legend]
Collaboration diagram for tawara::BlockGroup:
Collaboration graph
[legend]

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...
 
BlockAdditionsadditions ()
 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_typeat (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_typeoperator[] (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...
 
- Public Member Functions inherited from tawara::BlockElement
 BlockElement (tawara::ids::ID id, uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE)
 
- Public Member Functions inherited from tawara::Element
 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...
 
- Public Member Functions inherited from tawara::Block
 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...
 
- Protected Member Functions inherited from tawara::Element
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_
 
- Protected Attributes inherited from tawara::Element
tawara::ids::ID id_
 
std::streampos offset_
 

Friends

bool operator== (BlockGroup const &lhs, BlockGroup const &rhs)
 Equality operator. More...
 

Additional Inherited Members

- Public Types inherited from tawara::BlockElement
typedef boost::shared_ptr
< BlockElement
Ptr
 
- Public Types inherited from tawara::Block
enum  LacingType { LACING_NONE, LACING_EBML, LACING_FIXED }
 Lacing types. More...
 
typedef boost::shared_ptr< BlockPtr
 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< FrameFramePtr
 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]track_numberThe track number this block belongs to.
[in]timecodeThe timecode of this block.
[in]lacingThe type of lacing to use.
[in]durationThe duration of the block.
[in]ref_priorityThe reference priority for this block.

Member Function Documentation

BlockAdditions& tawara::BlockGroup::additions ( )
inline

Access the block additions property.

Definition at line 83 of file block_group.h.

virtual value_type& tawara::BlockGroup::at ( size_type  pos)
inlinevirtual

Get the frame at the given position, with bounds checking.

Returns
A reference to the specified frame's data.
Exceptions
std::out_of_rangeif the position is invalid.

Implements tawara::Block.

Definition at line 190 of file block_group.h.

virtual value_type const& tawara::BlockGroup::at ( size_type  pos) const
inlinevirtual

Get the frame at the given position, with bounds checking.

Returns
A reference to the specified frame's data.
Exceptions
std::out_of_rangeif the position is invalid.

Implements tawara::Block.

Definition at line 197 of file block_group.h.

virtual iterator tawara::BlockGroup::begin ( )
inlinevirtual

Get an iterator to the first frame.

Implements tawara::Block.

Definition at line 218 of file block_group.h.

virtual const_iterator tawara::BlockGroup::begin ( ) const
inlinevirtual

Get an iterator to the first frame.

Implements tawara::Block.

Definition at line 220 of file block_group.h.

virtual std::streamsize tawara::BlockGroup::body_size ( ) const
protectedvirtual

Get the size of the body of this element.

Implements tawara::Element.

virtual void tawara::BlockGroup::clear ( )
inlinevirtual

Remove all frames.

Implements tawara::Block.

Definition at line 258 of file block_group.h.

std::vector<char> tawara::BlockGroup::codec_state ( ) const
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.

void tawara::BlockGroup::codec_state ( std::vector< char > const &  codec_state)
inline

Set the codec state for this block.

Definition at line 130 of file block_group.h.

virtual size_type tawara::BlockGroup::count ( ) const
inlinevirtual

Get the number of frames.

Implements tawara::Block.

Definition at line 247 of file block_group.h.

uint64_t tawara::BlockGroup::duration ( ) const
inline

Get the block's duration.

The duration of this block may come from one of three sources:

  • If the block's track has no default duration and this value is 0, the duration is the difference between this block's time code and the timecode of the next block for the track.
  • If the block's track has a default duration and this value is 0, the track's default duration is used.
  • If the block's track has a default duration and this value is not zero, this value is used.

The units are the TimecodeScale of the segment.

Definition at line 98 of file block_group.h.

void tawara::BlockGroup::duration ( uint64_t  duration)
inline

Set the block's duration.

Definition at line 100 of file block_group.h.

virtual bool tawara::BlockGroup::empty ( ) const
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.

virtual iterator tawara::BlockGroup::end ( )
inlinevirtual

Get an iterator to the position past the last frame.

Implements tawara::Block.

Definition at line 222 of file block_group.h.

virtual const_iterator tawara::BlockGroup::end ( ) const
inlinevirtual

Get an iterator to the position past the last frame.

Implements tawara::Block.

Definition at line 224 of file block_group.h.

virtual void tawara::BlockGroup::erase ( iterator  position)
inlinevirtual

Erase the frame at the specified iterator.

Parameters
[in]positionThe position to erase at.

Implements tawara::Block.

Definition at line 264 of file block_group.h.

virtual void tawara::BlockGroup::erase ( iterator  first,
iterator  last 
)
inlinevirtual

Erase a range of frames.

Parameters
[in]firstThe start of the range.
[in]lastThe end of the range.

Implements tawara::Block.

Definition at line 270 of file block_group.h.

virtual bool tawara::BlockGroup::invisible ( ) const
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.

virtual void tawara::BlockGroup::invisible ( bool  invisible)
inlinevirtual

Set if this block is invisible.

Implements tawara::Block.

Definition at line 167 of file block_group.h.

virtual LacingType tawara::BlockGroup::lacing ( ) const
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.

virtual void tawara::BlockGroup::lacing ( LacingType  lacing)
inlinevirtual

Set the lacing type in use.

Implements tawara::Block.

Definition at line 181 of file block_group.h.

virtual size_type tawara::BlockGroup::max_count ( ) const
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.

virtual value_type& tawara::BlockGroup::operator[] ( size_type  pos)
inlinevirtual

Get a reference to a frame.

No bounds checking is performed.

Returns
A reference to the binary data of a frame stored in this block.

Implements tawara::Block.

Definition at line 206 of file block_group.h.

virtual value_type const& tawara::BlockGroup::operator[] ( size_type  pos) const
inlinevirtual

Get a reference to a frame.

No bounds checking is performed.

Returns
A reference to the binary data of a frame stored in this block.

Implements tawara::Block.

Definition at line 214 of file block_group.h.

virtual void tawara::BlockGroup::push_back ( value_type const &  value)
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.

Exceptions
MaxLaceSizeExceededif the new size is incompatible with the lacing type.
EmptyFrameif the frame data is empty.

Implements tawara::Block.

Definition at line 285 of file block_group.h.

virtual reverse_iterator tawara::BlockGroup::rbegin ( )
inlinevirtual

Get a reverse iterator to the last frame.

Implements tawara::Block.

Definition at line 226 of file block_group.h.

virtual const_reverse_iterator tawara::BlockGroup::rbegin ( ) const
inlinevirtual

Get a reverse iterator to the last frame.

Implements tawara::Block.

Definition at line 228 of file block_group.h.

virtual std::streamsize tawara::BlockGroup::read_body ( std::istream &  input,
std::streamsize  size 
)
protectedvirtual

Element body loading.

Implements tawara::Element.

std::vector<int16_t>& tawara::BlockGroup::ref_blocks ( )
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.

uint64_t tawara::BlockGroup::ref_priority ( ) const
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.

void tawara::BlockGroup::ref_priority ( uint64_t  ref_priority)
inline

Set the block's reference priority.

Definition at line 110 of file block_group.h.

virtual reverse_iterator tawara::BlockGroup::rend ( )
inlinevirtual

Get a reverse iterator to the position before the first frame.

Implements tawara::Block.

Definition at line 233 of file block_group.h.

virtual const_reverse_iterator tawara::BlockGroup::rend ( ) const
inlinevirtual

Get a reverse iterator to the position before the first frame.

Implements tawara::Block.

Definition at line 237 of file block_group.h.

void tawara::BlockGroup::reset ( )
protected

Reset all values to their defaults.

virtual void tawara::BlockGroup::resize ( size_type  count)
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.

Exceptions
MaxLaceSizeExceededif the new size is incompatible with the lacing type.

Implements tawara::Block.

Definition at line 303 of file block_group.h.

virtual void tawara::BlockGroup::swap ( BlockGroup other)
virtual

Swaps the contents of this block with another.

Parameters
[in]otherThe other block to swap with.
virtual int16_t tawara::BlockGroup::timecode ( ) const
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.

virtual void tawara::BlockGroup::timecode ( int16_t  timecode)
inlinevirtual

Set the block's timecode.

Implements tawara::Block.

Definition at line 157 of file block_group.h.

virtual uint64_t tawara::BlockGroup::track_number ( ) const
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.

virtual void tawara::BlockGroup::track_number ( uint64_t  track_number)
inlinevirtual

Set the block's track number.

Implements tawara::Block.

Definition at line 146 of file block_group.h.

virtual std::streamsize tawara::BlockGroup::write_body ( std::ostream &  output)
protectedvirtual

Element body writing.

Implements tawara::Element.

Friends And Related Function Documentation

bool operator== ( BlockGroup const &  lhs,
BlockGroup const &  rhs 
)
friend

Equality operator.

Member Data Documentation

BlockAdditions tawara::BlockGroup::additions_
protected

Definition at line 316 of file block_group.h.

BlockImpl tawara::BlockGroup::block_
protected

Definition at line 321 of file block_group.h.

BinaryElement tawara::BlockGroup::codec_state_
protected

Definition at line 320 of file block_group.h.

UIntElement tawara::BlockGroup::duration_
protected

Definition at line 317 of file block_group.h.

std::vector<int16_t> tawara::BlockGroup::ref_blocks_
protected

Definition at line 319 of file block_group.h.

UIntElement tawara::BlockGroup::ref_priority_
protected

Definition at line 318 of file block_group.h.


The documentation for this class was generated from the following file: