* <refsect2>
* <title>Example pipelines</title>
* |[
- * gst-launch ximagesrc ! video/x-raw-rgb,framerate=5/1 ! ffmpegcolorspace ! theoraenc ! oggmux ! filesink location=desktop.ogg
+ * gst-launch-1.0 ximagesrc ! video/x-raw,framerate=5/1 ! videoconvert ! theoraenc ! oggmux ! filesink location=desktop.ogg
* ]| Encodes your X display to an Ogg theora video at 5 frames per second.
* </refsect2>
*/
#include <gst/gst.h>
#include <gst/gst-i18n-plugin.h>
+#include <gst/video/video.h>
#include "gst/glib-compat-private.h"
static GstStaticPadTemplate t =
GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-raw-rgb, "
+ GST_STATIC_CAPS ("video/x-raw, "
"framerate = (fraction) [ 0, MAX ], "
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ], "
"pixel-aspect-ratio = (fraction) [ 0, MAX ]"));
#define gst_ximage_src_parent_class parent_class
G_DEFINE_TYPE (GstXImageSrc, gst_ximage_src, GST_TYPE_PUSH_SRC);
-static void gst_ximage_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
+static GstCaps *gst_ximage_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
static void gst_ximage_src_clear_bufpool (GstXImageSrc * ximagesrc);
/* Called when a buffer is returned from the pipeline */
GstXImageSrc *s = GST_XIMAGE_SRC (bs);
GstXContext *xcontext;
gint width, height;
+ GstVideoFormat format;
if ((!s->xcontext) && (!gst_ximage_src_open_display (s, s->display_name)))
- return
- gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC
- (s)->srcpad));
+ return gst_pad_get_pad_template_caps (GST_BASE_SRC (s)->srcpad);
if (!gst_ximage_src_recalc (s))
- return
- gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC
- (s)->srcpad));
+ return gst_pad_get_pad_template_caps (GST_BASE_SRC (s)->srcpad);
xcontext = s->xcontext;
width = s->xcontext->width;
if (s->endx >= s->startx && s->endy >= s->starty) {
/* this means user has put in values */
if (s->startx < xcontext->width && s->endx < xcontext->width &&
- s->starty < xcontext->height && s->endy < xcontext->height &&
- s->startx >= 0 && s->starty >= 0) {
+ s->starty < xcontext->height && s->endy < xcontext->height) {
/* values are fine */
s->width = width = s->endx - s->startx + 1;
s->height = height = s->endy - s->starty + 1;
s->endy = height - 1;
}
GST_DEBUG ("width = %d, height=%d", width, height);
- return gst_caps_new_simple ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, xcontext->bpp,
- "depth", G_TYPE_INT, xcontext->depth,
- "endianness", G_TYPE_INT, xcontext->endianness,
- "red_mask", G_TYPE_INT, xcontext->r_mask_output,
- "green_mask", G_TYPE_INT, xcontext->g_mask_output,
- "blue_mask", G_TYPE_INT, xcontext->b_mask_output,
+
+ format =
+ gst_video_format_from_masks (xcontext->depth, xcontext->bpp,
+ xcontext->endianness, xcontext->r_mask_output, xcontext->g_mask_output,
+ xcontext->b_mask_output, 0);
+
+ return gst_caps_new_simple ("video/x-raw",
+ "format", G_TYPE_STRING, gst_video_format_to_string (format),
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height,
"framerate", GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1,
return TRUE;
}
-static void
+static GstCaps *
gst_ximage_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
{
gint i;
GstStructure *structure;
+ caps = gst_caps_make_writable (caps);
+
for (i = 0; i < gst_caps_get_size (caps); ++i) {
structure = gst_caps_get_structure (caps, i);
gst_structure_fixate_field_nearest_fraction (structure, "framerate", 25, 1);
}
- GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps);
+ caps = GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps);
+
+ return caps;
}
static void
"Window name to capture from", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- gst_element_class_set_details_simple (ec, "Ximage video source",
+ gst_element_class_set_static_metadata (ec, "Ximage video source",
"Source/Video",
"Creates a screenshot video stream",
"Lutz Mueller <lutz@users.sourceforge.net>, "
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
- "ximagesrc",
+ ximagesrc,
"X11 video input plugin using standard Xlib calls",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);