[vlc-devel] [PATCH 12/14] vlm: move implementation to module

Romain Vimont rom1v at videolabs.io
Tue Sep 15 19:37:44 CEST 2020


---
 modules/Makefile.am                       |  1 +
 modules/vlm/Makefile.am                   |  7 +++++++
 {src/input => modules/vlm}/vlm.c          | 17 +++++++++++++----
 {src/input => modules/vlm}/vlm_event.c    |  0
 {src/input => modules/vlm}/vlm_event.h    |  0
 {src/input => modules/vlm}/vlm_internal.h |  3 ---
 {src/input => modules/vlm}/vlmshell.c     |  0
 src/Makefile.am                           |  5 +----
 src/input/vlmcore.c                       |  6 +++---
 9 files changed, 25 insertions(+), 14 deletions(-)
 create mode 100644 modules/vlm/Makefile.am
 rename {src/input => modules/vlm}/vlm.c (98%)
 rename {src/input => modules/vlm}/vlm_event.c (100%)
 rename {src/input => modules/vlm}/vlm_event.h (100%)
 rename {src/input => modules/vlm}/vlm_internal.h (96%)
 rename {src/input => modules/vlm}/vlmshell.c (100%)

diff --git a/modules/Makefile.am b/modules/Makefile.am
index e9f48422e0..a644f84df2 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -54,6 +54,7 @@ include video_filter/Makefile.am
 include video_splitter/Makefile.am
 include video_output/Makefile.am
 include visualization/Makefile.am
+include vlm/Makefile.am
 if ENABLE_SOUT
 include access_output/Makefile.am
 include mux/Makefile.am
diff --git a/modules/vlm/Makefile.am b/modules/vlm/Makefile.am
new file mode 100644
index 0000000000..d22515ca8b
--- /dev/null
+++ b/modules/vlm/Makefile.am
@@ -0,0 +1,7 @@
+vlmdir = $(pluginsdir)/vlm
+
+libvlm_plugin_la_SOURCES = \
+    vlm/vlm.c \
+    vlm/vlm_event.c \
+    vlm/vlmshell.c
+vlm_LTLIBRARIES = libvlm_plugin.la
diff --git a/src/input/vlm.c b/modules/vlm/vlm.c
similarity index 98%
rename from src/input/vlm.c
rename to modules/vlm/vlm.c
index 5abba9ed17..e3eb28547b 100644
--- a/src/input/vlm.c
+++ b/modules/vlm/vlm.c
@@ -39,6 +39,7 @@
 
 #include <vlc_vlm.h>
 #include <vlc_modules.h>
+#include <vlc_plugin.h>
 
 #include <vlc_player.h>
 #include <vlc_stream.h>
@@ -102,19 +103,20 @@ static void player_on_state_changed(vlc_player_t *player,
 static int ExecuteCommandImpl( vlm_t *vlm, const char *cmd,
                                vlm_message_t **msg_out );
 static int VaControlImpl( vlm_t *vlm, int query, va_list args );
-static void vlm_Close( vlm_t *vlm );
+static void Close( vlm_t *vlm );
 
 static const struct vlm_ops vlm_ops = {
     .execute = ExecuteCommandImpl,
     .va_control = VaControlImpl,
-    .close = vlm_Close,
+    .close = Close,
 };
 
 /*****************************************************************************
  * vlm_New:
  *****************************************************************************/
-int vlm_Open( vlm_t *p_vlm )
+static int Open( vlc_object_t *obj )
 {
+    vlm_t *p_vlm = (vlm_t *)obj;
     vlm_sys_t *sys = p_vlm->sys = malloc( sizeof( *sys ) );
     if (!sys)
         return VLC_ENOMEM;
@@ -143,7 +145,7 @@ int vlm_Open( vlm_t *p_vlm )
 /*****************************************************************************
  * vlm_Delete:
  *****************************************************************************/
-static void vlm_Close( vlm_t *p_vlm )
+static void Close( vlm_t *p_vlm )
 {
     vlm_sys_t *sys = p_vlm->sys;
 
@@ -926,3 +928,10 @@ static int VaControlImpl( vlm_t *p_vlm, int i_query, va_list args )
     return i_result;
 }
 
+vlc_module_begin()
+    set_shortname("VLM")
+    set_description("VLM")
+    set_capability("vlm", 0)
+    set_callback(Open)
+    add_shortcut("vlm")
+vlc_module_end()
diff --git a/src/input/vlm_event.c b/modules/vlm/vlm_event.c
similarity index 100%
rename from src/input/vlm_event.c
rename to modules/vlm/vlm_event.c
diff --git a/src/input/vlm_event.h b/modules/vlm/vlm_event.h
similarity index 100%
rename from src/input/vlm_event.h
rename to modules/vlm/vlm_event.h
diff --git a/src/input/vlm_internal.h b/modules/vlm/vlm_internal.h
similarity index 96%
rename from src/input/vlm_internal.h
rename to modules/vlm/vlm_internal.h
index d92b803468..32e41ccaf6 100644
--- a/src/input/vlm_internal.h
+++ b/modules/vlm/vlm_internal.h
@@ -98,7 +98,4 @@ int vlm_ControlInternal( vlm_t *p_vlm, int i_query, ... );
 int ExecuteCommand( vlm_t *, const char *, vlm_message_t ** );
 void vlm_ScheduleDelete( vlm_t *vlm, vlm_schedule_sys_t *sched );
 
-/* Tempory, until the VLM implementation is actually moved to a module */
-int vlm_Open(vlm_t *vlm);
-
 #endif
diff --git a/src/input/vlmshell.c b/modules/vlm/vlmshell.c
similarity index 100%
rename from src/input/vlmshell.c
rename to modules/vlm/vlmshell.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 408a4354c2..c39489318f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -286,8 +286,6 @@ libvlccore_la_SOURCES = \
 	input/stream.h \
 	input/input_internal.h \
 	input/input_interface.h \
-	input/vlm_internal.h \
-	input/vlm_event.h \
 	input/resource.h \
 	input/resource.c \
 	input/services_discovery.c \
@@ -512,8 +510,7 @@ libvlccore_la_SOURCES += \
 	stream_output/sap.c \
 	stream_output/stream_output.c stream_output/stream_output.h
 if ENABLE_VLM
-libvlccore_la_SOURCES += input/vlm.c input/vlm_event.c input/vlmshell.c \
-                         input/vlmcore.c
+libvlccore_la_SOURCES += input/vlmcore.c
 endif
 endif
 
diff --git a/src/input/vlmcore.c b/src/input/vlmcore.c
index b8180604c6..444ddaf9bd 100644
--- a/src/input/vlmcore.c
+++ b/src/input/vlmcore.c
@@ -28,8 +28,8 @@
 
 #include <vlc_common.h>
 #include <vlc_vlm.h>
+#include <vlc_modules.h>
 #include <limits.h>
-#include "vlm_internal.h"
 #include "../libvlc.h"
 
 typedef struct vlm_priv
@@ -75,8 +75,8 @@ vlm_t *vlm_New( libvlc_int_t *libvlc )
 
     p_vlm = &priv->vlm;
 
-    int ret = vlm_Open(p_vlm);
-    if (ret != VLC_SUCCESS)
+    module_t *module = module_need(p_vlm, "vlm", "vlm", true);
+    if (!module)
     {
         vlc_object_delete(p_vlm);
         vlc_mutex_unlock( &vlm_mutex );
-- 
2.28.0



More information about the vlc-devel mailing list