예제 #1
0
/*****************************************************************************
* 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 )
        return 0;

    audio_output_t *p_aout = input_GetAout( p_input );
    vlc_object_release( p_input );

    if( !p_aout)
        return 0;

    char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
    if( !psz_af || strstr ( psz_af, "equalizer" ) == NULL )
    {
        free( psz_af );
        vlc_object_release( p_aout );
        return 0;
    }
    free( psz_af );

    lua_pushnumber( L, var_GetFloat( p_aout, "equalizer-preamp") );
    vlc_object_release( p_aout );
    return 1;
}
예제 #2
0
static int vlclua_input_is_playing( lua_State *L )
{
    input_thread_t * p_input = vlclua_get_input_internal( L );
    lua_pushboolean( L, !!p_input );
    if( p_input )
        vlc_object_release( p_input );
    return 1;
}
예제 #3
0
/*****************************************************************************
* Set the equalizer level for the specified band
*****************************************************************************/
static int vlclua_equalizer_set( lua_State *L )
{
    int bandid = luaL_checknumber( L, 1 );
    if( bandid < 0 || bandid > 9)
        return 0;
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( !p_input )
        return 0;

    audio_output_t *p_aout = input_GetAout( p_input );
    vlc_object_release( p_input );
    if( !p_aout )
        return 0;

    char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
    if( !psz_af || strstr ( psz_af, "equalizer" ) == NULL )
    {
        free( psz_af );
        vlc_object_release( p_aout );
        return 0;
    }
    free( psz_af );

    float level = luaL_checknumber( L, 2 );
    char *bands = var_GetString( p_aout, "equalizer-bands" );

    locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
    locale_t oldloc = uselocale (loc);
    char *b = bands;
    while( bandid > 0 )
    {
        float dummy = strtof( b, &b );
        (void)dummy;
        bandid--;
    }
    if( *b != '\0' )
        *b++ = '\0';
    float dummy = strtof( b, &b );
    (void)dummy;

    char *newstr;
    if( asprintf( &newstr, "%s %.1f%s", bands, level, b ) != -1 )
    {
        var_SetString( p_aout, "equalizer-bands", newstr );
        free( newstr );
    }

    if( loc != (locale_t)0 )
    {
        uselocale (oldloc);
        freelocale (loc);
    }
    free( bands );
    vlc_object_release( p_aout );
    return 0;
}
예제 #4
0
파일: objects.c 프로젝트: iamnpc/myfaplayer
static int vlclua_get_input( lua_State *L )
{
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( p_input )
    {
        vlclua_push_vlc_object( L, p_input, vlclua_gc_release );
    }
    else lua_pushnil( L );
    return 1;
}
예제 #5
0
파일: equalizer.c 프로젝트: Flameeyes/vlc
/*****************************************************************************
* Return EQ level for all bands as a Table
*****************************************************************************/
static int vlclua_equalizer_get( lua_State *L )
{
    int bands = 9;
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( !p_input )
        return 0;
    audio_output_t *p_aout = input_GetAout( p_input );
    vlc_object_release( p_input );
    if( !p_aout )
        return 0;

    float level = 0 ;
    char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
    if( !psz_af || strstr ( psz_af, "equalizer" ) == NULL )
    {
        free( psz_af );
        vlc_object_release( p_aout );
        return 0;
    }
    free( psz_af );

    char *psz_bands_origin, *psz_bands;
    psz_bands_origin = psz_bands = var_GetNonEmptyString( p_aout, "equalizer-bands" );
    if( !psz_bands )
    {
        vlc_object_release( p_aout );
        return 0;
    }
    locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
    locale_t oldloc = uselocale (loc);
    int i = 0;
    char *str;
    lua_newtable( L );
    while( bands >= 0 )
    {
        level = strtof( psz_bands, &psz_bands);
        bands--;
        if( asprintf( &str , "%f" , level ) == -1 )
            return 0;
        lua_pushstring( L, str );
        free(str);
        if( asprintf( &str , "band id=\"%d\"", i++ ) == -1 )
            return 0;
        lua_setfield( L , -2 , str );
        free( str );
    }
    free( psz_bands_origin );
    if( loc != (locale_t)0 )
    {
        uselocale (oldloc);
        freelocale (loc);
    }
    vlc_object_release( p_aout );
    return 1;
}
예제 #6
0
파일: objects.c 프로젝트: BossKing/vlc
static int vlclua_get_input( lua_State *L )
{
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( p_input )
    {
        /* NOTE: p_input is already held by vlclua_get_input_internal() */
        vlclua_push_vlc_object( L, p_input );
    }
    else lua_pushnil( L );
    return 1;
}
예제 #7
0
static int vlclua_input_add_subtitle( lua_State *L )
{
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( !p_input )
        return luaL_error( L, "can't add subtitle: no current input" );
    if( !lua_isstring( L, 1 ) )
        return luaL_error( L, "vlc.input.add_subtitle() usage: (path)" );
    const char *psz_path = luaL_checkstring( L, 1 );
    input_AddSubtitle( p_input, psz_path, false );
    vlc_object_release( p_input );
    return 1;
}
예제 #8
0
/*****************************************************************************
* 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 );

        vlc_object_release( p_aout );
        vlc_object_release( p_input );
        return 1;
    }
    return 0;
}
예제 #9
0
static int vlclua_input_item_get_current( lua_State *L )
{
    input_thread_t *p_input = vlclua_get_input_internal( L );
    input_item_t *p_item = p_input ? input_GetItem( p_input ) : NULL;
    if( !p_item )
    {
        lua_pushnil( L );
        if( p_input ) vlc_object_release( p_input );
        return 1;
    }

    vlclua_input_item_get( L, p_item );

    if( p_input ) vlc_object_release( p_input );
    return 1;
}
예제 #10
0
파일: objects.c 프로젝트: BossKing/vlc
static int vlclua_get_vout( lua_State *L )
{
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( p_input )
    {
        vout_thread_t *p_vout = input_GetVout( p_input );
        vlc_object_release( p_input );
        if(p_vout)
        {
            vlclua_push_vlc_object( L, (vlc_object_t *) p_vout );
            return 1;
        }
    }
    lua_pushnil( L );
    return 1;
}
예제 #11
0
파일: equalizer.c 프로젝트: Flameeyes/vlc
/*****************************************************************************
* Set the equalizer level for the specified band
*****************************************************************************/
static int vlclua_equalizer_set( lua_State *L )
{
    int bandid = luaL_checknumber( L, 1 );
    if( bandid < 0 || bandid > 9)
        return 0;
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( !p_input )
        return 0;

    int i_pos = 0 , j = 0;
    audio_output_t *p_aout = input_GetAout( p_input );
    vlc_object_release( p_input );
    if( !p_aout )
        return 0;

    char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
    if( !psz_af || strstr ( psz_af, "equalizer" ) == NULL )
    {
        free( psz_af );
        vlc_object_release( p_aout );
        return 0;
    }
    free( psz_af );

    float level = luaL_checknumber( L, 2 );
    char *bands = var_GetString( p_aout, "equalizer-bands" );
    char newstr[7];
    while( j != bandid )
    {
        i_pos++;
        if( bands[i_pos] == '.' )
        {
            i_pos++;
            j++;
        }
    }
    if( bandid != 0 )
        i_pos++;
    snprintf( newstr, sizeof ( newstr ) , "%6.1f", level);
    for( int i = 0 ; i < 6 ; i++ )
        bands[i_pos+i] = newstr[i];
    var_SetString( p_aout, "equalizer-bands", bands );

    vlc_object_release( p_aout );
    return 1;
}
예제 #12
0
파일: osd.c 프로젝트: CSRedRat/vlc
static int vlclua_spu_channel_clear( lua_State *L )
{
    int i_chan = luaL_checkint( L, 1 );
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( !p_input )
        return luaL_error( L, "Unable to find input." );
    vout_thread_t *p_vout = input_GetVout( p_input );
    if( !p_vout )
    {
        vlc_object_release( p_input );
        return luaL_error( L, "Unable to find vout." );
    }

    vout_FlushSubpictureChannel( p_vout, i_chan );
    vlc_object_release( p_vout );
    vlc_object_release( p_input );
    return 0;
}
예제 #13
0
static int vlclua_osd_message( lua_State *L )
{
    const char *psz_message = luaL_checkstring( L, 1 );
    int i_chan = luaL_optint( L, 2, SPU_DEFAULT_CHANNEL );

    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( p_input )
    {
        vout_thread_t *p_vout = input_GetVout( p_input );
        if( p_vout )
        {
            vout_OSDMessage( p_vout, i_chan, "%s", psz_message );
            vlc_object_release( p_vout );
        }
        vlc_object_release( p_input );
    }
    return 0;
}
예제 #14
0
파일: osd.c 프로젝트: CSRedRat/vlc
static int vlclua_spu_channel_register( lua_State *L )
{
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( !p_input )
        return luaL_error( L, "Unable to find input." );

    vout_thread_t *p_vout = input_GetVout( p_input );
    if( !p_vout )
    {
        vlc_object_release( p_input );
        return luaL_error( L, "Unable to find vout." );
    }

    int i_chan = vout_RegisterSubpictureChannel( p_vout );
    vlc_object_release( p_vout );
    vlc_object_release( p_input );
    lua_pushinteger( L, i_chan );
    return 1;
}
예제 #15
0
파일: video.c 프로젝트: CSRedRat/vlc
/*****************************************************************************
 * Vout control
 *****************************************************************************/
