vlc | branch: master | Jean-Baptiste Kempf <[email protected]> | Sun May 22 02:18:03 2011 +0200| [c42f411638b51c95276c627b7917a866856324fc] | committer: Jean-Baptiste Kempf
MKV: privatize methods in virtual_segment_t > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c42f411638b51c95276c627b7917a866856324fc --- modules/demux/mkv/demux.cpp | 26 +++-------------- modules/demux/mkv/virtual_segment.cpp | 49 ++++++++++++++++++++++----------- modules/demux/mkv/virtual_segment.hpp | 34 +++++++++++++--------- 3 files changed, 58 insertions(+), 51 deletions(-) diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp index 13ae5e0..2afeceb 100644 --- a/modules/demux/mkv/demux.cpp +++ b/modules/demux/mkv/demux.cpp @@ -660,23 +660,23 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment ) for ( i=0; i< used_segments.size(); i++ ) { p_seg = used_segments[i]; - if ( p_seg->p_editions != NULL ) + if ( p_seg->Editions() != NULL ) { input_title_t *p_title = vlc_input_title_New(); p_seg->i_sys_title = i; int i_chapters; // TODO use a name for each edition, let the TITLE deal with a codec name - for ( j=0; j<p_seg->p_editions->size(); j++ ) + for ( j=0; j<p_seg->Editions()->size(); j++ ) { if ( p_title->psz_name == NULL ) { - const char* psz_tmp = (*p_seg->p_editions)[j]->GetMainName().c_str(); + const char* psz_tmp = (*p_seg->Editions())[j]->GetMainName().c_str(); if( *psz_tmp != '\0' ) p_title->psz_name = strdup( psz_tmp ); } - chapter_edition_c *p_edition = (*p_seg->p_editions)[j]; + chapter_edition_c *p_edition = (*p_seg->Editions())[j]; i_chapters = 0; p_edition->PublishChapters( *p_title, i_chapters, 0 ); @@ -708,24 +708,8 @@ bool demux_sys_t::IsUsedSegment( matroska_segment_c &segment ) const virtual_segment_c *demux_sys_t::VirtualFromSegments( matroska_segment_c *p_segment ) const { - size_t i_preloaded, i; - virtual_segment_c *p_result = new virtual_segment_c( p_segment ); - - // fill our current virtual segment with all hard linked segments - do { - i_preloaded = 0; - for ( i=0; i< opened_segments.size(); i++ ) - { - i_preloaded += p_result->AddSegment( opened_segments[i] ); - } - } while ( i_preloaded ); // worst case: will stop when all segments are found as linked - - p_result->Sort( ); - - p_result->PreloadLinked( ); - - p_result->PrepareChapters( ); + p_result->AddSegments( opened_segments ); return p_result; } diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp index a0bf289..c3bfc7b 100644 --- a/modules/demux/mkv/virtual_segment.cpp +++ b/modules/demux/mkv/virtual_segment.cpp @@ -54,50 +54,50 @@ void virtual_segment_c::PrepareChapters( ) bool virtual_segment_c::UpdateCurrentToChapter( demux_t & demux ) { demux_sys_t & sys = *demux.p_sys; - chapter_item_c *psz_curr_chapter; + chapter_item_c *p_curr_chapter; bool b_has_seeked = false; /* update current chapter/seekpoint */ if ( p_editions->size() ) { /* 1st, we need to know in which chapter we are */ - psz_curr_chapter = (*p_editions)[i_current_edition]->FindTimecode( sys.i_pts, psz_current_chapter ); + p_curr_chapter = (*p_editions)[i_current_edition]->FindTimecode( sys.i_pts, p_current_chapter ); /* we have moved to a new chapter */ - if (psz_curr_chapter != NULL && psz_current_chapter != psz_curr_chapter) + if (p_curr_chapter != NULL && p_current_chapter != p_curr_chapter) { if ( (*p_editions)[i_current_edition]->b_ordered ) { // Leave/Enter up to the link point - b_has_seeked = psz_curr_chapter->EnterAndLeave( psz_current_chapter ); + b_has_seeked = p_curr_chapter->EnterAndLeave( p_current_chapter ); if ( !b_has_seeked ) { // only physically seek if necessary - if ( psz_current_chapter == NULL || (psz_current_chapter->i_end_time != psz_curr_chapter->i_start_time) ) - Seek( demux, sys.i_pts, 0, psz_curr_chapter, -1 ); + if ( p_current_chapter == NULL || (p_current_chapter->i_end_time != p_curr_chapter->i_start_time) ) + Seek( demux, sys.i_pts, 0, p_curr_chapter, -1 ); } } - + if ( !b_has_seeked ) { - psz_current_chapter = psz_curr_chapter; - if ( psz_curr_chapter->i_seekpoint_num > 0 ) + p_current_chapter = p_curr_chapter; + if ( p_curr_chapter->i_seekpoint_num > 0 ) { demux.info.i_update |= INPUT_UPDATE_TITLE | INPUT_UPDATE_SEEKPOINT; demux.info.i_title = sys.i_current_title = i_sys_title; - demux.info.i_seekpoint = psz_curr_chapter->i_seekpoint_num - 1; + demux.info.i_seekpoint = p_curr_chapter->i_seekpoint_num - 1; } } return true; } - else if (psz_curr_chapter == NULL) + else if (p_curr_chapter == NULL) { // out of the scope of the data described by chapters, leave the edition - if ( (*p_editions)[i_current_edition]->b_ordered && psz_current_chapter != NULL ) + if ( (*p_editions)[i_current_edition]->b_ordered && p_current_chapter != NULL ) { - if ( !(*p_editions)[i_current_edition]->EnterAndLeave( psz_current_chapter, false ) ) - psz_current_chapter = NULL; + if ( !(*p_editions)[i_current_edition]->EnterAndLeave( p_current_chapter, false ) ) + p_current_chapter = NULL; else return true; } @@ -214,13 +214,13 @@ void virtual_segment_c::Seek( demux_t & demuxer, mtime_t i_date, mtime_t i_time_ if ( Edition() && Edition()->b_ordered ) { /* 1st, we need to know in which chapter we are */ - psz_chapter = (*p_editions)[i_current_edition]->FindTimecode( i_date, psz_current_chapter ); + psz_chapter = (*p_editions)[i_current_edition]->FindTimecode( i_date, p_current_chapter ); } } if ( psz_chapter != NULL ) { - psz_current_chapter = psz_chapter; + p_current_chapter = psz_chapter; p_sys->i_chapter_time = i_time_offset = psz_chapter->i_user_start_time - psz_chapter->i_start_time; if ( psz_chapter->i_seekpoint_num > 0 ) { @@ -262,3 +262,20 @@ chapter_item_c *virtual_segment_c::FindChapter( int64_t i_find_uid ) } return NULL; } + +void virtual_segment_c::AddSegments(std::vector<matroska_segment_c *> segments) +{ + // fill our current virtual segment with all hard linked segments + size_t i_preloaded; + do { + i_preloaded = 0; + for ( size_t i=0; i < segments.size(); i++ ) + { + i_preloaded += AddSegment( segments[i] ); + } + } while ( i_preloaded ); // worst case: will stop when all segments are found as linked + + Sort(); + PreloadLinked( ); + PrepareChapters( ); +} diff --git a/modules/demux/mkv/virtual_segment.hpp b/modules/demux/mkv/virtual_segment.hpp index bafbb58..0c1775e 100644 --- a/modules/demux/mkv/virtual_segment.hpp +++ b/modules/demux/mkv/virtual_segment.hpp @@ -36,11 +36,11 @@ class virtual_segment_c { public: virtual_segment_c( matroska_segment_c *p_segment ) - :p_editions(NULL) - ,i_sys_title(0) + :i_sys_title(0) ,i_current_segment(0) ,i_current_edition(-1) - ,psz_current_chapter(NULL) + ,p_current_chapter(NULL) + ,p_editions(NULL) { linked_segments.push_back( p_segment ); @@ -49,18 +49,19 @@ public: AppendUID( p_segment->p_next_segment_uid ); } - void Sort(); - size_t AddSegment( matroska_segment_c *p_segment ); - void PreloadLinked( ); - mtime_t Duration( ) const; + void AddSegments( std::vector<matroska_segment_c*> segments ); + void Seek( demux_t & demuxer, mtime_t i_date, mtime_t i_time_offset, chapter_item_c *psz_chapter, int64_t i_global_position ); + mtime_t Duration() const; + inline chapter_edition_c *Edition() { if ( i_current_edition >= 0 && size_t(i_current_edition) < p_editions->size() ) return (*p_editions)[i_current_edition]; return NULL; } + std::vector<chapter_edition_c*>* Editions() const { return p_editions; }; matroska_segment_c * Segment() const { @@ -69,9 +70,7 @@ public: return linked_segments[i_current_segment]; } - inline chapter_item_c *CurrentChapter() { - return psz_current_chapter; - } + chapter_item_c *CurrentChapter() { return p_current_chapter; } bool SelectNext() { @@ -93,16 +92,15 @@ public: return false; } + chapter_item_c *FindChapter( int64_t i_find_uid ); + bool UpdateCurrentToChapter( demux_t & demux ); - void PrepareChapters( ); chapter_item_c *BrowseCodecPrivate( unsigned int codec_id, bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ), const void *p_cookie, size_t i_cookie_size ); - chapter_item_c *FindChapter( int64_t i_find_uid ); - std::vector<chapter_edition_c*> *p_editions; int i_sys_title; protected: @@ -111,9 +109,17 @@ protected: size_t i_current_segment; int i_current_edition; - chapter_item_c *psz_current_chapter; + chapter_item_c *p_current_chapter; + + std::vector<chapter_edition_c*> *p_editions; void AppendUID( const EbmlBinary * UID ); + +private: + void Sort(); + size_t AddSegment( matroska_segment_c *p_segment ); + void PreloadLinked( ); + void PrepareChapters( ); }; #endif _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
