[vlc-devel] [PATCH 14/14] vlm: privatize VLM internal types and functions

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


All these types and functions are only used by the VLM module
internally, there is no need to expose them publicly.
---
 include/vlc_vlm.h          | 171 -------------------------------------
 modules/vlm/vlm_internal.h | 164 +++++++++++++++++++++++++++++++++++
 2 files changed, 164 insertions(+), 171 deletions(-)

diff --git a/include/vlc_vlm.h b/include/vlc_vlm.h
index a8eba9df4d..fedbcd88e8 100644
--- a/include/vlc_vlm.h
+++ b/include/vlc_vlm.h
@@ -77,25 +77,6 @@ typedef struct
 
 } vlm_media_t;
 
-/** VLM media instance */
-typedef struct
-{
-    char *psz_name;         /*< vlm media instance descriptive name */
-
-    int64_t     i_time;     /*< vlm media instance vlm media current time */
-    int64_t     i_length;   /*< vlm media instance vlm media item length */
-    double      d_position; /*< vlm media instance position in stream */
-    bool        b_paused;   /*< vlm media instance is paused */
-    float       f_rate;     // normal is 1.0f
-} vlm_media_instance_t;
-
-#if 0
-typedef struct
-{
-
-} vlm_schedule_t
-#endif
-
 /** VLM events
  * You can catch vlm event by adding a callback on the variable "intf-event"
  * of the VLM object.
@@ -229,158 +210,6 @@ VLC_API vlm_message_t * vlm_MessageNew( const char *, const char *, ... ) VLC_FO
 VLC_API vlm_message_t * vlm_MessageAdd( vlm_message_t *, vlm_message_t * );
 VLC_API void vlm_MessageDelete( vlm_message_t * );
 
-/* media helpers */
-
-/**
- * Initialize a vlm_media_t instance
- * \param p_media vlm_media_t instance to initialize
- */
-static inline void vlm_media_Init( vlm_media_t *p_media )
-{
-    memset( p_media, 0, sizeof(vlm_media_t) );
-    p_media->id = 0;    // invalid id
-    p_media->psz_name = NULL;
-    TAB_INIT( p_media->i_input, p_media->ppsz_input );
-    TAB_INIT( p_media->i_option, p_media->ppsz_option );
-    p_media->psz_output = NULL;
-
-    p_media->broadcast.b_loop = false;
-}
-
-/**
- * Copy a vlm_media_t instance into another vlm_media_t instance
- * \param p_dst vlm_media_t instance to copy to
- * \param p_src vlm_media_t instance to copy from
- */
-static inline void
-#ifndef __cplusplus
-vlm_media_Copy( vlm_media_t *restrict p_dst, const vlm_media_t *restrict p_src )
-#else
-vlm_media_Copy( vlm_media_t *p_dst, const vlm_media_t *p_src )
-#endif
-{
-    int i;
-
-    memset( p_dst, 0, sizeof(vlm_media_t) );
-    p_dst->id = p_src->id;
-    p_dst->b_enabled = p_src->b_enabled;
-    if( p_src->psz_name )
-        p_dst->psz_name = strdup( p_src->psz_name );
-
-    for( i = 0; i < p_src->i_input; i++ )
-        TAB_APPEND_CAST( (char**), p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) );
-    for( i = 0; i < p_src->i_option; i++ )
-        TAB_APPEND_CAST( (char**), p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) );
-
-    if( p_src->psz_output )
-        p_dst->psz_output = strdup( p_src->psz_output );
-
-    p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
-}
-
-/**
- * Cleanup and release memory associated with this vlm_media_t instance.
- * You still need to release p_media itself with vlm_media_Delete().
- * \param p_media vlm_media_t to cleanup
- */
-static inline void vlm_media_Clean( vlm_media_t *p_media )
-{
-    int i;
-    free( p_media->psz_name );
-
-    for( i = 0; i < p_media->i_input; i++ )
-        free( p_media->ppsz_input[i]);
-    TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
-
-    for( i = 0; i < p_media->i_option; i++ )
-        free( p_media->ppsz_option[i]);
-    TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
-
-    free( p_media->psz_output );
-}
-
-/**
- * Allocate a new vlm_media_t instance
- * \return vlm_media_t instance
- */
-static inline vlm_media_t *vlm_media_New(void)
-{
-    vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) );
-    if( p_media )
-        vlm_media_Init( p_media );
-    return p_media;
-}
-
-/**
- * Delete a vlm_media_t instance
- * \param p_media vlm_media_t instance to delete
- */
-static inline void vlm_media_Delete( vlm_media_t *p_media )
-{
-    vlm_media_Clean( p_media );
-    free( p_media );
-}
-
-/**
- * Copy a vlm_media_t instance
- * \param p_src vlm_media_t instance to copy
- * \return vlm_media_t duplicate of p_src
- */
-static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
-{
-    vlm_media_t *p_dst = vlm_media_New();
-    if( p_dst )
-        vlm_media_Copy( p_dst, p_src );
-    return p_dst;
-}
-
-/* media instance helpers */
-/**
- * Initialize vlm_media_instance_t
- * \param p_instance vlm_media_instance_t to initialize
- */
-static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
-{
-    memset( p_instance, 0, sizeof(vlm_media_instance_t) );
-    p_instance->psz_name = NULL;
-    p_instance->i_time = 0;
-    p_instance->i_length = 0;
-    p_instance->d_position = 0.0;
-    p_instance->b_paused = false;
-    p_instance->f_rate = 1.0f;
-}
-
-/**
- * Cleanup vlm_media_instance_t
- * \param p_instance vlm_media_instance_t to cleanup
- */
-static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
-{
-    free( p_instance->psz_name );
-}
-
-/**
- * Allocate a new vlm_media_instance_t
- * \return a new vlm_media_instance_t
- */
-static inline vlm_media_instance_t *vlm_media_instance_New(void)
-{
-    vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) );
-    if( p_instance )
-        vlm_media_instance_Init( p_instance );
-    return p_instance;
-}
-
-/**
- * Delete a vlm_media_instance_t
- * \param p_instance vlm_media_instance_t to delete
- */
-static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
-{
-    vlm_media_instance_Clean( p_instance );
-    free( p_instance );
-}
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/modules/vlm/vlm_internal.h b/modules/vlm/vlm_internal.h
index 32e41ccaf6..d86a2d9360 100644
--- a/modules/vlm/vlm_internal.h
+++ b/modules/vlm/vlm_internal.h
@@ -94,8 +94,172 @@ typedef struct vlm_sys
     vlm_schedule_sys_t **schedule;
 } vlm_sys_t;
 
