chapters.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * chapters.hpp : matroska demuxer
00003  *****************************************************************************
00004  * Copyright (C) 2003-2004 the VideoLAN team
00005  * $Id$
00006  *
00007  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
00008  *          Steve Lhomme <steve.lhomme@free.fr>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 /* chapter_item, chapter_edition, and chapter_translation classes */
00026 
00027 #ifndef _CHAPTER_H_
00028 #define _CHAPTER_H_
00029 
00030 #include "mkv.hpp"
00031 
00032 class chapter_translation_c
00033 {
00034 public:
00035     chapter_translation_c()
00036         :p_translated(NULL)
00037     {}
00038 
00039     ~chapter_translation_c()
00040     {
00041         delete p_translated;
00042     }
00043 
00044     KaxChapterTranslateID  *p_translated;
00045     unsigned int           codec_id;
00046     std::vector<uint64_t>  editions;
00047 };
00048 
00049 class chapter_codec_cmds_c;
00050 class chapter_item_c
00051 {
00052 public:
00053     chapter_item_c()
00054     :i_start_time(0)
00055     ,i_end_time(-1)
00056     ,i_user_start_time(-1)
00057     ,i_user_end_time(-1)
00058     ,i_seekpoint_num(-1)
00059     ,b_display_seekpoint(true)
00060     ,b_user_display(false)
00061     ,psz_parent(NULL)
00062     ,b_is_leaving(false)
00063     {}
00064 
00065     virtual ~chapter_item_c();
00066 
00067     int64_t RefreshChapters( bool b_ordered, int64_t i_prev_user_time );
00068     int PublishChapters( input_title_t & title, int & i_user_chapters, int i_level = 0 );
00069     virtual chapter_item_c * FindTimecode( mtime_t i_timecode, const chapter_item_c * p_current, bool & b_found );
00070     void Append( const chapter_item_c & edition );
00071     chapter_item_c * FindChapter( int64_t i_find_uid );
00072     virtual chapter_item_c *BrowseCodecPrivate( unsigned int codec_id,
00073                                     bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ),
00074                                     const void *p_cookie,
00075                                     size_t i_cookie_size );
00076     std::string                 GetCodecName( bool f_for_title = false ) const;
00077     bool                        ParentOf( const chapter_item_c & item ) const;
00078     int16                       GetTitleNumber( ) const;
00079  
00080     int64_t                     i_start_time, i_end_time;
00081     int64_t                     i_user_start_time, i_user_end_time; /* the time in the stream when an edition is ordered */
00082     std::vector<chapter_item_c*> sub_chapters;
00083     int                         i_seekpoint_num;
00084     int64_t                     i_uid;
00085     bool                        b_display_seekpoint;
00086     bool                        b_user_display;
00087     std::string                 psz_name;
00088     chapter_item_c              *psz_parent;
00089     bool                        b_is_leaving;
00090  
00091     std::vector<chapter_codec_cmds_c*> codecs;
00092 
00093     static bool CompareTimecode( const chapter_item_c * itemA, const chapter_item_c * itemB )
00094     {
00095         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) );
00096     }
00097 
00098     bool Enter( bool b_do_subchapters );
00099     bool Leave( bool b_do_subchapters );
00100     bool EnterAndLeave( chapter_item_c *p_item, bool b_enter = true );
00101 };
00102 
00103 class chapter_edition_c : public chapter_item_c
00104 {
00105 public:
00106     chapter_edition_c()
00107     :b_ordered(false)
00108     {}
00109  
00110     void RefreshChapters( );
00111     mtime_t Duration() const;
00112     std::string GetMainName() const;
00113     chapter_item_c * FindTimecode( mtime_t i_timecode, const chapter_item_c * p_current );
00114  
00115     bool                        b_ordered;
00116 };
00117 
00118 #endif

Generated on Tue May 25 08:04:55 2010 for VLC by  doxygen 1.5.6