plugins: cope with new GstVaapiMiniObject objects.

This commit is contained in:
Gwenole Beauchesne 2013-05-06 14:43:38 +02:00
parent da403b62d0
commit 9535bb9950
11 changed files with 77 additions and 93 deletions

View file

@ -130,17 +130,17 @@ G_DEFINE_TYPE_WITH_CODE(
static gboolean
gst_vaapidecode_update_src_caps(GstVaapiDecode *decode,
GstVideoCodecState *ref_state);
const GstVideoCodecState *ref_state);
static void
gst_vaapi_decoder_notify_caps(GObject *obj, GParamSpec *pspec, void *user_data)
gst_vaapi_decoder_state_changed(GstVaapiDecoder *decoder,
const GstVideoCodecState *codec_state, gpointer user_data)
{
GstVaapiDecode * const decode = GST_VAAPIDECODE(user_data);
g_assert(decode->decoder == GST_VAAPI_DECODER(obj));
g_assert(decode->decoder == decoder);
gst_vaapidecode_update_src_caps(decode,
gst_vaapi_decoder_get_codec_state(decode->decoder));
gst_vaapidecode_update_src_caps(decode, codec_state);
}
static inline gboolean
@ -152,7 +152,7 @@ gst_vaapidecode_update_sink_caps(GstVaapiDecode *decode, GstCaps *caps)
static gboolean
gst_vaapidecode_update_src_caps(GstVaapiDecode *decode,
GstVideoCodecState *ref_state)
const GstVideoCodecState *ref_state)
{
GstVideoDecoder * const vdec = GST_VIDEO_DECODER(decode);
GstVideoCodecState *state;
@ -160,7 +160,8 @@ gst_vaapidecode_update_src_caps(GstVaapiDecode *decode,
state = gst_video_decoder_set_output_state(vdec,
GST_VIDEO_INFO_FORMAT(&ref_state->info),
ref_state->info.width, ref_state->info.height, ref_state);
ref_state->info.width, ref_state->info.height,
(GstVideoCodecState *)ref_state);
if (!state)
return FALSE;
@ -553,12 +554,8 @@ gst_vaapidecode_create(GstVaapiDecode *decode, GstCaps *caps)
if (!decode->decoder)
return FALSE;
g_signal_connect(
G_OBJECT(decode->decoder),
"notify::caps",
G_CALLBACK(gst_vaapi_decoder_notify_caps),
decode
);
gst_vaapi_decoder_set_codec_state_changed_func(decode->decoder,
gst_vaapi_decoder_state_changed, decode);
decode->decoder_caps = gst_caps_ref(caps);
return gst_pad_start_task(decode->srcpad,
@ -569,7 +566,7 @@ static void
gst_vaapidecode_destroy(GstVaapiDecode *decode)
{
gst_pad_stop_task(decode->srcpad);
g_clear_object(&decode->decoder);
gst_vaapi_decoder_replace(&decode->decoder, NULL);
gst_caps_replace(&decode->decoder_caps, NULL);
gst_vaapidecode_release(decode);
}
@ -607,7 +604,7 @@ gst_vaapidecode_finalize(GObject *object)
gst_caps_replace(&decode->srcpad_caps, NULL);
gst_caps_replace(&decode->allowed_caps, NULL);
g_clear_object(&decode->display);
gst_vaapi_display_replace(&decode->display, NULL);
g_cond_clear(&decode->decoder_ready);
g_mutex_clear(&decode->decoder_mutex);
@ -629,7 +626,8 @@ gst_vaapidecode_open(GstVideoDecoder *vdec)
existing (cached) VA display */
decode->display = NULL;
success = gst_vaapidecode_ensure_display(decode);
g_clear_object(&old_display);
if (old_display)
gst_vaapi_display_unref(old_display);
return success;
}
@ -639,7 +637,7 @@ gst_vaapidecode_close(GstVideoDecoder *vdec)
GstVaapiDecode * const decode = GST_VAAPIDECODE(vdec);
gst_vaapidecode_destroy(decode);
g_clear_object(&decode->display);
gst_vaapi_display_replace(&decode->display, NULL);
return TRUE;
}

View file

@ -196,8 +196,8 @@ gst_vaapidownload_destroy(GstVaapiDownload *download)
download->allowed_caps = NULL;
}
g_clear_object(&download->images);
g_clear_object(&download->display);
gst_vaapi_video_pool_replace(&download->images, NULL);
gst_vaapi_display_replace(&download->display, NULL);
}
static void
@ -289,8 +289,7 @@ gst_vaapidownload_stop(GstBaseTransform *trans)
{
GstVaapiDownload * const download = GST_VAAPIDOWNLOAD(trans);
g_clear_object(&download->display);
gst_vaapi_display_replace(&download->display, NULL);
return TRUE;
}
@ -304,7 +303,7 @@ get_surface_format(GstVaapiSurface *surface)
image = gst_vaapi_surface_derive_image(surface);
if (image) {
format = gst_vaapi_image_get_format(image);
g_object_unref(image);
gst_vaapi_object_unref(image);
}
return format;
}
@ -499,7 +498,7 @@ gst_vaapidownload_ensure_image_pool(GstVaapiDownload *download, GstCaps *caps)
download->image_format = format;
download->image_width = width;
download->image_height = height;
g_clear_object(&download->images);
gst_vaapi_video_pool_replace(&download->images, NULL);
download->images = gst_vaapi_image_pool_new(download->display, caps);
if (!download->images)
return FALSE;

View file