+/** VLM media instance */
+typedef struct
+{
+    char *psz_name;         /*< vlm media instance descriptive name */
+
+    int64_t     i_time;     /*< vlm media instance vlm media current time */
+    int64_t     i_length;   /*< vlm media instance vlm media item length */
+    double      d_position; /*< vlm media instance position in stream */
+    bool        b_paused;   /*< vlm media instance is paused */
+    float       f_rate;     // normal is 1.0f
+} vlm_media_instance_t;
+
 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 );
 
+/* media helpers */
+
+/**
+ * Initialize a vlm_media_t instance
+ * \param p_media vlm_media_t instance to initialize
+ */
+static inline void vlm_media_Init( vlm_media_t *p_media )
+{
+    memset( p_media, 0, sizeof(vlm_media_t) );
+    p_media->id = 0;    // invalid id
+    p_media->psz_name = NULL;
+    TAB_INIT( p_media->i_input, p_media->ppsz_input );
+    TAB_INIT( p_media->i_option, p_media->ppsz_option );
+    p_media->psz_output = NULL;
+
+    p_media->broadcast.b_loop = false;
+}
+
+/**
+ * Copy a vlm_media_t instance into another vlm_media_t instance
+ * \param p_dst vlm_media_t instance to copy to
+ * \param p_src vlm_media_t instance to copy from
+ */
+static inline void
+#ifndef __cplusplus
+vlm_media_Copy( vlm_media_t *restrict p_dst, const vlm_media_t *restrict p_src )
+#else
+vlm_media_Copy( vlm_media_t *p_dst, const vlm_media_t *p_src )
+#endif
+{
+    int i;
+
+    memset( p_dst, 0, sizeof(vlm_media_t) );
+    p_dst->id = p_src->id;
+    p_dst->b_enabled = p_src->b_enabled;
+    if( p_src->psz_name )
+        p_dst->psz_name = strdup( p_src->psz_name );
+
+    for( i = 0; i < p_src->i_input; i++ )
+        TAB_APPEND_CAST( (char**), p_dst->i_input, p_dst->ppsz_input, strdup(p_src->ppsz_input[i]) );
+    for( i = 0; i < p_src->i_option; i++ )
+        TAB_APPEND_CAST( (char**), p_dst->i_option, p_dst->ppsz_option, strdup(p_src->ppsz_option[i]) );
+
+    if( p_src->psz_output )
+        p_dst->psz_output = strdup( p_src->psz_output );
+
+    p_dst->broadcast.b_loop = p_src->broadcast.b_loop;
+}
+
+/**
+ * Cleanup and release memory associated with this vlm_media_t instance.
+ * You still need to release p_media itself with vlm_media_Delete().
+ * \param p_media vlm_media_t to cleanup
+ */
+static inline void vlm_media_Clean( vlm_media_t *p_media )
+{
+    int i;
+    free( p_media->psz_name );
+
+    for( i = 0; i < p_media->i_input; i++ )
+        free( p_media->ppsz_input[i]);
+    TAB_CLEAN(p_media->i_input, p_media->ppsz_input );
+
+    for( i = 0; i < p_media->i_option; i++ )
+        free( p_media->ppsz_option[i]);
+    TAB_CLEAN(p_media->i_option, p_media->ppsz_option );
+
+    free( p_media->psz_output );
+}
+
+/**
+ * Allocate a new vlm_media_t instance
+ * \return vlm_media_t instance
+ */
+static inline vlm_media_t *vlm_media_New(void)
+{
+    vlm_media_t *p_media = (vlm_media_t *)malloc( sizeof(vlm_media_t) );
+    if( p_media )
+        vlm_media_Init( p_media );
+    return p_media;
+}
+
+/**
+ * Delete a vlm_media_t instance
+ * \param p_media vlm_media_t instance to delete
+ */
+static inline void vlm_media_Delete( vlm_media_t *p_media )
+{
+    vlm_media_Clean( p_media );
+    free( p_media );
+}
+
+/**
+ * Copy a vlm_media_t instance
+ * \param p_src vlm_media_t instance to copy
+ * \return vlm_media_t duplicate of p_src
+ */
+static inline vlm_media_t *vlm_media_Duplicate( vlm_media_t *p_src )
+{
+    vlm_media_t *p_dst = vlm_media_New();
+    if( p_dst )
+        vlm_media_Copy( p_dst, p_src );
+    return p_dst;
+}
+
+/* media instance helpers */
+/**
+ * Initialize vlm_media_instance_t
+ * \param p_instance vlm_media_instance_t to initialize
+ */
+static inline void vlm_media_instance_Init( vlm_media_instance_t *p_instance )
+{
+    memset( p_instance, 0, sizeof(vlm_media_instance_t) );
+    p_instance->psz_name = NULL;
+    p_instance->i_time = 0;
+    p_instance->i_length = 0;
+    p_instance->d_position = 0.0;
+    p_instance->b_paused = false;
+    p_instance->f_rate = 1.0f;
+}
+
+/**
+ * Cleanup vlm_media_instance_t
+ * \param p_instance vlm_media_instance_t to cleanup
+ */
+static inline void vlm_media_instance_Clean( vlm_media_instance_t *p_instance )
+{
+    free( p_instance->psz_name );
+}
+
+/**
+ * Allocate a new vlm_media_instance_t
+ * \return a new vlm_media_instance_t
+ */
+static inline vlm_media_instance_t *vlm_media_instance_New(void)
+{
+    vlm_media_instance_t *p_instance = (vlm_media_instance_t *) malloc( sizeof(vlm_media_instance_t) );
+    if( p_instance )
+        vlm_media_instance_Init( p_instance );
+    return p_instance;
+}
+
+/**
+ * Delete a vlm_media_instance_t
+ * \param p_instance vlm_media_instance_t to delete
+ */
+static inline void vlm_media_instance_Delete( vlm_media_instance_t *p_instance )
+{
+    vlm_media_instance_Clean( p_instance );
+    free( p_instance );
+}
+
 #endif
-- 
2.28.0



More information about the vlc-devel mailing list