[vlc-devel] [PATCH 13/14] medialibrary: Expose onHistoryChange event

Hugo Beauzée-Luyssen hugo at beauzee.fr
Mon Sep 23 11:44:56 CEST 2019


---
 include/vlc_media_library.h            | 17 +++++++++++++++++
 modules/misc/medialibrary/medialib.cpp | 16 +++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index 78b44f6538..6edb412312 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -76,6 +76,12 @@ typedef enum vlc_ml_thumbnail_size_t
     VLC_ML_THUMBNAIL_SIZE_COUNT
 } vlc_ml_thumbnail_size_t;
 
+typedef enum vlc_ml_history_type_t
+{
+    VLC_ML_HISTORY_TYPE_MEDIA,
+    VLC_ML_HISTORY_TYPE_NETWORK,
+} vlc_ml_history_type_t;
+
 typedef struct vlc_ml_thumbnail_t
 {
     char* psz_mrl;
@@ -628,6 +634,13 @@ enum vlc_ml_event_type
      * vlc_ml_event_t::media_thumbnail_generated::b_success
      */
     VLC_ML_EVENT_MEDIA_THUMBNAIL_GENERATED,
+    /**
+     * Sent after the history gets changed. It can be either cleaned, or simply
+     * modified because a media was recently played/removed from the history.
+     * The history type (media/network) is stored in
+     * vlc_ml_event_t::history_changed::history_type
+     */
+    VLC_ML_EVENT_HISTORY_CHANGED,
 };
 
 typedef struct vlc_ml_event_t
@@ -703,6 +716,10 @@ typedef struct vlc_ml_event_t
             vlc_ml_thumbnail_size_t i_size;
             bool b_success;
         } media_thumbnail_generated;
+        struct
+        {
+            vlc_ml_history_type_t history_type;
+        } history_changed;
     };
 } vlc_ml_event_t;
 
diff --git a/modules/misc/medialibrary/medialib.cpp b/modules/misc/medialibrary/medialib.cpp
index 9cf425fdad..baf44270ff 100644
--- a/modules/misc/medialibrary/medialib.cpp
+++ b/modules/misc/medialibrary/medialib.cpp
@@ -303,8 +303,22 @@ void MediaLibrary::onMediaThumbnailReady( medialibrary::MediaPtr media,
     m_vlc_ml->cbs->pf_send_event( m_vlc_ml, &ev );
 }
 
-void MediaLibrary::onHistoryChanged( medialibrary::HistoryType )
+void MediaLibrary::onHistoryChanged( medialibrary::HistoryType historyType )
 {
+    vlc_ml_event_t ev;
+    ev.i_type = VLC_ML_EVENT_HISTORY_CHANGED;
+    switch ( historyType )
+    {
+        case medialibrary::HistoryType::Media:
+            ev.history_changed.history_type = VLC_ML_HISTORY_TYPE_MEDIA;
+            break;
+        case medialibrary::HistoryType::Network:
+            ev.history_changed.history_type = VLC_ML_HISTORY_TYPE_NETWORK;
+            break;
+        default:
+            vlc_assert_unreachable();
+    }
+    m_vlc_ml->cbs->pf_send_event( m_vlc_ml, &ev );
 }
 
 MediaLibrary::MediaLibrary( vlc_medialibrary_module_t* ml )
-- 
2.20.1



More information about the vlc-devel mailing list