]> git.sesse.net Git - vlc/commitdiff
HTTP interface: give access to equalizer preamp
authorAkash Mehrotra <mehrotra.akash@gmail.com>
Tue, 14 Jun 2011 19:49:59 +0000 (01:19 +0530)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 15 Jun 2011 00:00:48 +0000 (02:00 +0200)
This is the first part of the equalizer control

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/lua/Modules.am
modules/lua/intf.c
modules/lua/libs.h
modules/lua/libs/equalizer.c [new file with mode: 0644]
share/lua/http/requests/README.txt
share/lua/http/requests/equalizer.xml [new file with mode: 0644]

index d715ef979875a3703e50e9c81cbe86f3e789a6af..a80680401b48ecd9b934ead36ad0b8b0faf257d3 100644 (file)
@@ -11,6 +11,7 @@ SOURCES_lua = \
        libs.h \
        libs/acl.c \
        libs/configuration.c \
+       libs/equalizer.c \
        libs/gettext.c \
        libs/dialog.c \
        libs/httpd.c \
index c2c203f04b8964a866ed7d410337629bf15916f2..bcc1df98d42ae4cd13770f317834169853f5bac6 100644 (file)
@@ -255,6 +255,7 @@ int Open_LuaIntf( vlc_object_t *p_this )
     luaopen_gettext( L );
     luaopen_xml( L );
     luaopen_md5( L );
+    luaopen_equalizer( L );
 
     /* clean up */
     lua_pop( L, 1 );
index 8bca89c41d6f6bd8dff382567a14d51c061c10c1..9afaac02fe13610101a647c19694f0df597946d4 100644 (file)
@@ -46,5 +46,6 @@ void luaopen_gettext( lua_State * );
 void luaopen_input_item( lua_State *L, input_item_t *item );
 void luaopen_xml( lua_State *L );
 void luaopen_md5( lua_State *L );
+void luaopen_equalizer( lua_State *L );
 
 #endif
diff --git a/modules/lua/libs/equalizer.c b/modules/lua/libs/equalizer.c
new file mode 100644 (file)
index 0000000..c4d8d38
--- /dev/null
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * equalizer.c
+ *****************************************************************************
+ * Copyright (C) 2011 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Akash Mehrotra < mehrotra <dot> akash <at> gmail <dot> com >
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#ifndef  _GNU_SOURCE
+#   define  _GNU_SOURCE
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_aout.h>
+#include <vlc_input.h>
+#include <lua.h>        /* Low level lua C API */
+#include <lauxlib.h>    /* Higher level C API */
+#include <lualib.h>     /* Lua libs */
+#include "input.h"
+/*****************************************************************************
+* Get the preamp level
+*****************************************************************************/
+static int vlclua_preamp_get( lua_State *L )
+{
+    input_thread_t *p_input = vlclua_get_input_internal( L );
+    if( p_input )
+    {
+        aout_instance_t *p_aout = input_GetAout( p_input );
+        float preamp = var_GetFloat( p_aout, "equalizer-preamp");
+        lua_pushnumber( L, preamp );
+        return 1;
+    }
+    return 0;
+}
+
+/*****************************************************************************
+* Set the preamp level
+*****************************************************************************/
+static int vlclua_preamp_set( lua_State *L )
+{
+    input_thread_t *p_input = vlclua_get_input_internal( L );
+    if( p_input )
+    {
+        aout_instance_t *p_aout = input_GetAout( p_input );
+        float preamp = luaL_checknumber( L, 1 );
+        var_SetFloat( p_aout, "equalizer-preamp",preamp);
+        lua_pushnumber( L, preamp );
+        return 1;
+    }
+    return 0;
+}
+
+static const luaL_Reg vlclua_equalizer_reg[] = {
+    { "preampget", vlclua_preamp_get },
+    { "preampset", vlclua_preamp_set },
+    { NULL, NULL }
+};
+
+void luaopen_equalizer( lua_State *L )
+{
+    lua_newtable( L );
+    luaL_register( L, NULL, vlclua_equalizer_reg );
+    lua_setfield( L, -2, "equalizer" );
+}
index 0b19bb647b44edc58c5efdf367be89a8727c498e..a327ff281be75f4695b6afbb48ec6585df4da898 100644 (file)
@@ -124,3 +124,8 @@ vlm_cmd.xml:
 < execute VLM command <cmd>
   ?command=<cmd>
 > get the error message from <cmd>
+
+equalizer.xml:
+=============
+>command=preamp&val=<val in dB> 
+ sets the preamp value, must be >=-20 and <=20
diff --git a/share/lua/http/requests/equalizer.xml b/share/lua/http/requests/equalizer.xml
new file mode 100644 (file)
index 0000000..7476487
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?<?vlcprint'>'?>
+<?vlc --[[
+vim:syntax=lua
+<!--  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
+<  equalizer.xml: VLC media player web interface
+< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
+<  Copyright (C) 2011 the VideoLAN team
+<  $Id$
+< 
+<  Authors: Akash Mehrotra < mehrotra <dot> akash <at> gmail <dot> com >
+< 
+<  This program is free software; you can redistribute it and/or modify
+<  it under the terms of the GNU General Public License as published by
+<  the Free Software Foundation; either version 2 of the License, or
+<  (at your option) any later version.
+< 
+<  This program is distributed in the hope that it will be useful,
+<  but WITHOUT ANY WARRANTY; without even the implied warranty of
+<  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+<  GNU General Public License for more details.
+< 
+<  You should have received a copy of the GNU General Public License
+<  along with this program; if not, write to the Free Software
+<  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+]]?>
+<?vlc
+
+local command = _GET['command']
+local val = _GET['val']
+function round(what, precision)
+   return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision)
+end
+if command == "preamp" then vlc.equalizer.preampset(val) end
+?>
+<root>
+  <preamp><?vlc print(round(vlc.equalizer.preampget(),2)) ?></preamp>
+</root>