Revert "thumbnail: disable broken test"
[vlc.git] / include / vlc_media_library.h
blob1e33576297af725900cad545b0a29be6c1233c02
1 /*****************************************************************************
2 * vlc_media_library.h: SQL-based media library
3 *****************************************************************************
4 * Copyright (C) 2008-2010 the VideoLAN Team and AUTHORS
5 * $Id$
7 * Authors: Antoine Lejeune <phytos@videolan.org>
8 * Jean-Philippe André <jpeg@videolan.org>
9 * Rémi Duraffort <ivoire@videolan.org>
10 * Adrien Maglo <magsoft@videolan.org>
11 * Srikanth Raju <srikiraju at gmail dot com>
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU Lesser General Public License as published by
15 * the Free Software Foundation; either version 2.1 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this program; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
28 #ifndef VLC_MEDIA_LIBRARY_H
29 # define VLC_MEDIA_LIBRARY_H
31 #include <assert.h>
32 #include <vlc_common.h>
34 # ifdef __cplusplus
35 extern "C" {
36 # endif
38 typedef enum vlc_ml_media_type_t
40 VLC_ML_MEDIA_TYPE_UNKNOWN,
41 VLC_ML_MEDIA_TYPE_VIDEO,
42 VLC_ML_MEDIA_TYPE_AUDIO,
43 VLC_ML_MEDIA_TYPE_EXTERNAL,
44 VLC_ML_MEDIA_TYPE_STREAM,
45 } vlc_ml_media_type_t;
47 typedef enum vlc_ml_media_subtype_t
49 VLC_ML_MEDIA_SUBTYPE_UNKNOWN,
50 VLC_ML_MEDIA_SUBTYPE_SHOW_EPISODE,
51 VLC_ML_MEDIA_SUBTYPE_MOVIE,
52 VLC_ML_MEDIA_SUBTYPE_ALBUMTRACK,
53 } vlc_ml_media_subtype_t;
55 typedef enum vlc_ml_file_type_t
57 VLC_ML_FILE_TYPE_UNKNOWN,
58 VLC_ML_FILE_TYPE_MAIN,
59 VLC_ML_FILE_TYPE_PART,
60 VLC_ML_FILE_TYPE_SOUNDTRACK,
61 VLC_ML_FILE_TYPE_SUBTITLE,
62 VLC_ML_FILE_TYPE_PLAYLIST,
63 } vlc_ml_file_type_t;
65 typedef enum vlc_ml_track_type_t
67 VLC_ML_TRACK_TYPE_UNKNOWN,
68 VLC_ML_TRACK_TYPE_VIDEO,
69 VLC_ML_TRACK_TYPE_AUDIO,
70 } vlc_ml_track_type_t;
72 typedef struct vlc_ml_movie_t
74 char* psz_summary;
75 char* psz_imdb_id;
76 } vlc_ml_movie_t;
78 typedef struct vlc_ml_show_episode_t
80 char* psz_summary;
81 char* psz_tvdb_id;
82 uint32_t i_episode_nb;
83 uint32_t i_season_number;
84 } vlc_ml_show_episode_t;
86 typedef struct vlc_ml_show_t
88 int64_t i_id;
89 char* psz_name;
90 char* psz_summary;
91 char* psz_artwork_mrl;
92 char* psz_tvdb_id;
93 unsigned int i_release_year;
94 uint32_t i_nb_episodes;
95 uint32_t i_nb_seasons;
96 } vlc_ml_show_t;
98 typedef struct vlc_ml_album_track_t
100 int64_t i_artist_id;
101 int64_t i_album_id;
102 int64_t i_genre_id;
104 int i_track_nb;
105 int i_disc_nb;
106 } vlc_ml_album_track_t;
108 typedef struct vlc_ml_label_t
110 int64_t i_id;
111 char* psz_name;
112 } vlc_ml_label_t;
114 typedef struct vlc_ml_label_list_t
116 size_t i_nb_items;
117 vlc_ml_label_t p_items[];
118 } vlc_ml_label_list_t;
120 typedef struct vlc_ml_file_t
122 char* psz_mrl;
123 vlc_ml_file_type_t i_type;
124 bool b_external;
125 } vlc_ml_file_t;
127 typedef struct vlc_ml_file_list_t
129 size_t i_nb_items;
130 vlc_ml_file_t p_items[];
131 } vlc_ml_file_list_t;
133 typedef struct vlc_ml_media_track_t
135 char* psz_codec;
136 char* psz_language;
137 char* psz_description;
138 vlc_ml_track_type_t i_type;
139 uint32_t i_bitrate;
140 union
142 struct
144 // Audio
145 uint32_t i_nbChannels;
146 uint32_t i_sampleRate;
147 } a;
148 struct
150 // Video
151 uint32_t i_height;
152 uint32_t i_width;
153 uint32_t i_sarNum;
154 uint32_t i_sarDen;
155 uint32_t i_fpsNum;
156 uint32_t i_fpsDen;
157 } v;
159 } vlc_ml_media_track_t;
161 typedef struct vlc_ml_media_track_list_t
163 size_t i_nb_items;
164 vlc_ml_media_track_t p_items[];
165 } vlc_ml_media_track_list_t;
167 typedef struct vlc_ml_media_t
169 int64_t i_id;
171 vlc_ml_media_type_t i_type;
172 vlc_ml_media_subtype_t i_subtype;
174 vlc_ml_file_list_t* p_files;
175 vlc_ml_media_track_list_t* p_tracks;
177 int32_t i_year;
178 /* Duration in milliseconds */
179 int64_t i_duration;
180 uint32_t i_playcount;
181 time_t i_last_played_date;
182 char* psz_title;
184 char* psz_artwork_mrl;
185 /* True if a thumbnail is available, or if thumbnail generation was
186 * attempted but failed */
187 bool b_artwork_generated;
188 bool b_is_favorite;
190 union
192 vlc_ml_show_episode_t show_episode;
193 vlc_ml_movie_t movie;
194 vlc_ml_album_track_t album_track;
196 } vlc_ml_media_t;
198 typedef struct vlc_ml_playlist_t
200 int64_t i_id;
201 char* psz_name;
202 uint32_t i_creation_date;
203 char* psz_artwork_mrl;
204 } vlc_ml_playlist_t;
206 typedef struct vlc_ml_artist_t
208 int64_t i_id;
209 char* psz_name;
210 char* psz_shortbio;
211 char* psz_artwork_mrl;
212 char* psz_mb_id;
214 unsigned int i_nb_album;
215 unsigned int i_nb_tracks;
216 } vlc_ml_artist_t;
218 typedef struct vlc_ml_artist_list_t
220 size_t i_nb_items;
221 vlc_ml_artist_t p_items[];
222 } vlc_ml_artist_list_t;
224 typedef struct vlc_ml_album_t {
225 int64_t i_id;
226 char* psz_title;
227 char* psz_summary;
228 char* psz_artwork_mrl;
229 char* psz_artist;
230 int64_t i_artist_id;
232 size_t i_nb_tracks;
233 unsigned int i_duration;
234 unsigned int i_year;
235 } vlc_ml_album_t;
237 typedef struct vlc_ml_genre_t
239 int64_t i_id;
240 char* psz_name;
241 size_t i_nb_tracks;
242 } vlc_ml_genre_t;
244 typedef struct vlc_ml_media_list_t
246 size_t i_nb_items;
247 vlc_ml_media_t p_items[];
248 } vlc_ml_media_list_t;
250 typedef struct vlc_ml_album_list_t
252 size_t i_nb_items;
253 vlc_ml_album_t p_items[];
254 } vlc_ml_album_list_t;
256 typedef struct vlc_ml_show_list_t
258 size_t i_nb_items;
259 vlc_ml_show_t p_items[];
260 } vlc_ml_show_list_t;
262 typedef struct vlc_ml_genre_list_t
264 size_t i_nb_items;
265 vlc_ml_genre_t p_items[];
266 } vlc_ml_genre_list_t;
268 typedef struct vlc_ml_playlist_list_t
270 size_t i_nb_items;
271 vlc_ml_playlist_t p_items[];
272 } vlc_ml_playlist_list_t;
274 typedef struct vlc_ml_entry_point_t
276 char* psz_mrl; /**< This entrypoint's MRL. Will be NULL if b_present is false */
277 bool b_present; /**< The presence state for this entrypoint. */
278 bool b_banned; /**< Will be true if the user required this entrypoint to be excluded */
279 } vlc_ml_entry_point_t;
281 typedef struct vlc_ml_entry_point_list_t
283 size_t i_nb_items;
284 vlc_ml_entry_point_t p_items[];
285 } vlc_ml_entry_point_list_t;
287 /* Opaque medialibrary pointer, to be used by any non-medialibrary module */
288 typedef struct vlc_medialibrary_t vlc_medialibrary_t;
289 /* "Private" medialibrary pointer, to be used by the core & medialibrary modules */
290 typedef struct vlc_medialibrary_module_t vlc_medialibrary_module_t;
291 /* Opaque event callback type */
292 typedef struct vlc_ml_event_callback_t vlc_ml_event_callback_t;
294 typedef enum vlc_ml_sorting_criteria_t
297 * Default depends on the entity type:
298 * - By track number (and disc number) for album tracks
299 * - Alphabetical order for others
301 VLC_ML_SORTING_DEFAULT,
302 VLC_ML_SORTING_ALPHA,
303 VLC_ML_SORTING_DURATION,
304 VLC_ML_SORTING_INSERTIONDATE,
305 VLC_ML_SORTING_LASTMODIFICATIONDATE,
306 VLC_ML_SORTING_RELEASEDATE,
307 VLC_ML_SORTING_FILESIZE,
308 VLC_ML_SORTING_ARTIST,
309 VLC_ML_SORTING_PLAYCOUNT,
310 VLC_ML_SORTING_ALBUM,
311 VLC_ML_SORTING_FILENAME,
312 VLC_ML_SORTING_TRACKNUMBER,
313 } vlc_ml_sorting_criteria_t;
315 typedef struct vlc_ml_query_params_t vlc_ml_query_params_t;
316 struct vlc_ml_query_params_t
318 const char* psz_pattern;
319 uint32_t i_nbResults;
320 uint32_t i_offset;
321 vlc_ml_sorting_criteria_t i_sort;
322 bool b_desc;
325 enum vlc_ml_get_queries
327 VLC_ML_GET_MEDIA, /**< arg1: Media ID; ret: vlc_ml_media_t* */
328 VLC_ML_GET_ALBUM, /**< arg1: Album ID; ret: vlc_ml_album_t* */
329 VLC_ML_GET_ARTIST, /**< arg1: Artist ID; ret: vlc_ml_artist_t* */
330 VLC_ML_GET_GENRE, /**< arg1: Genre ID; ret: vlc_ml_genre_t* */
331 VLC_ML_GET_SHOW, /**< arg1: Show ID; ret: vlc_ml_show_t* */
332 VLC_ML_GET_PLAYLIST, /**< arg1: Playlist ID; ret: vlc_ml_playlist_t* */
335 enum vlc_ml_list_queries
337 /* General listing: */
339 VLC_ML_LIST_VIDEOS, /**< arg1 (out): vlc_ml_media_list_t** */
340 VLC_ML_COUNT_VIDEOS, /**< arg1 (out): size_t* */
341 VLC_ML_LIST_AUDIOS, /**< arg1 (out): vlc_ml_media_list_t** */
342 VLC_ML_COUNT_AUDIOS, /**< arg1 (out): size_t* */
343 VLC_ML_LIST_ALBUMS, /**< arg1 (out): vlc_ml_album_list_t** */
344 VLC_ML_COUNT_ALBUMS, /**< arg1 (out): size_t* */
345 VLC_ML_LIST_GENRES, /**< arg1 (out): vlc_ml_genre_list_t** */
346 VLC_ML_COUNT_GENRES, /**< arg1 (out): size_t* */
347 VLC_ML_LIST_ARTISTS, /**< arg1 bool: includeAll; arg2 (out): vlc_ml_genre_list_t** */
348 VLC_ML_COUNT_ARTISTS, /**< arg1 bool: includeAll; arg2 (out): size_t* */
349 VLC_ML_LIST_SHOWS, /**< arg1 (out): vlc_ml_show_list_t** */
350 VLC_ML_COUNT_SHOWS, /**< arg1 (out): size_t* */
351 VLC_ML_LIST_PLAYLISTS, /**< arg1 (out): vlc_ml_playlist_list_t** */
352 VLC_ML_COUNT_PLAYLISTS, /**< arg1 (out): size_t* */
353 VLC_ML_LIST_HISTORY, /**< arg1 (out): vlc_ml_media_list_t** */
354 VLC_ML_LIST_STREAM_HISTORY, /**< arg1 (out): vlc_ml_media_list_t** */
356 /* Album specific listings */
357 VLC_ML_LIST_ALBUM_TRACKS, /**< arg1: The album id. arg2 (out): vlc_ml_media_list_t** */
358 VLC_ML_COUNT_ALBUM_TRACKS, /**< arg1: The album id. arg2 (out): size_t* */
359 VLC_ML_LIST_ALBUM_ARTISTS, /**< arg1: The album id. arg2 (out): vlc_ml_album_list_t** */
360 VLC_ML_COUNT_ALBUM_ARTISTS, /**< arg1: The album id. arg2 (out): size_t* */
362 /* Artist specific listings */
363 VLC_ML_LIST_ARTIST_ALBUMS, /**< arg1: The artist id. arg2(out): vlc_ml_album_list_t** */
364 VLC_ML_COUNT_ARTIST_ALBUMS, /**< arg1: The artist id. arg2(out): size_t* */
365 VLC_ML_LIST_ARTIST_TRACKS, /**< arg1: The artist id. arg2(out): vlc_ml_media_list_t** */
366 VLC_ML_COUNT_ARTIST_TRACKS, /**< arg1: The artist id. arg2(out): size_t* */
368 /* Genre specific listings */
369 VLC_ML_LIST_GENRE_ARTISTS, /**< arg1: genre id; arg2 (out): vlc_ml_artist_list_t** */
370 VLC_ML_COUNT_GENRE_ARTISTS, /**< arg1: genre id; arg2 (out): size_t* */
371 VLC_ML_LIST_GENRE_TRACKS, /**< arg1: genre id; arg2 (out): vlc_ml_media_list_t** */
372 VLC_ML_COUNT_GENRE_TRACKS, /**< arg1: genre id; arg2 (out): size_t* */
373 VLC_ML_LIST_GENRE_ALBUMS, /**< arg1: genre id; arg2 (out): vlc_ml_album_list_t** */
374 VLC_ML_COUNT_GENRE_ALBUMS, /**< arg1: genre id; arg2 (out): size_t* */
376 /* Show specific listings */
377 VLC_ML_LIST_SHOW_EPISODES, /**< arg1: show id; arg2(out): vlc_ml_media_list_t** */
378 VLC_ML_COUNT_SHOW_EPISODES, /**< arg1: show id; arg2(out): size_t* */
380 /* Media specific listings */
381 VLC_ML_LIST_MEDIA_LABELS, /**< arg1: media id; arg2 (out): vlc_ml_label_list_t** */
382 VLC_ML_COUNT_MEDIA_LABELS, /**< arg1: media id; arg2 (out): size_t* */
384 /* Playlist specific listings */
385 VLC_ML_LIST_PLAYLIST_MEDIA, /**< arg1: playlist id; arg2 (out): vlc_ml_media_list_t** */
386 VLC_ML_COUNT_PLAYLIST_MEDIA, /**< arg1: playlist id; arg2 (out): size_t* */
388 /* Children entities listing */
389 VLC_ML_LIST_MEDIA_OF, /**< arg1: parent entity type; arg2: parent entity id; arg3(out): ml_media_list_t** */
390 VLC_ML_COUNT_MEDIA_OF, /**< arg1: parent entity type; arg2: parent entity id; arg3(out): size_t* */
391 VLC_ML_LIST_ARTISTS_OF, /**< arg1: parent entity type; arg2: parent entity id; arg3(out): ml_artist_list_t** */
392 VLC_ML_COUNT_ARTISTS_OF, /**< arg1: parent entity type; arg2: parent entity id; arg3(out): size_t* */
393 VLC_ML_LIST_ALBUMS_OF, /**< arg1: parent entity type; arg2: parent entity id; arg3(out): ml_album_list_t** */
394 VLC_ML_COUNT_ALBUMS_OF, /**< arg1: parent entity type; arg2: parent entity id; arg3(out): size_t* */
397 enum vlc_ml_parent_type
399 VLC_ML_PARENT_ALBUM = 1,
400 VLC_ML_PARENT_ARTIST,
401 VLC_ML_PARENT_SHOW,
402 VLC_ML_PARENT_GENRE,
403 VLC_ML_PARENT_PLAYLIST,
406 enum vlc_ml_control
408 /* Adds a folder to discover through the medialibrary */
409 VLC_ML_ADD_FOLDER, /**< arg1: mrl (const char*) res: can't fail */
410 VLC_ML_REMOVE_FOLDER, /**< arg1: mrl (const char*) res: can't fail */
411 VLC_ML_BAN_FOLDER, /**< arg1: mrl (const char*) res: can't fail */
412 VLC_ML_UNBAN_FOLDER, /**< arg1: mrl (const char*) res: can't fail */
413 VLC_ML_LIST_FOLDERS, /**< arg1: entrypoints (vlc_ml_entry_point_list_t**); res: can fail */
415 * Reload a specific folder, or all.
416 * arg1: mrl (const char*), NULL to reload all folders
417 * res: can't fail
419 VLC_ML_RELOAD_FOLDER,
421 /* Pause/resume background operations, such as media discovery & media analysis */
422 VLC_ML_PAUSE_BACKGROUND, /**< no args; can't fail */
423 VLC_ML_RESUME_BACKGROUND, /**< no args; can't fail */
425 /* Misc operations */
426 VLC_ML_CLEAR_HISTORY, /**< no args; can't fail */
428 /* Create media */
429 VLC_ML_NEW_EXTERNAL_MEDIA, /**< arg1: const char*; arg2(out): vlc_ml_media_t** */
430 VLC_ML_NEW_STREAM, /**< arg1: const char*; arg2(out): vlc_ml_media_t** */
432 /* Media management */
433 VLC_ML_MEDIA_INCREASE_PLAY_COUNT, /**< arg1: media id; can fail */
434 VLC_ML_MEDIA_GET_MEDIA_PLAYBACK_PREF, /**< arg1: media id; arg2: vlc_ml_playback_pref; arg3: char**; */
435 VLC_ML_MEDIA_SET_MEDIA_PLAYBACK_PREF, /**< arg1: media id; arg2: vlc_ml_playback_pref; arg3: const char*; */
436 VLC_ML_MEDIA_SET_THUMBNAIL, /**< arg1: media id; arg2: const char*; */
437 VLC_ML_MEDIA_GENERATE_THUMBNAIL, /**< arg1: media id; */
438 VLC_ML_MEDIA_ADD_EXTERNAL_MRL, /**< arg1: media id; arg2: const char*; arg3: type(vlc_ml_file_type_t) */
442 * User playback settings.
443 * All values/units are up to the caller and are not interpreted by the media
444 * library.
445 * All values are stored and returned as strings.
446 * When calling vlc_medialibrary_t::pf_control with vlc_ml_MEDIA_GET_MEDIA_PLAYBACK_PREF,
447 * the value will be returned stored in the provided char**. If the preference was
448 * not set yet, NULL will be returned.
449 * When setting a preference, NULL can be provided as a value to unset it.
451 enum vlc_ml_playback_pref
453 VLC_ML_PLAYBACK_PREF_RATING,
454 VLC_ML_PLAYBACK_PREF_PROGRESS,
455 VLC_ML_PLAYBACK_PREF_SPEED,
456 VLC_ML_PLAYBACK_PREF_TITLE,
457 VLC_ML_PLAYBACK_PREF_CHAPTER,
458 VLC_ML_PLAYBACK_PREF_PROGRAM,
459 VLC_ML_PLAYBACK_PREF_SEEN,
460 VLC_ML_PLAYBACK_PREF_VIDEO_TRACK,
461 VLC_ML_PLAYBACK_PREF_ASPECT_RATIO,
462 VLC_ML_PLAYBACK_PREF_ZOOM,
463 VLC_ML_PLAYBACK_PREF_CROP,
464 VLC_ML_PLAYBACK_PREF_DEINTERLACE,
465 VLC_ML_PLAYBACK_PREF_VIDEO_FILTER,
466 VLC_ML_PLAYBACK_PREF_AUDIO_TRACK,
467 VLC_ML_PLAYBACK_PREF_GAIN,
468 VLC_ML_PLAYBACK_PREF_AUDIO_DELAY,
469 VLC_ML_PLAYBACK_PREF_SUBTITLE_TRACK,
470 VLC_ML_PLAYBACK_PREF_SUBTITLE_DELAY,
471 VLC_ML_PLAYBACK_PREF_APP_SPECIFIC,
474 enum vlc_ml_event_type
477 * Entity modification callbacks. The affected entity will be passed:
478 * - As a vlc_ml_<type>_t, depending on the type of the modified/inserted
479 * entity, in vlc_ml_event_t::modification::p_<type>
480 * for ADDED and UPDATED variants.
481 * - as an id, in vlc_ml_event_t::deletion::i_entity_id
482 * When _DELETED callbacks get invoked, the entity will already have been
483 * deleted from the database, and cannot be retrieved anymore
485 VLC_ML_EVENT_MEDIA_ADDED,
486 VLC_ML_EVENT_MEDIA_UPDATED,
487 VLC_ML_EVENT_MEDIA_DELETED,
488 VLC_ML_EVENT_ARTIST_ADDED,
489 VLC_ML_EVENT_ARTIST_UPDATED,
490 VLC_ML_EVENT_ARTIST_DELETED,
491 VLC_ML_EVENT_ALBUM_ADDED,
492 VLC_ML_EVENT_ALBUM_UPDATED,
493 VLC_ML_EVENT_ALBUM_DELETED,
494 VLC_ML_EVENT_PLAYLIST_ADDED,
495 VLC_ML_EVENT_PLAYLIST_UPDATED,
496 VLC_ML_EVENT_PLAYLIST_DELETED,
497 VLC_ML_EVENT_GENRE_ADDED,
498 VLC_ML_EVENT_GENRE_UPDATED,
499 VLC_ML_EVENT_GENRE_DELETED,
501 * A discovery started.
502 * For each VLC_ML_EVENT_DISCOVERY_STARTED event, there will be
503 * 1 VLC_ML_EVENT_DISCOVERY_COMPLETED event, and N
504 * VLC_ML_EVENT_DISCOVERY_COMPLETED events.
505 * The entry point being discovered is stored in
506 * vlc_ml_event_t::discovery_started::psz_entry_point.
508 VLC_ML_EVENT_DISCOVERY_STARTED,
510 * Sent when a discovery or reload operation starts analyzing a new folder.
511 * The discovered entry point is stored in
512 * vlc_ml_event_t::discovery_progress::psz_entry_point.
514 VLC_ML_EVENT_DISCOVERY_PROGRESS,
516 * Sent when an entry point discovery is completed.
517 * The entry point that was being discovered is stored in
518 * vlc_ml_event_t::discovery_completed::psz_entry_point.
519 * The success or failure state is stored in
520 * vlc_ml_event_t::discovery_completed::b_success
522 VLC_ML_EVENT_DISCOVERY_COMPLETED,
524 * An entry point reload operation started.
525 * For all the entry points being reloaded, N VLC_EVENT_DISCOVERY_PROGRESS
526 * and 1 VLC_EVENT_RELOAD_COMPLETED event will be sent.
527 * The entry point being reloaded is stored in
528 * vlc_ml_event_t::reload_started::psz_entry_point.
530 VLC_ML_EVENT_RELOAD_STARTED,
532 * Sent when an entry point reload is completed.
533 * The entry point that was being reloaded is stored in
534 * vlc_ml_event_t::reload_completed::psz_entry_point.
535 * The success or failure state is stored in
536 * vlc_ml_event_t::reload_completed::b_success
538 VLC_ML_EVENT_RELOAD_COMPLETED,
540 * Sent when an entry point removal request has been processed.
541 * The removed entry point is stored in
542 * vlc_ml_event_t::entry_point_removed::psz_entry_point and the success or failure
543 * state is stored in vlc_ml_event_t::entry_point_removed::b_success
545 VLC_ML_EVENT_ENTRY_POINT_REMOVED,
547 * Sent when an entry point ban request has been processed.
548 * The banned entry point is stored in
549 * vlc_ml_event_t::entry_point_banned::psz_entry_point and the operation success
550 * state is stored in vlc_ml_event_t::entry_point_banned::b_success
552 VLC_ML_EVENT_ENTRY_POINT_BANNED,
554 * Sent when an entry point unban request has been processed.
555 * The unbanned entry point is stored in
556 * vlc_ml_event_t::entry_point_unbanned::psz_entry_point and the operation success
557 * state is stored in vlc_ml_event_t::entry_point_unbanned::b_success
559 VLC_ML_EVENT_ENTRY_POINT_UNBANNED,
561 * Sent when a discoverer or parser threads changes its idle state.
562 * The idle state is stored in vlc_ml_event_t::background_idle_changed.b_idle.
563 * False means at least one background thread is in running, true means
564 * both discoverer & parser threads are paused.
566 VLC_ML_EVENT_BACKGROUND_IDLE_CHANGED,
568 * Sent when the parsing progress percentage gets updated.
569 * The percentage is stored as a [0;100] integer, in
570 * vlc_ml_event_t::parsing_progress::i_percent
571 * This value might decrease as more media get discovered, but it will only
572 * increase once all discovery operations are completed.
574 VLC_ML_EVENT_PARSING_PROGRESS_UPDATED,
576 * Sent after a media thumbnail was generated, or if it's generation failed.
577 * The media is stored in vlc_ml_event_t::media_thumbnail_generated::p_media
578 * and the success state is stored in
579 * vlc_ml_event_t::media_thumbnail_generated::b_success
581 VLC_ML_EVENT_MEDIA_THUMBNAIL_GENERATED,
584 typedef struct vlc_ml_event_t
586 int i_type;
587 union
589 struct
591 const char* psz_entry_point;
592 } discovery_started;
593 struct
595 const char* psz_entry_point;
596 } discovery_progress;
597 struct
599 const char* psz_entry_point;
600 bool b_success;
601 } discovery_completed;
602 struct
604 const char* psz_entry_point;
605 } reload_started;
606 struct
608 const char* psz_entry_point;
609 bool b_success;
610 } reload_completed;
611 struct
613 const char* psz_entry_point;
614 bool b_success;
615 } entry_point_removed;
616 struct
618 const char* psz_entry_point;
619 bool b_success;
620 } entry_point_banned;
621 struct
623 const char* psz_entry_point;
624 bool b_success;
625 } entry_point_unbanned;
626 struct
628 uint8_t i_percent;
629 } parsing_progress;
630 union
632 const vlc_ml_media_t* p_media;
633 const vlc_ml_artist_t* p_artist;
634 const vlc_ml_album_t* p_album;
635 const vlc_ml_playlist_t* p_playlist;
636 const vlc_ml_genre_t* p_genre;
637 } modification;
638 struct
640 int64_t i_entity_id;
641 } deletion;
642 struct
644 bool b_idle;
645 } background_idle_changed;
646 struct
648 const vlc_ml_media_t* p_media;
649 bool b_success;
650 } media_thumbnail_generated;
652 } vlc_ml_event_t;
654 typedef void (*vlc_ml_callback_t)( void* p_data, const vlc_ml_event_t* p_event );
656 typedef struct vlc_medialibrary_callbacks_t
658 void (*pf_send_event)( vlc_medialibrary_module_t* p_ml, const vlc_ml_event_t* p_event );
659 } vlc_medialibrary_callbacks_t;
661 struct vlc_medialibrary_module_t
663 struct vlc_common_members obj;
665 module_t *p_module;
667 void* p_sys;
669 int (*pf_control)( struct vlc_medialibrary_module_t* p_ml, int i_query, va_list args );
671 * List some entities from the medialibrary.
673 * \param p_ml The medialibrary module instance.
674 * \param i_query The type search to be performed. \see vlc_ml_list enumeration
675 * \param p_params A pointer to a vlc_ml_query_params_t structure, or NULL for
676 * the default parameters (alphabetical ascending sort, no pagination)
678 * \return VLC_SUCCESS or an error code
680 * Refer to the individual list of vlc_ml_list requests for the additional
681 * per-query input/ouput parameters values & types
683 int (*pf_list)( struct vlc_medialibrary_module_t* p_ml, int i_query,
684 const vlc_ml_query_params_t* p_params, va_list args );
687 * Get a specific entity by its id.
689 * \return The required entity, or a NULL pointer if couldn't be found.
691 * Refer to the list of queries for the specific return type
693 void* (*pf_get)( struct vlc_medialibrary_module_t* p_ml, int i_query, int64_t i_id );
695 const vlc_medialibrary_callbacks_t* cbs;
698 vlc_medialibrary_t* libvlc_MlCreate( libvlc_int_t* p_libvlc );
699 void libvlc_MlRelease( vlc_medialibrary_t* p_ml );
701 VLC_API vlc_medialibrary_t* vlc_ml_instance_get( vlc_object_t* p_obj ) VLC_USED;
702 #define vlc_ml_instance_get(x) vlc_ml_instance_get( VLC_OBJECT(x) )
704 VLC_API void* vlc_ml_get( vlc_medialibrary_t* p_ml, int i_query, int64_t i_id ) VLC_USED;
705 VLC_API int vlc_ml_control( vlc_medialibrary_t* p_ml, int i_query, ... ) VLC_USED;
706 VLC_API int vlc_ml_list( vlc_medialibrary_t* p_ml, int i_query,
707 const vlc_ml_query_params_t* p_params, ... );
710 * \brief Registers a medialibrary callback.
711 * \returns A handle to the callback, to be passed to vlc_ml_event_unregister_callback
713 VLC_API vlc_ml_event_callback_t*
714 vlc_ml_event_register_callback( vlc_medialibrary_t* p_ml, vlc_ml_callback_t cb, void* p_data );
717 * \brief Unregisters a medialibrary callback
718 * \param p_handle The handled returned by vlc_ml_register_callback
720 VLC_API void vlc_ml_event_unregister_callback( vlc_medialibrary_t* p_ml,
721 vlc_ml_event_callback_t* p_callback );
723 * \brief Unregisters a medialibrary callback from the said callback.
724 * \param p_callback The handle returned by vlc_ml_register_callback
726 * This must only be called synchronously from the callback function provided to
727 * vlc_ml_event_register_callback
728 * The p_callback handle must be considered invalid when this function returns
730 VLC_API void vlc_ml_event_unregister_from_callback( vlc_medialibrary_t* p_ml,
731 vlc_ml_event_callback_t* p_callback );
734 VLC_API void vlc_ml_show_release( vlc_ml_show_t* p_show );
735 VLC_API void vlc_ml_artist_release( vlc_ml_artist_t* p_artist );
736 VLC_API void vlc_ml_genre_release( vlc_ml_genre_t* p_genre );
737 VLC_API void vlc_ml_media_release( vlc_ml_media_t* p_media );
738 VLC_API void vlc_ml_album_release( vlc_ml_album_t* p_album );
739 VLC_API void vlc_ml_playlist_release( vlc_ml_playlist_t* p_playlist );
741 VLC_API void vlc_ml_label_list_release( vlc_ml_label_list_t* p_list );
742 VLC_API void vlc_ml_file_list_release( vlc_ml_file_list_t* p_list );
743 VLC_API void vlc_ml_artist_list_release( vlc_ml_artist_list_t* p_list );
744 VLC_API void vlc_ml_media_list_release( vlc_ml_media_list_t* p_list );
745 VLC_API void vlc_ml_album_list_release( vlc_ml_album_list_t* p_list );
746 VLC_API void vlc_ml_show_list_release( vlc_ml_show_list_t* p_list );
747 VLC_API void vlc_ml_genre_list_release( vlc_ml_genre_list_t* p_list );
748 VLC_API void vlc_ml_playlist_list_release( vlc_ml_playlist_list_t* p_list );
749 VLC_API void vlc_ml_entry_point_list_release( vlc_ml_entry_point_list_t* p_list );
751 static inline vlc_ml_query_params_t vlc_ml_query_params_create()
753 return (vlc_ml_query_params_t) {
754 .psz_pattern = NULL,
755 .i_nbResults = 0,
756 .i_offset = 0,
757 .i_sort = VLC_ML_SORTING_DEFAULT,
758 .b_desc = false
762 static inline int vlc_ml_add_folder( vlc_medialibrary_t* p_ml, const char* psz_folder )
764 return vlc_ml_control( p_ml, VLC_ML_ADD_FOLDER, psz_folder );
767 static inline int vlc_ml_remove_folder( vlc_medialibrary_t* p_ml, const char* psz_folder )
769 return vlc_ml_control( p_ml, VLC_ML_REMOVE_FOLDER, psz_folder );
772 static inline int vlc_ml_ban_folder( vlc_medialibrary_t* p_ml, const char* psz_folder )
774 return vlc_ml_control( p_ml, VLC_ML_BAN_FOLDER, psz_folder );
777 static inline int vlc_ml_unban_folder( vlc_medialibrary_t* p_ml, const char* psz_folder )
779 return vlc_ml_control( p_ml, VLC_ML_UNBAN_FOLDER, psz_folder );
782 static inline int vlc_ml_list_folder( vlc_medialibrary_t* p_ml,
783 vlc_ml_entry_point_list_t** pp_entrypoints )
785 return vlc_ml_control( p_ml, VLC_ML_LIST_FOLDERS, pp_entrypoints );
788 static inline int vlc_ml_reload_folder( vlc_medialibrary_t* p_ml, const char* psz_mrl )
790 return vlc_ml_control( p_ml, VLC_ML_RELOAD_FOLDER, psz_mrl );
793 static inline int vlc_ml_pause_background( vlc_medialibrary_t* p_ml )
795 return vlc_ml_control( p_ml, VLC_ML_PAUSE_BACKGROUND );
798 static inline int vlc_ml_resume_background( vlc_medialibrary_t* p_ml )
800 return vlc_ml_control( p_ml, VLC_ML_RESUME_BACKGROUND );
803 static inline int vlc_ml_clear_history( vlc_medialibrary_t* p_ml )
805 return vlc_ml_control( p_ml, VLC_ML_CLEAR_HISTORY );
808 static inline vlc_ml_media_t* vlc_ml_new_external_media( vlc_medialibrary_t* p_ml, const char* psz_mrl )
810 vlc_ml_media_t* res;
811 if ( vlc_ml_control( p_ml, VLC_ML_NEW_EXTERNAL_MEDIA, psz_mrl, &res ) != VLC_SUCCESS )
812 return NULL;
813 return res;
816 static inline vlc_ml_media_t* vlc_ml_new_stream( vlc_medialibrary_t* p_ml, const char* psz_mrl )
818 vlc_ml_media_t* res;
819 if ( vlc_ml_control( p_ml, VLC_ML_NEW_STREAM, psz_mrl, &res ) != VLC_SUCCESS )
820 return NULL;
821 return res;
824 static inline int vlc_ml_media_increase_playcount( vlc_medialibrary_t* p_ml, int64_t i_media_id )
826 return vlc_ml_control( p_ml, VLC_ML_MEDIA_INCREASE_PLAY_COUNT, i_media_id );
829 static inline int vlc_ml_media_get_playback_pref( vlc_medialibrary_t* p_ml, int64_t i_media_id, int i_pref, char** ppsz_result )
831 return vlc_ml_control( p_ml, VLC_ML_MEDIA_GET_MEDIA_PLAYBACK_PREF, i_media_id, i_pref, ppsz_result );
834 static inline int vlc_ml_media_set_playback_pref( vlc_medialibrary_t* p_ml, int64_t i_media_id, int i_pref, const char* psz_value )
836 return vlc_ml_control( p_ml, VLC_ML_MEDIA_SET_MEDIA_PLAYBACK_PREF, i_media_id, i_pref, psz_value );
839 static inline int vlc_ml_media_set_thumbnail( vlc_medialibrary_t* p_ml, int64_t i_media_id, const char* psz_mrl )
841 return vlc_ml_control( p_ml, VLC_ML_MEDIA_SET_THUMBNAIL, i_media_id, psz_mrl );
844 static inline int vlc_ml_media_generate_thumbnail( vlc_medialibrary_t* p_ml, int64_t i_media_id )
846 return vlc_ml_control( p_ml, VLC_ML_MEDIA_GENERATE_THUMBNAIL, i_media_id );
849 static inline int vlc_ml_media_add_external_mrl( vlc_medialibrary_t* p_ml, int64_t i_media_id,
850 const char* psz_mrl, int i_type )
852 return vlc_ml_control( p_ml, VLC_ML_MEDIA_ADD_EXTERNAL_MRL, i_media_id, psz_mrl, i_type );
855 static inline vlc_ml_media_t* vlc_ml_get_media( vlc_medialibrary_t* p_ml, int64_t i_media_id )
857 return (vlc_ml_media_t*)vlc_ml_get( p_ml, VLC_ML_GET_MEDIA, i_media_id );
860 static inline vlc_ml_album_t* vlc_ml_get_album( vlc_medialibrary_t* p_ml, int64_t i_album_id )
862 return (vlc_ml_album_t*)vlc_ml_get( p_ml, VLC_ML_GET_ALBUM, i_album_id );
865 static inline vlc_ml_artist_t* vlc_ml_get_artist( vlc_medialibrary_t* p_ml, int64_t i_artist_id )
867 return (vlc_ml_artist_t*)vlc_ml_get( p_ml, VLC_ML_GET_ARTIST, i_artist_id );
870 static inline vlc_ml_genre_t* vlc_ml_get_genre( vlc_medialibrary_t* p_ml, int64_t i_genre_id )
872 return (vlc_ml_genre_t*)vlc_ml_get( p_ml, VLC_ML_GET_GENRE, i_genre_id );
875 static inline vlc_ml_show_t* vlc_ml_get_show( vlc_medialibrary_t* p_ml, int64_t i_show_id )
877 return (vlc_ml_show_t*)vlc_ml_get( p_ml, VLC_ML_GET_SHOW, i_show_id );
880 static inline vlc_ml_playlist_t* vlc_ml_get_playlist( vlc_medialibrary_t* p_ml, int64_t i_playlist_id )
882 return (vlc_ml_playlist_t*)vlc_ml_get( p_ml, VLC_ML_GET_PLAYLIST, i_playlist_id );
885 static inline vlc_ml_media_list_t* vlc_ml_list_media_of( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int i_parent_type, int64_t i_parent_id )
887 vlc_assert( p_ml != NULL );
888 vlc_ml_media_list_t* res;
889 if ( vlc_ml_list( p_ml, VLC_ML_LIST_MEDIA_OF, params, i_parent_type, i_parent_id, &res ) != VLC_SUCCESS )
890 return NULL;
891 return res;
894 static inline size_t vlc_ml_count_media_of( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int i_parent_type, int64_t i_parent_id )
896 vlc_assert( p_ml != NULL );
897 size_t res;
898 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_MEDIA_OF, params, i_parent_type, i_parent_id, &res ) != VLC_SUCCESS )
899 return 0;
900 return res;
903 static inline vlc_ml_artist_list_t* vlc_ml_list_artist_of( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int i_parent_type, int64_t i_parent_id )
905 vlc_assert( p_ml != NULL );
906 vlc_ml_artist_list_t* res;
907 if ( vlc_ml_list( p_ml, VLC_ML_LIST_ARTISTS_OF, params, i_parent_type, i_parent_id, &res ) != VLC_SUCCESS )
908 return NULL;
909 return res;
912 static inline size_t vlc_ml_count_artists_of( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int i_parent_type, int64_t i_parent_id )
914 vlc_assert( p_ml != NULL );
915 size_t res;
916 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_ARTISTS_OF, params, i_parent_type, i_parent_id, &res ) != VLC_SUCCESS )
917 return 0;
918 return res;
921 static inline vlc_ml_album_list_t* vlc_ml_list_albums_of( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int i_parent_type, int64_t i_parent_id )
923 vlc_assert( p_ml != NULL );
924 vlc_ml_album_list_t* res;
925 if ( vlc_ml_list( p_ml, VLC_ML_LIST_ALBUMS_OF, params, i_parent_type, i_parent_id, &res ) != VLC_SUCCESS )
926 return NULL;
927 return res;
930 static inline size_t vlc_ml_count_albums_of( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int i_parent_type, int64_t i_parent_id )
932 vlc_assert( p_ml != NULL );
933 size_t res;
934 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_ALBUMS_OF, params, i_parent_type, i_parent_id, &res ) != VLC_SUCCESS )
935 return 0;
936 return res;
939 static inline vlc_ml_media_list_t* vlc_ml_list_album_tracks( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_album_id )
941 vlc_assert( p_ml != NULL );
942 vlc_ml_media_list_t* res;
943 if ( vlc_ml_list( p_ml, VLC_ML_LIST_ALBUM_TRACKS, params, i_album_id, &res ) != VLC_SUCCESS )
944 return NULL;
945 return res;
948 static inline size_t vlc_ml_count_album_tracks( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_album_id )
950 vlc_assert( p_ml != NULL );
951 size_t count;
952 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_ALBUM_TRACKS, params, i_album_id, &count ) != VLC_SUCCESS )
953 return 0;
954 return count;
957 static inline vlc_ml_media_list_t* vlc_ml_list_album_artists( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_album_id )
959 vlc_assert( p_ml != NULL );
960 vlc_ml_media_list_t* res;
961 if ( vlc_ml_list( p_ml, VLC_ML_LIST_ALBUM_ARTISTS, params, i_album_id, &res ) != VLC_SUCCESS )
962 return NULL;
963 return res;
966 static inline size_t vlc_ml_count_album_artists( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_album_id )
968 vlc_assert( p_ml != NULL );
969 size_t count;
970 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_ALBUM_ARTISTS, params, i_album_id, &count ) != VLC_SUCCESS )
971 return 0;
972 return count;
975 static inline vlc_ml_album_list_t* vlc_ml_list_artist_albums( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_artist_id )
977 vlc_assert( p_ml != NULL );
978 vlc_ml_album_list_t* res;
979 if ( vlc_ml_list( p_ml, VLC_ML_LIST_ARTIST_ALBUMS, params, i_artist_id, &res ) != VLC_SUCCESS )
980 return NULL;
981 return res;
984 static inline size_t vlc_ml_count_artist_albums( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_artist_id )
986 vlc_assert( p_ml != NULL );
987 size_t count;
988 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_ARTIST_ALBUMS, params, i_artist_id, &count ) != VLC_SUCCESS )
989 return 0;
990 return count;
993 static inline vlc_ml_media_list_t* vlc_ml_list_artist_tracks( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_artist_id )
995 vlc_assert( p_ml != NULL );
996 vlc_ml_media_list_t* res;
997 if ( vlc_ml_list( p_ml, VLC_ML_LIST_ARTIST_TRACKS, params, i_artist_id, &res ) != VLC_SUCCESS )
998 return NULL;
999 return res;
1002 static inline size_t vlc_ml_count_artist_tracks( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_artist_id )
1004 vlc_assert( p_ml != NULL );
1005 size_t count;
1006 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_ARTIST_TRACKS, params, i_artist_id, &count ) != VLC_SUCCESS )
1007 return 0;
1008 return count;
1011 static inline vlc_ml_media_list_t* vlc_ml_list_video_media( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1013 vlc_assert( p_ml != NULL );
1014 vlc_ml_media_list_t* res;
1015 if ( vlc_ml_list( p_ml, VLC_ML_LIST_VIDEOS, params, &res ) != VLC_SUCCESS )
1016 return NULL;
1017 return res;
1020 static inline size_t vlc_ml_count_video_media( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1022 vlc_assert( p_ml != NULL );
1023 size_t count;
1024 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_VIDEOS, params, &count ) != VLC_SUCCESS )
1025 return 0;
1026 return count;
1029 static inline vlc_ml_media_list_t* vlc_ml_list_audio_media( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1031 vlc_assert( p_ml != NULL );
1032 vlc_ml_media_list_t* res;
1033 if ( vlc_ml_list( p_ml, VLC_ML_LIST_AUDIOS, params, &res ) != VLC_SUCCESS )
1034 return NULL;
1035 return res;
1038 static inline size_t vlc_ml_count_audio_media( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1040 vlc_assert( p_ml != NULL );
1041 size_t count;
1042 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_AUDIOS, params, &count ) != VLC_SUCCESS )
1043 return 0;
1044 return count;
1047 static inline vlc_ml_album_list_t* vlc_ml_list_albums( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1049 vlc_assert( p_ml != NULL );
1050 vlc_ml_album_list_t* res;
1051 if ( vlc_ml_list( p_ml, VLC_ML_LIST_ALBUMS, params, &res ) != VLC_SUCCESS )
1052 return NULL;
1053 return res;
1056 static inline size_t vlc_ml_count_albums( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1058 vlc_assert( p_ml != NULL );
1059 size_t count;
1060 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_ALBUMS, params, &count ) != VLC_SUCCESS )
1061 return 0;
1062 return count;
1065 static inline vlc_ml_genre_list_t* vlc_ml_list_genres( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1067 vlc_assert( p_ml != NULL );
1068 vlc_ml_genre_list_t* res;
1069 if ( vlc_ml_list( p_ml, VLC_ML_LIST_GENRES, params, &res ) != VLC_SUCCESS )
1070 return NULL;
1071 return res;
1074 static inline size_t vlc_ml_count_genres( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1076 vlc_assert( p_ml != NULL );
1077 size_t count;
1078 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_GENRES, params, &count ) != VLC_SUCCESS )
1079 return 0;
1080 return count;
1084 * @brief vlc_ml_list_artists
1085 * @param params Query parameters, or NULL for the default
1086 * @param b_include_all True if you wish to fetch artists without at least one album.
1087 * @return
1089 static inline vlc_ml_artist_list_t* vlc_ml_list_artists( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, bool b_include_all )
1091 vlc_assert( p_ml != NULL );
1092 vlc_ml_artist_list_t* res;
1093 if ( vlc_ml_list( p_ml, VLC_ML_LIST_ARTISTS, params, (int)b_include_all, &res ) != VLC_SUCCESS )
1094 return NULL;
1095 return res;
1098 static inline size_t vlc_ml_count_artists( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, bool includeAll )
1100 vlc_assert( p_ml != NULL );
1101 size_t count;
1102 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_ARTISTS, params, includeAll, &count ) != VLC_SUCCESS )
1103 return 0;
1104 return count;
1107 static inline vlc_ml_show_list_t* vlc_ml_list_shows( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1109 vlc_assert( p_ml != NULL );
1110 vlc_ml_show_list_t* res;
1111 if ( vlc_ml_list( p_ml, VLC_ML_LIST_SHOWS, params, &res ) != VLC_SUCCESS )
1112 return NULL;
1113 return res;
1116 static inline size_t vlc_ml_count_shows( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1118 vlc_assert( p_ml != NULL );
1119 size_t count;
1120 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_SHOWS, params, &count ) != VLC_SUCCESS )
1121 return 0;
1122 return count;
1125 static inline vlc_ml_media_list_t* vlc_ml_list_genre_artists( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_genre_id )
1127 vlc_assert( p_ml != NULL );
1128 vlc_ml_media_list_t* res;
1129 if ( vlc_ml_list( p_ml, VLC_ML_LIST_GENRE_ARTISTS, params, i_genre_id, &res ) != VLC_SUCCESS )
1130 return NULL;
1131 return res;
1134 static inline size_t vlc_ml_count_genre_artists( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_genre_id )
1136 vlc_assert( p_ml != NULL );
1137 size_t count;
1138 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_GENRE_ARTISTS, params, i_genre_id, &count ) != VLC_SUCCESS )
1139 return 0;
1140 return count;
1143 static inline vlc_ml_media_list_t* vlc_ml_list_genre_tracks( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_genre_id )
1145 vlc_assert( p_ml != NULL );
1146 vlc_ml_media_list_t* res;
1147 if ( vlc_ml_list( p_ml, VLC_ML_LIST_GENRE_TRACKS, params, i_genre_id, &res ) != VLC_SUCCESS )
1148 return NULL;
1149 return res;
1152 static inline size_t vlc_ml_count_genre_tracks( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_genre_id )
1154 vlc_assert( p_ml != NULL );
1155 size_t count;
1156 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_GENRE_TRACKS, params, i_genre_id, &count ) != VLC_SUCCESS )
1157 return 0;
1158 return count;
1161 static inline vlc_ml_album_list_t* vlc_ml_list_genre_albums( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_genre_id )
1163 vlc_assert( p_ml != NULL );
1164 vlc_ml_album_list_t* res;
1165 if ( vlc_ml_list( p_ml, VLC_ML_LIST_GENRE_ALBUMS, params, i_genre_id, &res ) != VLC_SUCCESS )
1166 return NULL;
1167 return res;
1170 static inline size_t vlc_ml_count_genre_albums( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_genre_id )
1172 vlc_assert( p_ml != NULL );
1173 size_t count;
1174 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_GENRE_ALBUMS, params, i_genre_id, &count ) != VLC_SUCCESS )
1175 return 0;
1176 return count;
1179 static inline vlc_ml_media_list_t* vlc_ml_list_show_episodes( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_show_id )
1181 vlc_assert( p_ml != NULL );
1182 vlc_ml_media_list_t* res;
1183 if ( vlc_ml_list( p_ml, VLC_ML_LIST_SHOW_EPISODES, params, i_show_id, &res ) != VLC_SUCCESS )
1184 return NULL;
1185 return res;
1188 static inline size_t vlc_ml_count_show_episodes( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_show_id )
1190 vlc_assert( p_ml != NULL );
1191 size_t count;
1192 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_GENRE_ALBUMS, params, i_show_id, &count ) != VLC_SUCCESS )
1193 return 0;
1194 return count;
1197 static inline vlc_ml_label_list_t* vlc_ml_list_media_labels( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_media_id )
1199 vlc_assert( p_ml != NULL );
1200 vlc_ml_label_list_t* res;
1201 if ( vlc_ml_list( p_ml, VLC_ML_LIST_MEDIA_LABELS, params, i_media_id, &res ) != VLC_SUCCESS )
1202 return NULL;
1203 return res;
1206 static inline size_t vlc_ml_count_media_labels( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_media_id )
1208 vlc_assert( p_ml != NULL );
1209 size_t count;
1210 if ( vlc_ml_list( p_ml, VLC_ML_LIST_MEDIA_LABELS, params, i_media_id, &count ) != VLC_SUCCESS )
1211 return 0;
1212 return count;
1215 static inline vlc_ml_media_list_t* vlc_ml_list_history( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1217 vlc_assert( p_ml != NULL );
1218 vlc_ml_media_list_t* res;
1219 if ( vlc_ml_list( p_ml, VLC_ML_LIST_HISTORY, params, &res ) != VLC_SUCCESS )
1220 return NULL;
1221 return res;
1224 static inline vlc_ml_media_list_t* vlc_ml_list_stream_history( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1226 vlc_assert( p_ml != NULL );
1227 vlc_ml_media_list_t* res;
1228 if ( vlc_ml_list( p_ml, VLC_ML_LIST_STREAM_HISTORY, params, &res ) != VLC_SUCCESS )
1229 return NULL;
1230 return res;
1233 static inline vlc_ml_playlist_list_t* vlc_ml_list_playlists( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1235 vlc_assert( p_ml != NULL );
1236 vlc_ml_playlist_list_t* res;
1237 if ( vlc_ml_list( p_ml, VLC_ML_LIST_PLAYLISTS, params, &res ) != VLC_SUCCESS )
1238 return NULL;
1239 return res;
1242 static inline size_t vlc_ml_count_playlists( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
1244 vlc_assert( p_ml != NULL );
1245 size_t count;
1246 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_PLAYLISTS, params, &count ) != VLC_SUCCESS )
1247 return 0;
1248 return count;
1251 static inline vlc_ml_media_list_t* vlc_ml_list_playlist_media( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_playlist_id )
1253 vlc_assert( p_ml != NULL );
1254 vlc_ml_media_list_t* res;
1255 if ( vlc_ml_list( p_ml, VLC_ML_LIST_PLAYLIST_MEDIA, params, i_playlist_id, &res ) != VLC_SUCCESS )
1256 return NULL;
1257 return res;
1260 static inline size_t vlc_ml_count_playlist_media( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, int64_t i_playlist_id )
1262 vlc_assert( p_ml != NULL );
1263 size_t count;
1264 if ( vlc_ml_list( p_ml, VLC_ML_COUNT_PLAYLIST_MEDIA, params, i_playlist_id, &count ) != VLC_SUCCESS )
1265 return 0;
1266 return count;
1269 #ifdef __cplusplus
1271 #endif /* C++ */
1273 #ifndef __cplusplus
1274 # define vlc_ml_release( OBJ ) _Generic( ( OBJ ), \
1275 vlc_ml_show_t*: vlc_ml_show_release, \
1276 vlc_ml_artist_t*: vlc_ml_artist_release, \
1277 vlc_ml_album_t*: vlc_ml_album_release, \
1278 vlc_ml_genre_t*: vlc_ml_genre_release, \
1279 vlc_ml_media_t*: vlc_ml_media_release, \
1280 vlc_ml_playlist_t*: vlc_ml_playlist_release, \
1281 vlc_ml_label_list_t*: vlc_ml_label_list_release, \
1282 vlc_ml_file_list_t*: vlc_ml_file_list_release, \
1283 vlc_ml_artist_list_t*: vlc_ml_artist_list_release, \
1284 vlc_ml_media_list_t*: vlc_ml_media_list_release, \
1285 vlc_ml_album_list_t*: vlc_ml_album_list_release, \
1286 vlc_ml_show_list_t*: vlc_ml_show_list_release, \
1287 vlc_ml_genre_list_t*: vlc_ml_genre_list_release, \
1288 vlc_ml_playlist_list_t*: vlc_ml_playlist_list_release, \
1289 vlc_ml_entry_point_list_t*: vlc_ml_entry_point_list_release \
1290 )( OBJ )
1291 #else
1292 static inline void vlc_ml_release( vlc_ml_show_t* show ) { vlc_ml_show_release( show ); }
1293 static inline void vlc_ml_release( vlc_ml_artist_t* artist ) { vlc_ml_artist_release( artist ); }
1294 static inline void vlc_ml_release( vlc_ml_album_t* album ) { vlc_ml_album_release( album ); }
1295 static inline void vlc_ml_release( vlc_ml_genre_t* genre ) { vlc_ml_genre_release( genre ); }
1296 static inline void vlc_ml_release( vlc_ml_media_t* media ) { vlc_ml_media_release( media ); }
1297 static inline void vlc_ml_release( vlc_ml_playlist_t* playlist ) { vlc_ml_playlist_release( playlist ); }
1298 static inline void vlc_ml_release( vlc_ml_label_list_t* list ) { vlc_ml_label_list_release( list ); }
1299 static inline void vlc_ml_release( vlc_ml_file_list_t* list ) { vlc_ml_file_list_release( list ); }
1300 static inline void vlc_ml_release( vlc_ml_artist_list_t* list ) { vlc_ml_artist_list_release( list ); }
1301 static inline void vlc_ml_release( vlc_ml_media_list_t* list ) { vlc_ml_media_list_release( list ); }
1302 static inline void vlc_ml_release( vlc_ml_album_list_t* list ) { vlc_ml_album_list_release( list ); }
1303 static inline void vlc_ml_release( vlc_ml_show_list_t* list ) { vlc_ml_show_list_release( list ); }
1304 static inline void vlc_ml_release( vlc_ml_genre_list_t* list ) { vlc_ml_genre_list_release( list ); }
1305 static inline void vlc_ml_release( vlc_ml_playlist_list_t* list ) { vlc_ml_playlist_list_release( list ); }
1306 static inline void vlc_ml_release( vlc_ml_entry_point_list_t* list ) { vlc_ml_entry_point_list_release( list ); }
1307 #endif
1309 #endif /* VLC_MEDIA_LIBRARY_H */