[vlc-commits] medialibrary: Expose onHistoryChange event

Hugo Beauzée-Luyssen git at videolan.org
Tue Sep 24 14:34:30 CEST 2019


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Jul 31 11:17:13 2019 +0200| [f12cd172a9f760e7f4ee6adfce58119fda2fca55] | committer: Hugo Beauzée-Luyssen

medialibrary: Expose onHistoryChange event

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f12cd172a9f760e7f4ee6adfce58119fda2fca55
---

 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 138fb19f05..8c599a3710 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
@@ -707,6 +720,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 3b1a210eb6..cdbf5e39a7 100644
--- a/modules/misc/medialibrary/medialib.cpp
+++ b/modules/misc/medialibrary/medialib.cpp
@@ -317,8 +317,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 )



More information about the vlc-commits mailing list