Exemplo n.º 1
0
/*****************************************************************************
 * Callback to update params on the fly
 *****************************************************************************/
static int BarGraphCallback(vlc_object_t *p_this, char const *psz_var,
                         vlc_value_t oldval, vlc_value_t newval, void *p_data)
{
    VLC_UNUSED(p_this); VLC_UNUSED(oldval);
    filter_sys_t *p_sys = p_data;
    BarGraph_t *p_BarGraph = &p_sys->p_BarGraph;

    vlc_mutex_lock(&p_sys->lock);
    if (!strcmp(psz_var, CFG_PREFIX "x"))
        p_sys->i_pos_x = newval.i_int;
    else if (!strcmp(psz_var, CFG_PREFIX "y"))
        p_sys->i_pos_y = newval.i_int;
    else if (!strcmp(psz_var, CFG_PREFIX "position"))
        p_sys->i_pos = newval.i_int;
    else if (!strcmp(psz_var, CFG_PREFIX "transparency"))
        p_BarGraph->i_alpha = VLC_CLIP(newval.i_int, 0, 255);
    else if (!strcmp(psz_var, CFG_PREFIX "i_values")) {
        if (newval.psz_string)
            parse_i_values(p_BarGraph, newval.psz_string);
        Draw(p_BarGraph);
    } else if (!strcmp(psz_var, CFG_PREFIX "alarm")) {
        p_BarGraph->alarm = newval.b_bool;
        Draw(p_BarGraph);
    } else if (!strcmp(psz_var, CFG_PREFIX "barWidth")) {
        p_BarGraph->barWidth = newval.i_int;
        Draw(p_BarGraph);
    } else if (!strcmp(psz_var, CFG_PREFIX "barHeight")) {
        p_BarGraph->scale = newval.i_int;
        Draw(p_BarGraph);
    }
    p_sys->b_spu_update = true;
    vlc_mutex_unlock(&p_sys->lock);

    return VLC_SUCCESS;
}
Exemplo n.º 2
0
/*****************************************************************************
 * Callback to update params on the fly
 *****************************************************************************/
static int BarGraphCallback(vlc_object_t *p_this, char const *psz_var,
                         vlc_value_t oldval, vlc_value_t newval, void *p_data)
{
    VLC_UNUSED(p_this); VLC_UNUSED(oldval);
    filter_sys_t *p_sys = p_data;
    BarGraph_t *p_BarGraph = &p_sys->p_BarGraph;
    char* res = NULL;

    vlc_mutex_lock(&p_sys->lock);
    if (!strcmp(psz_var, CFG_PREFIX "x"))
        p_sys->i_pos_x = newval.i_int;
    else if (!strcmp(psz_var, CFG_PREFIX "y"))
        p_sys->i_pos_y = newval.i_int;
    else if (!strcmp(psz_var, CFG_PREFIX "position"))
        p_sys->i_pos = newval.i_int;
    else if (!strcmp(psz_var, CFG_PREFIX "transparency"))
        p_BarGraph->i_alpha = VLC_CLIP(newval.i_int, 0, 255);
    else if (!strcmp(psz_var, CFG_PREFIX "i_values")) {
        char *psz = xstrdup(newval.psz_string ? newval.psz_string : "");
        // in case many answer are received at the same time, only keep one
        res = strchr(psz, '@');
        if (res)
            *res = '\0';
        parse_i_values(p_BarGraph, psz);
        free(psz);
        Draw(p_BarGraph);
    } else if (!strcmp(psz_var, CFG_PREFIX "alarm")) {
        p_BarGraph->alarm = newval.b_bool;
        Draw(p_BarGraph);
    } else if (!strcmp(psz_var, CFG_PREFIX "barWidth")) {
        p_BarGraph->barWidth = newval.i_int;
        Draw(p_BarGraph);
    } else if (!strcmp(psz_var, CFG_PREFIX "barHeight")) {
        p_BarGraph->scale = newval.i_int;
        Draw(p_BarGraph);
    }
    p_sys->b_spu_update = true;
    vlc_mutex_unlock(&p_sys->lock);

    return VLC_SUCCESS;
}
Exemplo n.º 3
0
/*****************************************************************************
 * Callback to update params on the fly
 *****************************************************************************/
