Commit 187293b6 authored by Akash Mehrotra's avatar Akash Mehrotra Committed by Jean-Baptiste Kempf

HTTP interface: give access to equalizer preamp

This is the first part of the equalizer control
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent df8d46d7
...@@ -11,6 +11,7 @@ SOURCES_lua = \ ...@@ -11,6 +11,7 @@ SOURCES_lua = \
libs.h \ libs.h \
libs/acl.c \ libs/acl.c \
libs/configuration.c \ libs/configuration.c \
libs/equalizer.c \
libs/gettext.c \ libs/gettext.c \
libs/dialog.c \ libs/dialog.c \
libs/httpd.c \ libs/httpd.c \
......
...@@ -255,6 +255,7 @@ int Open_LuaIntf( vlc_object_t *p_this ) ...@@ -255,6 +255,7 @@ int Open_LuaIntf( vlc_object_t *p_this )
luaopen_gettext( L ); luaopen_gettext( L );
luaopen_xml( L ); luaopen_xml( L );
luaopen_md5( L ); luaopen_md5( L );
luaopen_equalizer( L );
/* clean up */ /* clean up */
lua_pop( L, 1 ); lua_pop( L, 1 );
......
...@@ -46,5 +46,6 @@ void luaopen_gettext( lua_State * ); ...@@ -46,5 +46,6 @@ void luaopen_gettext( lua_State * );
void luaopen_input_item( lua_State *L, input_item_t *item ); void luaopen_input_item( lua_State *L, input_item_t *item );
void luaopen_xml( lua_State *L ); void luaopen_xml( lua_State *L );
void luaopen_md5( lua_State *L ); void luaopen_md5( lua_State *L );
void luaopen_equalizer( lua_State *L );
#endif #endif
/*****************************************************************************
* 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" );
}
...@@ -124,3 +124,8 @@ vlm_cmd.xml: ...@@ -124,3 +124,8 @@ vlm_cmd.xml:
< execute VLM command <cmd> < execute VLM command <cmd>
?command=<cmd> ?command=<cmd>
> get the error message from <cmd> > get the error message from <cmd>
equalizer.xml:
=============
>command=preamp&val=<val in dB>
sets the preamp value, must be >=-20 and <=20
<?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>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment