[vlc-commits] [Git][videolan/vlc][master] medialibrary: expose b_is_favorite property and set_favorite APIs
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Aug 17 09:43:59 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
58674ee9 by Mohak Gupta at 2024-08-17T09:31:11+00:00
medialibrary: expose b_is_favorite property and set_favorite APIs
- - - - -
3 changed files:
- include/vlc_media_library.h
- modules/misc/medialibrary/entities.cpp
- modules/misc/medialibrary/medialibrary.cpp
Changes:
=====================================
include/vlc_media_library.h
=====================================
@@ -296,6 +296,7 @@ typedef struct vlc_ml_playlist_t
uint32_t i_nb_duration_unknown;
bool b_is_read_only;
+ bool b_is_favorite;
} vlc_ml_playlist_t;
typedef struct vlc_ml_artist_t
@@ -309,6 +310,7 @@ typedef struct vlc_ml_artist_t
unsigned int i_nb_album;
unsigned int i_nb_tracks;
uint32_t i_nb_present_tracks;
+ bool b_is_favorite;
} vlc_ml_artist_t;
typedef struct vlc_ml_artist_list_t
@@ -330,6 +332,7 @@ typedef struct vlc_ml_album_t {
uint32_t i_nb_discs;
int64_t i_duration; /* in ms */
unsigned int i_year;
+ bool b_is_favorite;
} vlc_ml_album_t;
typedef struct vlc_ml_genre_t
@@ -338,6 +341,7 @@ typedef struct vlc_ml_genre_t
char* psz_name;
size_t i_nb_tracks;
vlc_ml_thumbnail_t thumbnails[VLC_ML_THUMBNAIL_SIZE_COUNT];
+ bool b_is_favorite;
} vlc_ml_genre_t;
typedef struct vlc_ml_media_list_t
@@ -385,6 +389,7 @@ typedef struct vlc_ml_folder_t
unsigned int i_nb_video; /**< The number of video for this folder */
unsigned int i_nb_audio; /**< The number of audio for this volder */
int64_t i_duration; /**< The sum of all the member durations of the folder in ms. */
+ bool b_is_favorite; /**< The folder's favorite state */
bool b_present; /**< The folder's presence state */
bool b_banned; /**< Will be true if the user required this folder to be excluded */
} vlc_ml_folder_t;
@@ -625,7 +630,14 @@ enum vlc_ml_control
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 */
- VLC_ML_PLAYLIST_RENAME /**< arg1: playlist id; arg2: const char*; can fail */
+ VLC_ML_PLAYLIST_RENAME, /**< arg1: playlist id; arg2: const char*; can fail */
+
+ /* Set Favorites */
+ VLC_ML_FOLDER_SET_FAVORITE, /**< arg1: mrl (const char*); arg2: bool; res: can fail */
+ VLC_ML_ARTIST_SET_FAVORITE, /**< arg1: artist id; arg2: bool; can fail */
+ VLC_ML_ALBUM_SET_FAVORITE, /**< arg1: album id; arg2: bool; can fail */
+ VLC_ML_GENRE_SET_FAVORITE, /**< arg1: genre id; arg2: bool; can fail */
+ VLC_ML_PLAYLIST_SET_FAVORITE, /**< arg1: playlist id; arg2: bool; can fail */
};
/**
@@ -1954,6 +1966,31 @@ static inline size_t vlc_ml_count_folder_media(vlc_medialibrary_t * p_ml,
return count;
}
+static inline int vlc_ml_folder_set_favorite( vlc_medialibrary_t* p_ml, const char* psz_mrl, bool b_favorite )
+{
+ return vlc_ml_control( p_ml, VLC_ML_FOLDER_SET_FAVORITE, psz_mrl, (int)b_favorite );
+}
+
+static inline int vlc_ml_artist_set_favorite( vlc_medialibrary_t* p_ml, int64_t i_artist_id, bool b_favorite )
+{
+ return vlc_ml_control( p_ml, VLC_ML_ARTIST_SET_FAVORITE, i_artist_id, (int)b_favorite );
+}
+
+static inline int vlc_ml_album_set_favorite( vlc_medialibrary_t* p_ml, int64_t i_album_id, bool b_favorite )
+{
+ return vlc_ml_control( p_ml, VLC_ML_ALBUM_SET_FAVORITE, i_album_id, (int)b_favorite );
+}
+
+static inline int vlc_ml_genre_set_favorite( vlc_medialibrary_t* p_ml, int64_t i_genre_id, bool b_favorite )
+{
+ return vlc_ml_control( p_ml, VLC_ML_GENRE_SET_FAVORITE, i_genre_id, (int)b_favorite );
+}
+
+static inline int vlc_ml_playlist_set_favorite( vlc_medialibrary_t *p_ml, int64_t i_playlist_id, bool b_favorite )
+{
+ return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_SET_FAVORITE, i_playlist_id, (int)b_favorite );
+}
+
#ifdef __cplusplus
}
#endif /* C++ */
=====================================
modules/misc/medialibrary/entities.cpp
=====================================
@@ -328,6 +328,7 @@ bool Convert( const medialibrary::IAlbum* input, vlc_ml_album_t& output )
output.i_nb_discs = input->nbDiscs();
output.i_duration = input->duration();
output.i_year = input->releaseYear();
+ output.b_is_favorite = input->isFavorite();
if( !strdup_helper( input->title(), output.psz_title ) ||
!strdup_helper( input->shortSummary(), output.psz_summary ) )
@@ -378,6 +379,7 @@ bool Convert( const medialibrary::IArtist* input, vlc_ml_artist_t& output )
output.i_nb_tracks = input->nbTracks();
output.i_nb_present_tracks = input->nbPresentTracks();
output.psz_name = strdup( artistName( input ) );
+ output.b_is_favorite = input->isFavorite();
if ( unlikely( output.psz_name == nullptr ) )
return false;
@@ -392,6 +394,7 @@ bool Convert( const medialibrary::IGenre* input, vlc_ml_genre_t& output )
{
output.i_id = input->id();
output.i_nb_tracks = input->nbTracks();
+ output.b_is_favorite = input->isFavorite();
assert( input->name().empty() == false );
if ( !strdup_helper( input->name(), output.psz_name ) )
@@ -480,6 +483,7 @@ bool Convert( const medialibrary::IPlaylist* input, vlc_ml_playlist_t& output )
output.i_nb_duration_unknown = input->nbDurationUnknown();
output.b_is_read_only = input->isReadOnly();
+ output.b_is_favorite = input->isFavorite();
if( !strdup_helper( input->name(), output.psz_name ) ||
!strdup_helper( input->artworkMrl(), output.psz_artwork_mrl ) )
@@ -506,6 +510,7 @@ bool Convert( const medialibrary::IFolder* input, vlc_ml_folder_t& output )
output.i_duration = input->duration();
output.b_banned = input->isBanned();
+ output.b_is_favorite = input->isFavorite();
if ( strdup_helper( input->name(), output.psz_name ) == false )
return false;
=====================================
modules/misc/medialibrary/medialibrary.cpp
=====================================
@@ -767,6 +767,61 @@ int MediaLibrary::Control( int query, va_list args )
return VLC_EGENERIC;
return VLC_SUCCESS;
}
+ case VLC_ML_FOLDER_SET_FAVORITE:
+ {
+ const char* mrl = va_arg( args, const char* );
+ bool favorite = va_arg( args, int );
+ auto folder = m_ml->folder( mrl );
+ if ( folder == nullptr )
+ return VLC_EGENERIC;
+ if ( folder->setFavorite( favorite ) == false )
+ return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
+ case VLC_ML_ARTIST_SET_FAVORITE:
+ {
+ int64_t artistId = va_arg( args, int64_t );
+ bool favorite = va_arg( args, int );
+ auto artist = m_ml->artist( artistId );
+ if ( artist == nullptr )
+ return VLC_EGENERIC;
+ if ( artist->setFavorite( favorite ) == false )
+ return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
+ case VLC_ML_ALBUM_SET_FAVORITE:
+ {
+ int64_t albumId = va_arg( args, int64_t );
+ bool favorite = va_arg( args, int );
+ auto album = m_ml->album( albumId );
+ if ( album == nullptr )
+ return VLC_EGENERIC;
+ if ( album->setFavorite( favorite ) == false )
+ return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
+ case VLC_ML_GENRE_SET_FAVORITE:
+ {
+ int64_t genreId = va_arg( args, int64_t );
+ bool favorite = va_arg( args, int );
+ auto genre = m_ml->genre( genreId );
+ if ( genre == nullptr )
+ return VLC_EGENERIC;
+ if ( genre->setFavorite( favorite ) == false)
+ return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
+ case VLC_ML_PLAYLIST_SET_FAVORITE:
+ {
+ int64_t playlistId = va_arg( args, int64_t );
+ bool favorite = va_arg( args, int );
+ auto playlist = m_ml->playlist( playlistId );
+ if ( playlist == nullptr )
+ return VLC_EGENERIC;
+ if ( playlist->setFavorite( favorite ) == false )
+ return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
default:
return VLC_EGENERIC;
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/58674ee975de3ea8aba3d0f028c59a055e4a5fa5
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/58674ee975de3ea8aba3d0f028c59a055e4a5fa5
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list