[vlc-commits] medialibrary: Add playlist support
Benjamin Arnaud
git at videolan.org
Tue Feb 23 08:54:07 UTC 2021
vlc | branch: master | Benjamin Arnaud <benjamin.arnaud at videolabs.io> | Fri Feb 19 11:25:25 2021 +0100| [b431e9da08851984aabd37a4db42790c3224575d] | committer: Pierre Lamot
medialibrary: Add playlist support
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b431e9da08851984aabd37a4db42790c3224575d
---
include/vlc_media_library.h | 34 ++++++++++++++++++++++++++++++
modules/misc/medialibrary/medialibrary.cpp | 25 ++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index fde638692d..38cf37f895 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -498,6 +498,11 @@ enum vlc_ml_control
VLC_ML_MEDIA_REMOVE_BOOKMARK, /**< arg1: media id; arg2: int64_t */
VLC_ML_MEDIA_REMOVE_ALL_BOOKMARKS, /**< arg1: media id */
VLC_ML_MEDIA_UPDATE_BOOKMARK, /**< arg1: media id; arg2: int64_t; arg3: const char*; arg4: const char* */
+
+ /* Playlist management */
+ VLC_ML_PLAYLIST_CREATE, /**< arg1: const char*; arg2(out): vlc_ml_playlist_t**; can fail */
+ VLC_ML_PLAYLIST_DELETE, /**< arg1: playlist id; can fail */
+ VLC_ML_PLAYLIST_APPEND /**< arg1: playlist id; arg2: media id; can fail */
};
/**
@@ -1045,6 +1050,35 @@ vlc_ml_media_remove_all_bookmarks( vlc_medialibrary_t* p_ml, int64_t i_media_id
return vlc_ml_control( p_ml, VLC_ML_MEDIA_REMOVE_ALL_BOOKMARKS, i_media_id );
}
+static inline vlc_ml_playlist_t*
+vlc_ml_playlist_create( vlc_medialibrary_t * p_ml, const char * name)
+{
+ assert( p_ml != NULL );
+
+ vlc_ml_playlist_t* result;
+
+ if (vlc_ml_control( p_ml, VLC_ML_PLAYLIST_CREATE, name, &result ) != VLC_SUCCESS )
+ return NULL;
+
+ return result;
+}
+
+static inline int
+vlc_ml_playlist_delete( vlc_medialibrary_t * p_ml, int64_t i_playlist_id )
+{
+ assert( p_ml != NULL );
+
+ return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_DELETE, i_playlist_id );
+}
+
+static inline int
+vlc_ml_playlist_append( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, int64_t i_media_id )
+{
+ assert( p_ml != NULL );
+
+ return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_APPEND, i_playlist_id, i_media_id );
+}
+
static inline vlc_ml_media_t* vlc_ml_get_media( vlc_medialibrary_t* p_ml, int64_t i_media_id )
{
return (vlc_ml_media_t*)vlc_ml_get( p_ml, VLC_ML_GET_MEDIA, i_media_id );
diff --git a/modules/misc/medialibrary/medialibrary.cpp b/modules/misc/medialibrary/medialibrary.cpp
index 6c4583f66e..1df3c59473 100644
--- a/modules/misc/medialibrary/medialibrary.cpp
+++ b/modules/misc/medialibrary/medialibrary.cpp
@@ -623,6 +623,31 @@ int MediaLibrary::Control( int query, va_list args )
case VLC_ML_MEDIA_REMOVE_ALL_BOOKMARKS:
case VLC_ML_MEDIA_UPDATE_BOOKMARK:
return controlMedia( query, args );
+ case VLC_ML_PLAYLIST_CREATE:
+ {
+ auto name = va_arg( args, const char * );
+ auto playlist = m_ml->createPlaylist( name );
+ if ( playlist == nullptr )
+ return VLC_EGENERIC;
+ auto result = va_arg( args, vlc_ml_playlist_t** );
+ *result = CreateAndConvert<vlc_ml_playlist_t>( playlist.get() );
+ return VLC_SUCCESS;
+ }
+ case VLC_ML_PLAYLIST_DELETE:
+ {
+ if ( m_ml->deletePlaylist( va_arg( args, int64_t ) ) == false )
+ return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
+ case VLC_ML_PLAYLIST_APPEND:
+ {
+ auto playlist = m_ml->playlist( va_arg( args, int64_t ) );
+ if ( playlist == nullptr )
+ return VLC_EGENERIC;
+ if ( playlist->append(va_arg( args, int64_t )) == false )
+ return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
default:
return VLC_EGENERIC;
}
More information about the vlc-commits
mailing list