mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
tests: cope with new GstVaapiMiniObject objects.
This commit is contained in:
parent
98bee4240f
commit
da403b62d0
10 changed files with 59 additions and 97 deletions
|
@ -62,18 +62,16 @@ find_codec_defs(const gchar *codec_str)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#define CODEC_DEFS_KEY "codec-defs"
|
||||
|
||||
static inline const CodecDefs *
|
||||
get_codec_defs(GstVaapiDecoder *decoder)
|
||||
{
|
||||
return g_object_get_data(G_OBJECT(decoder), CODEC_DEFS_KEY);
|
||||
return gst_vaapi_decoder_get_user_data(decoder);
|
||||
}
|
||||
|
||||
static inline void
|
||||
set_codec_defs(GstVaapiDecoder *decoder, const CodecDefs *c)
|
||||
{
|
||||
g_object_set_data(G_OBJECT(decoder), CODEC_DEFS_KEY, (gpointer)c);
|
||||
gst_vaapi_decoder_set_user_data(decoder, (gpointer)c);
|
||||
}
|
||||
|
||||
GstVaapiDecoder *
|
||||
|
|
|
@ -43,7 +43,7 @@ image_generate(
|
|||
image_draw_rectangle(image, w/2, h/2, w/2, h/2, 0xff000000))
|
||||
return image;
|
||||
|
||||
g_object_unref(image);
|
||||
gst_vaapi_object_unref(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -355,6 +355,6 @@ image_upload(GstVaapiImage *image, GstVaapiSurface *surface)
|
|||
g_error("could not associate subpicture to surface");
|
||||
|
||||
/* The surface holds a reference to the subpicture. This is safe */
|
||||
g_object_unref(subpicture);
|
||||
gst_vaapi_object_unref(subpicture);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ video_output_create_display(const gchar *display_name)
|
|||
if (display) {
|
||||
if (gst_vaapi_display_get_display(display))
|
||||
break;
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
display = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,16 +331,13 @@ app_set_framerate(App *app, guint fps_n, guint fps_d)
|
|||
}
|
||||
|
||||
static void
|
||||
handle_decoder_caps(GObject *obj, GParamSpec *pspec, void *user_data)
|
||||
handle_decoder_state_changes(GstVaapiDecoder *decoder,
|
||||
const GstVideoCodecState *codec_state, gpointer user_data)
|
||||
{
|
||||
App * const app = user_data;
|
||||
GstVideoCodecState *codec_state;
|
||||
|
||||
g_assert(app->decoder == GST_VAAPI_DECODER(obj));
|
||||
|
||||
codec_state = gst_vaapi_decoder_get_codec_state(app->decoder);
|
||||
g_assert(app->decoder == decoder);
|
||||
app_set_framerate(app, codec_state->info.fps_n, codec_state->info.fps_d);
|
||||
gst_video_codec_state_unref(codec_state);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -383,8 +380,8 @@ start_decoder(App *app)
|
|||
if (!app->decoder)
|
||||
return FALSE;
|
||||
|
||||
g_signal_connect(G_OBJECT(app->decoder), "notify::caps",
|
||||
G_CALLBACK(handle_decoder_caps), app);
|
||||
gst_vaapi_decoder_set_codec_state_changed_func(app->decoder,
|
||||
handle_decoder_state_changes, app);
|
||||
|
||||
g_timer_start(app->timer);
|
||||
|
||||
|
@ -538,9 +535,9 @@ app_free(App *app)
|
|||
}
|
||||
g_free(app->file_name);
|
||||
|
||||
g_clear_object(&app->decoder);
|
||||
g_clear_object(&app->window);
|
||||
g_clear_object(&app->display);
|
||||
gst_vaapi_decoder_replace(&app->decoder, NULL);
|
||||
gst_vaapi_window_replace(&app->window, NULL);
|
||||
gst_vaapi_display_replace(&app->display, NULL);
|
||||
|
||||
if (app->decoder_queue) {
|
||||
g_async_queue_unref(app->decoder_queue);
|
||||
|
|
|
@ -68,7 +68,7 @@ main(int argc, char *argv[])
|
|||
if (CHECK_DISPLAY_CACHE)
|
||||
display2 = video_output_create_display(NULL);
|
||||
else
|
||||
display2 = g_object_ref(display);
|
||||
display2 = gst_vaapi_display_ref(display);
|
||||
if (!display2)
|
||||
g_error("could not create second VA display");
|
||||
|
||||
|
@ -97,10 +97,10 @@ main(int argc, char *argv[])
|
|||
|
||||
pause();
|
||||
|
||||
g_object_unref(decoder);
|
||||
g_object_unref(window);
|
||||
g_object_unref(display);
|
||||
g_object_unref(display2);
|
||||
gst_vaapi_decoder_unref(decoder);
|
||||
gst_vaapi_window_unref(window);
|
||||
gst_vaapi_display_unref(display);
|
||||
gst_vaapi_display_unref(display2);
|
||||
g_free(g_codec_str);
|
||||
video_output_exit();
|
||||
return 0;
|
||||
|
|
|
@ -179,17 +179,6 @@ free_property_cb(gpointer data, gpointer user_data)
|
|||
gst_vaapi_display_property_free(data);
|
||||
}
|
||||
|
||||
static inline GParamSpec *
|
||||
get_display_property(GstVaapiDisplay *display, const gchar *name)
|
||||
{
|
||||
GObjectClass *klass;
|
||||
|
||||
klass = G_OBJECT_CLASS(GST_VAAPI_DISPLAY_GET_CLASS(display));
|
||||
if (!klass)
|
||||
return NULL;
|
||||
return g_object_class_find_property(klass, name);
|
||||
}
|
||||
|
||||
static void
|
||||
dump_properties(GstVaapiDisplay *display)
|
||||
{
|
||||
|
@ -212,25 +201,21 @@ dump_properties(GstVaapiDisplay *display)
|
|||
return;
|
||||
|
||||
for (i = 0; g_properties[i] != NULL; i++) {
|
||||
GParamSpec *pspec = get_display_property(display, g_properties[i]);
|
||||
const gchar * const name = g_properties[i];
|
||||
|
||||
if (!pspec) {
|
||||
GST_ERROR("failed to find GstVaapiDisplay property '%s'",
|
||||
g_properties[i]);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!gst_vaapi_display_has_property(display, pspec->name))
|
||||
if (!gst_vaapi_display_has_property(display, name))
|
||||
continue;
|
||||
|
||||
prop = gst_vaapi_display_property_new(pspec->name);
|
||||
prop = gst_vaapi_display_property_new(name);
|
||||
if (!prop) {
|
||||
GST_ERROR("failed to allocate GstVaapiDisplayProperty");
|
||||
goto end;
|
||||
}
|
||||
|
||||
g_value_init(&prop->value, pspec->value_type);
|
||||
g_object_get_property(G_OBJECT(display), pspec->name, &prop->value);
|
||||
if (!gst_vaapi_display_get_property(display, name, &prop->value)) {
|
||||
GST_ERROR("failed to get property '%s'", name);
|
||||
goto end;
|
||||
}
|
||||
g_ptr_array_add(properties, prop);
|
||||
}
|
||||
|
||||
|
@ -301,7 +286,7 @@ main(int argc, char *argv[])
|
|||
g_error("could not create Gst/VA display");
|
||||
|
||||
dump_info(display);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
}
|
||||
g_print("\n");
|
||||
|
||||
|
@ -320,7 +305,7 @@ main(int argc, char *argv[])
|
|||
g_error("could not create Gst/VA display");
|
||||
|
||||
dump_info(display);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
close(drm_device);
|
||||
}
|
||||
g_print("\n");
|
||||
|
@ -345,7 +330,7 @@ main(int argc, char *argv[])
|
|||
g_error("could not create Gst/VA display");
|
||||
|
||||
dump_info(display);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
close(drm_device);
|
||||
}
|
||||
g_print("\n");
|
||||
|
@ -367,7 +352,7 @@ main(int argc, char *argv[])
|
|||
g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d);
|
||||
|
||||
dump_info(display);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
}
|
||||
g_print("\n");
|
||||
|
||||
|
@ -386,7 +371,7 @@ main(int argc, char *argv[])
|
|||
g_error("could not create Gst/VA display");
|
||||
|
||||
dump_info(display);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
XCloseDisplay(x11_display);
|
||||
}
|
||||
g_print("\n");
|
||||
|
@ -411,7 +396,7 @@ main(int argc, char *argv[])
|
|||
g_error("could not create Gst/VA display");
|
||||
|
||||
dump_info(display);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
XCloseDisplay(x11_display);
|
||||
}
|
||||
g_print("\n");
|
||||
|
@ -433,7 +418,7 @@ main(int argc, char *argv[])
|
|||
g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d);
|
||||
|
||||
dump_info(display);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
}
|
||||
g_print("\n");
|
||||
|
||||
|
@ -452,7 +437,7 @@ main(int argc, char *argv[])
|
|||
g_error("could not create Gst/VA display");
|
||||
|
||||
dump_info(display);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
XCloseDisplay(x11_display);
|
||||
}
|
||||
g_print("\n");
|
||||
|
@ -478,7 +463,7 @@ main(int argc, char *argv[])
|
|||
g_error("could not create Gst/VA display");
|
||||
|
||||
dump_info(display);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
XCloseDisplay(x11_display);
|
||||
}
|
||||
g_print("\n");
|
||||
|
@ -501,7 +486,7 @@ main(int argc, char *argv[])
|
|||
g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d);
|
||||
|
||||
dump_info(display);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
}
|
||||
g_print("\n");
|
||||
#endif
|
||||
|
|
|
@ -171,9 +171,9 @@ main(int argc, char *argv[])
|
|||
pause();
|
||||
|
||||
gst_video_overlay_composition_unref(compo);
|
||||
g_object_unref(decoder);
|
||||
g_object_unref(window);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_decoder_unref(decoder);
|
||||
gst_vaapi_window_unref(window);
|
||||
gst_vaapi_display_unref(display);
|
||||
g_free(g_codec_str);
|
||||
video_output_exit();
|
||||
return 0;
|
||||
|
|
|
@ -26,12 +26,6 @@
|
|||
|
||||
#define MAX_SURFACES 4
|
||||
|
||||
static void
|
||||
gst_vaapi_object_destroy_cb(gpointer object, gpointer user_data)
|
||||
{
|
||||
g_print("destroying GstVaapiObject %p\n", object);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -58,14 +52,11 @@ main(int argc, char *argv[])
|
|||
if (!surface)
|
||||
g_error("could not create Gst/VA surface");
|
||||
|
||||
/* This also tests for the GstVaapiParamSpecID */
|
||||
g_object_get(G_OBJECT(surface), "id", &surface_id, NULL);
|
||||
if (surface_id != gst_vaapi_surface_get_id(surface))
|
||||
g_error("could not retrieve the native surface ID");
|
||||
surface_id = gst_vaapi_surface_get_id(surface);
|
||||
g_print("created surface %" GST_VAAPI_ID_FORMAT "\n",
|
||||
GST_VAAPI_ID_ARGS(surface_id));
|
||||
|
||||
g_object_unref(surface);
|
||||
gst_vaapi_object_unref(surface);
|
||||
|
||||
caps = gst_caps_new_simple(
|
||||
GST_VAAPI_SURFACE_CAPS_NAME,
|
||||
|
@ -91,7 +82,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Check the pool doesn't return the last free'd surface */
|
||||
surface = g_object_ref(surfaces[1]);
|
||||
surface = gst_vaapi_object_ref(surfaces[1]);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
gst_vaapi_video_pool_put_object(pool, surfaces[i]);
|
||||
|
@ -114,20 +105,11 @@ main(int argc, char *argv[])
|
|||
surfaces[i] = NULL;
|
||||
}
|
||||
|
||||
g_signal_connect(
|
||||
G_OBJECT(surface),
|
||||
"destroy",
|
||||
G_CALLBACK(gst_vaapi_object_destroy_cb), NULL
|
||||
);
|
||||
|
||||
/* Unref in random order to check objects are correctly refcounted */
|
||||
g_print("unref display\n");
|
||||
g_object_unref(display);
|
||||
gst_vaapi_display_unref(display);
|
||||
gst_caps_unref(caps);
|
||||
g_print("unref pool\n");
|
||||
g_object_unref(pool);
|
||||
g_print("unref surface\n");
|
||||
g_object_unref(surface);
|
||||
gst_vaapi_video_pool_unref(pool);
|
||||
gst_vaapi_object_unref(surface);
|
||||
video_output_exit();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -182,12 +182,12 @@ main(int argc, char *argv[])
|
|||
gst_vaapi_window_glx_swap_buffers(glx_window);
|
||||
pause();
|
||||
|
||||
g_object_unref(textures[0]);
|
||||
g_object_unref(textures[1]);
|
||||
gst_vaapi_texture_unref(textures[0]);
|
||||
gst_vaapi_texture_unref(textures[1]);
|
||||
glDeleteTextures(1, &texture_id);
|
||||
|
||||
g_object_unref(window);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_window_unref(window);
|
||||
gst_vaapi_display_unref(display);
|
||||
gst_deinit();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ create_test_surface(GstVaapiDisplay *display, guint width, guint height)
|
|||
if (!gst_vaapi_surface_sync(surface))
|
||||
g_error("could not complete image upload");
|
||||
|
||||
g_object_unref(image);
|
||||
gst_vaapi_object_unref(image);
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
@ -125,11 +125,11 @@ main(int argc, char *argv[])
|
|||
g_error("could not render surface");
|
||||
|
||||
pause();
|
||||
g_object_unref(window);
|
||||
gst_vaapi_window_unref(window);
|
||||
}
|
||||
|
||||
g_object_unref(surface);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_object_unref(surface);
|
||||
gst_vaapi_display_unref(display);
|
||||
#endif
|
||||
|
||||
#if USE_X11
|
||||
|
@ -155,7 +155,7 @@ main(int argc, char *argv[])
|
|||
g_error("could not render surface");
|
||||
|
||||
pause();
|
||||
g_object_unref(window);
|
||||
gst_vaapi_window_unref(window);
|
||||
}
|
||||
|
||||
g_print("#\n");
|
||||
|
@ -192,13 +192,13 @@ main(int argc, char *argv[])
|
|||
g_error("could not render surface");
|
||||
|
||||
pause();
|
||||
g_object_unref(window);
|
||||
gst_vaapi_window_unref(window);
|
||||
XUnmapWindow(dpy, win);
|
||||
XDestroyWindow(dpy, win);
|
||||
}
|
||||
|
||||
g_object_unref(surface);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_object_unref(surface);
|
||||
gst_vaapi_display_unref(display);
|
||||
#endif
|
||||
|
||||
#if USE_WAYLAND
|
||||
|
@ -224,11 +224,11 @@ main(int argc, char *argv[])
|
|||
g_error("could not render surface");
|
||||
|
||||
pause();
|
||||
g_object_unref(window);
|
||||
gst_vaapi_window_unref(window);
|
||||
}
|
||||
|
||||
g_object_unref(surface);
|
||||
g_object_unref(display);
|
||||
gst_vaapi_object_unref(surface);
|
||||
gst_vaapi_display_unref(display);
|
||||
#endif
|
||||
|
||||
gst_deinit();
|
||||
|
|
Loading…
Reference in a new issue