0022-libvlc-media_player-Add-record-method.patch 2.44 KB
Newer Older
Soomin Lee's avatar
Soomin Lee committed
1
From 87cd0f78e8008894857b55334e3f97ef412fd7f2 Mon Sep 17 00:00:00 2001
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
From: Soomin Lee <bubu@mikan.io>
Date: Wed, 31 Oct 2018 10:08:55 +0100
Subject: [PATCH 22/24] libvlc: media_player: Add record method

---
 include/vlc/libvlc_media_player.h | 13 +++++++++++++
 lib/media_player.c                | 21 +++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index cbb5ec251a..d58dc4ddcf 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -2108,6 +2108,19 @@ 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
+ *
+ * \version LibVLC 4.0.0 and later.
+ *
+ * \param p_mi media player
+ * \param enable true to start recording, false to stop
+ * \param path the path of the recording directory
+ * \return 0 on success, -1 on error
+ */
+LIBVLC_API int libvlc_media_player_record(libvlc_media_player_t *p_mi,
+                                          bool enable,
+                                          const char *path);
 
 /** @} audio */
 
diff --git a/lib/media_player.c b/lib/media_player.c
index 29285065f0..7e714d247b 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -622,6 +622,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
     var_Create (mp, "rate", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT);
     var_Create (mp, "sout", VLC_VAR_STRING);
     var_Create (mp, "demux-filter", VLC_VAR_STRING);
+    var_Create (mp, "input-record-path", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
     var_Create (mp, "http-cookies", VLC_VAR_ADDRESS);
 
     /* Video */
@@ -2092,3 +2093,23 @@ int libvlc_media_player_get_role(libvlc_media_player_t *mp)
     free(str);
     return ret;
 }
+
+int libvlc_media_player_record( libvlc_media_player_t *p_mi,
+                                bool enable,
+                                const char *path)
+{
+    vlc_value_t val = { .psz_string = (char *)path };
+    input_thread_t *p_input_thread;
+
+    p_input_thread = libvlc_get_input_thread ( p_mi );
+    if( !p_input_thread )
+        return VLC_EGENERIC;
+
+    if( enable )
+        var_Set( p_mi, "input-record-path", val );
+
+    var_SetBool( p_input_thread, "record", enable);
+
+    vlc_object_release( p_input_thread );
+    return VLC_SUCCESS;
+}
-- 
Soomin Lee's avatar
Soomin Lee committed
72
2.19.1
73