Add decoder demos. Use -c (mpeg2|h264|vc1) to select the codec.
[profile/ivi/gstreamer-vaapi.git] / tests / test-surfaces.c
index d201bdb..9332391 100644 (file)
 
 #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[])
 {
-    GstVaapiDisplay *display;
-    GstVaapiSurface *surface;
-    GstVaapiSurface *surfaces[MAX_SURFACES];
-    GstVaapiVideoPool *pool;
-    GstCaps *caps;
-    gint i;
+    GstVaapiDisplay    *display;
+    GstVaapiSurface    *surface;
+    GstVaapiID          surface_id;
+    GstVaapiSurface    *surfaces[MAX_SURFACES];
+    GstVaapiVideoPool  *pool;
+    GstCaps            *caps;
+    gint                i;
 
     static const GstVaapiChromaType chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
     static const guint              width       = 320;
@@ -47,6 +54,14 @@ main(int argc, char *argv[])
     surface = gst_vaapi_surface_new(display, chroma_type, width, height);
     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");
+    g_print("created surface %" GST_VAAPI_ID_FORMAT "\n",
+            GST_VAAPI_ID_ARGS(surface_id));
+
     g_object_unref(surface);
 
     caps = gst_caps_new_simple(
@@ -66,8 +81,8 @@ main(int argc, char *argv[])
         surface = gst_vaapi_video_pool_get_object(pool);
         if (!surface)
             g_error("could not allocate Gst/VA surface from pool");
-        g_print("created surface 0x%08x from pool\n",
-                gst_vaapi_surface_get_id(surface));
+        g_print("created surface %" GST_VAAPI_ID_FORMAT " from pool\n",
+                GST_VAAPI_ID_ARGS(gst_vaapi_surface_get_id(surface)));
         surfaces[i] = surface;
     }
 
@@ -81,8 +96,8 @@ main(int argc, char *argv[])
         surfaces[i] = gst_vaapi_video_pool_get_object(pool);
         if (!surfaces[i])
             g_error("could not re-allocate Gst/VA surface%d from pool", i);
-        g_print("created surface 0x%08x from pool (realloc)\n",
-                gst_vaapi_surface_get_id(surfaces[i]));
+        g_print("created surface %" GST_VAAPI_ID_FORMAT " from pool (realloc)\n",
+                GST_VAAPI_ID_ARGS(gst_vaapi_surface_get_id(surfaces[i])));
     }
 
     if (surface == surfaces[0])
@@ -95,6 +110,12 @@ 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);