Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
c4a3e9ce by Alaric Senat at 2024-04-11T13:19:17+00:00
medialibrary: expose the `publicOnly` query parameter

Allow medialibrary queries to process and list public media.

Public media are a new addition of the medialibrary 0.13 version. With
this, the users will have the opportunity to allow a subset of the
medialibrary to be exposed on network interfaces (notably the upnp
server and the HTTP remote control).

Community discussions around the subject can be found here:
https://code.videolan.org/videolan/vlc/-/merge_requests/269#note_274345

- - - - -
2bb616a5 by Alaric Senat at 2024-04-11T13:19:17+00:00
medialibrary: media: expose an `is_public` accessor

- - - - -
baed3b02 by Alaric Senat at 2024-04-11T13:19:17+00:00
medialibrary: allow changing folder public state

This is the main mechanism that will be exposed to the user to
allow/disallow multiple media to be publicly exposed on the network by
VLC.

- - - - -


5 changed files:

- include/vlc_media_library.h
- modules/lua/libs/medialibrary.c
- modules/misc/medialibrary/entities.cpp
- modules/misc/medialibrary/medialibrary.cpp
- share/lua/README.txt


Changes:

=====================================
include/vlc_media_library.h
=====================================
@@ -222,6 +222,7 @@ typedef struct vlc_ml_media_t
     vlc_ml_thumbnail_t thumbnails[VLC_ML_THUMBNAIL_SIZE_COUNT];
 
     bool b_is_favorite;
+    bool b_is_public;
 
     union
     {
@@ -443,6 +444,7 @@ typedef struct vlc_ml_query_params_t
     vlc_ml_sorting_criteria_t i_sort;
     bool b_desc;
     bool b_favorite_only;
+    bool b_public_only;
 } vlc_ml_query_params_t;
 
 enum vlc_ml_get_queries
@@ -576,6 +578,9 @@ enum vlc_ml_control
      */
     VLC_ML_RELOAD_FOLDER,
 
+    VLC_ML_SET_FOLDER_PUBLIC,       /**< arg1: mrl (const char *); res: can't 
fail */
+    VLC_ML_SET_FOLDER_PRIVATE,      /**< arg1: mrl (const char *); res: can't 
fail */
+
     /* Pause/resume background operations, such as media discovery & media 
analysis */
     VLC_ML_PAUSE_BACKGROUND,        /**< no args; can't fail */
     VLC_ML_RESUME_BACKGROUND,       /**< no args; can't fail */
@@ -1010,6 +1015,16 @@ static inline int vlc_ml_reload_folder( 
vlc_medialibrary_t* p_ml, const char* ps
     return vlc_ml_control( p_ml, VLC_ML_RELOAD_FOLDER, psz_mrl );
 }
 
+static inline int vlc_ml_set_folder_public( vlc_medialibrary_t* p_ml, const 
char* psz_mrl )
+{
+    return vlc_ml_control( p_ml, VLC_ML_SET_FOLDER_PUBLIC, psz_mrl );
+}
+
+static inline int vlc_ml_set_folder_private( vlc_medialibrary_t* p_ml, const 
char* psz_mrl )
+{
+    return vlc_ml_control( p_ml, VLC_ML_SET_FOLDER_PRIVATE, psz_mrl );
+}
+
 static inline int vlc_ml_pause_background( vlc_medialibrary_t* p_ml )
 {
     return vlc_ml_control( p_ml, VLC_ML_PAUSE_BACKGROUND );


=====================================
modules/lua/libs/medialibrary.c
=====================================
@@ -251,12 +251,14 @@ static void vlclua_ml_assign_params( lua_State *L, 
vlc_ml_query_params_t *params
     *params = vlc_ml_query_params_create();
     if (!lua_istable(L, paramIndex))
         return;
+    lua_getfield(L, 1, "public_only" );
     lua_getfield(L, 1, "favorite_only" );
     lua_getfield(L, 1, "limit" );
     lua_getfield(L, 1, "offset" );
     lua_getfield(L, 1, "desc" );
     lua_getfield(L, 1, "sort" );
     lua_getfield(L, 1, "pattern" );
+    params->b_public_only = lua_toboolean( L, -7 );
     params->b_favorite_only = lua_toboolean( L, -6 );
     params->i_nbResults = lua_tointeger( L, -5 );
     params->i_offset = lua_tointeger( L, -4 );


=====================================
modules/misc/medialibrary/entities.cpp
=====================================
@@ -240,6 +240,7 @@ bool Convert( const medialibrary::IMedia* input, 
vlc_ml_media_t& output )
     output.i_playcount = input->playCount();
     output.f_progress = input->lastPosition();
     output.i_last_played_date = input->lastPlayedDate();
+    output.b_is_public = input->isPublic();
 
     output.psz_title = strdup( input->title().c_str() );
     if ( unlikely( output.psz_title == nullptr ) )


=====================================
modules/misc/medialibrary/medialibrary.cpp
=====================================
@@ -522,6 +522,8 @@ int MediaLibrary::Control( int query, va_list args )
         case VLC_ML_BAN_FOLDER:
         case VLC_ML_UNBAN_FOLDER:
         case VLC_ML_RELOAD_FOLDER:
+        case VLC_ML_SET_FOLDER_PUBLIC:
+        case VLC_ML_SET_FOLDER_PRIVATE:
         case VLC_ML_RESUME_BACKGROUND:
         case VLC_ML_NEW_EXTERNAL_MEDIA:
         case VLC_ML_NEW_STREAM:
@@ -544,6 +546,8 @@ int MediaLibrary::Control( int query, va_list args )
         case VLC_ML_REMOVE_FOLDER:
         case VLC_ML_BAN_FOLDER:
         case VLC_ML_UNBAN_FOLDER:
+        case VLC_ML_SET_FOLDER_PUBLIC:
+        case VLC_ML_SET_FOLDER_PRIVATE:
         {
             const char* mrl = va_arg( args, const char* );
             switch( query )
@@ -560,6 +564,17 @@ int MediaLibrary::Control( int query, va_list args )
                 case VLC_ML_UNBAN_FOLDER:
                     m_ml->unbanFolder( mrl );
                     break;
+                case VLC_ML_SET_FOLDER_PUBLIC:
+                case VLC_ML_SET_FOLDER_PRIVATE:
+                {
+                    auto folder = m_ml->folder(mrl);
+                    const bool is_public = query == VLC_ML_SET_FOLDER_PUBLIC;
+
+                    if (folder)
+                        folder->setPublic(is_public);
+                    break;
+                }
+                    
             }
             break;
         }
@@ -775,6 +790,7 @@ int MediaLibrary::List( int listQuery, const 
vlc_ml_query_params_t* params, va_l
         p.desc = params->b_desc;
         p.sort = sortingCriteria( params->i_sort );
         p.favoriteOnly = params->b_favorite_only;
+        p.publicOnly = params->b_public_only;
         nbItems = params->i_nbResults;
         offset = params->i_offset;
         psz_pattern = params->psz_pattern;


=====================================
share/lua/README.txt
=====================================
@@ -432,6 +432,7 @@ query_params = {
   "sort": integer,
   "pattern": string,
   "favorite_only": boolean,
+  "public_only": boolean,
 }
 
 vlc.ml.video(query_params): Get video media list



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/533ff6236d3c18698c87ceaa28a8b110534fdfdf...baed3b02ec4bb981a1f682ee5916832a9c3b97f0

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/533ff6236d3c18698c87ceaa28a8b110534fdfdf...baed3b02ec4bb981a1f682ee5916832a9c3b97f0
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to