gst/videobox/gstvideobox.c: Fix caps negotiation correctly, add debugging category.

Original commit message from CVS:
2005-10-24  Julien MOUTTE  <julien@moutte.net>

* gst/videobox/gstvideobox.c: (gst_video_box_class_init),
(gst_video_box_transform_caps), (gst_video_box_get_unit_size):
Fix caps negotiation correctly, add debugging category.
This commit is contained in:
Julien Moutte 2005-10-24 13:22:14 +00:00
parent 79240332d1
commit 70b4bda644
2 changed files with 41 additions and 34 deletions

View file

@ -1,3 +1,9 @@
2005-10-24 Julien MOUTTE <julien@moutte.net>
* gst/videobox/gstvideobox.c: (gst_video_box_class_init),
(gst_video_box_transform_caps), (gst_video_box_get_unit_size):
Fix caps negotiation correctly, add debugging category.
2005-10-24 Christian Schaller <christian@fluendo.com> 2005-10-24 Christian Schaller <christian@fluendo.com>
* configure.ac: Port over Thomas's change from base listing all plugins * configure.ac: Port over Thomas's change from base listing all plugins

View file

@ -26,6 +26,9 @@
#include <string.h> #include <string.h>
GST_DEBUG_CATEGORY (videobox_debug);
#define GST_CAT_DEFAULT videobox_debug
#define GST_TYPE_VIDEO_BOX \ #define GST_TYPE_VIDEO_BOX \
(gst_video_box_get_type()) (gst_video_box_get_type())
#define GST_VIDEO_BOX(obj) \ #define GST_VIDEO_BOX(obj) \
@ -212,6 +215,9 @@ gst_video_box_class_init (GstVideoBoxClass * klass)
trans_class->set_caps = gst_video_box_set_caps; trans_class->set_caps = gst_video_box_set_caps;
trans_class->get_unit_size = gst_video_box_get_unit_size; trans_class->get_unit_size = gst_video_box_get_unit_size;
trans_class->transform = gst_video_box_transform; trans_class->transform = gst_video_box_transform;
GST_DEBUG_CATEGORY_INIT (videobox_debug, "videobox", 0,
"Resizes a video by adding borders or cropping");
} }
static void static void
@ -337,48 +343,43 @@ gst_video_box_transform_caps (GstBaseTransform * trans,
{ {
GstVideoBox *video_box; GstVideoBox *video_box;
GstCaps *to; GstCaps *to;
GstStructure *structure;
GValue list_value = { 0 }, value = {
0};
gint dir, i, tmp;
video_box = GST_VIDEO_BOX (trans); video_box = GST_VIDEO_BOX (trans);
if (gst_caps_is_fixed (from)) { g_value_init (&list_value, GST_TYPE_LIST);
GstCaps *to_ayuv, *to_i420; g_value_init (&value, GST_TYPE_FOURCC);
GstStructure *structure; gst_value_set_fourcc (&value, GST_MAKE_FOURCC ('I', '4', '2', '0'));
gint width, height, dir; gst_value_list_append_value (&list_value, &value);
gdouble fps; g_value_unset (&value);
dir = (direction == GST_PAD_SINK) ? -1 : 1; to = gst_caps_copy (from);
dir = (direction == GST_PAD_SINK) ? -1 : 1;
structure = gst_caps_get_structure (from, 0); for (i = 0; i < gst_caps_get_size (to); i++) {
structure = gst_caps_get_structure (to, i);
gst_structure_get_int (structure, "width", &width); if (direction == GST_PAD_SINK) { /* I420 to { I420, AYUV } */
gst_structure_get_int (structure, "height", &height); g_value_init (&value, GST_TYPE_FOURCC);
gst_structure_get_double (structure, "framerate", &fps); gst_value_set_fourcc (&value, GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'));
gst_value_list_append_value (&list_value, &value);
width += dir * (video_box->box_left + video_box->box_right); g_value_unset (&value);
height += dir * (video_box->box_top + video_box->box_bottom); gst_structure_set_value (structure, "format", &list_value);
} else if (direction == GST_PAD_SRC) {
to_i420 = gst_caps_new_simple ("video/x-raw-yuv", gst_structure_set_value (structure, "format", &list_value);
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, "framerate", G_TYPE_DOUBLE, fps, NULL);
to_ayuv = gst_caps_new_simple ("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'),
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, "framerate", G_TYPE_DOUBLE, fps, NULL);
to = to_i420;
gst_caps_append (to, to_ayuv);
} else {
GstPadTemplate *tmpl;
if (direction == GST_PAD_SINK) {
tmpl = gst_static_pad_template_get (&gst_video_box_src_template);
} else {
tmpl = gst_static_pad_template_get (&gst_video_box_sink_template);
} }
to = gst_caps_copy (gst_pad_template_get_caps (tmpl)); if (gst_structure_get_int (structure, "width", &tmp))
gst_structure_set (structure, "width", G_TYPE_INT,
tmp + direction * (video_box->box_left + video_box->box_right), NULL);
if (gst_structure_get_int (structure, "height", &tmp))
gst_structure_set (structure, "height", G_TYPE_INT,
tmp + direction * (video_box->box_top + video_box->box_bottom), NULL);
} }
g_value_unset (&list_value);
return to; return to;
} }