Tide 0.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends

tide::BlockGroup Class Reference

The BlockGroup is the standard block. More...

#include <tide/block_group.h>

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

List of all members.

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.
BlockAdditionsadditions ()
 Access the block additions property.
uint64_t duration () const
 Get the block's duration.
void duration (uint64_t duration)
 Set the block's duration.
uint64_t ref_priority () const
 Get the block's reference priority.
void ref_priority (uint64_t ref_priority)
 Set the block's reference priority.
std::vector< int16_t > & ref_blocks ()
 Get the reference block timecode array.
std::vector< char > codec_state () const
 Get the codec state for this block.
void codec_state (std::vector< char > const &codec_state)
 Set the codec state for this block.
virtual uint64_t track_number () const
 The block's track number.
virtual void track_number (uint64_t track_number)
 Set the block's track number.
virtual int16_t timecode () const
 The timecode of this block.
virtual void timecode (int16_t timecode)
 Set the block's timecode.
virtual bool invisible () const
 If this block is invisible.
virtual void invisible (bool invisible)
 Set if this block is invisible.
virtual LacingType lacing () const
 Get the lacing type in use.
virtual void lacing (LacingType lacing)
 Set the lacing type in use.
virtual value_typeat (size_type pos)
 Get the frame at the given position, with bounds checking.
virtual value_type const & at (size_type pos) const
 Get the frame at the given position, with bounds checking.
virtual value_typeoperator[] (size_type pos)
 Get a reference to a frame.
virtual value_type const & operator[] (size_type pos) const
 Get a reference to a frame.
virtual iterator begin ()
 Get an iterator to the first frame.
virtual const_iterator begin () const
 Get an iterator to the first frame.
virtual iterator end ()
 Get an iterator to the position past the last frame.
virtual const_iterator end () const
 Get an iterator to the position past the last frame.
virtual reverse_iterator rbegin ()
 Get a reverse iterator to the last frame.
virtual const_reverse_iterator rbegin () const
 Get a reverse iterator to the last frame.
virtual reverse_iterator rend ()
 Get a reverse iterator to the position before the first frame.
virtual const_reverse_iterator rend () const
 Get a reverse iterator to the position before the first frame.
virtual bool empty () const
 Check if there are no frames.
virtual size_type count () const
 Get the number of frames.
virtual size_type max_count () const
 Get the maximum number of frames.
virtual void clear ()
 Remove all frames.
virtual void erase (iterator position)
 Erase the frame at the specified iterator.
virtual void erase (iterator first, iterator last)
 Erase a range of frames.
virtual void push_back (value_type const &value)
 Add a frame to this block.
virtual void resize (size_type count)
 Resizes the frames storage.
virtual void swap (BlockGroup &other)
 Swaps the contents of this block with another.

Protected Member Functions

virtual std::streamsize body_size () const
 Get the size of the body of this element.
virtual std::streamsize read_body (std::istream &input, std::streamsize size)
 Element body loading.
virtual std::streamsize write_body (std::ostream &output)
 Element body writing.
void reset ()
 Reset all values to their defaults.

Protected Attributes

BlockAdditions additions_
UIntElement duration_
UIntElement ref_priority_
std::vector< int16_t > ref_blocks_
BinaryElement codec_state_
BlockImpl block_

Friends

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

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 55 of file block_group.h.


Constructor & Destructor Documentation

tide::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& tide::BlockGroup::additions ( ) [inline]

Access the block additions property.

Definition at line 72 of file block_group.h.

virtual value_type& tide::BlockGroup::at ( size_type  pos) [inline, virtual]

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 tide::Block.

Definition at line 179 of file block_group.h.

virtual value_type const& tide::BlockGroup::at ( size_type  pos) const [inline, virtual]

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 tide::Block.

Definition at line 186 of file block_group.h.

virtual iterator tide::BlockGroup::begin ( ) [inline, virtual]

Get an iterator to the first frame.

Implements tide::Block.

Definition at line 207 of file block_group.h.

virtual const_iterator tide::BlockGroup::begin ( ) const [inline, virtual]

Get an iterator to the first frame.

Implements tide::Block.

Definition at line 209 of file block_group.h.

virtual std::streamsize tide::BlockGroup::body_size ( ) const [protected, virtual]

Get the size of the body of this element.

Implements tide::Element.

virtual void tide::BlockGroup::clear ( ) [inline, virtual]

Remove all frames.

Implements tide::Block.

Definition at line 247 of file block_group.h.

void tide::BlockGroup::codec_state ( std::vector< char > const &  codec_state) [inline]

Set the codec state for this block.

Definition at line 119 of file block_group.h.

std::vector<char> tide::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 116 of file block_group.h.

virtual size_type tide::BlockGroup::count ( ) const [inline, virtual]

Get the number of frames.

Implements tide::Block.

Definition at line 236 of file block_group.h.

uint64_t tide::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 87 of file block_group.h.

void tide::BlockGroup::duration ( uint64_t  duration) [inline]

Set the block's duration.

Definition at line 89 of file block_group.h.

virtual bool tide::BlockGroup::empty ( ) const [inline, virtual]

Check if there are no frames.

