medialib: add function to get history count

This commit is contained in:
Pierre Lamot 2020-10-14 15:42:50 +02:00
parent dcf865237f
commit d91ce0b082
2 changed files with 26 additions and 4 deletions

View File

@ -399,6 +399,7 @@ enum vlc_ml_list_queries
VLC_ML_LIST_PLAYLISTS, /**< arg1 (out): vlc_ml_playlist_list_t** */
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_STREAM_HISTORY, /**< arg1 (out): vlc_ml_media_list_t** */
VLC_ML_COUNT_STREAM_HISTORY, /**< arg1 (out): size_t* */
@ -1428,6 +1429,16 @@ static inline vlc_ml_media_list_t* vlc_ml_list_history( vlc_medialibrary_t* p_ml
return res;
}
static inline size_t vlc_ml_count_history( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params )
{
vlc_assert( p_ml != NULL );
size_t count;
if ( vlc_ml_list( p_ml, VLC_ML_COUNT_HISTORY, params, &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 );

View File

@ -862,14 +862,25 @@ int MediaLibrary::List( int listQuery, const vlc_ml_query_params_t* params, va_l
case VLC_ML_COUNT_PLAYLISTS:
return listPlaylist( listQuery, paramsPtr, psz_pattern, nbItems, offset, args );
case VLC_ML_LIST_HISTORY:
case VLC_ML_COUNT_HISTORY:
{
auto query = m_ml->history();
if ( query == nullptr )
return VLC_EGENERIC;
*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;
switch ( listQuery )
{
case VLC_ML_LIST_HISTORY:
*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:
*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: