]> git.sesse.net Git - vlc/blob - modules/demux/mkv/chapters.hpp
MKV: misc simplifications, renaming and privatizations
[vlc] / modules / demux / mkv / chapters.hpp
1 /*****************************************************************************
2  * chapters.hpp : matroska demuxer
3  *****************************************************************************
4  * Copyright (C) 2003-2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *          Steve Lhomme <steve.lhomme@free.fr>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 /* chapter_item, chapter_edition, and chapter_translation classes */
26
27 #ifndef _CHAPTER_H_
28 #define _CHAPTER_H_
29
30 #include "mkv.hpp"
31
32 class chapter_translation_c
33 {
34 public:
35     chapter_translation_c()
36         :p_translated(NULL)
37     {}
38
39     ~chapter_translation_c()
40     {
41         delete p_translated;
42     }
43
44     KaxChapterTranslateID  *p_translated;
45     unsigned int           codec_id;
46     std::vector<uint64_t>  editions;
47 };
48
49 class chapter_codec_cmds_c;
50 class chapter_item_c
51 {
52 public:
53     chapter_item_c()
54     :i_start_time(0)
55     ,i_end_time(-1)
56     ,i_user_start_time(-1)
57     ,i_user_end_time(-1)
58     ,i_seekpoint_num(-1)
59     ,b_display_seekpoint(true)
60     ,b_user_display(false)
61     ,p_parent(NULL)
62     ,b_is_leaving(false)
63     {}
64
65     virtual ~chapter_item_c();
66
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 );
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
73     virtual chapter_item_c *BrowseCodecPrivate( unsigned int codec_id,
74                                     bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ),
75                                     const void *p_cookie,
76                                     size_t i_cookie_size );
77     std::string                 GetCodecName( bool f_for_title = false ) const;
78     bool                        ParentOf( const chapter_item_c & item ) const;
79     int16                       GetTitleNumber( ) const;
80
81     int64_t                     i_start_time, i_end_time;
82     int64_t                     i_user_start_time, i_user_end_time; /* the time in the stream when an edition is ordered */
83     std::vector<chapter_item_c*> sub_chapters;
84     int                         i_seekpoint_num;
85     int64_t                     i_uid;
86     bool                        b_display_seekpoint;
87     bool                        b_user_display;
88     std::string                 psz_name;
89     chapter_item_c              *p_parent;
90     bool                        b_is_leaving;
91
92     std::vector<chapter_codec_cmds_c*> codecs;
93
94     static bool CompareTimecode( const chapter_item_c * itemA, const chapter_item_c * itemB )
95     {
96         return ( itemA->i_user_start_time < itemB->i_user_start_time ||
97                 (itemA->i_user_start_time == itemB->i_user_start_time && itemA->i_user_end_time < itemB->i_user_end_time) );
98     }
99
100     bool Enter( bool b_do_subchapters );
101     bool Leave( bool b_do_subchapters );
102     bool EnterAndLeave( chapter_item_c *p_item, bool b_enter = true );
103 };
104
105 class chapter_edition_c : public chapter_item_c
106 {
107 public:
108     chapter_edition_c()
109     :b_ordered(false)
110     {}
111
112     void RefreshChapters( );
113     mtime_t Duration() const;
114     std::string GetMainName() const;
115     chapter_item_c * FindTimecode( mtime_t i_timecode, const chapter_item_c * p_current );
116
117     bool                        b_ordered;
118 };
119
120 #endif