matroska_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 #ifndef _MATROSKA_SEGMENT_HPP_
00026 #define _MATROSKA_SEGMENT_HPP_
00027
00028 #include "mkv.hpp"
00029
00030
00031 #include "Ebml_parser.hpp"
00032
00033 class chapter_edition_c;
00034 class chapter_translation_c;
00035 class chapter_item_c;
00036
00037 class matroska_segment_c
00038 {
00039 public:
00040 matroska_segment_c( demux_sys_t & demuxer, EbmlStream & estream )
00041 :segment(NULL)
00042 ,es(estream)
00043 ,i_timescale(MKVD_TIMECODESCALE)
00044 ,i_duration(-1)
00045 ,i_start_time(0)
00046 ,i_seekhead_count(0)
00047 ,i_seekhead_position(-1)
00048 ,i_cues_position(-1)
00049 ,i_tracks_position(-1)
00050 ,i_info_position(-1)
00051 ,i_chapters_position(-1)
00052 ,i_tags_position(-1)
00053 ,i_attachments_position(-1)
00054 ,cluster(NULL)
00055 ,i_block_pos(0)
00056 ,i_cluster_pos(0)
00057 ,i_start_pos(0)
00058 ,p_segment_uid(NULL)
00059 ,p_prev_segment_uid(NULL)
00060 ,p_next_segment_uid(NULL)
00061 ,b_cues(false)
00062 ,i_index(0)
00063 ,i_index_max(1024)
00064 ,psz_muxing_application(NULL)
00065 ,psz_writing_application(NULL)
00066 ,psz_segment_filename(NULL)
00067 ,psz_title(NULL)
00068 ,psz_date_utc(NULL)
00069 ,i_default_edition(0)
00070 ,sys(demuxer)
00071 ,ep(NULL)
00072 ,b_preloaded(false)
00073 {
00074 p_indexes = (mkv_index_t*)malloc( sizeof( mkv_index_t ) * i_index_max );
00075 }
00076
00077 virtual ~matroska_segment_c();
00078
00079 KaxSegment *segment;
00080 EbmlStream & es;
00081
00082
00083 uint64_t i_timescale;
00084
00085
00086 mtime_t i_duration;
00087 mtime_t i_start_time;
00088
00089
00090 std::vector<mkv_track_t*> tracks;
00091
00092
00093 int i_seekhead_count;
00094 int64_t i_seekhead_position;
00095 int64_t i_cues_position;
00096 int64_t i_tracks_position;
00097 int64_t i_info_position;
00098 int64_t i_chapters_position;
00099 int64_t i_tags_position;
00100 int64_t i_attachments_position;
00101
00102 KaxCluster *cluster;
00103 uint64 i_block_pos;
00104 uint64 i_cluster_pos;
00105 int64_t i_start_pos;
00106 KaxSegmentUID *p_segment_uid;
00107 KaxPrevUID *p_prev_segment_uid;
00108 KaxNextUID *p_next_segment_uid;
00109
00110 bool b_cues;
00111 int i_index;
00112 int i_index_max;
00113 mkv_index_t *p_indexes;
00114
00115
00116 char *psz_muxing_application;
00117 char *psz_writing_application;
00118 char *psz_segment_filename;
00119 char *psz_title;
00120 char *psz_date_utc;
00121
00122
00123
00124
00125 std::vector<chapter_edition_c*> stored_editions;
00126 int i_default_edition;
00127
00128 std::vector<chapter_translation_c*> translations;
00129 std::vector<KaxSegmentFamily*> families;
00130
00131 demux_sys_t & sys;
00132 EbmlParser *ep;
00133 bool b_preloaded;
00134
00135 bool Preload( );
00136 bool LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int64_t i_element_position );
00137 bool PreloadFamily( const matroska_segment_c & segment );
00138 void ParseInfo( KaxInfo *info );
00139 void ParseAttachments( KaxAttachments *attachments );
00140 void ParseChapters( KaxChapters *chapters );
00141 void ParseSeekHead( KaxSeekHead *seekhead );
00142 void ParseTracks( KaxTracks *tracks );
00143 void ParseChapterAtom( int i_level, KaxChapterAtom *ca, chapter_item_c & chapters );
00144 void ParseTrackEntry( KaxTrackEntry *m );
00145 void ParseCluster( );
00146 void IndexAppendCluster( KaxCluster *cluster );
00147 void LoadCues( KaxCues *cues );
00148 void LoadTags( KaxTags *tags );
00149 void InformationCreate( );
00150 void Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_global_position );
00151 int BlockGet( KaxBlock * &, KaxSimpleBlock * &, bool *, bool *, int64_t *);
00152
00153 int BlockFindTrackIndex( size_t *pi_track,
00154 const KaxBlock *, const KaxSimpleBlock * );
00155
00156
00157 bool Select( mtime_t i_start_time );
00158 void UnSelect( );
00159
00160 static bool CompareSegmentUIDs( const matroska_segment_c * item_a, const matroska_segment_c * item_b );
00161 };
00162
00163
00164 #endif