summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/vdpau/gstvdp.c61
-rw-r--r--sys/vdpau/gstvdpdevice.c12
-rw-r--r--sys/vdpau/gstvdpdevice.h8
-rw-r--r--sys/vdpau/gstvdputils.c26
-rw-r--r--sys/vdpau/gstvdputils.h3
-rw-r--r--sys/vdpau/gstvdpvideobuffer.c78
-rw-r--r--sys/vdpau/gstvdpvideobuffer.h2
-rw-r--r--sys/vdpau/gstvdpvideosrcpad.c8
-rw-r--r--sys/vdpau/gstvdpvideosrcpad.h2
9 files changed, 111 insertions, 89 deletions
diff --git a/sys/vdpau/gstvdp.c b/sys/vdpau/gstvdp.c
index 5c127935b..2324fe60d 100644
--- a/sys/vdpau/gstvdp.c
+++ b/sys/vdpau/gstvdp.c
@@ -1,31 +1,44 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
+/*
+ * GStreamer
+ * Copyright (C) 2009 Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
#include <gst/gst.h>
-#include "gstvdpmpegdec.h"
-#include "gstvdpvideopostprocess.h"
-#include "gstvdpsink.h"
+#include "gstvdpdevice.h"
+#include "gstvdpvideobuffer.h"
+#include "gstvdpvideosrcpad.h"
+#include "gstvdpoutputbuffer.h"
+#include "gstvdpoutputsrcpad.h"
+
+#include "gstvdp.h"
-static gboolean
-vdpau_init (GstPlugin * vdpau_plugin)
+GST_DEBUG_CATEGORY (gst_vdp_debug);
+
+void
+gst_vdp_init ()
{
- /* Before giving these elements a rank again, make sure they pass at
- * least the generic/states test when there's no device available */
- gst_element_register (vdpau_plugin, "vdpaumpegdec",
- GST_RANK_NONE, GST_TYPE_VDP_MPEG_DEC);
- gst_element_register (vdpau_plugin, "vdpauvideopostprocess",
- GST_RANK_NONE, GST_TYPE_VDP_VIDEO_POST_PROCESS);
- gst_element_register (vdpau_plugin, "vdpausink",
- GST_RANK_NONE, GST_TYPE_VDP_SINK);
+ /* do this so debug categories get created */
+ gst_vdp_device_get_type ();
+ gst_vdp_output_buffer_get_type ();
+ gst_vdp_video_buffer_get_type ();
+ gst_vdp_video_src_pad_get_type ();
+ gst_vdp_output_src_pad_get_type ();
- return TRUE;
+ GST_DEBUG_CATEGORY_INIT (gst_vdp_debug, "vdp", 0, "GstVdp debug category");
}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "vdpau",
- "Various elements utilizing VDPAU",
- vdpau_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")
diff --git a/sys/vdpau/gstvdpdevice.c b/sys/vdpau/gstvdpdevice.c
index 79e14e74b..a41be6bfb 100644
--- a/sys/vdpau/gstvdpdevice.c
+++ b/sys/vdpau/gstvdpdevice.c
@@ -18,13 +18,14 @@
* Boston, MA 02111-1307, USA.
*/
-#include <gst/gst.h>
-
#include "gstvdpdevice.h"
GST_DEBUG_CATEGORY_STATIC (gst_vdp_device_debug);
#define GST_CAT_DEFAULT gst_vdp_device_debug
+#define DEBUG_INIT(bla) \
+GST_DEBUG_CATEGORY_INIT (gst_vdp_device_debug, "vdpdevice", 0, "VDPAU device object");
+
enum
{
PROP_0,
@@ -33,7 +34,8 @@ enum
-G_DEFINE_TYPE (GstVdpDevice, gst_vdp_device, G_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_CODE (GstVdpDevice, gst_vdp_device, G_TYPE_OBJECT,
+ DEBUG_INIT ());
static void
gst_vdp_device_init (GstVdpDevice * device)
@@ -116,6 +118,8 @@ gst_vdp_device_constructed (GObject * object)
&device->vdp_output_surface_get_bits_native},
{VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11,
&device->vdp_presentation_queue_target_create_x11},
+ {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY,
+ &device->vdp_presentation_queue_target_destroy},
{VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE,
&device->vdp_presentation_queue_create},
{VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY,
@@ -290,8 +294,6 @@ gst_vdp_get_device (const gchar * display_name)
GstVdpDevice *device;
if (g_once_init_enter (&once)) {
- GST_DEBUG_CATEGORY_INIT (gst_vdp_device_debug, "vdpaudevice",
- 0, "vdpaudevice");
device_cache.hash_table =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
device_cache.mutex = g_mutex_new ();
diff --git a/sys/vdpau/gstvdpdevice.h b/sys/vdpau/gstvdpdevice.h
index d6f1f9c6f..df1367524 100644
--- a/sys/vdpau/gstvdpdevice.h
+++ b/sys/vdpau/gstvdpdevice.h
@@ -25,7 +25,7 @@
#include <vdpau/vdpau.h>
#include <vdpau/vdpau_x11.h>
-#include <glib-object.h>
+#include <gst/gst.h>
G_BEGIN_DECLS
@@ -83,7 +83,9 @@ struct _GstVdpDevice
VdpOutputSurfaceQueryCapabilities *vdp_output_surface_query_capabilities;
VdpOutputSurfaceGetBitsNative *vdp_output_surface_get_bits_native;
- VdpPresentationQueueTargetCreateX11 *vdp_presentation_queue_target_create_x11;
+ VdpPresentationQueueTargetCreateX11 *vdp_presentation_queue_target_create_x11;
+ VdpPresentationQueueTargetDestroy *vdp_presentation_queue_target_destroy;
+
VdpPresentationQueueCreate *vdp_presentation_queue_create;
VdpPresentationQueueDestroy *vdp_presentation_queue_destroy;
VdpPresentationQueueDisplay *vdp_presentation_queue_display;
@@ -92,7 +94,7 @@ struct _GstVdpDevice
VdpPresentationQueueQuerySurfaceStatus *vdp_presentation_queue_query_surface_status;
};
-GType gst_vdp_device_get_type (void) G_GNUC_CONST;
+GType gst_vdp_device_get_type (void);
GstVdpDevice *gst_vdp_get_device (const gchar *display_name);
diff --git a/sys/vdpau/gstvdputils.c b/sys/vdpau/gstvdputils.c
index 1b2de3b42..bb3f50e67 100644
--- a/sys/vdpau/gstvdputils.c
+++ b/sys/vdpau/gstvdputils.c
@@ -40,32 +40,6 @@ gst_vdp_video_remove_pixel_aspect_ratio (GstStructure * structure)
}
GstCaps *
-gst_vdp_yuv_to_output_caps (GstCaps * caps)
-{
- GstCaps *result;
- gint i;
-
- result = gst_caps_copy (caps);
- for (i = 0; i < gst_caps_get_size (caps); i++) {
- GstStructure *structure, *rgb_structure;
-
- structure = gst_caps_get_structure (result, i);
- rgb_structure = gst_structure_copy (structure);
-
- gst_structure_set_name (structure, "video/x-vdpau-output");
- gst_structure_remove_field (structure, "format");
- gst_vdp_video_remove_pixel_aspect_ratio (structure);
-
- gst_structure_set_name (rgb_structure, "video/x-raw-rgb");
- gst_structure_remove_field (rgb_structure, "format");
- gst_vdp_video_remove_pixel_aspect_ratio (rgb_structure);
- gst_caps_append_structure (result, rgb_structure);
- }
-
- return result;
-}
-
-GstCaps *
gst_vdp_video_to_output_caps (GstCaps * caps)
{
GstCaps *result;
diff --git a/sys/vdpau/gstvdputils.h b/sys/vdpau/gstvdputils.h
index f5fc054cf..7df4cd2a2 100644
--- a/sys/vdpau/gstvdputils.h
+++ b/sys/vdpau/gstvdputils.h
@@ -24,7 +24,6 @@
#include <gst/gst.h>
#include "gstvdpdevice.h"
-GstCaps *gst_vdp_video_to_output_caps (GstCaps * caps);
-GstCaps *gst_vdp_yuv_to_output_caps (GstCaps *caps);
+GstCaps *gst_vdp_video_to_output_caps (GstCaps *caps);
#endif /* _GST_VDP_UTILS_H_ */
diff --git a/sys/vdpau/gstvdpvideobuffer.c b/sys/vdpau/gstvdpvideobuffer.c
index 9a8666e92..16484f4f5 100644
--- a/sys/vdpau/gstvdpvideobuffer.c
+++ b/sys/vdpau/gstvdpvideobuffer.c
@@ -24,6 +24,12 @@
#include "gstvdpvideobuffer.h"
+GST_DEBUG_CATEGORY_STATIC (gst_vdp_video_buffer_debug);
+#define GST_CAT_DEFAULT gst_vdp_video_buffer_debug
+
+#define DEBUG_INIT(bla) \
+GST_DEBUG_CATEGORY_INIT (gst_vdp_video_buffer_debug, "vdpvideobuffer", 0, "VDPAU video buffer");
+
GstVdpVideoBuffer *
gst_vdp_video_buffer_new (GstVdpDevice * device, VdpChromaType chroma_type,
gint width, gint height)
@@ -293,41 +299,63 @@ gst_vdp_video_buffer_calculate_size (guint32 fourcc, gint width, gint height,
return TRUE;
}
-gboolean
-gst_vdp_video_buffer_parse_yuv_caps (GstCaps * yuv_caps,
- VdpChromaType * chroma_type, gint * width, gint * height)
+GstCaps *
+gst_vdp_video_buffer_parse_yuv_caps (GstCaps * yuv_caps)
{
- GstStructure *structure;
- guint32 fourcc;
+
+ GstCaps *video_caps;
gint i;
- g_return_val_if_fail (GST_IS_CAPS (yuv_caps), FALSE);
- g_return_val_if_fail (!gst_caps_is_empty (yuv_caps), FALSE);
- g_return_val_if_fail (chroma_type, FALSE);
- g_return_val_if_fail (width, FALSE);
- g_return_val_if_fail (height, FALSE);
+ g_return_val_if_fail (GST_IS_CAPS (yuv_caps), NULL);
- structure = gst_caps_get_structure (yuv_caps, 0);
- if (!gst_structure_has_name (structure, "video/x-raw-yuv"))
- return FALSE;
+ video_caps = gst_caps_copy (yuv_caps);
+ for (i = 0; i < gst_caps_get_size (video_caps); i++) {
+ GstStructure *structure;
+ guint32 fourcc;
+ VdpChromaType chroma_type;
- if (!gst_structure_get_fourcc (structure, "format", &fourcc) ||
- !gst_structure_get_int (structure, "width", width) ||
- !gst_structure_get_int (structure, "height", height))
- return FALSE;
+ structure = gst_caps_get_structure (video_caps, i);
+ if (!gst_structure_has_name (structure, "video/x-raw-yuv"))
+ goto not_yuv_error;
- *chroma_type = -1;
- for (i = 0; i < G_N_ELEMENTS (formats); i++) {
- if (formats[i].fourcc == fourcc) {
- *chroma_type = formats[i].chroma_type;
- break;
+ if (!gst_structure_get_fourcc (structure, "format", &fourcc))
+ goto no_format_error;
+
+ chroma_type = -1;
+ for (i = 0; i < G_N_ELEMENTS (formats); i++) {
+ if (formats[i].fourcc == fourcc) {
+ chroma_type = formats[i].chroma_type;
+ break;
+ }
}
+
+ if (chroma_type == -1)
+ goto no_chroma_error;
+
+ /* now we transform the caps */
+ gst_structure_set_name (structure, "video/x-vdpau-video");
+ gst_structure_remove_field (structure, "format");
+ gst_structure_set (structure, "chroma-type", G_TYPE_INT, chroma_type, NULL);
}
- if (*chroma_type == -1)
- return FALSE;
+ return video_caps;
+
+error:
+ gst_caps_unref (video_caps);
+ return NULL;
+
+not_yuv_error:
+ GST_WARNING ("The caps weren't of type \"video/x-raw-yuv\"");
+ goto error;
+
+no_format_error:
+ GST_WARNING ("The caps didn't have a \"fourcc\" field");
+ goto error;
+
+no_chroma_error:
+ GST_WARNING ("The caps had an invalid \"fourcc\" field");
+ goto error;
- return TRUE;
}
gboolean
diff --git a/sys/vdpau/gstvdpvideobuffer.h b/sys/vdpau/gstvdpvideobuffer.h
index d99237bdc..bef8642f5 100644
--- a/sys/vdpau/gstvdpvideobuffer.h
+++ b/sys/vdpau/gstvdpvideobuffer.h
@@ -99,7 +99,7 @@ GstCaps *gst_vdp_video_buffer_get_caps (gboolean filter, VdpChromaType chroma_ty
GstCaps *gst_vdp_video_buffer_get_allowed_yuv_caps (GstVdpDevice * device);
GstCaps *gst_vdp_video_buffer_get_allowed_video_caps (GstVdpDevice * device);
-gboolean gst_vdp_video_buffer_parse_yuv_caps (GstCaps *yuv_caps, VdpChromaType *chroma_type, gint *width, gint *height);
+GstCaps *gst_vdp_video_buffer_parse_yuv_caps (GstCaps *yuv_caps);
gboolean gst_vdp_video_buffer_calculate_size (guint32 fourcc, gint width, gint height, guint *size);
gboolean gst_vdp_video_buffer_download (GstVdpVideoBuffer *inbuf, GstBuffer *outbuf, guint32 fourcc, gint width, gint height);
diff --git a/sys/vdpau/gstvdpvideosrcpad.c b/sys/vdpau/gstvdpvideosrcpad.c
index abf64fac0..48c10f2f8 100644
--- a/sys/vdpau/gstvdpvideosrcpad.c
+++ b/sys/vdpau/gstvdpvideosrcpad.c
@@ -113,9 +113,13 @@ gst_vdp_video_src_pad_push (GstVdpVideoSrcPad * vdp_pad,
GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS);
gst_buffer_unref (GST_BUFFER_CAST (video_buf));
} else
- out_buf = GST_BUFFER (video_buf);
+ out_buf = GST_BUFFER_CAST (video_buf);
- gst_buffer_set_caps (out_buf, GST_PAD_CAPS (vdp_pad));
+ /* FIXME: can't use gst_buffer_set_caps since we may have additional
+ * references to the bufffer. We can't either use
+ * gst_buffer_make_metadata_writable since that creates a regular buffer and
+ * not a GstVdpVideoBuffer */
+ gst_caps_replace (&(GST_BUFFER_CAPS (out_buf)), GST_PAD_CAPS (vdp_pad));
return gst_pad_push (pad, out_buf);
}
diff --git a/sys/vdpau/gstvdpvideosrcpad.h b/sys/vdpau/gstvdpvideosrcpad.h
index 4d7c2c2f0..300c5e19f 100644
--- a/sys/vdpau/gstvdpvideosrcpad.h
+++ b/sys/vdpau/gstvdpvideosrcpad.h
@@ -49,7 +49,7 @@ GstCaps *gst_vdp_video_src_pad_get_template_caps ();
GstVdpVideoSrcPad * gst_vdp_video_src_pad_new (GstPadTemplate * templ, const gchar * name);
-GType gst_vdp_video_src_pad_get_type (void) G_GNUC_CONST;
+GType gst_vdp_video_src_pad_get_type (void);
G_END_DECLS