|
1
|
1 #pragma once
|
|
|
2 #include "file_info_impl.h"
|
|
|
3
|
|
|
4 // Not everything is on #ifdef FOOBAR2000_HAVE_CHAPTERIZER
|
|
|
5 // Some things use chapter_list internally even if chapterizer is disabled
|
|
|
6
|
|
|
7 //! Interface for object storing list of chapters.
|
|
|
8 class NOVTABLE chapter_list {
|
|
|
9 public:
|
|
|
10 //! Returns number of chapters.
|
|
|
11 virtual t_size get_chapter_count() const = 0;
|
|
|
12 //! Queries description of specified chapter.
|
|
|
13 //! @param p_chapter Index of chapter to query, greater or equal zero and less than get_chapter_count() value. If p_chapter value is out of valid range, results are undefined (e.g. crash).
|
|
|
14 //! @returns reference to file_info object describing specified chapter (length part of file_info indicates distance between beginning of this chapter and next chapter mark). Returned reference value for temporary use only, becomes invalid after any non-const operation on the chapter_list object.
|
|
|
15 virtual const file_info & get_info(t_size p_chapter) const = 0;
|
|
|
16
|
|
|
17 //! Sets number of chapters.
|
|
|
18 virtual void set_chapter_count(t_size p_count) = 0;
|
|
|
19 //! Modifies description of specified chapter.
|
|
|
20 //! @param p_chapter Index of chapter to modify, greater or equal zero and less than get_chapter_count() value. If p_chapter value is out of valid range, results are undefined (e.g. crash).
|
|
|
21 //! @param p_info New chapter description. Note that length part of file_info is used to calculate chapter marks.
|
|
|
22 virtual void set_info(t_size p_chapter,const file_info & p_info) = 0;
|
|
|
23
|
|
|
24 //! Gets first track pregap - offset into audio at which first track begins.
|
|
|
25 //! Not every chapterizer supports this, see chapterizer::supports_pregaps()
|
|
|
26 virtual double get_pregap() const = 0;
|
|
|
27 //! Sets first track pregap - offset into audio at which first track begins.
|
|
|
28 //! Not every chapterizer supports this, see chapterizer::supports_pregaps()
|
|
|
29 virtual void set_pregap(double val) = 0;
|
|
|
30
|
|
|
31 //! Copies contents of specified chapter_list object to this object.
|
|
|
32 void copy(const chapter_list & p_source);
|
|
|
33
|
|
|
34 inline const chapter_list & operator=(const chapter_list & p_source) {copy(p_source); return *this;}
|
|
|
35
|
|
|
36 protected:
|
|
|
37 chapter_list() {}
|
|
|
38 ~chapter_list() {}
|
|
|
39 };
|
|
|
40
|
|
|
41 //! Implements chapter_list.
|
|
|
42 template<typename file_info_ = file_info_impl>
|
|
|
43 class chapter_list_impl_t : public chapter_list {
|
|
|
44 public:
|
|
|
45 chapter_list_impl_t() {}
|
|
|
46 typedef chapter_list_impl_t<file_info_> t_self;
|
|
|
47 chapter_list_impl_t(const chapter_list & p_source) : m_pregap() {copy(p_source);}
|
|
|
48 const t_self & operator=(const chapter_list & p_source) {copy(p_source); return *this;}
|
|
|
49
|
|
|
50 t_size get_chapter_count() const {return m_infos.get_size();}
|
|
|
51 const file_info & get_info(t_size p_chapter) const {return m_infos[p_chapter];}
|
|
|
52
|
|
|
53 void set_chapter_count(t_size p_count) {m_infos.set_size(p_count);}
|
|
|
54 void set_info(t_size p_chapter,const file_info & p_info) {m_infos[p_chapter] = p_info;}
|
|
|
55 file_info_ & get_info_(t_size p_chapter) {return m_infos[p_chapter];}
|
|
|
56
|
|
|
57 double get_pregap() const {return m_pregap;}
|
|
|
58 void set_pregap(double val) {PFC_ASSERT(val >= 0); m_pregap = val;}
|
|
|
59 private:
|
|
|
60 pfc::array_t<file_info_> m_infos;
|
|
|
61 double m_pregap = 0;
|
|
|
62 };
|
|
|
63
|
|
|
64 typedef chapter_list_impl_t<> chapter_list_impl;
|
|
|
65
|
|
|
66 #ifdef FOOBAR2000_HAVE_CHAPTERIZER
|
|
|
67
|
|
|
68 //! This service implements chapter list editing operations for various file formats, e.g. for MP4 chapters or CD images with embedded cuesheets. Used by converter "encode single file with chapters" feature.
|
|
|
69 class NOVTABLE chapterizer : public service_base {
|
|
|
70 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(chapterizer);
|
|
|
71 public:
|
|
|
72 //! Tests whether specified path is supported by this implementation.
|
|
|
73 virtual bool is_our_path(const char * p_path) = 0;
|
|
|
74
|
|
|
75 //! Writes new chapter list to specified file.
|
|
|
76 //! @param p_path Path of file to modify.
|
|
|
77 //! @param p_list New chapter list to write.
|
|
|
78 //! @param p_abort abort_callback object signaling user aborting the operation.
|
|
|
79 virtual void set_chapters(const char * p_path,chapter_list const & p_list,abort_callback & p_abort) = 0;
|
|
|
80 //! Retrieves chapter list from specified file.
|
|
|
81 //! @param p_path Path of file to examine.
|
|
|
82 //! @param p_list Object receiving chapter list.
|
|
|
83 //! @param p_abort abort_callback object signaling user aborting the operation.
|
|
|
84 virtual void get_chapters(const char * p_path,chapter_list & p_list,abort_callback & p_abort) = 0;
|
|
|
85
|
|
|
86 //! @returns Whether this chapterizer supports altering pregap before first track, see chapter_list::get_pregap() & set_pregap()
|
|
|
87 virtual bool supports_pregaps() = 0;
|
|
|
88
|
|
|
89 //! Static helper, tries to find chapterizer interface that supports specified file.
|
|
|
90 static bool g_find(service_ptr_t<chapterizer> & p_out,const char * p_path);
|
|
|
91
|
|
|
92 static bool g_is_pregap_capable(const char * p_path);
|
|
|
93 };
|
|
|
94
|
|
|
95 #endif
|