@ -127,7 +127,7 @@ gst_vaapi_ensure_display(
display_type = m->type;
break;
}
g_object_unref(display);
gst_vaapi_display_unref(display);
display = NULL;
}
@ -154,8 +154,8 @@ gst_vaapi_set_display(
dpy = gst_vaapi_display_new_with_display(g_value_get_pointer(value));
}
else if (!strcmp(type, "gst-vaapi-display")) {
g_return_if_fail(G_VALUE_HOLDS_OBJECT(value));
dpy = g_value_dup_object(value);
g_return_if_fail(G_VALUE_HOLDS_POINTER(value));
dpy = gst_vaapi_display_ref(g_value_get_pointer(value));
}
#if USE_DRM
else if (!strcmp(type, "drm-device")) {
@ -205,9 +205,8 @@ gst_vaapi_set_display(
#endif
if (dpy) {
if (*display)
g_object_unref(*display);
*display = dpy;
gst_vaapi_display_replace(display, dpy);
gst_vaapi_display_unref(dpy);
}
}
@ -237,7 +236,7 @@ gst_vaapi_reply_to_query(GstQuery *query, GstVaapiDisplay *display)
res = TRUE;
if (!strcmp(type, "gst-vaapi-display")) {
gst_video_context_query_set_object(query, type, G_OBJECT(display));
gst_video_context_query_set_pointer(query, type, display);
}
else if (!strcmp(type, "vaapi-display")) {
VADisplay vadpy = gst_vaapi_display_get_display(display);

View file

@ -207,7 +207,7 @@ gst_vaapipostproc_destroy(GstVaapiPostproc *postproc)
{
gst_caps_replace(&postproc->postproc_caps, NULL);
g_clear_object(&postproc->display);
gst_vaapi_display_replace(&postproc->display, NULL);
}
static gboolean
@ -232,7 +232,7 @@ gst_vaapipostproc_start(GstVaapiPostproc *postproc)
static gboolean
gst_vaapipostproc_stop(GstVaapiPostproc *postproc)
{
g_clear_object(&postproc->display);
gst_vaapi_display_replace(&postproc->display, NULL);
return TRUE;
}

View file

@ -253,8 +253,8 @@ static void
gst_vaapisink_destroy(GstVaapiSink *sink)
{
gst_buffer_replace(&sink->video_buffer, NULL);
g_clear_object(&sink->texture);
g_clear_object(&sink->display);
gst_vaapi_texture_replace(&sink->texture, NULL);
gst_vaapi_display_replace(&sink->display, NULL);
g_clear_object(&sink->uploader);
gst_caps_replace(&sink->caps, NULL);
@ -540,7 +540,7 @@ gst_vaapisink_ensure_window_xid(GstVaapiSink *sink, guintptr window_id)
gst_vaapi_window_x11_get_xid(GST_VAAPI_WINDOW_X11(sink->window)) == xid)
return TRUE;
g_clear_object(&sink->window);
gst_vaapi_window_replace(&sink->window, NULL);
switch (sink->display_type) {
#if USE_GLX
@ -685,8 +685,8 @@ gst_vaapisink_stop(GstBaseSink *base_sink)
#if GST_CHECK_VERSION(1,0,0)
g_clear_object(&sink->video_buffer_pool);
#endif
g_clear_object(&sink->window);
g_clear_object(&sink->display);
gst_vaapi_window_replace(&sink->window, NULL);
gst_vaapi_display_replace(&sink->display, NULL);
g_clear_object(&sink->uploader);
return TRUE;
@ -982,10 +982,9 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
}
#endif
if (sink->display != gst_vaapi_video_meta_get_display(meta)) {
g_clear_object(&sink->display);
sink->display = g_object_ref(gst_vaapi_video_meta_get_display(meta));
}
if (sink->display != gst_vaapi_video_meta_get_display(meta))
gst_vaapi_display_replace(&sink->display,
gst_vaapi_video_meta_get_display(meta));
if (!sink->window)
goto error;

View file

@ -174,7 +174,7 @@ static void
gst_vaapiupload_destroy(GstVaapiUpload *upload)
{
g_clear_object(&upload->uploader);
g_clear_object(&upload->display);
gst_vaapi_display_replace(&upload->display, NULL);
}
static void
@ -279,8 +279,7 @@ gst_vaapiupload_stop(GstBaseTransform *trans)
{
GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
g_clear_object(&upload->display);
gst_vaapi_display_replace(&upload->display, NULL);
return TRUE;
}

View file

@ -73,9 +73,9 @@ gst_vaapi_uploader_destroy(GstVaapiUploader *uploader)
gst_caps_replace(&priv->image_caps, NULL);
gst_caps_replace(&priv->allowed_caps, NULL);
g_clear_object(&priv->images);
g_clear_object(&priv->surfaces);
g_clear_object(&priv->display);
gst_vaapi_video_pool_replace(&priv->images, NULL);
gst_vaapi_video_pool_replace(&priv->surfaces, NULL);
gst_vaapi_display_replace(&priv->display, NULL);
}
static gboolean
@ -83,12 +83,7 @@ ensure_display(GstVaapiUploader *uploader, GstVaapiDisplay *display)
{
GstVaapiUploaderPrivate * const priv = uploader->priv;
if (priv->display == display)
return TRUE;
g_clear_object(&priv->display);
if (display)
priv->display = g_object_ref(display);
gst_vaapi_display_replace(&priv->display, display);
return TRUE;
}
@ -156,7 +151,7 @@ ensure_allowed_caps(GstVaapiUploader *uploader)
continue;
if (ensure_image(image) && gst_vaapi_surface_put_image(surface, image))
gst_caps_append_structure(out_caps, gst_structure_copy(structure));
gst_object_unref(image);
gst_vaapi_object_unref(image);
}
gst_caps_replace(&priv->allowed_caps, out_caps);
@ -167,7 +162,7 @@ end:
if (image_caps)
gst_caps_unref(image_caps);
if (surface)
gst_object_unref(surface);
gst_vaapi_object_unref(surface);
return success;
}
@ -184,7 +179,7 @@ ensure_image_pool(GstVaapiUploader *uploader, GstCaps *caps)
if (width != priv->image_width || height != priv->image_height) {
priv->image_width = width;
priv->image_height = height;
g_clear_object(&priv->images);
gst_vaapi_video_pool_replace(&priv->images, NULL);
priv->images = gst_vaapi_image_pool_new(priv->display, caps);
if (!priv->images)
return FALSE;
@ -206,7 +201,7 @@ ensure_surface_pool(GstVaapiUploader *uploader, GstCaps *caps)
if (width != priv->surface_width || height != priv->surface_height) {
priv->surface_width = width;
priv->surface_height = height;
g_clear_object(&priv->surfaces);
gst_vaapi_video_pool_replace(&priv->surfaces, NULL);
priv->surfaces = gst_vaapi_surface_pool_new(priv->display, caps);
if (!priv->surfaces)
return FALSE;
@ -230,7 +225,7 @@ gst_vaapi_uploader_set_property(GObject *object, guint prop_id,
switch (prop_id) {
case PROP_DISPLAY:
ensure_display(uploader, g_value_get_object(value));
ensure_display(uploader, g_value_get_pointer(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@ -246,7 +241,7 @@ gst_vaapi_uploader_get_property(GObject *object, guint prop_id,
switch (prop_id) {
case PROP_DISPLAY:
g_value_set_object(value, uploader->priv->display);
g_value_set_pointer(value, uploader->priv->display);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@ -271,11 +266,10 @@ gst_vaapi_uploader_class_init(GstVaapiUploaderClass *klass)
g_object_class_install_property(
object_class,
PROP_DISPLAY,
g_param_spec_object(
g_param_spec_pointer(
"display",
"Display",
"The GstVaapiDisplay this object is bound to",
GST_VAAPI_TYPE_DISPLAY,
G_PARAM_READWRITE));
}

View file

@ -56,7 +56,7 @@ gst_vaapi_video_buffer_pool_finalize(GObject *object)
G_OBJECT_CLASS(gst_vaapi_video_buffer_pool_parent_class)->finalize(object);
g_clear_object(&priv->display);
gst_vaapi_display_replace(&priv->display, NULL);
g_clear_object(&priv->allocator);
}
@ -69,7 +69,7 @@ gst_vaapi_video_buffer_pool_set_property(GObject *object, guint prop_id,
switch (prop_id) {
case PROP_DISPLAY:
priv->display = g_object_ref(g_value_get_object(value));
priv->display = gst_vaapi_display_ref(g_value_get_pointer(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@ -86,7 +86,7 @@ gst_vaapi_video_buffer_pool_get_property(GObject *object, guint prop_id,
switch (prop_id) {
case PROP_DISPLAY:
g_value_set_object(value, priv->display);
g_value_set_pointer(value, priv->display);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@ -265,10 +265,9 @@ gst_vaapi_video_buffer_pool_class_init(GstVaapiVideoBufferPoolClass *klass)
g_object_class_install_property
(object_class,
PROP_DISPLAY,
g_param_spec_object("display",
g_param_spec_pointer("display",
"Display",
"The GstVaapiDisplay to use for this video pool",
GST_VAAPI_TYPE_DISPLAY,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
}

View file

@ -64,7 +64,7 @@ gst_vaapi_video_converter_glx_dispose(GObject *object)
GstVaapiVideoConverterGLXPrivate * const priv =
GST_VAAPI_VIDEO_CONVERTER_GLX(object)->priv;
g_clear_object(&priv->texture);
gst_vaapi_texture_replace(&priv->texture, NULL);
G_OBJECT_CLASS(gst_vaapi_video_converter_glx_parent_class)->dispose(object);
}
@ -144,7 +144,7 @@ gst_vaapi_video_converter_glx_upload(GstSurfaceConverter *self,
if (old_dpy != new_dpy) {
const guint texture = gst_vaapi_texture_get_id(priv->texture);
g_clear_object(&priv->texture);
gst_vaapi_texture_replace(&priv->texture, NULL);
priv->texture = gst_vaapi_texture_new_with_texture(new_dpy,
texture, GL_TEXTURE_2D, GL_BGRA);
}

View file

@ -217,8 +217,8 @@ gst_vaapi_video_memory_new(GstAllocator *base_allocator,
static void
gst_vaapi_video_memory_free(GstVaapiVideoMemory *mem)
{
g_clear_object(&mem->surface);
g_clear_object(&mem->image);
gst_vaapi_object_replace(&mem->surface, NULL);
gst_vaapi_object_replace(&mem->image, NULL);
gst_vaapi_video_meta_unref(mem->meta);
g_slice_free(GstVaapiVideoMemory, mem);
}
@ -398,8 +398,8 @@ gst_vaapi_video_allocator_new(GstVaapiDisplay *display, GstCaps *caps)
GST_VIDEO_INFO_FORMAT_STRING(&allocator->surface_info),
allocator->has_direct_rendering ? "yes" : "no");
} while (0);
g_clear_object(&surface);
g_clear_object(&image);
gst_vaapi_object_unref(surface);
gst_vaapi_object_unref(image);
}
allocator->image_info = *vip;
@ -419,7 +419,7 @@ gst_vaapi_video_allocator_new(GstVaapiDisplay *display, GstCaps *caps)
gst_video_info_update_from_image(&allocator->image_info, image);
gst_vaapi_image_unmap(image);
} while (0);
g_clear_object(&image);
gst_vaapi_object_unref(image);
}
return GST_ALLOCATOR_CAST(allocator);
}

View file

@ -48,26 +48,23 @@ struct _GstVaapiVideoMeta {
guint render_flags;
};
static void
static inline void
set_display(GstVaapiVideoMeta *meta, GstVaapiDisplay *display)
{
g_clear_object(&meta->display);
if (display)
meta->display = g_object_ref(display);
gst_vaapi_display_replace(&meta->display, display);
}
static inline void
set_image(GstVaapiVideoMeta *meta, GstVaapiImage *image)
{
meta->image = g_object_ref(image);
meta->image = gst_vaapi_object_ref(image);
set_display(meta, gst_vaapi_object_get_display(GST_VAAPI_OBJECT(image)));
}
static inline void
set_surface(GstVaapiVideoMeta *meta, GstVaapiSurface *surface)
{
meta->surface = g_object_ref(surface);
meta->surface = gst_vaapi_object_ref(surface);
set_display(meta, gst_vaapi_object_get_display(GST_VAAPI_OBJECT(surface)));
}
@ -77,10 +74,10 @@ gst_vaapi_video_meta_destroy_image(GstVaapiVideoMeta *meta)
if (meta->image) {
if (meta->image_pool)
gst_vaapi_video_pool_put_object(meta->image_pool, meta->image);
g_object_unref(meta->image);
gst_vaapi_object_unref(meta->image);
meta->image = NULL;
}
g_clear_object(&meta->image_pool);
gst_vaapi_video_pool_replace(&meta->image_pool, NULL);
}
static void
@ -91,10 +88,10 @@ gst_vaapi_video_meta_destroy_surface(GstVaapiVideoMeta *meta)
if (meta->surface) {
if (meta->surface_pool)
gst_vaapi_video_pool_put_object(meta->surface_pool, meta->surface);
g_object_unref(meta->surface);
gst_vaapi_object_unref(meta->surface);
meta->surface = NULL;
}
g_clear_object(&meta->surface_pool);
gst_vaapi_video_pool_replace(&meta->surface_pool, NULL);
}
#if !GST_CHECK_VERSION(1,0,0)
@ -120,7 +117,7 @@ gst_vaapi_video_meta_finalize(GstVaapiVideoMeta *meta)
{
gst_vaapi_video_meta_destroy_image(meta);
gst_vaapi_video_meta_destroy_surface(meta);
g_clear_object(&meta->display);
gst_vaapi_display_replace(&meta->display, NULL);
}
static void
@ -197,11 +194,11 @@ gst_vaapi_video_meta_copy(GstVaapiVideoMeta *meta)
return NULL;
copy->ref_count = 1;
copy->display = g_object_ref(meta->display);
copy->display = gst_vaapi_display_ref(meta->display);
copy->image_pool = NULL;
copy->image = meta->image ? g_object_ref(meta->image) : NULL;
copy->image = meta->image ? gst_vaapi_object_ref(meta->image) : NULL;
copy->surface_pool = NULL;
copy->surface = meta->surface ? g_object_ref(meta->surface) : NULL;
copy->surface = meta->surface ? gst_vaapi_object_ref(meta->surface) : NULL;
copy->proxy = meta->proxy ?
gst_vaapi_surface_proxy_ref(meta->proxy) : NULL;
copy->converter = meta->converter;
@ -447,7 +444,7 @@ gst_vaapi_video_meta_get_display(GstVaapiVideoMeta *meta)
*
* Retrieves the #GstVaapiImage bound to the @meta. The @meta owns
* the #GstVaapiImage so the caller is responsible for calling
* g_object_ref() when needed.
* gst_vaapi_object_ref() when needed.
*
* Return value: the #GstVaapiImage bound to the @meta, or %NULL if
* there is none
@ -507,7 +504,7 @@ gst_vaapi_video_meta_set_image_from_pool(GstVaapiVideoMeta *meta,
if (!image)
return FALSE;
set_image(meta, image);
meta->image_pool = g_object_ref(pool);
meta->image_pool = gst_vaapi_video_pool_ref(pool);
}
return TRUE;
}
@ -518,7 +515,7 @@ gst_vaapi_video_meta_set_image_from_pool(GstVaapiVideoMeta *meta,
*
* Retrieves the #GstVaapiSurface bound to the @meta. The @meta
* owns the #GstVaapiSurface so the caller is responsible for calling
* g_object_ref() when needed.
* gst_vaapi_object_ref() when needed.
*
* Return value: the #GstVaapiSurface bound to the @meta, or %NULL if
* there is none
@ -579,7 +576,7 @@ gst_vaapi_video_meta_set_surface_from_pool(GstVaapiVideoMeta *meta,
if (!surface)
return FALSE;
set_surface(meta, surface);
meta->surface_pool = g_object_ref(pool);
meta->surface_pool = gst_vaapi_video_pool_ref(pool);
}
return TRUE;
}
@ -590,7 +587,7 @@ gst_vaapi_video_meta_set_surface_from_pool(GstVaapiVideoMeta *meta,
*
* Retrieves the #GstVaapiSurfaceProxy bound to the @meta. The @meta
* owns the #GstVaapiSurfaceProxy so the caller is responsible for calling
* g_object_ref() when needed.
* gst_surface_proxy_ref() when needed.
*
* Return value: the #GstVaapiSurfaceProxy bound to the @meta, or
* %NULL if there is none