X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=mlt%2Fsrc%2Fmodules%2Fsdl%2Fconsumer_sdl.c;h=cf02c737e7c00317e71e2a0fca31e20f0d6fbcc4;hb=092636b85449e57fd33ffd4954a2de23c2a5f81c;hp=2d70b903d17be032987defdae4e240fd4da9f4e6;hpb=bbc63e064f2874ea16a4c8cf0e6331fb73f3ffb5;p=melted diff --git a/mlt/src/modules/sdl/consumer_sdl.c b/mlt/src/modules/sdl/consumer_sdl.c index 2d70b90..cf02c73 100644 --- a/mlt/src/modules/sdl/consumer_sdl.c +++ b/mlt/src/modules/sdl/consumer_sdl.c @@ -46,6 +46,8 @@ struct consumer_sdl_s pthread_cond_t audio_cond; int window_width; int window_height; + int width; + int height; }; /** Forward references to static functions. @@ -59,7 +61,7 @@ static int consumer_get_dimensions( int *width, int *height ); via the argument, but keep it simple. */ -mlt_consumer consumer_sdl_init( void *dummy ) +mlt_consumer consumer_sdl_init( char *arg ) { // Create the consumer object consumer_sdl this = calloc( sizeof( struct consumer_sdl_s ), 1 ); @@ -85,8 +87,24 @@ mlt_consumer consumer_sdl_init( void *dummy ) pthread_mutex_init( &this->audio_mutex, NULL ); pthread_cond_init( &this->audio_cond, NULL); - // TODO: process actual param - + // process actual param + if ( arg == NULL || !strcmp( arg, "PAL" ) ) + { + this->width = 720; + this->height = 576; + } + else if ( !strcmp( arg, "NTSC" ) ) + { + this->width = 720; + this->height = 480; + } + else if ( sscanf( arg, "%dx%d", &this->width, &this->height ) != 2 ) + { + this->width = 720; + this->height = 576; + } + + // Create the the thread pthread_create( &this->thread, NULL, consumer_thread, this ); @@ -170,6 +188,9 @@ static void *consumer_thread( void *arg ) // Get the service assoicated to the consumer mlt_service service = mlt_consumer_service( consumer ); + // Get the properties of this consumer + mlt_properties properties = this->properties; + // Define a frame pointer mlt_frame frame; @@ -194,7 +215,7 @@ static void *consumer_thread( void *arg ) if ( mlt_service_get_frame( service, &frame, 0 ) == 0 ) { mlt_image_format vfmt = mlt_image_yuv422; - int width, height; + int width = this->width, height = this->height; uint8_t *image; mlt_audio_format afmt = mlt_audio_pcm; @@ -213,7 +234,7 @@ static void *consumer_thread( void *arg ) request.freq = frequency; request.format = AUDIO_S16; request.channels = channels; - request.samples = 1024; + request.samples = 512; request.callback = sdl_fill_audio; request.userdata = (void *)this; if ( SDL_OpenAudio( &request, NULL ) < 0 ) @@ -251,6 +272,14 @@ static void *consumer_thread( void *arg ) this->window_height = event.resize.h; changed = 1; break; + case SDL_KEYDOWN: + { + mlt_producer producer = mlt_properties_get_data( properties, "transport_producer", NULL ); + void (*callback)( mlt_producer, char * ) = mlt_properties_get_data( properties, "transport_callback", NULL ); + if ( callback != NULL && producer != NULL ) + callback( producer, SDL_GetKeyName(event.key.keysym.sym) ); + } + break; } } } @@ -291,7 +320,7 @@ static void *consumer_thread( void *arg ) if ( sdl_overlay != NULL ) SDL_FreeYUVOverlay( sdl_overlay ); sdl_lock_display(); - sdl_overlay = SDL_CreateYUVOverlay( width, height, SDL_YUY2_OVERLAY, sdl_screen ); + sdl_overlay = SDL_CreateYUVOverlay( this->width, this->height, SDL_YUY2_OVERLAY, sdl_screen ); sdl_unlock_display(); } } @@ -303,7 +332,7 @@ static void *consumer_thread( void *arg ) { if ( SDL_LockYUVOverlay( sdl_overlay ) >= 0 ) { - memcpy( buffer, image, width * height * 2 ); + mlt_resize_yuv422( buffer, this->width, this->height, image, width, height ); SDL_UnlockYUVOverlay( sdl_overlay ); SDL_DisplayYUVOverlay( sdl_overlay, &sdl_screen->clip_rect ); }