vlc | branch: master | Pierre Lamot <pie...@videolabs.io> | Wed Dec 9 11:19:08 2020 +0100| [b03d64acfb13b69276180e0131218f6dc1a01007] | committer: Pierre Lamot
medialib: add function to get media history by type > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b03d64acfb13b69276180e0131218f6dc1a01007 --- include/vlc_media_library.h | 22 ++++++++++++++++++++++ modules/misc/medialibrary/medialib.cpp | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h index fbc8ff8676..fde638692d 100644 --- a/include/vlc_media_library.h +++ b/include/vlc_media_library.h @@ -400,6 +400,8 @@ enum vlc_ml_list_queries VLC_ML_COUNT_PLAYLISTS, /**< arg1 (out): size_t* */ VLC_ML_LIST_HISTORY, /**< arg1 (out): vlc_ml_media_list_t** */ VLC_ML_COUNT_HISTORY, /**< arg1 (out): size_t* */ + VLC_ML_LIST_HISTORY_BY_TYPE, /**< arg1 vlc_ml_media_type_t: the media type. arg2 (out): vlc_ml_media_list_t** */ + VLC_ML_COUNT_HISTORY_BY_TYPE, /**< arg1 vlc_ml_media_type_t: the media type. arg2 (out): vlc_ml_media_list_t***/ VLC_ML_LIST_STREAM_HISTORY, /**< arg1 (out): vlc_ml_media_list_t** */ VLC_ML_COUNT_STREAM_HISTORY, /**< arg1 (out): size_t* */ @@ -1439,6 +1441,26 @@ static inline size_t vlc_ml_count_history( vlc_medialibrary_t* p_ml, const vlc_m } +static inline vlc_ml_media_list_t* vlc_ml_list_history_by_type( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, vlc_ml_media_type_t type ) +{ + vlc_assert( p_ml != NULL ); + vlc_ml_media_list_t* res; + if ( vlc_ml_list( p_ml, VLC_ML_LIST_HISTORY_BY_TYPE, params, (int)type, &res ) != VLC_SUCCESS ) + return NULL; + return res; +} + +static inline size_t vlc_ml_count_history_by_type( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params, vlc_ml_media_type_t type ) +{ + vlc_assert( p_ml != NULL ); + size_t count; + if ( vlc_ml_list( p_ml, VLC_ML_COUNT_HISTORY_BY_TYPE, params, (int)type, &count ) != VLC_SUCCESS ) + return 0; + return count; +} + + + static inline vlc_ml_media_list_t* vlc_ml_list_stream_history( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params ) { vlc_assert( p_ml != NULL ); diff --git a/modules/misc/medialibrary/medialib.cpp b/modules/misc/medialibrary/medialib.cpp index 5f3c2fc493..3cd342f833 100644 --- a/modules/misc/medialibrary/medialib.cpp +++ b/modules/misc/medialibrary/medialib.cpp @@ -882,6 +882,28 @@ int MediaLibrary::List( int listQuery, const vlc_ml_query_params_t* params, va_l vlc_assert_unreachable(); } } + case VLC_ML_COUNT_HISTORY_BY_TYPE: + case VLC_ML_LIST_HISTORY_BY_TYPE: + { + auto type = va_arg(args, int); + auto query = m_ml->history(static_cast<medialibrary::IMedia::Type>( type )); + if ( query == nullptr ) + return VLC_EGENERIC; + + switch ( listQuery ) + { + case VLC_ML_LIST_HISTORY_BY_TYPE: + *va_arg( args, vlc_ml_media_list_t**) = + ml_convert_list<vlc_ml_media_list_t, vlc_ml_media_t>( + query->items( nbItems, offset ) ); + return VLC_SUCCESS; + case VLC_ML_COUNT_HISTORY_BY_TYPE: + *va_arg( args, size_t* ) = query->count(); + return VLC_SUCCESS; + default: + vlc_assert_unreachable(); + } + } case VLC_ML_LIST_STREAM_HISTORY: case VLC_ML_COUNT_STREAM_HISTORY: { _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits