2003-06-13 05:37:19 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*#define DEBUG_ENABLED */
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2003-06-13 05:37:19 +00:00
|
|
|
#include <gstvideoflip.h>
|
|
|
|
#include <videoflip.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* elementfactory information */
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstElementDetails videoflip_details =
|
|
|
|
GST_ELEMENT_DETAILS ("Video scaler",
|
|
|
|
"Filter/Effect/Video",
|
|
|
|
"Resizes video",
|
|
|
|
"Wim Taymans <wim.taymans@chello.be>");
|
2003-06-13 05:37:19 +00:00
|
|
|
|
|
|
|
/* GstVideoflip signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-06-13 05:37:19 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-06-13 05:37:19 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_METHOD,
|
|
|
|
/* FILL ME */
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_videoflip_base_init (gpointer g_class);
|
|
|
|
static void gst_videoflip_class_init (GstVideoflipClass * klass);
|
|
|
|
static void gst_videoflip_init (GstVideoflip * videoflip);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_videoflip_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_videoflip_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_videoflip_chain (GstPad * pad, GstData * _data);
|
|
|
|
static GstCaps *gst_videoflip_get_capslist (void);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2003-06-13 05:37:19 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
|
|
|
#define GST_TYPE_VIDEOFLIP_METHOD (gst_videoflip_method_get_type())
|
|
|
|
|
|
|
|
static GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_method_get_type (void)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
|
|
|
static GType videoflip_method_type = 0;
|
|
|
|
static GEnumValue videoflip_methods[] = {
|
2004-03-14 22:34:33 +00:00
|
|
|
{GST_VIDEOFLIP_METHOD_IDENTITY, "0", "Identity (no rotation)"},
|
|
|
|
{GST_VIDEOFLIP_METHOD_90R, "1", "Rotate right 90 degrees"},
|
|
|
|
{GST_VIDEOFLIP_METHOD_180, "2", "Rotate 180 degrees"},
|
|
|
|
{GST_VIDEOFLIP_METHOD_90L, "3", "Rotate left 90 degrees"},
|
|
|
|
{GST_VIDEOFLIP_METHOD_HORIZ, "4", "Flip horizontally"},
|
|
|
|
{GST_VIDEOFLIP_METHOD_VERT, "5", "Flip vertically"},
|
|
|
|
{GST_VIDEOFLIP_METHOD_TRANS, "6",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Flip across upper left/lower right diagonal"},
|
2004-03-14 22:34:33 +00:00
|
|
|
{GST_VIDEOFLIP_METHOD_OTHER, "7",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Flip across upper right/lower left diagonal"},
|
2004-03-14 22:34:33 +00:00
|
|
|
{0, NULL, NULL},
|
2003-06-13 05:37:19 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!videoflip_method_type) {
|
|
|
|
videoflip_method_type = g_enum_register_static ("GstVideoflipMethod",
|
2004-03-15 19:32:27 +00:00
|
|
|
videoflip_methods);
|
2003-06-13 05:37:19 +00:00
|
|
|
}
|
|
|
|
return videoflip_method_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 21:30:09 +00:00
|
|
|
static GstPadTemplate *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_src_template_factory (void)
|
2003-11-02 21:30:09 +00:00
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
/* well, actually RGB too, but since there's no RGB format anyway */
|
|
|
|
GstCaps *caps = gst_caps_from_string ("video/x-raw-yuv, "
|
2004-03-14 22:34:33 +00:00
|
|
|
"width = (int) [ 0, MAX ], "
|
|
|
|
"height = (int) [ 0, MAX ], " "framerate = (double) [ 0, MAX ]");
|
2003-11-02 21:30:09 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
caps = gst_caps_intersect (caps, gst_videoflip_get_capslist ());
|
2003-11-02 21:30:09 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
return gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
|
2003-11-02 21:30:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstPadTemplate *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_sink_template_factory (void)
|
2003-11-02 21:30:09 +00:00
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
GstCaps *caps = gst_caps_from_string ("video/x-raw-yuv, "
|
2004-03-14 22:34:33 +00:00
|
|
|
"width = (int) [ 0, MAX ], "
|
|
|
|
"height = (int) [ 0, MAX ], " "framerate = (double) [ 0, MAX ]");
|
2003-11-02 21:30:09 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
caps = gst_caps_intersect (caps, gst_videoflip_get_capslist ());
|
2003-11-02 21:30:09 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
return gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
|
2003-11-02 21:30:09 +00:00
|
|
|
}
|
|
|
|
|
2003-06-13 05:37:19 +00:00
|
|
|
GType
|
|
|
|
gst_videoflip_get_type (void)
|
|
|
|
{
|
|
|
|
static GType videoflip_type = 0;
|
|
|
|
|
|
|
|
if (!videoflip_type) {
|
|
|
|
static const GTypeInfo videoflip_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstVideoflipClass),
|
2003-11-02 21:30:09 +00:00
|
|
|
gst_videoflip_base_init,
|
2003-06-13 05:37:19 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GClassInitFunc) gst_videoflip_class_init,
|
2003-06-13 05:37:19 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstVideoflip),
|
2003-06-13 05:37:19 +00:00
|
|
|
0,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GInstanceInitFunc) gst_videoflip_init,
|
2003-06-13 05:37:19 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
videoflip_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstVideoflip",
|
|
|
|
&videoflip_info, 0);
|
2003-06-13 05:37:19 +00:00
|
|
|
}
|
|
|
|
return videoflip_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 21:30:09 +00:00
|
|
|
static void
|
|
|
|
gst_videoflip_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
|
|
|
gst_element_class_set_details (element_class, &videoflip_details);
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_videoflip_sink_template_factory ());
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_videoflip_src_template_factory ());
|
2003-11-02 21:30:09 +00:00
|
|
|
}
|
2003-06-13 05:37:19 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_class_init (GstVideoflipClass * klass)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_METHOD,
|
|
|
|
g_param_spec_enum ("method", "method", "method",
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_TYPE_VIDEOFLIP_METHOD, GST_VIDEOFLIP_METHOD_90R,
|
|
|
|
G_PARAM_READWRITE));
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_videoflip_set_property;
|
|
|
|
gobject_class->get_property = gst_videoflip_get_property;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstCaps *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_get_capslist (void)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
|
|
|
GstCaps *caps;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
2003-06-13 05:37:19 +00:00
|
|
|
int i;
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
caps = gst_caps_new_empty ();
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < videoflip_n_formats; i++) {
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = videoflip_get_cap (videoflip_formats + i);
|
|
|
|
gst_caps_append_structure (caps, structure);
|
2003-06-13 05:37:19 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
return caps;
|
2003-06-13 05:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstCaps *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_sink_getcaps (GstPad * pad)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
|
|
|
GstVideoflip *videoflip;
|
|
|
|
GstCaps *capslist = NULL;
|
|
|
|
GstCaps *peercaps;
|
|
|
|
GstCaps *sizecaps;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstCaps *caps;
|
2003-06-13 05:37:19 +00:00
|
|
|
int i;
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_DEBUG ("gst_videoflip_sink_getcaps");
|
2003-06-13 05:37:19 +00:00
|
|
|
videoflip = GST_VIDEOFLIP (gst_pad_get_parent (pad));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-06-13 05:37:19 +00:00
|
|
|
/* get list of peer's caps */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (pad == videoflip->srcpad) {
|
2003-06-13 05:37:19 +00:00
|
|
|
peercaps = gst_pad_get_allowed_caps (videoflip->sinkpad);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2003-06-13 05:37:19 +00:00
|
|
|
peercaps = gst_pad_get_allowed_caps (videoflip->srcpad);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME videoflip doesn't allow passthru of video formats it
|
|
|
|
* doesn't understand. */
|
|
|
|
/* Look through our list of caps and find those that match with
|
|
|
|
* the peer's formats. Create a list of them. */
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < videoflip_n_formats; i++) {
|
|
|
|
GstCaps *fromcaps =
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_caps_new_full (videoflip_get_cap (videoflip_formats + i), NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (gst_caps_is_always_compatible (fromcaps, peercaps)) {
|
|
|
|
gst_caps_append (capslist, fromcaps);
|
2003-06-13 05:37:19 +00:00
|
|
|
}
|
|
|
|
}
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_caps_free (peercaps);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
sizecaps = gst_caps_from_string ("video/x-raw-yuv, "
|
2004-03-14 22:34:33 +00:00
|
|
|
"width = (int) [ 0, MAX ], "
|
|
|
|
"height = (int) [ 0, MAX ], " "framerate = (double) [ 0, MAX ]");
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
caps = gst_caps_intersect (capslist, sizecaps);
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_caps_free (sizecaps);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_src_link (GstPad * pad, const GstCaps * caps)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
|
|
|
GstVideoflip *videoflip;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
gboolean ret;
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("gst_videoflip_src_link");
|
2003-06-13 05:37:19 +00:00
|
|
|
videoflip = GST_VIDEOFLIP (gst_pad_get_parent (pad));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
|
|
|
videoflip->format = videoflip_find_by_caps (caps);
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_val_if_fail (videoflip->format, GST_PAD_LINK_REFUSED);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
ret = gst_structure_get_int (structure, "width", &videoflip->to_width);
|
|
|
|
ret &= gst_structure_get_int (structure, "height", &videoflip->to_height);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!ret)
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
2003-06-13 05:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_sink_link (GstPad * pad, const GstCaps * caps)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
|
|
|
GstVideoflip *videoflip;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
gboolean ret;
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_DEBUG ("gst_videoflip_sink_link");
|
2003-06-13 05:37:19 +00:00
|
|
|
videoflip = GST_VIDEOFLIP (gst_pad_get_parent (pad));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
|
|
|
videoflip->format = videoflip_find_by_caps (caps);
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_val_if_fail (videoflip->format, GST_PAD_LINK_REFUSED);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
ret = gst_structure_get_int (structure, "width", &videoflip->from_width);
|
|
|
|
ret &= gst_structure_get_int (structure, "height", &videoflip->from_height);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!ret)
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
2003-06-13 05:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_init (GstVideoflip * videoflip)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("gst_videoflip_init");
|
2004-03-14 22:34:33 +00:00
|
|
|
videoflip->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_videoflip_sink_template_factory (),
|
|
|
|
"sink");
|
|
|
|
gst_element_add_pad (GST_ELEMENT (videoflip), videoflip->sinkpad);
|
|
|
|
gst_pad_set_chain_function (videoflip->sinkpad, gst_videoflip_chain);
|
|
|
|
gst_pad_set_link_function (videoflip->sinkpad, gst_videoflip_sink_link);
|
|
|
|
gst_pad_set_getcaps_function (videoflip->sinkpad, gst_videoflip_sink_getcaps);
|
|
|
|
|
|
|
|
videoflip->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_videoflip_src_template_factory (), "src");
|
|
|
|
gst_element_add_pad (GST_ELEMENT (videoflip), videoflip->srcpad);
|
|
|
|
gst_pad_set_link_function (videoflip->srcpad, gst_videoflip_src_link);
|
2003-06-13 05:37:19 +00:00
|
|
|
//gst_pad_set_getcaps_function(videoflip->srcpad,gst_videoflip_getcaps);
|
|
|
|
|
|
|
|
videoflip->inited = FALSE;
|
|
|
|
videoflip->force_size = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_chain (GstPad * pad, GstData * _data)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
2003-10-08 16:08:18 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
2003-06-13 05:37:19 +00:00
|
|
|
GstVideoflip *videoflip;
|
|
|
|
guchar *data;
|
|
|
|
gulong size;
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("gst_videoflip_chain");
|
2003-06-13 05:37:19 +00:00
|
|
|
|
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
|
|
|
g_return_if_fail (buf != NULL);
|
|
|
|
|
|
|
|
videoflip = GST_VIDEOFLIP (gst_pad_get_parent (pad));
|
|
|
|
g_return_if_fail (videoflip->inited);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
data = GST_BUFFER_DATA (buf);
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (videoflip->passthru) {
|
|
|
|
gst_pad_push (videoflip->srcpad, GST_DATA (buf));
|
2003-06-13 05:37:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("gst_videoflip_chain: got buffer of %ld bytes in '%s'", size,
|
|
|
|
GST_OBJECT_NAME (videoflip));
|
|
|
|
|
|
|
|
GST_DEBUG
|
|
|
|
("size=%ld from=%dx%d to=%dx%d fromsize=%ld (should be %d) tosize=%d",
|
|
|
|
size, videoflip->from_width, videoflip->from_height, videoflip->to_width,
|
|
|
|
videoflip->to_height, size, videoflip->from_buf_size,
|
|
|
|
videoflip->to_buf_size);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
|
|
|
g_return_if_fail (size == videoflip->from_buf_size);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
outbuf = gst_buffer_new ();
|
2003-06-13 05:37:19 +00:00
|
|
|
/* FIXME: handle bufferpools */
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_BUFFER_SIZE (outbuf) = videoflip->to_buf_size;
|
|
|
|
GST_BUFFER_DATA (outbuf) = g_malloc (videoflip->to_buf_size);
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (videoflip->format);
|
|
|
|
GST_DEBUG ("format %s", videoflip->format->fourcc);
|
|
|
|
g_return_if_fail (videoflip->format->scale);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
videoflip->format->scale (videoflip, GST_BUFFER_DATA (outbuf), data);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("gst_videoflip_chain: pushing buffer of %d bytes in '%s'",
|
|
|
|
GST_BUFFER_SIZE (outbuf), GST_OBJECT_NAME (videoflip));
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_push (videoflip->srcpad, GST_DATA (outbuf));
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_buffer_unref (buf);
|
2003-06-13 05:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
|
|
|
GstVideoflip *src;
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_VIDEOFLIP (object));
|
|
|
|
src = GST_VIDEOFLIP (object);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("gst_videoflip_set_property");
|
2003-06-13 05:37:19 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_METHOD:
|
|
|
|
src->method = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_videoflip_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
|
|
|
GstVideoflip *src;
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_VIDEOFLIP (object));
|
|
|
|
src = GST_VIDEOFLIP (object);
|
2003-06-13 05:37:19 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_METHOD:
|
|
|
|
g_value_set_enum (value, src->method);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2003-06-13 05:37:19 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
return gst_element_register (plugin, "videoflip", GST_RANK_NONE,
|
|
|
|
GST_TYPE_VIDEOFLIP);
|
2003-06-13 05:37:19 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"videoflip",
|
|
|
|
"Resizes video", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
|