1 /*****************************************************************************
2 * chapters.hpp : matroska demuxer
3 *****************************************************************************
4 * Copyright (C) 2003-2004 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Steve Lhomme <steve.lhomme@free.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /* chapter_item, chapter_edition, and chapter_translation classes */
32 class chapter_translation_c
35 chapter_translation_c()
39 ~chapter_translation_c()
44 KaxChapterTranslateID *p_translated;
45 unsigned int codec_id;
46 std::vector<uint64_t> editions;
49 class chapter_codec_cmds_c;
56 ,i_user_start_time(-1)
59 ,b_display_seekpoint(true)
60 ,b_user_display(false)
65 virtual ~chapter_item_c();
67 int64_t RefreshChapters( bool b_ordered, int64_t i_prev_user_time );
68 int PublishChapters( input_title_t & title, int & i_user_chapters, int i_level = 0 );
69 virtual chapter_item_c * FindTimecode( mtime_t i_timecode, const chapter_item_c * p_current, bool & b_found );
70 void Append( const chapter_item_c & edition );
71 chapter_item_c * FindChapter( int64_t i_find_uid );
72 virtual chapter_item_c *BrowseCodecPrivate( unsigned int codec_id,
73 bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ),
75 size_t i_cookie_size );
76 std::string GetCodecName( bool f_for_title = false ) const;
77 bool ParentOf( const chapter_item_c & item ) const;
78 int16 GetTitleNumber( ) const;
80 int64_t i_start_time, i_end_time;
81 int64_t i_user_start_time, i_user_end_time; /* the time in the stream when an edition is ordered */
82 std::vector<chapter_item_c*> sub_chapters;
85 bool b_display_seekpoint;
88 chapter_item_c *psz_parent;
91 std::vector<chapter_codec_cmds_c*> codecs;
93 static bool CompareTimecode( const chapter_item_c * itemA, const chapter_item_c * itemB )
95 return ( itemA->i_user_start_time < itemB->i_user_start_time || (itemA->i_user_start_time == itemB->i_user_start_time && itemA->i_user_end_time < itemB->i_user_end_time) );
98 bool Enter( bool b_do_subchapters );
99 bool Leave( bool b_do_subchapters );
100 bool EnterAndLeave( chapter_item_c *p_item, bool b_enter = true );
103 class chapter_edition_c : public chapter_item_c
110 void RefreshChapters( );
111 mtime_t Duration() const;
112 std::string GetMainName() const;
113 chapter_item_c * FindTimecode( mtime_t i_timecode, const chapter_item_c * p_current );