diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2011-03-02 23:14:36 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2011-03-02 23:14:36 +0100 |
commit | fdbdbfefd2972f99e2e8566c446542fdf204b554 (patch) | |
tree | ef06305f82d7fdfa4564e0b9a9a69b8f5f3ff460 /ext/cairo | |
parent | 6810b1bab97068ecd16ad5c5f830e4ab7183a81e (diff) |
cairooverlay: Some minor cleanup
Diffstat (limited to 'ext/cairo')
-rw-r--r-- | ext/cairo/gstcairooverlay.c | 33 | ||||
-rw-r--r-- | ext/cairo/gstcairooverlay.h | 19 |
2 files changed, 30 insertions, 22 deletions
diff --git a/ext/cairo/gstcairooverlay.c b/ext/cairo/gstcairooverlay.c index 7bddb30b7..bdb0a39d1 100644 --- a/ext/cairo/gstcairooverlay.c +++ b/ext/cairo/gstcairooverlay.c @@ -98,9 +98,9 @@ #include <cairo.h> #if G_BYTE_ORDER == G_LITTLE_ENDIAN -#define ARGB_CAPS GST_VIDEO_CAPS_BGRx " ; " GST_VIDEO_CAPS_BGRA " ; " +#define TEMPLATE_CAPS GST_VIDEO_CAPS_BGRx " ; " GST_VIDEO_CAPS_BGRA " ; " #else -#define ARGB_CAPS GST_VIDEO_CAPS_xRGB " ; " GST_VIDEO_CAPS_ARGB " ; " +#define TEMPLATE_CAPS GST_VIDEO_CAPS_xRGB " ; " GST_VIDEO_CAPS_ARGB " ; " #endif @@ -108,14 +108,14 @@ static GstStaticPadTemplate gst_cairo_overlay_src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (ARGB_CAPS) + GST_STATIC_CAPS (TEMPLATE_CAPS) ); static GstStaticPadTemplate gst_cairo_overlay_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (ARGB_CAPS) + GST_STATIC_CAPS (TEMPLATE_CAPS) ); @@ -128,6 +128,7 @@ enum SIGNAL_CAPS_CHANGED, N_SIGNALS }; + static guint gst_cairo_overlay_signals[N_SIGNALS]; static gboolean @@ -135,17 +136,18 @@ gst_cairo_overlay_set_caps (GstBaseTransform * btrans, GstCaps * incaps, GstCaps * outcaps) { GstCairoOverlay *overlay = GST_CAIRO_OVERLAY (btrans); - GstStructure *s = gst_caps_get_structure (incaps, 0); + gboolean ret; - if (!gst_structure_get_int (s, "bpp", &(overlay->bpp))) { + ret = + gst_video_format_parse_caps (incaps, &overlay->format, &overlay->width, + &overlay->height); + if (G_UNLIKELY (!ret)) return FALSE; - } g_signal_emit (overlay, gst_cairo_overlay_signals[SIGNAL_CAPS_CHANGED], 0, incaps, NULL); - return G_LIKELY (gst_video_format_parse_caps (incaps, - &overlay->caps_format, &overlay->caps_width, &overlay->caps_height)); + return ret; } static GstFlowReturn @@ -157,11 +159,13 @@ gst_cairo_overlay_transform_ip (GstBaseTransform * btrans, GstBuffer * buf) cairo_t *cr; cairo_format_t format; - format = (overlay->bpp == 32) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24; + format = (overlay->format == GST_VIDEO_FORMAT_ARGB + || overlay->format == GST_VIDEO_FORMAT_BGRA) ? + CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24; surface = cairo_image_surface_create_for_data (GST_BUFFER_DATA (buf), format, - overlay->caps_width, overlay->caps_height, overlay->caps_width * 4); + overlay->width, overlay->height, overlay->width * 4); if (G_UNLIKELY (!surface)) return GST_FLOW_ERROR; @@ -176,6 +180,7 @@ gst_cairo_overlay_transform_ip (GstBaseTransform * btrans, GstBuffer * buf) cairo_destroy (cr); cairo_surface_destroy (surface); + return GST_FLOW_OK; } @@ -209,8 +214,8 @@ gst_cairo_overlay_class_init (GstCairoOverlayClass * klass) * GstCairoOverlay::draw: * @overlay: Overlay element emitting the signal. * @cr: Cairo context to draw to. - * @timestamp: Timestamp (see GstClockTime) of the current buffer. - * @duration: Duration (see GstClockTime) of the current buffer. + * @timestamp: Timestamp (see #GstClockTime) of the current buffer. + * @duration: Duration (see #GstClockTime) of the current buffer. * * This signal is emitted when the overlay should be drawn. */ @@ -227,7 +232,7 @@ gst_cairo_overlay_class_init (GstCairoOverlayClass * klass) /** * GstCairoOverlay::caps-changed: * @overlay: Overlay element emitting the signal. - * @caps: The caps of the element. + * @caps: The #GstCaps of the element. * * This signal is emitted when the caps of the element has changed. */ diff --git a/ext/cairo/gstcairooverlay.h b/ext/cairo/gstcairooverlay.h index a29350713..0c1ad2711 100644 --- a/ext/cairo/gstcairooverlay.h +++ b/ext/cairo/gstcairooverlay.h @@ -40,18 +40,21 @@ G_BEGIN_DECLS #define GST_IS_CAIRO_OVERLAY_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAIRO_OVERLAY)) -typedef struct _GstCairoOverlay { +typedef struct _GstCairoOverlay GstCairoOverlay; +typedef struct _GstCairoOverlayClass GstCairoOverlayClass; + +struct _GstCairoOverlay { GstVideoFilter parent_instance; + /* < private > */ - GstVideoFormat caps_format; - int caps_width; - int caps_height; - int bpp; -} GstCairoOverlay; + GstVideoFormat format; + gint width; + gint height; +}; -typedef struct _GstCairoOverlayClass { +struct _GstCairoOverlayClass { GstVideoFilterClass parent_class; -} GstCairoOverlayClass; +}; GType gst_cairo_overlay_get_type(void); |