[vlc-devel] [PATCH 3/3] medialibrary: add folder listing
Alaric Senat
dev.asenat at posteo.net
Mon Mar 8 13:35:00 UTC 2021
This patch adds new functions to list and access the medialibrary folder
interface.
---
include/vlc_media_library.h | 27 ++++++----
modules/misc/medialibrary/medialibrary.cpp | 63 ++++++++++++++++++++++
2 files changed, 81 insertions(+), 9 deletions(-)
diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index 9e3895a7d4..39342c7a88 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -370,15 +370,16 @@ struct vlc_ml_query_params_t
enum vlc_ml_get_queries
{
- VLC_ML_GET_MEDIA, /**< arg1: Media ID; ret: vlc_ml_media_t* */
- VLC_ML_GET_MEDIA_BY_MRL, /**< arg1: Media MRL; ret: vlc_ml_media_t* */
- VLC_ML_GET_INPUT_ITEM, /**< arg1: Media ID; ret: input_item_t* */
- VLC_ML_GET_INPUT_ITEM_BY_MRL,/**< arg1: Media MRL; ret: input_item_t* */
- VLC_ML_GET_ALBUM, /**< arg1: Album ID; ret: vlc_ml_album_t* */
- VLC_ML_GET_ARTIST, /**< arg1: Artist ID; ret: vlc_ml_artist_t* */
- VLC_ML_GET_GENRE, /**< arg1: Genre ID; ret: vlc_ml_genre_t* */
- VLC_ML_GET_SHOW, /**< arg1: Show ID; ret: vlc_ml_show_t* */
- VLC_ML_GET_PLAYLIST, /**< arg1: Playlist ID; ret: vlc_ml_playlist_t* */
+ VLC_ML_GET_MEDIA, /**< arg1: Media ID; ret: vlc_ml_media_t* */
+ VLC_ML_GET_MEDIA_BY_MRL, /**< arg1: Media MRL; ret: vlc_ml_media_t* */
+ VLC_ML_GET_INPUT_ITEM, /**< arg1: Media ID; ret: input_item_t* */
+ VLC_ML_GET_INPUT_ITEM_BY_MRL, /**< arg1: Media MRL; ret: input_item_t* */
+ VLC_ML_GET_ALBUM, /**< arg1: Album ID; ret: vlc_ml_album_t* */
+ VLC_ML_GET_ARTIST, /**< arg1: Artist ID; ret: vlc_ml_artist_t* */
+ VLC_ML_GET_GENRE, /**< arg1: Genre ID; ret: vlc_ml_genre_t* */
+ VLC_ML_GET_SHOW, /**< arg1: Show ID; ret: vlc_ml_show_t* */
+ VLC_ML_GET_PLAYLIST, /**< arg1: Playlist ID; ret: vlc_ml_playlist_t* */
+ VLC_ML_GET_FOLDER, /**< arg1: folder ID; ret: vlc_ml_folder_t* */
};
enum vlc_ml_list_queries
@@ -407,6 +408,8 @@ enum vlc_ml_list_queries
VLC_ML_COUNT_STREAM_HISTORY, /**< arg1 (out): size_t* */
VLC_ML_LIST_ENTRY_POINTS, /**< arg1 bool: list_banned; arg2 (out): vlc_ml_folder_list_t** */
VLC_ML_COUNT_ENTRY_POINTS, /**< arg1 bool: list_banned; arg2 (out): size_t* */
+ VLC_ML_LIST_FOLDERS, /**< arg1 (out): vlc_ml_folder_list_t** */
+ VLC_ML_COUNT_FOLDERS, /**< arg1 (out): size_t* */
/* Album specific listings */
VLC_ML_LIST_ALBUM_TRACKS, /**< arg1: The album id. arg2 (out): vlc_ml_media_list_t** */
@@ -441,6 +444,12 @@ enum vlc_ml_list_queries
VLC_ML_LIST_PLAYLIST_MEDIA, /**< arg1: playlist id; arg2 (out): vlc_ml_media_list_t** */
VLC_ML_COUNT_PLAYLIST_MEDIA, /**< arg1: playlist id; arg2 (out): size_t* */
+ /* Folder specific listings */
+ VLC_ML_LIST_SUBFOLDERS, /**< arg1: parent id; arg2 (out): vlc_ml_folder_list_t** */
+ VLC_ML_COUNT_SUBFOLDERS, /**< arg1: parent id; arg2 (out): size_t* */
+ VLC_ML_LIST_FOLDER_MEDIAS, /**< arg1: folder id; arg2 (out): vlc_ml_media_list_t** */
+ VLC_ML_COUNT_FOLDER_MEDIAS, /**< arg1: folder id; arg2 (out): size_t* */
+
/* Children entities listing */
VLC_ML_LIST_MEDIA_OF, /**< arg1: parent entity type; arg2: parent entity id; arg3(out): ml_media_list_t** */
VLC_ML_COUNT_MEDIA_OF, /**< arg1: parent entity type; arg2: parent entity id; arg3(out): size_t* */
diff --git a/modules/misc/medialibrary/medialibrary.cpp b/modules/misc/medialibrary/medialibrary.cpp
index a64654218a..e8518af283 100644
--- a/modules/misc/medialibrary/medialibrary.cpp
+++ b/modules/misc/medialibrary/medialibrary.cpp
@@ -967,6 +967,63 @@ int MediaLibrary::List( int listQuery, const vlc_ml_query_params_t* params, va_l
*( va_arg( args, size_t* ) ) = query ? query->count() : 0;
break;
}
+ case VLC_ML_LIST_SUBFOLDERS:
+ {
+ const auto parent = m_ml->folder( va_arg( args, int64_t ) );
+ if ( parent == nullptr )
+ return VLC_EGENERIC;
+ const auto query = parent->subfolders();
+ if ( query == nullptr )
+ return VLC_EGENERIC;
+ auto* res = ml_convert_list<vlc_ml_folder_list_t, vlc_ml_folder_t>( query->all() );
+ *( va_arg( args, vlc_ml_folder_list_t** ) ) = res;
+ break;
+ }
+ case VLC_ML_COUNT_SUBFOLDERS:
+ {
+ const auto parent = m_ml->folder( va_arg( args, int64_t ) );
+ if ( parent == nullptr )
+ return VLC_EGENERIC;
+ const auto query = parent->subfolders();
+ *( va_arg( args, size_t* ) ) = query == nullptr ? 0 : query->count();
+ break;
+ }
+ case VLC_ML_LIST_FOLDERS:
+ {
+ const auto query = m_ml->folders( medialibrary::IMedia::Type::Unknown, paramsPtr );
+ if ( query == nullptr )
+ return VLC_EGENERIC;
+ auto* res = ml_convert_list<vlc_ml_folder_list_t, vlc_ml_folder_t>( query->all() );
+ *( va_arg( args, vlc_ml_folder_list_t** ) ) = res;
+ break;
+ }
+ case VLC_ML_COUNT_FOLDERS:
+ {
+ const auto query = m_ml->folders( medialibrary::IMedia::Type::Unknown, paramsPtr );
+ *( va_arg( args, size_t* ) ) = query == nullptr ? 0 : query->count();
+ break;
+ }
+ case VLC_ML_LIST_FOLDER_MEDIAS:
+ {
+ const auto folder = m_ml->folder( va_arg( args, int64_t ) );
+ if ( folder == nullptr )
+ return VLC_EGENERIC;
+ const auto query = folder->media( medialibrary::IMedia::Type::Unknown, paramsPtr );
+ if ( query == nullptr )
+ return VLC_EGENERIC;
+ auto* res = ml_convert_list<vlc_ml_media_list_t, vlc_ml_media_t>( query->all() );
+ *( va_arg( args, vlc_ml_media_list_t** ) ) = res;
+ break;
+ }
+ case VLC_ML_COUNT_FOLDER_MEDIAS:
+ {
+ const auto folder = m_ml->folder( va_arg( args, int64_t ) );
+ if ( folder == nullptr )
+ return VLC_EGENERIC;
+ const auto query = folder->media( medialibrary::IMedia::Type::Unknown, paramsPtr );
+ *( va_arg( args, size_t* ) ) = query == nullptr ? 0 : query->count();
+ break;
+ }
}
return VLC_SUCCESS;
}
@@ -1020,6 +1077,12 @@ void* MediaLibrary::Get( int query, va_list args )
auto playlist = m_ml->playlist( id );
return CreateAndConvert<vlc_ml_playlist_t>( playlist.get() );
}
+ case VLC_ML_GET_FOLDER:
+ {
+ auto id = va_arg( args, int64_t );
+ auto folder = m_ml->folder( id );
+ return CreateAndConvert<vlc_ml_folder_t>( folder.get() );
+ }
case VLC_ML_GET_MEDIA_BY_MRL:
{
auto mrl = va_arg( args, const char* );
--
2.29.2
More information about the vlc-devel
mailing list