virtual_segment.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _VIRTUAL_SEGMENT_HPP_
00027 #define _VIRTUAL_SEGMENT_HPP_
00028
00029 #include "mkv.hpp"
00030
00031 #include "matroska_segment.hpp"
00032 #include "chapters.hpp"
00033
00034
00035 class virtual_segment_c
00036 {
00037 public:
00038 virtual_segment_c( matroska_segment_c *p_segment )
00039 :p_editions(NULL)
00040 ,i_sys_title(0)
00041 ,i_current_segment(0)
00042 ,i_current_edition(-1)
00043 ,psz_current_chapter(NULL)
00044 {
00045 linked_segments.push_back( p_segment );
00046
00047 AppendUID( p_segment->p_segment_uid );
00048 AppendUID( p_segment->p_prev_segment_uid );
00049 AppendUID( p_segment->p_next_segment_uid );
00050 }
00051
00052 void Sort();
00053 size_t AddSegment( matroska_segment_c *p_segment );
00054 void PreloadLinked( );
00055 mtime_t Duration( ) const;
00056 void Seek( demux_t & demuxer, mtime_t i_date, mtime_t i_time_offset, chapter_item_c *psz_chapter, int64_t i_global_position );
00057
00058 inline chapter_edition_c *Edition()
00059 {
00060 if ( i_current_edition >= 0 && size_t(i_current_edition) < p_editions->size() )
00061 return (*p_editions)[i_current_edition];
00062 return NULL;
00063 }
00064
00065 matroska_segment_c * Segment() const
00066 {
00067 if ( linked_segments.size() == 0 || i_current_segment >= linked_segments.size() )
00068 return NULL;
00069 return linked_segments[i_current_segment];
00070 }
00071
00072 inline chapter_item_c *CurrentChapter() {
00073 return psz_current_chapter;
00074 }
00075
00076 bool SelectNext()
00077 {
00078 if ( i_current_segment < linked_segments.size()-1 )
00079 {
00080 i_current_segment++;
00081 return true;
00082 }
00083 return false;
00084 }
00085
00086 bool FindUID( KaxSegmentUID & uid ) const
00087 {
00088 for ( size_t i=0; i<linked_uids.size(); i++ )
00089 {
00090 if ( linked_uids[i] == uid )
00091 return true;
00092 }
00093 return false;
00094 }
00095
00096 bool UpdateCurrentToChapter( demux_t & demux );
00097 void PrepareChapters( );
00098
00099 chapter_item_c *BrowseCodecPrivate( unsigned int codec_id,
00100 bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ),
00101 const void *p_cookie,
00102 size_t i_cookie_size );
00103 chapter_item_c *FindChapter( int64_t i_find_uid );
00104
00105 std::vector<chapter_edition_c*> *p_editions;
00106 int i_sys_title;
00107
00108 protected:
00109 std::vector<matroska_segment_c*> linked_segments;
00110 std::vector<KaxSegmentUID> linked_uids;
00111 size_t i_current_segment;
00112
00113 int i_current_edition;
00114 chapter_item_c *psz_current_chapter;
00115
00116 void AppendUID( const EbmlBinary * UID );
00117 };
00118
00119 #endif