summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2009-09-22 09:37:55 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2009-09-22 09:37:55 +0200
commit102f895fb61f5d797f82aebb81ad0430fc6eb5eb (patch)
treeee7130ca1f6d1d2a707389a240e9e1743c6e913f
parentbc14e845a7ac477b6303f4455ad5aee04410c139 (diff)
Add VideoUtil.FormatToTemplateCaps() to generate pad template caps
-rw-r--r--gstreamer-sharp/VideoUtil.custom11
-rw-r--r--gstreamer-sharp/glue/Makefile.am3
-rw-r--r--gstreamer-sharp/glue/videoutil.c44
3 files changed, 57 insertions, 1 deletions
diff --git a/gstreamer-sharp/VideoUtil.custom b/gstreamer-sharp/VideoUtil.custom
index 3b93f7b..45ed281 100644
--- a/gstreamer-sharp/VideoUtil.custom
+++ b/gstreamer-sharp/VideoUtil.custom
@@ -22,3 +22,14 @@ public static Gst.Fourcc FormatToFourcc (Gst.Video.VideoFormat format) {
public static Gst.Video.VideoFormat FormatFromFourcc (Gst.Fourcc fourcc) {
return FormatFromFourcc (fourcc.Val);
}
+
+[DllImport ("gstreamersharpglue-0.10.dll") ]
+static extern IntPtr gstsharp_gst_videoutil_get_template_caps (Gst.Video.VideoFormat fmt);
+
+public static Gst.Caps FormatToTemplateCaps (Gst.Video.VideoFormat fmt) {
+ IntPtr raw_ret = gstsharp_gst_videoutil_get_template_caps (fmt);
+ if (raw_ret == IntPtr.Zero)
+ return null;
+
+ return (Gst.Caps) Gst.GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Caps), true);
+}
diff --git a/gstreamer-sharp/glue/Makefile.am b/gstreamer-sharp/glue/Makefile.am
index 48945b7..71212b1 100644
--- a/gstreamer-sharp/glue/Makefile.am
+++ b/gstreamer-sharp/glue/Makefile.am
@@ -20,7 +20,8 @@ libgstreamersharpglue_0_10_la_SOURCES = \
tunernorm.c \
adapter.c \
controller.c \
- controlsource.c
+ controlsource.c \
+ videoutil.c
nodist_libgstreamersharpglue_0_10_la_SOURCES = generated.c
diff --git a/gstreamer-sharp/glue/videoutil.c b/gstreamer-sharp/glue/videoutil.c
new file mode 100644
index 0000000..f377d76
--- /dev/null
+++ b/gstreamer-sharp/glue/videoutil.c
@@ -0,0 +1,44 @@
+#include <gst/gst.h>
+#include <gst/video/video.h>
+
+GstCaps *
+gstsharp_gst_videoutil_get_template_caps (GstVideoFormat fmt) {
+ if (gst_video_format_is_yuv (fmt)) {
+ guint32 fourcc = gst_video_format_to_fourcc (fmt);
+ GstCaps *caps;
+
+ if (fourcc == 0)
+ return NULL;
+
+ caps = gst_caps_from_string (GST_VIDEO_CAPS_YUV ("AYUV"));
+ gst_caps_set_simple (caps, fourcc, GST_TYPE_FOURCC, fourcc, NULL);
+ return caps;
+ } else {
+ switch (fmt) {
+ case GST_VIDEO_FORMAT_ABGR:
+ return gst_caps_from_string (GST_VIDEO_CAPS_ABGR);
+ case GST_VIDEO_FORMAT_ARGB:
+ return gst_caps_from_string (GST_VIDEO_CAPS_ARGB);
+ case GST_VIDEO_FORMAT_BGR:
+ return gst_caps_from_string (GST_VIDEO_CAPS_BGR);
+ case GST_VIDEO_FORMAT_BGRA:
+ return gst_caps_from_string (GST_VIDEO_CAPS_BGRA);
+ case GST_VIDEO_FORMAT_BGRx:
+ return gst_caps_from_string (GST_VIDEO_CAPS_BGRx);
+ case GST_VIDEO_FORMAT_RGB:
+ return gst_caps_from_string (GST_VIDEO_CAPS_RGB);
+ case GST_VIDEO_FORMAT_RGBA:
+ return gst_caps_from_string (GST_VIDEO_CAPS_RGBA);
+ case GST_VIDEO_FORMAT_RGBx:
+ return gst_caps_from_string (GST_VIDEO_CAPS_RGBx);
+ case GST_VIDEO_FORMAT_xBGR:
+ return gst_caps_from_string (GST_VIDEO_CAPS_xBGR);
+ case GST_VIDEO_FORMAT_xRGB:
+ return gst_caps_from_string (GST_VIDEO_CAPS_xRGB);
+ default:
+ return NULL;
+ }
+ }
+
+ return NULL;
+}