diff options
author | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-01-30 20:47:43 +0000 |
---|---|---|
committer | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-01-30 20:47:43 +0000 |
commit | d62cdbbc61aba0cf2fee37c111ef57a0215cd91f (patch) | |
tree | d90c7a782f6e0fad7e3c196aa23fbfac2b8f8987 | |
parent | 1c6ceb5c0bc0e572a47e0889818d06ea54365355 (diff) | |
download | gst-plugins-bad-d62cdbbc61aba0cf2fee37c111ef57a0215cd91f.tar.gz gst-plugins-bad-d62cdbbc61aba0cf2fee37c111ef57a0215cd91f.tar.bz2 gst-plugins-bad-d62cdbbc61aba0cf2fee37c111ef57a0215cd91f.zip |
Add untested get-video-size function (bug 104360)
Original commit message from CVS:
Add untested get-video-size function (bug 104360)
-rw-r--r-- | gst-libs/gst/video/video.c | 41 | ||||
-rw-r--r-- | gst-libs/gst/video/video.h | 5 |
2 files changed, 41 insertions, 5 deletions
diff --git a/gst-libs/gst/video/video.c b/gst-libs/gst/video/video.c index 7b63d819..7c8b4852 100644 --- a/gst-libs/gst/video/video.c +++ b/gst-libs/gst/video/video.c @@ -33,22 +33,55 @@ gst_video_frame_rate (GstPad *pad) /* do a convert request on the source pad */ if (!gst_pad_convert(pad, - GST_FORMAT_TIME, GST_SECOND * NUM_UNITS, - &dest_format, &dest_value)) + GST_FORMAT_TIME, GST_SECOND * NUM_UNITS, + &dest_format, &dest_value)) { g_warning("gstvideo: pad %s:%s failed to convert time to unit!\n", - GST_ELEMENT_NAME(gst_pad_get_parent (pad)), GST_PAD_NAME(pad)); + GST_ELEMENT_NAME(gst_pad_get_parent (pad)), GST_PAD_NAME(pad)); return 0.; } fps = ((gdouble) dest_value) / NUM_UNITS; GST_DEBUG(GST_CAT_ELEMENT_PADS, "Framerate request on pad %s:%s - %f fps", - GST_ELEMENT_NAME(gst_pad_get_parent (pad)), GST_PAD_NAME(pad), fps); + GST_ELEMENT_NAME(gst_pad_get_parent (pad)), GST_PAD_NAME(pad), fps); return fps; } +gboolean +gst_video_get_size (GstPad *pad, + gint *width, + gint *height) +{ + GstCaps *caps; + + g_return_val_if_fail(pad != NULL, FALSE); + + caps = GST_PAD_CAPS(pad); + if (!caps) { + g_warning("gstvideo: failed to get caps of pad %s:%s", + GST_ELEMENT_NAME(gst_pad_get_parent (pad)), GST_PAD_NAME(pad)); + return FALSE; + } + if (!gst_caps_has_property(caps, "width") || + !gst_caps_has_property(caps, "height")) { + g_warning("gstvideo: resulting caps doesn't have width/height properties"); + return FALSE; + } + + if (width) + gst_caps_get_int(caps, "width", width); + if (height) + gst_caps_get_int(caps, "height", height); + + GST_DEBUG(GST_CAT_ELEMENT_PADS, "size request on pad %s:%s: %dx%d", + GST_ELEMENT_NAME(gst_pad_get_parent (pad)), GST_PAD_NAME(pad), + width?*width:0, height?*height:0); + + return TRUE; +} + static gboolean plugin_init (GModule *module, GstPlugin *plugin) { diff --git a/gst-libs/gst/video/video.h b/gst-libs/gst/video/video.h index 6062b92d..802520da 100644 --- a/gst-libs/gst/video/video.h +++ b/gst-libs/gst/video/video.h @@ -23,6 +23,9 @@ #include <gst/gst.h> -gdouble gst_video_frame_rate (GstPad *pad); +gdouble gst_video_frame_rate (GstPad *pad); +gboolean gst_video_get_size (GstPad *pad, + gint *width, + gint *height); #endif /* __GST_VIDEO_H__ */ |