[vlc-devel] [PATCH 15/18] medialibrary: add function to get stream history count

Prince Gupta guptaprince8832 at gmail.com
Wed Sep 23 19:40:13 CEST 2020


---
 include/vlc_media_library.h            | 10 ++++++++++
 modules/misc/medialibrary/medialib.cpp | 18 ++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index 0ac5f039aa..39d41efac1 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -400,6 +400,7 @@ 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_LIST_STREAM_HISTORY,   /**< arg1 (out): vlc_ml_media_list_t**                            */
+    VLC_ML_COUNT_STREAM_HISTORY,  /**< arg1 (out): size_t*                                          */
 
     /* Album specific listings */
     VLC_ML_LIST_ALBUM_TRACKS,     /**< arg1: The album id. arg2 (out): vlc_ml_media_list_t**  */
@@ -1436,6 +1437,15 @@ static inline vlc_ml_media_list_t* vlc_ml_list_stream_history( vlc_medialibrary_
     return res;
 }
 
+static inline size_t vlc_ml_count_stream_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_STREAM_HISTORY, params, &count ) != VLC_SUCCESS )
+        return 0;
+    return count;
+}
+
 static inline vlc_ml_playlist_list_t* vlc_ml_list_playlists( 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 b0355b89c1..056f6be4a0 100644
--- a/modules/misc/medialibrary/medialib.cpp
+++ b/modules/misc/medialibrary/medialib.cpp
@@ -872,14 +872,24 @@ int MediaLibrary::List( int listQuery, const vlc_ml_query_params_t* params, va_l
             return VLC_SUCCESS;
         }
         case VLC_ML_LIST_STREAM_HISTORY:
+        case VLC_ML_COUNT_STREAM_HISTORY:
         {
             auto query = m_ml->streamHistory();
             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_STREAM_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_STREAM_HISTORY:
+                    *va_arg( args, size_t* ) = query->count();
+                    return VLC_SUCCESS;
+                default:
+                    vlc_assert_unreachable();
+            }
         }
     }
     return VLC_SUCCESS;
-- 
2.25.1



More information about the vlc-devel mailing list