]> git.sesse.net Git - vlc/blob - modules/demux/mkv/chapters.hpp
Use var_InheritString for --decklink-video-connection.
[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     ,psz_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 = 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 ),
74                                     const void *p_cookie,
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;
79  
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;
83     int                         i_seekpoint_num;
84     int64_t                     i_uid;
85     bool                        b_display_seekpoint;
86     bool                        b_user_display;
87     std::string                 psz_name;
88     chapter_item_c              *psz_parent;
89     bool                        b_is_leaving;
90  
91     std::vector<chapter_codec_cmds_c*> codecs;
92
93     static bool CompareTimecode( const chapter_item_c * itemA, const chapter_item_c * itemB )
94     {
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) );
96     }
97
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 );
101 };
102
103 class chapter_edition_c : public chapter_item_c
104 {
105 public:
106     chapter_edition_c()
107     :b_ordered(false)
108     {}
109  
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 );
114  
115     bool                        b_ordered;
116 };
117
118 #endif