|
1
|
1 #pragma once
|
|
|
2
|
|
|
3 #include <functional>
|
|
|
4 #include "commonObjects.h"
|
|
|
5 #include "exception_io.h"
|
|
|
6 #include "filesystem.h"
|
|
|
7 #include "metadb.h"
|
|
|
8
|
|
|
9 namespace fb2k {
|
|
|
10 class image;
|
|
|
11 }
|
|
|
12 //! Namespace containing identifiers of album art types.
|
|
|
13 namespace album_art_ids {
|
|
|
14 //! Front cover.
|
|
|
15 static constexpr GUID cover_front = { 0xf1e66f4e, 0xfe09, 0x4b94, { 0x91, 0xa3, 0x67, 0xc2, 0x3e, 0xd1, 0x44, 0x5e } };
|
|
|
16 //! Back cover.
|
|
|
17 static constexpr GUID cover_back = { 0xcb552d19, 0x86d5, 0x434c, { 0xac, 0x77, 0xbb, 0x24, 0xed, 0x56, 0x7e, 0xe4 } };
|
|
|
18 //! Picture of a disc or other storage media.
|
|
|
19 static constexpr GUID disc = { 0x3dba9f36, 0xf928, 0x4fa4, { 0x87, 0x9c, 0xd3, 0x40, 0x47, 0x59, 0x58, 0x7e } };
|
|
|
20 //! Album-specific icon (NOT a file type icon).
|
|
|
21 static constexpr GUID icon = { 0x74cdf5b4, 0x7053, 0x4b3d, { 0x9a, 0x3c, 0x54, 0x69, 0xf5, 0x82, 0x6e, 0xec } };
|
|
|
22 //! Artist picture.
|
|
|
23 static constexpr GUID artist = { 0x9a654042, 0xacd1, 0x43f7, { 0xbf, 0xcf, 0xd3, 0xec, 0xf, 0xfe, 0x40, 0xfa } };
|
|
|
24
|
|
|
25 size_t num_types();
|
|
|
26 GUID query_type( size_t );
|
|
|
27 // returns lowercase name
|
|
|
28 const char * query_name( size_t );
|
|
|
29 const char * name_of( const GUID & );
|
|
|
30 const char * name_of_ex( const GUID &, const char * def = "undefined");
|
|
|
31 // returns Capitalized name
|
|
|
32 const char * query_capitalized_name( size_t );
|
|
|
33 const char * capitalized_name_of( const GUID & );
|
|
|
34
|
|
|
35 GUID by_name(const char*);
|
|
|
36 };
|
|
|
37
|
|
|
38 PFC_DECLARE_EXCEPTION(exception_album_art_not_found,exception_io_not_found,"Attached picture not found");
|
|
|
39 PFC_DECLARE_EXCEPTION(exception_album_art_unsupported_entry,exception_io_data,"Unsupported attached picture entry");
|
|
|
40
|
|
|
41 PFC_DECLARE_EXCEPTION(exception_album_art_unsupported_format,exception_io_data,"Attached picture operations not supported for this file format");
|
|
|
42
|
|
|
43 //! Class encapsulating access to album art stored in a media file. Use album_art_extractor class obtain album_art_extractor_instance referring to specified media file.
|
|
|
44 class NOVTABLE album_art_extractor_instance : public service_base {
|
|
|
45 FB2K_MAKE_SERVICE_INTERFACE(album_art_extractor_instance,service_base);
|
|
|
46 public:
|
|
|
47 //! Throws exception_album_art_not_found when the requested album art entry could not be found in the referenced media file.
|
|
|
48 virtual album_art_data_ptr query(const GUID & p_what,abort_callback & p_abort) = 0;
|
|
|
49
|
|
|
50 bool have_entry( const GUID & what, abort_callback & abort );
|
|
|
51 bool query(const GUID & what, album_art_data::ptr & out, abort_callback & abort);
|
|
|
52
|
|
|
53 //! Future compatiblity, load directly to fb2k::image
|
|
|
54 //! Might be eventually specialized for operating system supported formats
|
|
|
55 service_ptr_t<fb2k::image> query_image_(const GUID &, abort_callback&);
|
|
|
56 };
|
|
|
57
|
|
|
58 //! Class encapsulating access to album art stored in a media file. Use album_art_editor class to obtain album_art_editor_instance referring to specified media file.
|
|
|
59 class NOVTABLE album_art_editor_instance : public album_art_extractor_instance {
|
|
|
60 FB2K_MAKE_SERVICE_INTERFACE(album_art_editor_instance,album_art_extractor_instance);
|
|
|
61 public:
|
|
|
62 //! Throws exception_album_art_unsupported_entry when the file format we're dealing with does not support specific entry.
|
|
|
63 virtual void set(const GUID & p_what,album_art_data_ptr p_data,abort_callback & p_abort) = 0;
|
|
|
64
|
|
|
65 //! Removes the requested entry. Fails silently when the entry doesn't exist.
|
|
|
66 virtual void remove(const GUID & p_what) = 0;
|
|
|
67
|
|
|
68 //! Finalizes file tag update operation.
|
|
|
69 virtual void commit(abort_callback & p_abort) = 0;
|
|
|
70
|
|
|
71 //! Helper; see album_art_editor_instance_v2::remove_all();
|
|
|
72 void remove_all_();
|
|
|
73 };
|
|
|
74
|
|
|
75 //! Extension to album_art_editor_instance, adds remove_all().
|
|
|
76 class NOVTABLE album_art_editor_instance_v2 : public album_art_editor_instance {
|
|
|
77 FB2K_MAKE_SERVICE_INTERFACE(album_art_editor_instance_v2, album_art_editor_instance);
|
|
|
78 public:
|
|
|
79 //! Tells the editor to remove all entries, including unsupported picture types that do not translate to fb2k ids.
|
|
|
80 virtual void remove_all() = 0;
|
|
|
81 };
|
|
|
82
|
|
|
83 typedef service_ptr_t<album_art_extractor_instance> album_art_extractor_instance_ptr;
|
|
|
84 typedef service_ptr_t<album_art_editor_instance> album_art_editor_instance_ptr;
|
|
|
85
|
|
|
86 //! Entrypoint class for accessing album art extraction functionality. Register your own implementation to allow album art extraction from your media file format. \n
|
|
|
87 //! If you want to extract album art from a media file, it's recommended that you use album_art_manager API instead of calling album_art_extractor directly.
|
|
|
88 class NOVTABLE album_art_extractor : public service_base {
|
|
|
89 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_extractor);
|
|
|
90 public:
|
|
|
91 //! Returns whether the specified file is one of formats supported by our album_art_extractor implementation.
|
|
|
92 //! @param p_path Path to file being queried.
|
|
|
93 //! @param p_extension Extension of file being queried (also present in p_path parameter) - provided as a separate parameter for performance reasons.
|
|
|
94 virtual bool is_our_path(const char * p_path,const char * p_extension) = 0;
|
|
|
95
|
|
|
96 //! Instantiates album_art_extractor_instance providing access to album art stored in a specified media file. \n
|
|
|
97 //! Throws one of I/O exceptions on failure; exception_album_art_not_found when the file has no album art record at all.
|
|
|
98 //! @param p_filehint Optional; specifies a file interface to use for accessing the specified file; can be null - in that case, the implementation will open and close the file internally.
|
|
|
99 virtual album_art_extractor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) = 0;
|
|
|
100
|
|
|
101 static bool g_get_interface(service_ptr_t<album_art_extractor> & out,const char * path);
|
|
|
102 static bool g_is_supported_path(const char * path);
|
|
|
103 static album_art_extractor_instance_ptr g_open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort);
|
|
|
104 static album_art_extractor_instance_ptr g_open_allowempty(file_ptr p_filehint,const char * p_path,abort_callback & p_abort);
|
|
|
105
|
|
|
106 //! Returns GUID of the corresponding input class. Null GUID if none.
|
|
|
107 GUID get_guid();
|
|
|
108 };
|
|
|
109
|
|
|
110 //! \since 1.5
|
|
|
111 class NOVTABLE album_art_extractor_v2 : public album_art_extractor {
|
|
|
112 FB2K_MAKE_SERVICE_INTERFACE(album_art_extractor_v2 , album_art_extractor);
|
|
|
113 public:
|
|
|
114 //! Returns GUID of the corresponding input class. Null GUID if none.
|
|
|
115 virtual GUID get_guid() = 0;
|
|
|
116 };
|
|
|
117
|
|
|
118 //! Entrypoint class for accessing album art editing functionality. Register your own implementation to allow album art editing on your media file format.
|
|
|
119 class NOVTABLE album_art_editor : public service_base {
|
|
|
120 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_editor);
|
|
|
121 public:
|
|
|
122 //! Returns whether the specified file is one of formats supported by our album_art_editor implementation.
|
|
|
123 //! @param p_path Path to file being queried.
|
|
|
124 //! @param p_extension Extension of file being queried (also present in p_path parameter) - provided as a separate parameter for performance reasons.
|
|
|
125 virtual bool is_our_path(const char * p_path,const char * p_extension) = 0;
|
|
|
126
|
|
|
127 //! Instantiates album_art_editor_instance providing access to album art stored in a specified media file. \n
|
|
|
128 //! @param p_filehint Optional; specifies a file interface to use for accessing the specified file; can be null - in that case, the implementation will open and close the file internally.
|
|
|
129 virtual album_art_editor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) = 0;
|
|
|
130
|
|
|
131 //! Helper; attempts to retrieve an album_art_editor service pointer that supports the specified file.
|
|
|
132 //! @returns True on success, false on failure (no registered album_art_editor supports this file type).
|
|
|
133 static bool g_get_interface(service_ptr_t<album_art_editor> & out,const char * path);
|
|
|
134 //! Helper; returns whether one of registered album_art_editor implementations is capable of opening the specified file.
|
|
|
135 static bool g_is_supported_path(const char * path);
|
|
|
136
|
|
|
137 static album_art_editor_instance_ptr g_open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort);
|
|
|
138
|
|
|
139 //! Returns GUID of the corresponding input class. Null GUID if none.
|
|
|
140 GUID get_guid();
|
|
|
141 };
|
|
|
142
|
|
|
143 //! \since 1.5
|
|
|
144 class NOVTABLE album_art_editor_v2 : public album_art_editor {
|
|
|
145 FB2K_MAKE_SERVICE_INTERFACE( album_art_editor_v2, album_art_editor )
|
|
|
146 public:
|
|
|
147 //! Returns GUID of the corresponding input class. Null GUID if none.
|
|
|
148 virtual GUID get_guid() = 0;
|
|
|
149 };
|
|
|
150
|
|
|
151 //! \since 0.9.5
|
|
|
152 //! Helper API for extracting album art from APEv2 tags.
|
|
|
153 class NOVTABLE tag_processor_album_art_utils : public service_base {
|
|
|
154 FB2K_MAKE_SERVICE_COREAPI(tag_processor_album_art_utils)
|
|
|
155 public:
|
|
|
156
|
|
|
157 //! Throws one of I/O exceptions on failure; exception_album_art_not_found when the file has no album art record at all.
|
|
|
158 virtual album_art_extractor_instance_ptr open(file_ptr p_file,abort_callback & p_abort) = 0;
|
|
|
159
|
|
|
160 //! \since 1.1.6
|
|
|
161 //! Throws exception_not_implemented on earlier than 1.1.6.
|
|
|
162 virtual album_art_editor_instance_ptr edit(file_ptr p_file,abort_callback & p_abort) = 0;
|
|
|
163 };
|
|
|
164
|
|
|
165
|
|
|
166 //! Album art path list - see album_art_extractor_instance_v2
|
|
|
167 class NOVTABLE album_art_path_list : public service_base {
|
|
|
168 FB2K_MAKE_SERVICE_INTERFACE(album_art_path_list, service_base)
|
|
|
169 public:
|
|
|
170 virtual const char * get_path(t_size index) const = 0;
|
|
|
171 virtual t_size get_count() const = 0;
|
|
|
172
|
|
|
173 static bool equals(album_art_path_list const& v1, album_art_path_list const& v2);
|
|
|
174 static bool equals(ptr const& v1, ptr const& v2);
|
|
|
175 };
|
|
|
176
|
|
|
177 //! album_art_extractor_instance extension; lets the frontend query referenced file paths (eg. when using external album art).
|
|
|
178 class NOVTABLE album_art_extractor_instance_v2 : public album_art_extractor_instance {
|
|
|
179 FB2K_MAKE_SERVICE_INTERFACE(album_art_extractor_instance_v2, album_art_extractor_instance)
|
|
|
180 public:
|
|
|
181 virtual album_art_path_list::ptr query_paths(const GUID & p_what, abort_callback & p_abort) = 0;
|
|
|
182 };
|
|
|
183
|
|
|
184
|
|
|
185 //! \since 1.0
|
|
|
186 //! Provides methods for interfacing with the foobar2000 core album art loader. \n
|
|
|
187 //! Use this when you need to load album art for a specific group of tracks.
|
|
|
188 class NOVTABLE album_art_manager_v2 : public service_base {
|
|
|
189 FB2K_MAKE_SERVICE_COREAPI(album_art_manager_v2)
|
|
|
190 public:
|
|
|
191 //! Instantiates an album art extractor object for the specified group of items.
|
|
|
192 virtual album_art_extractor_instance_v2::ptr open(metadb_handle_list_cref items, pfc::list_base_const_t<GUID> const & ids, abort_callback & abort) = 0;
|
|
|
193
|
|
|
194 //! Instantiates an album art extractor object that retrieves stub images.
|
|
|
195 virtual album_art_extractor_instance_v2::ptr open_stub(abort_callback & abort) = 0;
|
|
|
196 };
|
|
|
197
|
|
|
198
|
|
|
199 //! \since 1.0
|
|
|
200 //! Called when no other album art source (internal, external, other registered fallbacks) returns relevant data for the specified items. \n
|
|
|
201 //! Can be used to implement online lookup and such.
|
|
|
202 class NOVTABLE album_art_fallback : public service_base {
|
|
|
203 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_fallback)
|
|
|
204 public:
|
|
|
205 virtual album_art_extractor_instance_v2::ptr open(metadb_handle_list_cref items, pfc::list_base_const_t<GUID> const & ids, abort_callback & abort) = 0;
|
|
|
206 };
|
|
|
207
|
|
|
208 //! \since 1.1.7
|
|
|
209 class NOVTABLE album_art_manager_config : public service_base {
|
|
|
210 FB2K_MAKE_SERVICE_INTERFACE(album_art_manager_config, service_base)
|
|
|
211 public:
|
|
|
212 virtual bool get_external_pattern(pfc::string_base & out, const GUID & type) = 0;
|
|
|
213 virtual bool use_embedded_pictures() = 0;
|
|
|
214 virtual bool use_fallbacks() = 0;
|
|
|
215 };
|
|
|
216
|
|
|
217 //! \since 1.1.7
|
|
|
218 class NOVTABLE album_art_manager_v3 : public album_art_manager_v2 {
|
|
|
219 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(album_art_manager_v3, album_art_manager_v2)
|
|
|
220 public:
|
|
|
221 //! @param config An optional album_art_manager_config object to override global settings. Pass null to use global settings.
|
|
|
222 virtual album_art_extractor_instance_v2::ptr open_v3(metadb_handle_list_cref items, pfc::list_base_const_t<GUID> const & ids, album_art_manager_config::ptr config, abort_callback & abort) = 0;
|
|
|
223 };
|
|
|
224
|
|
|
225 //! \since 1.4
|
|
|
226 //! A notification about a newly loaded album art being ready to display. \n
|
|
|
227 //! See: now_playing_album_art_notify_manager.
|
|
|
228 class NOVTABLE now_playing_album_art_notify {
|
|
|
229 public:
|
|
|
230 //! Called when album art has finished loading for the now playing track.
|
|
|
231 //! @param data The newly loaded album art. Never a null object - the callbacks are simply not called when there is nothing to show.
|
|
|
232 virtual void on_album_art( album_art_data::ptr data ) = 0;
|
|
|
233 };
|
|
|
234
|
|
|
235 //! \since 1.4
|
|
|
236 //! Since various components require the album art of the now-playing track, a centralized loader has been provided, so the file isn't hammered independently by different components. \n
|
|
|
237 //! Use this in conjunction with play_callback notifications to render now-playing track information.
|
|
|
238 class NOVTABLE now_playing_album_art_notify_manager : public service_base {
|
|
|
239 FB2K_MAKE_SERVICE_COREAPI(now_playing_album_art_notify_manager)
|
|
|
240 public:
|
|
|
241 //! Register a notification to be told when the album art has been loaded.
|
|
|
242 virtual void add(now_playing_album_art_notify*) = 0;
|
|
|
243 //! Unregister a previously registered notification.
|
|
|
244 virtual void remove(now_playing_album_art_notify*) = 0;
|
|
|
245 //! Retrieves the album art for the currently playing track.
|
|
|
246 //! @returns The current album art (front cover), or null if there is no art or the art is being loaded and is not yet available.
|
|
|
247 virtual album_art_data::ptr current() = 0;
|
|
|
248
|
|
|
249 //! Helper; register a lambda notification. Pass the returned obejct to remove() to unregister.
|
|
|
250 now_playing_album_art_notify* add( std::function<void (album_art_data::ptr) > );
|
|
|
251 };
|
|
|
252
|
|
|
253 //! \since 1.6.6
|
|
|
254 class NOVTABLE now_playing_album_art_notify_manager_v2 : public now_playing_album_art_notify_manager {
|
|
|
255 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(now_playing_album_art_notify_manager_v2, now_playing_album_art_notify_manager);
|
|
|
256 public:
|
|
|
257 struct info_t {
|
|
|
258 album_art_data::ptr data;
|
|
|
259 album_art_path_list::ptr paths;
|
|
|
260
|
|
|
261 static bool equals(const info_t& v1, const info_t& v2) {
|
|
|
262 return album_art_data::equals(v1.data, v2.data) && album_art_path_list::equals(v1.paths, v2.paths);
|
|
|
263 }
|
|
|
264 bool operator==(const info_t& other) const { return equals(*this, other); }
|
|
|
265 bool operator!=(const info_t& other) const { return !equals(*this, other); }
|
|
|
266
|
|
|
267 void clear() { *this = {}; }
|
|
|
268 bool is_valid() const { return data.is_valid(); }
|
|
|
269 operator bool() const { return is_valid(); }
|
|
|
270 };
|
|
|
271 virtual info_t current_v2() = 0;
|
|
|
272 };
|