G_DEFINE_TYPE(GstVaapiSurfaceProxy, gst_vaapi_surface_proxy, G_TYPE_OBJECT);
+#define GST_VAAPI_SURFACE_PROXY_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+ GST_VAAPI_TYPE_SURFACE_PROXY, \
+ GstVaapiSurfaceProxyPrivate))
+
+struct _GstVaapiSurfaceProxyPrivate {
+ GstVaapiContext *context;
+ GstVaapiSurface *surface;
+ GstClockTime timestamp;
+};
+
enum {
PROP_0,
PROP_CONTEXT,
- PROP_SURFACE
+ PROP_SURFACE,
+ PROP_TIMESTAMP
};
static void
gst_vaapi_surface_proxy_finalize(GObject *object)
{
GstVaapiSurfaceProxy * const proxy = GST_VAAPI_SURFACE_PROXY(object);
+ GstVaapiSurfaceProxyPrivate * const priv = proxy->priv;
- if (proxy->surface) {
- if (proxy->context)
- gst_vaapi_context_put_surface(proxy->context, proxy->surface);
- g_object_unref(proxy->surface);
- proxy->surface = NULL;
+ if (priv->surface) {
+ if (priv->context)
+ gst_vaapi_context_put_surface(priv->context, priv->surface);
+ g_object_unref(priv->surface);
+ priv->surface = NULL;
}
- if (proxy->context) {
- g_object_unref(proxy->context);
- proxy->context = NULL;
+ if (priv->context) {
+ g_object_unref(priv->context);
+ priv->context = NULL;
}
G_OBJECT_CLASS(gst_vaapi_surface_proxy_parent_class)->finalize(object);
case PROP_SURFACE:
gst_vaapi_surface_proxy_set_surface(proxy, g_value_get_pointer(value));
break;
+ case PROP_TIMESTAMP:
+ gst_vaapi_surface_proxy_set_timestamp(proxy, g_value_get_uint64(value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
case PROP_SURFACE:
g_value_set_pointer(value, gst_vaapi_surface_proxy_get_surface(proxy));
break;
+ case PROP_TIMESTAMP:
+ g_value_set_uint64(value, gst_vaapi_surface_proxy_get_timestamp(proxy));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
{
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
+ g_type_class_add_private(klass, sizeof(GstVaapiSurfaceProxyPrivate));
+
object_class->finalize = gst_vaapi_surface_proxy_finalize;
object_class->set_property = gst_vaapi_surface_proxy_set_property;
object_class->get_property = gst_vaapi_surface_proxy_get_property;
"Surface",
"The surface stored in the proxy",
G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class,
+ PROP_TIMESTAMP,
+ g_param_spec_uint64("timestamp",
+ "Timestamp",
+ "The presentation time of the surface",
+ 0, G_MAXUINT64, GST_CLOCK_TIME_NONE,
+ G_PARAM_READWRITE));
}
static void
gst_vaapi_surface_proxy_init(GstVaapiSurfaceProxy *proxy)
-{
- proxy->context = NULL;
- proxy->surface = NULL;
+{
+ GstVaapiSurfaceProxyPrivate *priv;
+
+ priv = GST_VAAPI_SURFACE_PROXY_GET_PRIVATE(proxy);
+ proxy->priv = priv;
+ priv->context = NULL;
+ priv->surface = NULL;
+ priv->timestamp = GST_CLOCK_TIME_NONE;
}
/**
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), NULL);
return g_object_new(GST_VAAPI_TYPE_SURFACE_PROXY,
- "context", context,
- "surface", surface,
+ "context", context,
+ "surface", surface,
NULL);
}
{
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
- return proxy->context;
+ return proxy->priv->context;
}
/**
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
g_return_if_fail(GST_VAAPI_IS_CONTEXT(context));
- if (proxy->context) {
- g_object_unref(proxy->context);
- proxy->context = NULL;
+ if (proxy->priv->context) {
+ g_object_unref(proxy->priv->context);
+ proxy->priv->context = NULL;
}
if (context)
- proxy->context = g_object_ref(context);
+ proxy->priv->context = g_object_ref(context);
}
/**
{
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
- return proxy->surface;
+ return proxy->priv->surface;
}
/**
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
g_return_if_fail(GST_VAAPI_IS_SURFACE(surface));
- if (proxy->surface) {
- g_object_unref(proxy->surface);
- proxy->surface = NULL;
+ if (proxy->priv->surface) {
+ g_object_unref(proxy->priv->surface);
+ proxy->priv->surface = NULL;
}
if (surface)
- proxy->surface = g_object_ref(surface);
+ proxy->priv->surface = g_object_ref(surface);
+}
+
+/**
+ * gst_vaapi_surface_proxy_get_timestamp:
+ * @proxy: a #GstVaapiSurfaceProxy
+ *
+ * Returns the presentation timestamp of the #GstVaapiSurface held by @proxy.
+ *
+ * Return value: the presentation timestamp of the surface, or
+ * %GST_CLOCK_TIME_NONE is none was set
+ */
+GstClockTime
+gst_vaapi_surface_proxy_get_timestamp(GstVaapiSurfaceProxy *proxy)
+{
+ g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), GST_CLOCK_TIME_NONE);
+
+ return proxy->priv->timestamp;
+}
+
+/**
+ * gst_vaapi_surface_proxy_set_timestamp:
+ * @proxy: a #GstVaapiSurfaceProxy
+ * @timestamp: the new presentation timestamp as a #GstClockTime
+ *
+ * Sets the presentation timestamp of the @proxy surface to @timestamp.
+ */
+void
+gst_vaapi_surface_proxy_set_timestamp(
+ GstVaapiSurfaceProxy *proxy,
+ GstClockTime timestamp
+)
+{
+ g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
+
+ proxy->priv->timestamp = timestamp;
}
GST_VAAPI_TYPE_SURFACE_PROXY, \
GstVaapiSurfaceProxyClass))
+/**
+ * GST_VAAPI_SURFACE_PROXY_SURFACE:
+ * @surface: a #GstVaapiSurfaceProxy
+ *
+ * Macro that evaluates to the #GstVaapiSurface of @surface.
+ */
+#define GST_VAAPI_SURFACE_PROXY_SURFACE(surface) \
+ gst_vaapi_surface_proxy_get_surface(surface)
+
+/**
+ * GST_VAAPI_SURFACE_PROXY_TIMESTAMP:
+ * @surface: a #GstVaapiSurfaceProxy
+ *
+ * Macro that evaluates to the @surface timestamp, or
+ * %GST_CLOCK_TIME_NONE if none was set.
+ */
+#define GST_VAAPI_SURFACE_PROXY_TIMESTAMP(surface) \
+ gst_vaapi_surface_proxy_get_timestamp(surface)
+
typedef struct _GstVaapiSurfaceProxy GstVaapiSurfaceProxy;
+typedef struct _GstVaapiSurfaceProxyPrivate GstVaapiSurfaceProxyPrivate;
typedef struct _GstVaapiSurfaceProxyClass GstVaapiSurfaceProxyClass;
/**
/*< private >*/
GObject parent_instance;
- GstVaapiContext *context;
- GstVaapiSurface *surface;
+ GstVaapiSurfaceProxyPrivate *priv;
};
/**
GstVaapiSurface *surface
);
+GstClockTime
+gst_vaapi_surface_proxy_get_timestamp(GstVaapiSurfaceProxy *proxy);
+
+void
+gst_vaapi_surface_proxy_set_timestamp(
+ GstVaapiSurfaceProxy *proxy,
+ GstClockTime timestamp
+);
+
G_END_DECLS
#endif /* GST_VAAPI_SURFACE_PROXY_H */