コード例 #1
0
ファイル: charlie.c プロジェクト: Enlik/mlt
void transport( mlt_producer producer )
{
	mlt_properties properties = mlt_producer_properties( producer );

	term_init( );
	fprintf( stderr, "Press 'q' to continue\n" );
	while( mlt_properties_get_int( properties, "done" ) == 0 )
	{
		int value = term_read( );
		if ( value != -1 )
			transport_action( producer, ( char * )&value );
	}
}
コード例 #2
0
ファイル: melt.c プロジェクト: hrshadhin/mlt
static void event_handling( mlt_producer producer, mlt_consumer consumer )
{
    SDL_Event event;

    while ( SDL_PollEvent( &event ) )
    {
        switch( event.type )
        {
        case SDL_QUIT:
            mlt_properties_set_int( MLT_PRODUCER_PROPERTIES( consumer ), "done", 1 );
            break;

        case SDL_KEYDOWN:
            if ( event.key.keysym.unicode < 0x80 && event.key.keysym.unicode > 0 )
            {
                char keyboard[ 2 ] = { event.key.keysym.unicode, 0 };
                transport_action( producer, keyboard );
            }
            break;
        }
    }
}
コード例 #3
0
ファイル: melt.c プロジェクト: hrshadhin/mlt
static void transport( mlt_producer producer, mlt_consumer consumer )
{
    mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
    int silent = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "silent" );
    int progress = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "progress" );
    struct timespec tm = { 0, 40000000 };
    int total_length = mlt_producer_get_length( producer );
    int last_position = 0;

    if ( mlt_properties_get_int( properties, "done" ) == 0 && !mlt_consumer_is_stopped( consumer ) )
    {
        if ( !silent && !progress )
        {
            term_init( );

            fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
            fprintf( stderr, "|1=-10| |2= -5| |3= -2| |4= -1| |5=  0| |6=  1| |7=  2| |8=  5| |9= 10|\n" );
            fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );

            fprintf( stderr, "+---------------------------------------------------------------------+\n" );
            fprintf( stderr, "|               H = back 1 minute,  L = forward 1 minute              |\n" );
            fprintf( stderr, "|                 h = previous frame,  l = next frame                 |\n" );
            fprintf( stderr, "|           g = start of clip, j = next clip, k = previous clip       |\n" );
            fprintf( stderr, "|                0 = restart, q = quit, space = play                  |\n" );
            fprintf( stderr, "+---------------------------------------------------------------------+\n" );
        }

        while( mlt_properties_get_int( properties, "done" ) == 0 && !mlt_consumer_is_stopped( consumer ) )
        {
            int value = ( silent || progress )? -1 : term_read( );

            if ( value != -1 )
            {
                char string[ 2 ] = { value, 0 };
                transport_action( producer, string );
            }

#if (defined(__DARWIN__) || defined(WIN32)) && !defined(MELT_NOSDL)
            event_handling( producer, consumer );
#endif

            if ( !silent && mlt_properties_get_int( properties, "stats_off" ) == 0 )
            {
                if ( progress )
                {
                    int current_position = mlt_producer_position( producer );
                    if ( current_position > last_position )
                    {
                        fprintf( stderr, "Current Frame: %10d, percentage: %10d%c",
                                 current_position, 100 * current_position / total_length,
                                 progress == 2 ? '\n' : '\r' );
                        last_position = current_position;
                    }
                }
                else
                {
                    fprintf( stderr, "Current Position: %10d\r", (int)mlt_consumer_position( consumer ) );
                }
                fflush( stderr );
            }

            if ( silent || progress )
                nanosleep( &tm, NULL );
        }

        if ( !silent )
            fprintf( stderr, "\n" );
    }
}