From: Gwenole Beauchesne Date: Tue, 15 Jan 2013 17:49:28 +0000 (+0100) Subject: tests: simple-decoder: set window size to the surface dimensions. X-Git-Tag: 0.5.1~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b4dadc8ae0ee9a8b0ec531264a4348ee646c6b4;p=platform%2Fupstream%2Fgstreamer-vaapi.git tests: simple-decoder: set window size to the surface dimensions. Set the window size to the decoded surface dimensions, if the user has not requested the application to run in full-screen mode. Besides, no effort is made to preserve aspect ratio or to center the video within the mapped window. --- diff --git a/tests/simple-decoder.c b/tests/simple-decoder.c index 76d4c39..d01ae42 100644 --- a/tests/simple-decoder.c +++ b/tests/simple-decoder.c @@ -74,8 +74,11 @@ typedef struct { GCond decoder_ready; GAsyncQueue *decoder_queue; GstVaapiCodec codec; - GstVideoCodecState codec_state; + guint surface_width; + guint surface_height; GstVaapiWindow *window; + guint window_width; + guint window_height; GThread *render_thread; volatile gboolean render_thread_cancel; GstBuffer *last_buffer; @@ -324,6 +327,25 @@ stop_decoder(App *app) return TRUE; } +static void +ensure_window_size(App *app, GstVaapiSurface *surface) +{ + guint width, height; + + if (gst_vaapi_window_get_fullscreen(app->window)) + return; + + gst_vaapi_surface_get_size(surface, &width, &height); + if (app->surface_width == width && app->surface_height == height) + return; + app->surface_width = width; + app->surface_height = height; + + gst_vaapi_window_set_size(app->window, width, height); + gst_vaapi_window_get_size(app->window, + &app->window_width, &app->window_height); +} + static gboolean renderer_process(App *app, GstBuffer *buffer) { @@ -345,6 +367,8 @@ renderer_process(App *app, GstBuffer *buffer) if (!surface) SEND_ERROR("failed to get decoded surface from video meta"); + ensure_window_size(app, surface); + if (!gst_vaapi_window_put_surface(app->window, surface, NULL, NULL, GST_VAAPI_PICTURE_STRUCTURE_FRAME)) SEND_ERROR("failed to render surface %" GST_VAAPI_ID_FORMAT, @@ -453,6 +477,9 @@ app_new(void) g_cond_init(&app->event_cond); g_cond_init(&app->decoder_ready); + app->window_width = 640; + app->window_height = 480; + app->decoder_queue = g_async_queue_new_full( (GDestroyNotify)gst_buffer_unref); if (!app->decoder_queue) @@ -533,7 +560,8 @@ app_run(App *app, int argc, char *argv[]) return FALSE; } - app->window = video_output_create_window(app->display, 640, 480); + app->window = video_output_create_window(app->display, + app->window_width, app->window_height); if (!app->window) { g_message("failed to create window"); return FALSE;