Empty blocks cannot be written. If this returns true, an error will occur when write() is called.

Implements tide::Block.

Definition at line 234 of file block_group.h.

virtual iterator tide::BlockGroup::end ( ) [inline, virtual]

Get an iterator to the position past the last frame.

Implements tide::Block.

Definition at line 211 of file block_group.h.

virtual const_iterator tide::BlockGroup::end ( ) const [inline, virtual]

Get an iterator to the position past the last frame.

Implements tide::Block.

Definition at line 213 of file block_group.h.

virtual void tide::BlockGroup::erase ( iterator  position) [inline, virtual]

Erase the frame at the specified iterator.

Parameters:
[in]positionThe position to erase at.

Implements tide::Block.

Definition at line 253 of file block_group.h.

virtual void tide::BlockGroup::erase ( iterator  first,
iterator  last 
) [inline, virtual]

Erase a range of frames.

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

Implements tide::Block.

Definition at line 259 of file block_group.h.

virtual bool tide::BlockGroup::invisible ( ) const [inline, virtual]

If this block is invisible.

Invisible blocks should be decoded by the codec (thus updating codec state) but not used for playback.

Implements tide::Block.

Definition at line 154 of file block_group.h.

virtual void tide::BlockGroup::invisible ( bool  invisible) [inline, virtual]

Set if this block is invisible.

Implements tide::Block.

Definition at line 156 of file block_group.h.

virtual void tide::BlockGroup::lacing ( LacingType  lacing) [inline, virtual]

Set the lacing type in use.

Implements tide::Block.

Definition at line 170 of file block_group.h.

virtual LacingType tide::BlockGroup::lacing ( ) const [inline, virtual]

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 tide::Block.

Definition at line 168 of file block_group.h.

virtual size_type tide::BlockGroup::max_count ( ) const [inline, virtual]

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 tide::Block.

Definition at line 244 of file block_group.h.

virtual value_type& tide::BlockGroup::operator[] ( size_type  pos) [inline, virtual]

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 tide::Block.

Definition at line 195 of file block_group.h.

virtual value_type const& tide::BlockGroup::operator[] ( size_type  pos) const [inline, virtual]

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 tide::Block.

Definition at line 203 of file block_group.h.

virtual void tide::BlockGroup::push_back ( value_type const &  value) [inline, virtual]

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 tide::Block.

Definition at line 274 of file block_group.h.

virtual reverse_iterator tide::BlockGroup::rbegin ( ) [inline, virtual]

Get a reverse iterator to the last frame.

Implements tide::Block.

Definition at line 215 of file block_group.h.

virtual const_reverse_iterator tide::BlockGroup::rbegin ( ) const [inline, virtual]

Get a reverse iterator to the last frame.

Implements tide::Block.

Definition at line 217 of file block_group.h.

virtual std::streamsize tide::BlockGroup::read_body ( std::istream &  input,
std::streamsize  size 
) [protected, virtual]

Element body loading.

Implements tide::Element.

std::vector<int16_t>& tide::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 108 of file block_group.h.

uint64_t tide::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 97 of file block_group.h.

void tide::BlockGroup::ref_priority ( uint64_t  ref_priority) [inline]

Set the block's reference priority.

Definition at line 99 of file block_group.h.

virtual reverse_iterator tide::BlockGroup::rend ( ) [inline, virtual]

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

Implements tide::Block.

Definition at line 222 of file block_group.h.

virtual const_reverse_iterator tide::BlockGroup::rend ( ) const [inline, virtual]

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

Implements tide::Block.

Definition at line 226 of file block_group.h.

void tide::BlockGroup::reset ( ) [protected]

Reset all values to their defaults.

virtual void tide::BlockGroup::resize ( size_type  count) [inline, virtual]

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 tide::Block.

Definition at line 292 of file block_group.h.

virtual void tide::BlockGroup::swap ( BlockGroup other) [virtual]

Swaps the contents of this block with another.

Parameters:
[in]otherThe other block to swap with.
virtual void tide::BlockGroup::timecode ( int16_t  timecode) [inline, virtual]

Set the block's timecode.

Implements tide::Block.

Definition at line 146 of file block_group.h.

virtual int16_t tide::BlockGroup::timecode ( ) const [inline, virtual]

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 tide::Block.

Definition at line 144 of file block_group.h.

virtual void tide::BlockGroup::track_number ( uint64_t  track_number) [inline, virtual]

Set the block's track number.

Implements tide::Block.

Definition at line 135 of file block_group.h.

virtual uint64_t tide::BlockGroup::track_number ( ) const [inline, virtual]

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 tide::Block.

Definition at line 132 of file block_group.h.

virtual std::streamsize tide::BlockGroup::write_body ( std::ostream &  output) [protected, virtual]

Element body writing.

Implements tide::Element.


Friends And Related Function Documentation

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

Equality operator.


Member Data Documentation

Definition at line 305 of file block_group.h.

Definition at line 310 of file block_group.h.

Definition at line 309 of file block_group.h.

Definition at line 306 of file block_group.h.

std::vector<int16_t> tide::BlockGroup::ref_blocks_ [protected]

Definition at line 308 of file block_group.h.

Definition at line 307 of file block_group.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines