[vlc-commits] [Git][videolan/vlc][master] 5 commits: input: pass dir_path to DEMUX/STREAM SET_RECORD_STATE

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Sat Aug 13 09:04:23 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
a76000e5 by Thomas Guillem at 2022-08-13T08:45:38+00:00
input: pass dir_path to DEMUX/STREAM SET_RECORD_STATE

If NULL, it continue to use default directories or the
"input-record-path" variable.

- - - - -
1c5d29d1 by Thomas Guillem at 2022-08-13T08:45:38+00:00
player: add a dir_path to vlc_player_SetRecordingEnabled

- - - - -
f85ccf12 by Thomas Guillem at 2022-08-13T08:45:38+00:00
sout: record: set "record-file" var to any parents that created it

Not adding an helper for that, this is hackish and should be avoided.

- - - - -
e31cdb43 by Thomas Guillem at 2022-08-13T08:45:38+00:00
stream_filter: record: set "record-file" var to any parents that created it

Not adding an helper for that, this is hackish and should be avoided.

- - - - -
89dbd928 by Martin Finkel at 2022-08-13T08:45:38+00:00
lib/media_player: add record method

Co-Authored-by: Thomas Guillem <thomas at gllm.fr>

- - - - -


20 changed files:

- include/vlc/libvlc_events.h
- include/vlc/libvlc_media_player.h
- include/vlc_demux.h
- include/vlc_player.h
- include/vlc_stream.h
- lib/libvlc.sym
- lib/media_player.c
- modules/control/cli/player.c
- modules/demux/mpeg/ts.c
- modules/demux/mpeg/ts.h
- modules/demux/nsv.c
- modules/gui/macosx/playlist/VLCPlayerController.m
- modules/gui/qt/player/player_controller.cpp
- modules/stream_filter/record.c
- modules/stream_out/record.c
- src/input/es_out.c
- src/input/es_out.h
- src/input/input.c
- src/input/input_internal.h
- src/player/player.c


Changes:

=====================================
include/vlc/libvlc_events.h
=====================================
@@ -31,6 +31,8 @@
 
 # ifdef __cplusplus
 extern "C" {
+# else
+#  include <stdbool.h>
 # endif
 
 typedef struct libvlc_renderer_item_t libvlc_renderer_item_t;
@@ -147,6 +149,7 @@ enum libvlc_event_e {
      */
     libvlc_MediaPlayerTitleSelectionChanged,
     libvlc_MediaPlayerChapterChanged,
+    libvlc_MediaPlayerRecordChanged,
 
     /**
      * A \link #libvlc_media_t media item\endlink was added to a
@@ -400,6 +403,13 @@ typedef struct libvlc_event_t
             const char *device;
         } media_player_audio_device;
 
+        struct
+        {
+            bool recording;
+            /** Only valid when recording ends (recording == false) */
+            const char *recorded_file_path;
+        } media_player_record_changed;
+
         struct
         {
             libvlc_renderer_item_t *item;


=====================================
include/vlc/libvlc_media_player.h
=====================================
@@ -2650,6 +2650,22 @@ LIBVLC_API int libvlc_media_player_get_role(libvlc_media_player_t *p_mi);
 LIBVLC_API int libvlc_media_player_set_role(libvlc_media_player_t *p_mi,
                                             unsigned role);
 
+/**
+ * Start/stop recording
+ *
+ * \note The user should listen to the libvlc_MediaPlayerRecordChanged event,
+ * to monitor the recording state.
+ *
+ * \version LibVLC 4.0.0 and later.
+ *
+ * \param p_mi media player
+ * \param enable true to start recording, false to stop
+ * \param dir_path path of the recording directory or NULL (use default path),
+ * has only an effect when first enabling recording.
+ */
+LIBVLC_API void libvlc_media_player_record(libvlc_media_player_t *p_mi,
+                                           bool enable, const char *dir_path);
+
 /** @} audio */
 
 /** \defgroup libvlc_media_player_watch_time LibVLC media player time watch API


=====================================
include/vlc_demux.h
=====================================
@@ -242,7 +242,7 @@ enum demux_query_e
      * The control is never used if DEMUX_CAN_RECORD fails or returns false.
      * Can fail.
      *
-     * arg1= bool */
+     * arg1= bool arg2= string */
     DEMUX_SET_RECORD_STATE,
 
     /* II. Specific access_demux queries */


=====================================
include/vlc_player.h
=====================================
@@ -861,9 +861,12 @@ vlc_player_IsRecording(vlc_player_t *player);
  *
  * @param player locked player instance
  * @param enabled true to enable recording
+ * @param dir_path path of the recording directory or NULL (use default path),
+ * has only an effect when first enabling recording.
  */
 VLC_API void
-vlc_player_SetRecordingEnabled(vlc_player_t *player, bool enabled);
+vlc_player_SetRecordingEnabled(vlc_player_t *player, bool enabled,
+                               const char *dir_path);
 
 /**
  * Helper to toggle the recording state
@@ -871,7 +874,7 @@ vlc_player_SetRecordingEnabled(vlc_player_t *player, bool enabled);
 static inline void
 vlc_player_ToggleRecording(vlc_player_t *player)
 {
-    vlc_player_SetRecordingEnabled(player, !vlc_player_IsRecording(player));
+    vlc_player_SetRecordingEnabled(player, !vlc_player_IsRecording(player), NULL);
 }
 
 /**


=====================================
include/vlc_stream.h
=====================================
@@ -166,7 +166,8 @@ enum stream_query_e
     STREAM_SET_SEEKPOINT,   /**< arg1= int          res=can fail */
 
     /* XXX only data read through vlc_stream_Read/Block will be recorded */
-    STREAM_SET_RECORD_STATE,     /**< arg1=bool, arg2=const char *psz_ext (if arg1 is true)  res=can fail */
+    STREAM_SET_RECORD_STATE,     /**< arg1=bool, arg2=const char *dir_path (if arg1 is true)
+                                      arg3=const char *psz_ext (if arg1 is true)  res=can fail */
 
     STREAM_SET_PRIVATE_ID_STATE = 0x1000, /* arg1= int i_private_data, bool b_selected    res=can fail */
     STREAM_SET_PRIVATE_ID_CA,             /* arg1= void * */


=====================================
lib/libvlc.sym
=====================================
@@ -160,6 +160,7 @@ libvlc_media_player_set_pause
 libvlc_media_player_pause
 libvlc_media_player_play
 libvlc_media_player_previous_chapter
+libvlc_media_player_record
 libvlc_media_player_release
 libvlc_media_player_retain
 libvlc_media_player_set_android_context


=====================================
lib/media_player.c
=====================================
@@ -110,6 +110,25 @@ on_state_changed(vlc_player_t *player, enum vlc_player_state new_state,
     libvlc_event_send(&mp->event_manager, &event);
 }
 
+static void
+on_recording_changed(vlc_player_t *player, bool recording, void *data)
+{
+    (void) player;
+    libvlc_media_player_t *mp = data;
+
+    /* "record-file" is only valid when recording ends */
+    char *file_path = !recording ? var_GetString(mp, "record-file") : NULL;
+
+    libvlc_event_t event;
+    event.type = libvlc_MediaPlayerRecordChanged;
+    event.u.media_player_record_changed.recorded_file_path = file_path;
+    event.u.media_player_record_changed.recording = recording;
+
+    libvlc_event_send(&mp->event_manager, &event);
+
+    free(file_path);
+}
+
 static void
 on_error_changed(vlc_player_t *player, enum vlc_player_error error, void *data)
 {
@@ -504,6 +523,7 @@ static const struct vlc_player_cbs vlc_player_cbs = {
     .on_media_subitems_changed = on_media_subitems_changed,
     .on_cork_changed = on_cork_changed,
     .on_vout_changed = on_vout_changed,
+    .on_recording_changed = on_recording_changed,
 };
 
 static const struct vlc_player_aout_cbs vlc_player_aout_cbs = {
@@ -717,8 +737,10 @@ libvlc_media_player_new( libvlc_instance_t *instance )
     var_Create (mp, "equalizer-vlcfreqs", VLC_VAR_BOOL);
     var_Create (mp, "equalizer-bands", VLC_VAR_STRING);
 
-    mp->timer.id = NULL;
+    /* variables for signalling creation of new files */
+    var_Create(mp, "record-file", VLC_VAR_STRING);
 
+    mp->timer.id = NULL;
     mp->p_md = NULL;
     mp->p_libvlc_instance = instance;
     /* use a reentrant lock to allow calling libvlc functions from callbacks */
@@ -2209,6 +2231,17 @@ int libvlc_media_player_get_role(libvlc_media_player_t *mp)
     return ret;
 }
 
+void libvlc_media_player_record( libvlc_media_player_t *p_mi,
+                                 bool enable,
+                                 const char *path)
+{
+    vlc_player_t *player = p_mi->player;
+
+    vlc_player_Lock(player);
+    vlc_player_SetRecordingEnabled(player, enable, path);
+    vlc_player_Unlock(player);
+}
+
 #define PLAYER_TIME_CORE_TO_LIB(point) { \
     .position = point->position, \
     .rate = point->rate, \


=====================================
modules/control/cli/player.c
=====================================
@@ -497,7 +497,7 @@ static int PlayerRecord(struct cli_client *cl, const char *const *args,
     }
 
     if (cur_value != new_value)
-        vlc_player_SetRecordingEnabled(player, new_value);
+        vlc_player_SetRecordingEnabled(player, new_value, NULL);
     vlc_player_Unlock(player);
     (void) cl;
     return 0;


=====================================
modules/demux/mpeg/ts.c
=====================================
@@ -401,6 +401,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_ts_read = 50;
     p_sys->csa = NULL;
     p_sys->b_start_record = false;
+    p_sys->record_dir_path = NULL;
 
     vlc_dictionary_init( &p_sys->attachments, 0 );
 
@@ -590,6 +591,7 @@ static void Close( vlc_object_t *p_this )
     /* Clear up attachments */
     vlc_dictionary_clear( &p_sys->attachments, FreeDictAttachment, NULL );
 
+    free( p_sys->record_dir_path );
     free( p_sys );
 }
 
@@ -647,7 +649,7 @@ static int Demux( demux_t *p_demux )
         {
             /* Enable recording once synchronized */
             vlc_stream_Control( p_sys->stream, STREAM_SET_RECORD_STATE, true,
-                                "ts" );
+                                p_sys->record_dir_path, "ts" );
             p_sys->b_start_record = false;
         }
 
@@ -1174,10 +1176,20 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
     case DEMUX_SET_RECORD_STATE:
         b_bool = va_arg( args, int );
+        const char *dir_path = va_arg( args, const char * );
+
+        free( p_sys->record_dir_path );
+        p_sys->record_dir_path = NULL;
 
         if( !b_bool )
             vlc_stream_Control( p_sys->stream, STREAM_SET_RECORD_STATE,
                                 false );
+        else if( dir_path != NULL )
+        {
+            p_sys->record_dir_path = strdup(dir_path);
+            if( p_sys->record_dir_path == NULL )
+                return VLC_ENOMEM;
+        }
         p_sys->b_start_record = b_bool;
         return VLC_SUCCESS;
 


=====================================
modules/demux/mpeg/ts.h
=====================================
@@ -141,6 +141,7 @@ struct demux_sys_t
 
     /* */
     bool        b_start_record;
+    char        *record_dir_path;
 };
 
 void TsChangeStandard( demux_sys_t *, ts_standards_e );


=====================================
modules/demux/nsv.c
=====================================
@@ -75,6 +75,7 @@ typedef struct
     vlc_tick_t  i_pcr_inc;
 
     bool b_start_record;
+    char *record_dir_path;
 } demux_sys_t;
 
 static int Demux  ( demux_t *p_demux );
@@ -128,6 +129,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_pcr_inc = 0;
 
     p_sys->b_start_record = false;
+    p_sys->record_dir_path = NULL;
 
     return VLC_SUCCESS;
 }
@@ -140,6 +142,7 @@ static void Close( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys = p_demux->p_sys;
 
+    free( p_sys->record_dir_path );
     free( p_sys );
 }
 
@@ -172,7 +175,8 @@ static int Demux( demux_t *p_demux )
             if( p_sys->b_start_record )
             {
                 /* Enable recording once synchronized */
-                vlc_stream_Control( p_demux->s, STREAM_SET_RECORD_STATE, true, "nsv" );
+                vlc_stream_Control( p_demux->s, STREAM_SET_RECORD_STATE, true,
+                                    p_sys->record_dir_path, "nsv" );
                 p_sys->b_start_record = false;
             }
 
@@ -408,13 +412,24 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_SET_RECORD_STATE:
+        {
             b_bool = (bool)va_arg( args, int );
+            const char *dir_path = va_arg( args, const char * );
+
+            free( p_sys->record_dir_path );
+            p_sys->record_dir_path = NULL;
 
             if( !b_bool )
                 vlc_stream_Control( p_demux->s, STREAM_SET_RECORD_STATE, false );
+            else if( dir_path != NULL )
+            {
+                p_sys->record_dir_path = strdup(dir_path);
+                if( p_sys->record_dir_path == NULL )
+                    return VLC_ENOMEM;
+            }
             p_sys->b_start_record = b_bool;
             return VLC_SUCCESS;
-
+        }
 
         case DEMUX_SET_TIME:
             return VLC_EGENERIC;


=====================================
modules/gui/macosx/playlist/VLCPlayerController.m
=====================================
@@ -1558,14 +1558,14 @@ static int BossCallback(vlc_object_t *p_this,
 - (void)setEnableRecording:(BOOL)enableRecording
 {
     vlc_player_Lock(_p_player);
-    vlc_player_SetRecordingEnabled(_p_player, enableRecording);
+    vlc_player_SetRecordingEnabled(_p_player, enableRecording, NULL);
     vlc_player_Unlock(_p_player);
 }
 
 - (void)toggleRecord
 {
     vlc_player_Lock(_p_player);
-    vlc_player_SetRecordingEnabled(_p_player, !_enableRecording);
+    vlc_player_SetRecordingEnabled(_p_player, !_enableRecording, NULL);
     vlc_player_Unlock(_p_player);
 }
 


=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -1771,7 +1771,7 @@ void PlayerController::setRecording( bool recording )
 {
     Q_D(PlayerController);
     vlc_player_locker lock{ d->m_player };
-    vlc_player_SetRecordingEnabled( d->m_player, recording );
+    vlc_player_SetRecordingEnabled( d->m_player, recording, NULL );
 }
 
 void PlayerController::snapshot()


=====================================
modules/stream_filter/record.c
=====================================
@@ -66,7 +66,7 @@ static ssize_t Read( stream_t *, void *p_read, size_t i_read );
 static int  Seek   ( stream_t *, uint64_t );
 static int  Control( stream_t *, int i_query, va_list );
 
-static int  Start  ( stream_t *, const char *psz_extension );
+static int  Start  ( stream_t *, const char *dir_path, const char *psz_extension );
 static int  Stop   ( stream_t * );
 static void Write  ( stream_t *, const uint8_t *p_buffer, size_t i_buffer );
 
@@ -138,23 +138,38 @@ static int Control( stream_t *s, int i_query, va_list args )
 
     stream_sys_t *sys = s->p_sys;
     bool b_active = (bool)va_arg( args, int );
-    const char *psz_extension = NULL;
+    const char *psz_extension = NULL, *dir_path = NULL;
     if( b_active )
+    {
+        dir_path = va_arg( args, const char* );
         psz_extension = va_arg( args, const char* );
+    }
 
     if( !sys->f == !b_active )
         return VLC_SUCCESS;
 
     if( b_active )
-        return Start( s, psz_extension );
+        return Start( s, dir_path, psz_extension );
     else
         return Stop( s );
 }
 
