[vlc-devel] [PATCH 4/4] lib/audio: provide API to set and get audio filter options
Pierre Lamot
pierre at videolabs.io
Wed Sep 6 15:02:55 CEST 2017
---
include/vlc/libvlc_media_player.h | 92 ++++++++++++++++++++++++++++++
lib/audio.c | 116 ++++++++++++++++++++++++++++++++++++++
lib/libvlc.sym | 8 +++
3 files changed, 216 insertions(+)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 3118624219..7dec7d130d 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -2047,6 +2047,98 @@ LIBVLC_API void libvlc_audio_set_filters( libvlc_media_player_t *p_mi,
*/
LIBVLC_API const char *libvlc_audio_get_filters( libvlc_media_player_t *p_mi );
+/**
+ * Get the value of the option parameter \a psz_option
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \return the value of the option
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API const char *libvlc_audio_get_filter_option_string( libvlc_media_player_t *p_mi,
+ const char *psz_option );
+
+/**
+ * Set the value of the option parameter \a psz_option
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \param psz_value the value of the option
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API void libvlc_audio_set_filter_option_string( libvlc_media_player_t *p_mi,
+ const char *psz_option,
+ const char *psz_value );
+
+
+/**
+ * Get the value of the option parameter \a psz_option
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \return the value of the option
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API int64_t libvlc_audio_get_filter_option_int( libvlc_media_player_t *p_mi,
+ const char *psz_option );
+
+/**
+ * Set the value of the option parameter \a psz_option
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \param i_value the value of the option
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API void libvlc_audio_set_filter_option_int( libvlc_media_player_t *p_mi, const
+ char *psz_option, int64_t i_value );
+
+/**
+ * Get the value of the option parameter \a psz_option
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \return the value of the option
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API float libvlc_audio_get_filter_option_float( libvlc_media_player_t *p_mi,
+ const char *psz_option );
+
+/**
+ * Set the value of the option parameter \a psz_option
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \param f_value the value of the option
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API void libvlc_audio_set_filter_option_float( libvlc_media_player_t *p_mi,
+ const char *psz_option,
+ float f_value );
+
+/**
+ * Get the value of the option parameter \a psz_option
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \return the value of the option
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API bool libvlc_audio_get_filter_option_bool( libvlc_media_player_t *p_mi,
+ const char *psz_option );
+
+/**
+ * Set the value of the option parameter \a psz_option
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \param b_value the value of the option
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API void libvlc_audio_set_filter_option_bool( libvlc_media_player_t *p_mi,
+ const char *psz_option,
+ bool b_value );
+
/**
* Get the number of equalizer presets.
*
diff --git a/lib/audio.c b/lib/audio.c
index d83d9cdf36..314a87d89c 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -521,6 +521,122 @@ const char *libvlc_audio_get_filters( libvlc_media_player_t *p_mi )
return psz_audio;
}
+static void libvlc_audio_set_filter_option( libvlc_media_player_t *p_mi, const char *psz_option,
+ unsigned i_expected_type, vlc_value_t *val)
+{
+ int i_type = 0;
+ vlc_value_t value;
+
+ audio_output_t *p_aout = GetAOut( p_mi );
+
+ if( p_aout != NULL )
+ {
+ i_type = var_Type( p_aout, psz_option );
+ }
+ if( i_type == 0 )
+ i_type = config_GetType( psz_option );
+
+ i_type &= VLC_VAR_CLASS;
+
+ switch (i_type) {
+ case VLC_VAR_INTEGER:
+ case VLC_VAR_BOOL:
+ case VLC_VAR_FLOAT:
+ case VLC_VAR_STRING:
+ if (i_expected_type != i_type)
+ {
+ libvlc_printerr( "unexpected variable type" );
+ goto end;
+ }
+ break;
+ default:
+ {
+ libvlc_printerr( "unexpected variable type" );
+ goto end;
+ }
+ };
+
+ /* Set the new value to the media player. Next vouts created from this
+ * media player will inherit this new value */
+ if ( var_SetChecked( p_mi, psz_option, i_type, *val ) == VLC_ENOVAR )
+ {
+ var_Create( p_mi, psz_option, i_type | VLC_VAR_DOINHERIT );
+ var_SetChecked( p_mi, psz_option, i_type, *val );
+ }
+
+ /* Set the new value to loaded aout */
+ if( p_aout != NULL )
+ var_SetChecked( p_aout, psz_option, i_type, *val );
+
+end:
+ vlc_object_release( p_aout );
+}
+
+const char * libvlc_audio_get_filter_option_string( libvlc_media_player_t *p_mi, const char *psz_option )
+{
+ if ( ( var_Type( p_mi, psz_option ) & VLC_VAR_CLASS ) != VLC_VAR_STRING )
+ {
+ libvlc_printerr( "Invalid argument to %s", psz_option );
+ return NULL;
+ }
+ return var_GetString( p_mi, psz_option );
+}
+
+void libvlc_audio_set_filter_option_string( libvlc_media_player_t *p_mi, const char *psz_option,
+ const char * psz_value )
+{
+ libvlc_audio_set_filter_option( p_mi, psz_option, VLC_VAR_STRING,
+ &(vlc_value_t) { .psz_string = (char *)psz_value } );
+}
+
+int64_t libvlc_audio_get_filter_option_int( libvlc_media_player_t *p_mi, const char *psz_option )
+{
+ if ( ( var_Type( p_mi, psz_option ) & VLC_VAR_CLASS ) != VLC_VAR_INTEGER )
+ {
+ libvlc_printerr( "Invalid argument to %s", psz_option );
+ return 0;
+ }
+ return var_GetInteger( p_mi, psz_option );
+}
+
+void libvlc_audio_set_filter_option_float( libvlc_media_player_t *p_mi, const char *psz_option, float f_value )
+{
+ libvlc_audio_set_filter_option( p_mi, psz_option, VLC_VAR_FLOAT,
+ &(vlc_value_t) { .f_float = f_value } );
+}
+
+void libvlc_audio_set_filter_option_int( libvlc_media_player_t *p_mi, const char *psz_option, int64_t i_value )
+{
+ libvlc_audio_set_filter_option( p_mi, psz_option, VLC_VAR_INTEGER,
+ &(vlc_value_t) { .i_int = i_value } );
+}
+
+float libvlc_audio_get_filter_option_float( libvlc_media_player_t *p_mi, const char *psz_option )
+{
+ if ( ( var_Type( p_mi, psz_option ) & VLC_VAR_CLASS ) != VLC_VAR_FLOAT )
+ {
+ libvlc_printerr( "Invalid argument to %s", psz_option );
+ return 0.0f;
+ }
+ return var_GetFloat( p_mi, psz_option );
+}
+
+bool libvlc_audio_get_filter_option_bool( libvlc_media_player_t *p_mi, const char *psz_option )
+{
+ if ( ( var_Type( p_mi, psz_option ) & VLC_VAR_CLASS ) != VLC_VAR_BOOL )
+ {
+ libvlc_printerr( "Invalid argument to %s", psz_option );
+ return false;
+ }
+ return var_GetBool( p_mi, psz_option );
+}
+
+void libvlc_audio_set_filter_option_bool( libvlc_media_player_t *p_mi, const char *psz_option, bool b_value )
+{
+ libvlc_audio_set_filter_option( p_mi, psz_option, VLC_VAR_BOOL,
+ &(vlc_value_t) { .b_bool = b_value } );
+}
+
/*****************************************************************************
* libvlc_audio_equalizer_get_preset_count : Get the number of equalizer presets
*****************************************************************************/
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index a228e21f0f..a413bfb559 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -30,6 +30,10 @@ libvlc_audio_output_set_device_type
libvlc_audio_get_channel
libvlc_audio_get_delay
libvlc_audio_get_filters
+libvlc_audio_get_filter_option_string
+libvlc_audio_get_filter_option_int
+libvlc_audio_get_filter_option_float
+libvlc_audio_get_filter_option_bool
libvlc_audio_get_mute
libvlc_audio_get_track
libvlc_audio_get_track_count
@@ -38,6 +42,10 @@ libvlc_audio_get_volume
libvlc_audio_set_channel
libvlc_audio_set_delay
libvlc_audio_set_filters
+libvlc_audio_set_filter_option_string
+libvlc_audio_set_filter_option_int
+libvlc_audio_set_filter_option_float
+libvlc_audio_set_filter_option_bool
libvlc_audio_set_mute
libvlc_audio_set_track
libvlc_audio_set_volume
--
2.14.1
More information about the vlc-devel
mailing list