[vlc-devel] [PATCH 01/15] medialibrary: Add playlist insert, move and remove
Benjamin Arnaud
benjamin.arnaud at videolabs.io
Thu Mar 11 09:16:45 UTC 2021
---
include/vlc_media_library.h | 31 ++++++++++++++++++++-
modules/misc/medialibrary/medialibrary.cpp | 32 ++++++++++++++++++++++
2 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index ab8bcf14d8..eeaa1460f6 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -503,7 +503,10 @@ enum vlc_ml_control
/* 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 */
+ VLC_ML_PLAYLIST_APPEND, /**< arg1: playlist id; arg2: media id; can fail */
+ VLC_ML_PLAYLIST_INSERT, /**< arg1: playlist id; arg2: media id; arg3: position; can fail */
+ VLC_ML_PLAYLIST_MOVE, /**< arg1: playlist id; arg2: from; arg3: to; can fail */
+ VLC_ML_PLAYLIST_REMOVE /**< arg1: playlist id; arg2: position; can fail */
};
/**
@@ -1086,6 +1089,32 @@ vlc_ml_playlist_append( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, int64_
return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_APPEND, i_playlist_id, i_media_id );
}
+static inline int
+vlc_ml_playlist_insert( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, int64_t i_media_id,
+ uint32_t i_position )
+{
+ assert( p_ml != NULL );
+
+ return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_INSERT, i_playlist_id, i_media_id, i_position );
+}
+
+static inline int
+vlc_ml_playlist_move( vlc_medialibrary_t * p_ml,
+ int64_t i_playlist_id, uint32_t i_from, uint32_t i_to )
+{
+ assert( p_ml != NULL );
+
+ return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_MOVE, i_playlist_id, i_from, i_to );
+}
+
+static inline int
+vlc_ml_playlist_remove( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, uint32_t i_position )
+{
+ assert( p_ml != NULL );
+
+ return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_REMOVE, i_playlist_id, i_position );
+}
+
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 fb3d158706..7f9c218c3d 100644
--- a/modules/misc/medialibrary/medialibrary.cpp
+++ b/modules/misc/medialibrary/medialibrary.cpp
@@ -651,6 +651,38 @@ int MediaLibrary::Control( int query, va_list args )
return VLC_EGENERIC;
return VLC_SUCCESS;
}
+ case VLC_ML_PLAYLIST_INSERT:
+ {
+ auto playlist = m_ml->playlist( va_arg( args, int64_t ) );
+ if ( playlist == nullptr )
+ return VLC_EGENERIC;
+ int64_t mediaId = va_arg( args, int64_t );
+ uint32_t position = va_arg( args, uint32_t );
+ if ( playlist->add(mediaId, position) == false )
+ return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
+ case VLC_ML_PLAYLIST_MOVE:
+ {
+ auto playlist = m_ml->playlist( va_arg( args, int64_t ) );
+ if ( playlist == nullptr )
+ return VLC_EGENERIC;
+ uint32_t from = va_arg( args, uint32_t );
+ uint32_t to = va_arg( args, uint32_t );
+ if ( playlist->move(from, to) == false )
+ return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
+ case VLC_ML_PLAYLIST_REMOVE:
+ {
+ auto playlist = m_ml->playlist( va_arg( args, int64_t ) );
+ if ( playlist == nullptr )
+ return VLC_EGENERIC;
+ uint32_t position = va_arg( args, uint32_t );
+ if ( playlist->remove(position) == false )
+ return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
default:
return VLC_EGENERIC;
}
--
2.25.1
More information about the vlc-devel
mailing list