+static void set_record_file_var(vlc_object_t *obj, const char *file)
+{
+    while ((obj = vlc_object_parent(obj)) != NULL)
+    {
+        if (var_Type(obj, "record-file") != 0)
+        {
+            var_SetString(obj, "record-file", file);
+            break;
+        }
+    }
+}
+
 /****************************************************************************
  * Helpers
  ****************************************************************************/
-static int Start( stream_t *s, const char *psz_extension )
+static int Start( stream_t *s, const char *dir_path, const char *psz_extension )
 {
     stream_sys_t *p_sys = s->p_sys;
 
@@ -166,16 +181,21 @@ static int Start( stream_t *s, const char *psz_extension )
         psz_extension = "dat";
 
     /* Retrieve path */
-    char *psz_path = var_CreateGetNonEmptyString( s, "input-record-path" );
-    if( !psz_path )
-        psz_path = config_GetUserDir( VLC_DOWNLOAD_DIR );
+    char *psz_path = NULL;
+    if( dir_path == NULL )
+    {
+        psz_path = var_CreateGetNonEmptyString( s, "input-record-path" );
+        if( psz_path == NULL )
+            psz_path = config_GetUserDir( VLC_DOWNLOAD_DIR );
+        dir_path = psz_path;
+    }
 
-    if( !psz_path )
+    if( dir_path == NULL )
         return VLC_ENOMEM;
 
     /* Create file name
      * TODO allow prefix configuration */
-    psz_file = input_item_CreateFilename( s->p_input_item, psz_path,
+    psz_file = input_item_CreateFilename( s->p_input_item, dir_path,
                                           INPUT_RECORD_PREFIX, psz_extension );
 
     free( psz_path );
@@ -191,7 +211,7 @@ static int Start( stream_t *s, const char *psz_extension )
     }
 
     /* signal new record file */
-    var_SetString( vlc_object_instance(s), "record-file", psz_file );
+    set_record_file_var(VLC_OBJECT(s), psz_file);
 
     msg_Dbg( s, "Recording into %s", psz_file );
     free( psz_file );


=====================================
modules/stream_out/record.c
=====================================
@@ -313,6 +313,18 @@ static const muxer_properties_t p_muxers[] = {
 };
 #undef M
 
+static void set_record_file_var(vlc_object_t *obj, const char *file)
+{
+    while ((obj = vlc_object_parent(obj)) != NULL)
+    {
+        if (var_Type(obj, "record-file") != 0)
+        {
+            var_SetString(obj, "record-file", file);
+            break;
+        }
+    }
+}
+
 static int OutputNew( sout_stream_t *p_stream,
                       const char *psz_muxer, const char *psz_prefix, const char *psz_extension  )
 {
@@ -364,7 +376,7 @@ static int OutputNew( sout_stream_t *p_stream,
     }
 
     if( psz_file && psz_extension )
-        var_SetString( vlc_object_instance(p_stream), "record-file", psz_file );
+        set_record_file_var(VLC_OBJECT(p_stream), psz_file);
 
     free( psz_file );
     free( psz_output );


=====================================
src/input/es_out.c
=====================================
@@ -243,7 +243,7 @@ static void         EsOutSelect( es_out_t *, es_out_id_t *es, bool b_force );
 static void         EsOutSelectList( es_out_t *, enum es_format_category_e cat,
                                      vlc_es_id_t *const* es_id_list );
 static void         EsOutUpdateInfo( es_out_t *, es_out_id_t *es, const vlc_meta_t * );
-static int          EsOutSetRecord(  es_out_t *, bool b_record );
+static int          EsOutSetRecord(  es_out_t *, bool b_record, const char *dir_path );
 
 static bool EsIsSelected( es_out_id_t *es );
 static void EsOutSelectEs( es_out_t *out, es_out_id_t *es, bool b_force );
@@ -678,7 +678,7 @@ static void EsOutTerminate( es_out_t *out )
     es_out_id_t *es;
 
     if( p_sys->p_sout_record )
-        EsOutSetRecord( out, false );
+        EsOutSetRecord( out, false, NULL );
 
     foreach_es_then_es_slaves(es)
     {
@@ -793,7 +793,7 @@ static void EsOutSetDelay( es_out_t *out, int i_cat, vlc_tick_t i_delay )
                            p_sys->i_pts_jitter, p_sys->i_cr_average);
 }
 
-static int EsOutSetRecord(  es_out_t *out, bool b_record )
+static int EsOutSetRecord(  es_out_t *out, bool b_record, const char *dir_path )
 {
     es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
     input_thread_t *p_input = p_sys->p_input;
@@ -803,23 +803,29 @@ static int EsOutSetRecord(  es_out_t *out, bool b_record )
 
     if( b_record )
     {
-        char *psz_path = var_CreateGetNonEmptyString( p_input, "input-record-path" );
-        if( !psz_path )
+        char *psz_path = NULL;
+        if( dir_path == NULL )
         {
-            if( var_CountChoices( p_input, "video-es" ) )
-                psz_path = config_GetUserDir( VLC_VIDEOS_DIR );
-            else if( var_CountChoices( p_input, "audio-es" ) )
-                psz_path = config_GetUserDir( VLC_MUSIC_DIR );
-            else
-                psz_path = config_GetUserDir( VLC_DOWNLOAD_DIR );
+            psz_path = var_CreateGetNonEmptyString( p_input, "input-record-path" );
+            if( psz_path == NULL )
+            {
+                if( var_CountChoices( p_input, "video-es" ) )
+                    psz_path = config_GetUserDir( VLC_VIDEOS_DIR );
+                else if( var_CountChoices( p_input, "audio-es" ) )
+                    psz_path = config_GetUserDir( VLC_MUSIC_DIR );
+                else
+                    psz_path = config_GetUserDir( VLC_DOWNLOAD_DIR );
+            }
+
+            dir_path = psz_path;
         }
 
         char *psz_sout = NULL;  // TODO conf
 
-        if( !psz_sout && psz_path )
+        if( !psz_sout && dir_path )
         {
             char *psz_file = input_item_CreateFilename( input_GetItem(p_input),
-                                                        psz_path,
+                                                        dir_path,
                                                         INPUT_RECORD_PREFIX, NULL );
             if( psz_file )
             {
@@ -3855,7 +3861,8 @@ static int EsOutVaPrivControlLocked( es_out_t *out, int query, va_list args )
     case ES_OUT_PRIV_SET_RECORD_STATE:
     {
         bool b = va_arg( args, int );
-        return EsOutSetRecord( out, b );
+        const char *dir_path = va_arg( args, const char * );
+        return EsOutSetRecord( out, b, dir_path );
     }
     case ES_OUT_PRIV_SET_PAUSE_STATE:
     {


=====================================
src/input/es_out.h
=====================================
@@ -187,9 +187,9 @@ static inline void es_out_SetDelay( es_out_t *p_out, int i_cat, vlc_tick_t i_del
     int i_ret = es_out_PrivControl( p_out, ES_OUT_PRIV_SET_DELAY, i_cat, i_delay );
     assert( !i_ret );
 }
-static inline int es_out_SetRecordState( es_out_t *p_out, bool b_record )
+static inline int es_out_SetRecordState( es_out_t *p_out, bool b_record, const char *dir_path )
 {
-    return es_out_PrivControl( p_out, ES_OUT_PRIV_SET_RECORD_STATE, b_record );
+    return es_out_PrivControl( p_out, ES_OUT_PRIV_SET_RECORD_STATE, b_record, dir_path );
 }
 static inline int es_out_SetPauseState( es_out_t *p_out, bool b_source_paused, bool b_paused, vlc_tick_t i_date )
 {


=====================================
src/input/input.c
=====================================
@@ -1637,6 +1637,9 @@ static void ControlRelease( int i_type, const input_control_param_t *p_param )
     case INPUT_CONTROL_SET_ES_CAT_IDS:
         free( p_param->cat_ids.str_ids );
         break;
+    case INPUT_CONTROL_SET_RECORD_STATE:
+        free( p_param->record_state.dir_path );
+        break;
 
     default:
         break;
@@ -1936,7 +1939,6 @@ static bool Control( input_thread_t *p_input,
     const vlc_tick_t i_control_date = vlc_tick_now();
     /* FIXME b_force_update is abused, it should be carefully checked */
     bool b_force_update = false;
-    vlc_value_t val;
 
     switch( i_type )
     {
@@ -2290,27 +2292,30 @@ static bool Control( input_thread_t *p_input,
             break;
 
         case INPUT_CONTROL_SET_RECORD_STATE:
-            val = param.val;
-            if( !!priv->b_recording != !!val.b_bool )
+        {
+            bool enabled = param.record_state.enabled;
+            const char *dir_path = param.record_state.dir_path;
+            if( !!priv->b_recording != enabled )
             {
                 if( priv->master->b_can_stream_record )
                 {
                     if( demux_Control( priv->master->p_demux,
-                                       DEMUX_SET_RECORD_STATE, val.b_bool ) )
-                        val.b_bool = false;
+                                       DEMUX_SET_RECORD_STATE, enabled, dir_path ) )
+                        enabled = false;
                 }
                 else
                 {
-                    if( es_out_SetRecordState( priv->p_es_out_display, val.b_bool ) )
-                        val.b_bool = false;
+                    if( es_out_SetRecordState( priv->p_es_out_display, enabled, dir_path ) )
+                        enabled = false;
                 }
-                priv->b_recording = val.b_bool;
+                priv->b_recording = enabled;
 
-                input_SendEventRecord( p_input, val.b_bool );
+                input_SendEventRecord( p_input, enabled );
 
                 b_force_update = true;
             }
             break;
+        }
 
         case INPUT_CONTROL_SET_FRAME_NEXT:
             if( priv->i_state == PAUSE_S )


=====================================
src/input/input_internal.h
=====================================
@@ -437,6 +437,10 @@ typedef union
         vlc_es_id_t *id;
         bool enabled;
     } vbi_transparency;
+    struct {
+        bool enabled;
+        char *dir_path;
+    } record_state;
 } input_control_param_t;
 
 typedef struct


=====================================
src/player/player.c
=====================================
@@ -1617,14 +1617,25 @@ vlc_player_IsRecording(vlc_player_t *player)
 }
 
 void
-vlc_player_SetRecordingEnabled(vlc_player_t *player, bool enable)
+vlc_player_SetRecordingEnabled(vlc_player_t *player, bool enable,
+                               const char *dir_path_)
 {
     struct vlc_player_input *input = vlc_player_get_input_locked(player);
     if (!input)
         return;
-    int ret = input_ControlPushHelper(input->thread,
-                                      INPUT_CONTROL_SET_RECORD_STATE,
-                                      &(vlc_value_t) { .b_bool = enable });
+    char *dir_path;
+    if (dir_path_ != NULL)
+    {
+        dir_path = strdup(dir_path_);
+        if (dir_path == NULL)
+            return;
+    }
+    else
+        dir_path = NULL;
+
+    const input_control_param_t param = { .record_state = { enable, dir_path } };
+    int ret = input_ControlPush(input->thread,
+                                INPUT_CONTROL_SET_RECORD_STATE, &param);
 
     if (ret == VLC_SUCCESS)
         vlc_player_osd_Message(player, enable ?



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/158868c4dbadc340430146cd7d9a794aef999288...89dbd928131b89892326274298b7a1d5b4989c00

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/158868c4dbadc340430146cd7d9a794aef999288...89dbd928131b89892326274298b7a1d5b4989c00
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