static int BarGraphCallback( vlc_object_t *p_this, char const *psz_var,
                         vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
    VLC_UNUSED(oldval);
    filter_sys_t *p_sys = (filter_sys_t *)p_data;
    BarGraph_t *p_BarGraph = &(p_sys->p_BarGraph);
    char* res = NULL;

    vlc_mutex_lock( &p_sys->lock );
    if ( !strcmp( psz_var, "audiobargraph_v-x" ) )
    {
        p_sys->i_pos_x = newval.i_int;
    }
    else if ( !strcmp( psz_var, "audiobargraph_v-y" ) )
    {
        p_sys->i_pos_y = newval.i_int;
    }
    else if ( !strcmp( psz_var, "audiobargraph_v-position" ) )
    {
        p_sys->i_pos = newval.i_int;
    }
    else if ( !strcmp( psz_var, "audiobargraph_v-transparency" ) )
    {
        p_BarGraph->i_alpha = VLC_CLIP( newval.i_int, 0, 255 );
    }
    else if ( !strcmp( psz_var, "audiobargraph_v-i_values" ) )
    {
        if( p_BarGraph->p_pic )
        {
            picture_Release( p_BarGraph->p_pic );
            p_BarGraph->p_pic = NULL;
        }
        char *psz_i_values = strdup( newval.psz_string );
        free(p_BarGraph->i_values);
        //p_BarGraph->i_values = NULL;
        //p_BarGraph->nbChannels = 0;
        // in case many answer are received at the same time, only keep one
        res = strchr(psz_i_values, '@');
        if (res)
            *res = 0;
        parse_i_values( p_BarGraph, psz_i_values);
        free( psz_i_values );
        LoadBarGraph(p_this,p_BarGraph);
    }
    else if ( !strcmp( psz_var, "audiobargraph_v-alarm" ) )
    {
        if( p_BarGraph->p_pic )
        {
            picture_Release( p_BarGraph->p_pic );
            p_BarGraph->p_pic = NULL;
        }
        p_BarGraph->alarm = newval.i_int;
        LoadBarGraph(p_this,p_BarGraph);
    }
    else if ( !strcmp( psz_var, "audiobargraph_v-barWidth" ) )
    {
        if( p_BarGraph->p_pic )
        {
            picture_Release( p_BarGraph->p_pic );
            p_BarGraph->p_pic = NULL;
        }
        p_BarGraph->barWidth = newval.i_int;
        LoadBarGraph(p_this,p_BarGraph);
    }
    p_sys->b_spu_update = true;
    vlc_mutex_unlock( &p_sys->lock );

    return VLC_SUCCESS;
}
Exemplo n.º 4
0
/**
 * Common open function
 */
static int OpenCommon( vlc_object_t *p_this, bool b_sub )
{
    filter_t *p_filter = (filter_t *)p_this;
    filter_sys_t *p_sys;
    BarGraph_t *p_BarGraph;
    char* i_values = NULL;

    /* */
    if( !b_sub && !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) )
    {
        msg_Err( p_filter, "Input and output format does not match" );
        return VLC_EGENERIC;
    }


    /* */
    p_filter->p_sys = p_sys = malloc( sizeof( *p_sys ) );
    if( !p_sys )
        return VLC_ENOMEM;
    p_BarGraph = &(p_sys->p_BarGraph);

    /* */
    p_sys->p_blend = NULL;
    if( !b_sub )
    {

        p_sys->p_blend = filter_NewBlend( VLC_OBJECT(p_filter),
                                          &p_filter->fmt_in.video );
        if( !p_sys->p_blend )
        {
            //free( p_BarGraph );
            free( p_sys );
            return VLC_EGENERIC;
        }
    }

    /* */
    config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                       p_filter->p_cfg );

    /* create and initialize variables */
    p_sys->i_pos = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-position" );
    p_sys->i_pos_x = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-x" );
    p_sys->i_pos_y = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-y" );
    p_BarGraph->i_alpha = var_CreateGetIntegerCommand( p_filter,
                                                        "audiobargraph_v-transparency" );
    p_BarGraph->i_alpha = VLC_CLIP( p_BarGraph->i_alpha, 0, 255 );
    i_values = var_CreateGetStringCommand( p_filter, "audiobargraph_v-i_values" );
    //p_BarGraph->nbChannels = 0;
    //p_BarGraph->i_values = NULL;
    parse_i_values(p_BarGraph, i_values);
    p_BarGraph->alarm = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-alarm" );
    p_BarGraph->barWidth = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-barWidth" );
    p_BarGraph->scale = 400;

    /* Ignore aligment if a position is given for video filter */
    if( !b_sub && p_sys->i_pos_x >= 0 && p_sys->i_pos_y >= 0 )
        p_sys->i_pos = 0;

    vlc_mutex_init( &p_sys->lock );
    LoadBarGraph( p_this, p_BarGraph );
    p_sys->b_spu_update = true;

    for( int i = 0; ppsz_filter_callbacks[i]; i++ )
        var_AddCallback( p_filter, ppsz_filter_callbacks[i],
                         BarGraphCallback, p_sys );

    /* Misc init */
    if( b_sub )
    {
        p_filter->pf_sub_source = FilterSub;
    }
    else
    {
        p_filter->pf_video_filter = FilterVideo;
    }

    free( i_values );
    return VLC_SUCCESS;
}