static int vlclua_fullscreen( lua_State *L )
{
    vout_thread_t *p_vout;
    int i_ret;

    input_thread_t * p_input = vlclua_get_input_internal( L );
    if( !p_input ) return vlclua_error( L );

    p_vout = input_GetVout( p_input );
    if( !p_vout )
    {
        vlc_object_release( p_input );
        return vlclua_error( L );
    }

    i_ret = vlclua_var_toggle_or_set( L, p_vout, "fullscreen" );

    vlc_object_release( p_vout );
    vlc_object_release( p_input );
    return i_ret;
}
예제 #16
0
파일: osd.c 프로젝트: CSRedRat/vlc
static int vlclua_osd_icon( lua_State *L )
{
    const char *psz_icon = luaL_checkstring( L, 1 );
    int i_icon = vlc_osd_icon_from_string( psz_icon );
    int i_chan = luaL_optint( L, 2, SPU_DEFAULT_CHANNEL );
    if( !i_icon )
        return luaL_error( L, "\"%s\" is not a valid osd icon.", psz_icon );

    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( p_input )
    {
        vout_thread_t *p_vout = input_GetVout( p_input );
        if( p_vout )
        {
            vout_OSDIcon( p_vout, i_chan, i_icon );
            vlc_object_release( p_vout );
        }
        vlc_object_release( p_input );
    }
    return 0;
}
예제 #17
0
파일: osd.c 프로젝트: CSRedRat/vlc
static int vlclua_osd_message( lua_State *L )
{
    const char *psz_message = luaL_checkstring( L, 1 );
    int i_chan = luaL_optint( L, 2, SPU_DEFAULT_CHANNEL );
    const char *psz_position = luaL_optstring( L, 3, "top-right" );
    mtime_t duration = luaL_optint( L, 4, 1000000 );

    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( p_input )
    {
        vout_thread_t *p_vout = input_GetVout( p_input );
        if( p_vout )
        {
            vout_OSDText( p_vout, i_chan, vlc_osd_position_from_string( psz_position ),
                          duration, psz_message );
            vlc_object_release( p_vout );
        }
        vlc_object_release( p_input );
    }
    return 0;
}
예제 #18
0
/*****************************************************************************
* Set the preset specified by preset id
*****************************************************************************/
static int vlclua_equalizer_setpreset( lua_State *L )
{
    int presetid = luaL_checknumber( L, 1 );
    if( presetid >= NB_PRESETS || presetid < 0 )
        return 0;
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( p_input )
    {
        audio_output_t *p_aout = input_GetAout( p_input );
        vlc_object_release( p_input );
        if( !p_aout )
        {
            return 0;
        }
        char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
        if( !psz_af || strstr ( psz_af, "equalizer" ) == NULL )
        {
            free( psz_af );
            vlc_object_release( p_aout );
            return 0;
        }
        free( psz_af );
        char *newstr;
        if( asprintf( &newstr , "%6.1f" , eqz_preset_10b[presetid].f_amp[0] ) == -1 )
            return 0;
        for ( int i = 1 ; i < 10 ; i++ )
        {
            if( asprintf( &newstr, "%s%6.1f",newstr ,eqz_preset_10b[presetid].f_amp[i]) == -1 )
                return 0;
        }
        var_SetString( p_aout, "equalizer-bands",newstr );
        var_SetFloat( p_aout, "equalizer-preamp", eqz_preset_10b[presetid].f_preamp );
        var_SetString( p_aout , "equalizer-preset" , preset_list[presetid] );
        vlc_object_release( p_aout );
        free( newstr );
        return 1;
    }
    return 0;
}
예제 #19
0
파일: osd.c 프로젝트: CSRedRat/vlc
static int vlclua_osd_slider( lua_State *L )
{
    int i_position = luaL_checkint( L, 1 );
    const char *psz_type = luaL_checkstring( L, 2 );
    int i_type = vlc_osd_slider_type_from_string( psz_type );
    int i_chan = luaL_optint( L, 3, SPU_DEFAULT_CHANNEL );
    if( !i_type )
        return luaL_error( L, "\"%s\" is not a valid slider type.",
                           psz_type );

    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( p_input )
    {
        vout_thread_t *p_vout = input_GetVout( p_input );
        if( p_vout )
        {
            vout_OSDSlider( p_vout, i_chan, i_position, i_type );
            vlc_object_release( p_vout );
        }
        vlc_object_release( p_input );
    }
    return 0;
}
예제 #20
0
/*****************************************************************************
* Return EQ level for all bands as a Table
*****************************************************************************/
static int vlclua_equalizer_get( lua_State *L )
{
    const unsigned bands = 10;
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( !p_input )
        return 0;
    audio_output_t *p_aout = input_GetAout( p_input );
    vlc_object_release( p_input );
    if( !p_aout )
        return 0;

    char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
    if( !psz_af || strstr ( psz_af, "equalizer" ) == NULL )
    {
        free( psz_af );
        vlc_object_release( p_aout );
        return 0;
    }
    free( psz_af );

    char *psz_bands_origin, *psz_bands;
    psz_bands_origin = psz_bands = var_GetNonEmptyString( p_aout, "equalizer-bands" );
    if( !psz_bands )
    {
        vlc_object_release( p_aout );
        return 0;
    }

    bool error = false;
    locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
    locale_t oldloc = uselocale (loc);
    lua_newtable( L );
    for( unsigned i = 0; i < bands; i++ )
    {
        float level = strtof( psz_bands, &psz_bands );
        char *str;
        if( asprintf( &str , "%f" , level ) == -1 )
        {
            error = true;
            break;
        }
        lua_pushstring( L, str );
        free(str);
        if( asprintf( &str , "band id=\"%u\"", i ) == -1 )
        {
            error = true;
            break;
        }
        lua_setfield( L , -2 , str );
        free( str );
    }

    free( psz_bands_origin );
    if( loc != (locale_t)0 )
    {
        uselocale (oldloc);
        freelocale (loc);
    }
    vlc_object_release( p_aout );
    return error ? 0 : 1;
}