[vlc-devel] [PATCH 2/4] medialibrary: Add media/input_item getters through mrl
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Tue Jun 25 16:04:53 CEST 2019
---
include/vlc_media_library.h | 14 ++++++++++++++
modules/misc/medialibrary/medialib.cpp | 14 ++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index b9e7c96c24..6d2d39d0a0 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -326,7 +326,9 @@ struct vlc_ml_query_params_t
enum vlc_ml_get_queries
{
VLC_ML_GET_MEDIA, /**< arg1: Media ID; ret: vlc_ml_media_t* */
+ VLC_ML_GET_MEDIA_BY_MRL, /**< arg1: Media MRL; ret: vlc_ml_media_t* */
VLC_ML_GET_INPUT_ITEM, /**< arg1: Media ID; ret: input_item_t* */
+ VLC_ML_GET_INPUT_ITEM_BY_MRL,/**< arg1: Media MRL; ret: input_item_t* */
VLC_ML_GET_ALBUM, /**< arg1: Album ID; ret: vlc_ml_album_t* */
VLC_ML_GET_ARTIST, /**< arg1: Artist ID; ret: vlc_ml_artist_t* */
VLC_ML_GET_GENRE, /**< arg1: Genre ID; ret: vlc_ml_genre_t* */
@@ -867,11 +869,23 @@ static inline vlc_ml_media_t* vlc_ml_get_media( vlc_medialibrary_t* p_ml, int64_
return (vlc_ml_media_t*)vlc_ml_get( p_ml, VLC_ML_GET_MEDIA, i_media_id );
}
+static inline vlc_ml_media_t* vlc_ml_get_media_by_mrl( vlc_medialibrary_t* p_ml,
+ const char* psz_mrl )
+{
+ return (vlc_ml_media_t*)vlc_ml_get( p_ml, VLC_ML_GET_MEDIA_BY_MRL, psz_mrl );
+}
+
static inline input_item_t* vlc_ml_get_input_item( vlc_medialibrary_t* p_ml, int64_t i_media_id )
{
return (input_item_t*)vlc_ml_get( p_ml, VLC_ML_GET_INPUT_ITEM, i_media_id );
}
+static inline input_item_t* vlc_ml_get_input_item_by_mrl( vlc_medialibrary_t* p_ml,
+ const char* psz_mrl )
+{
+ return (input_item_t*)vlc_ml_get( p_ml, VLC_ML_GET_INPUT_ITEM_BY_MRL, psz_mrl );
+}
+
static inline vlc_ml_album_t* vlc_ml_get_album( vlc_medialibrary_t* p_ml, int64_t i_album_id )
{
return (vlc_ml_album_t*)vlc_ml_get( p_ml, VLC_ML_GET_ALBUM, i_album_id );
diff --git a/modules/misc/medialibrary/medialib.cpp b/modules/misc/medialibrary/medialib.cpp
index cc96da7f82..99eb8b3a91 100644
--- a/modules/misc/medialibrary/medialib.cpp
+++ b/modules/misc/medialibrary/medialib.cpp
@@ -811,6 +811,20 @@ void* MediaLibrary::Get( int query, va_list args )
auto playlist = m_ml->playlist( id );
return CreateAndConvert<vlc_ml_playlist_t>( playlist.get() );
}
+ case VLC_ML_GET_MEDIA_BY_MRL:
+ {
+ auto mrl = va_arg( args, const char* );
+ auto media = m_ml->media( mrl );
+ return CreateAndConvert<vlc_ml_media_t>( media.get() );
+ }
+ case VLC_ML_GET_INPUT_ITEM_BY_MRL:
+ {
+ auto mrl = va_arg( args, const char* );
+ auto media = m_ml->media( mrl );
+ if ( media == nullptr )
+ return nullptr;
+ return MediaToInputItem( media.get() );
+ }
default:
vlc_assert_unreachable();
--
2.20.1
More information about the vlc-devel
mailing list