From e71fc2718fdc95122c5d0eb563bcd9c4c70ff4de Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Mon, 15 Mar 2004 21:41:35 +0000 Subject: [PATCH] gst-libs/gst/play/play.c: First draft of gst_play_get_framerate. Original commit message from CVS: 2004-03-15 Julien MOUTTE * gst-libs/gst/play/play.c: (gst_play_get_framerate), (gst_play_get_sink_element): First draft of gst_play_get_framerate. * gst-libs/gst/play/play.h: --- ChangeLog | 6 ++++++ gst-libs/gst/play/play.c | 42 ++++++++++++++++++++++++++++++++++++++-- gst-libs/gst/play/play.h | 6 ++++-- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1f2de023c6..25ce4fef75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-03-15 Julien MOUTTE + + * gst-libs/gst/play/play.c: (gst_play_get_framerate), + (gst_play_get_sink_element): First draft of gst_play_get_framerate. + * gst-libs/gst/play/play.h: + 2004-03-15 Thomas Vander Stichele * *.c, *.cc: don't mix tabs and spaces diff --git a/gst-libs/gst/play/play.c b/gst-libs/gst/play/play.c index ba24eb865a..28acb075bf 100644 --- a/gst-libs/gst/play/play.c +++ b/gst-libs/gst/play/play.c @@ -1126,6 +1126,46 @@ gst_play_connect_visualization (GstPlay * play, gboolean connect) return TRUE; } +/** + * gst_play_get_framerate: + * @play: a #GstPlay. + * + * Get the video framerate from @play. + * + * Returns: a #gdouble indicating video framerate in frame per second. + */ +gdouble +gst_play_get_framerate (GstPlay * play) +{ + GstElement *video_element = NULL; + GstPad *video_pad = NULL; + GstCaps *video_pad_caps = NULL; + GstStructure *structure = NULL; + + g_return_val_if_fail (GST_IS_PLAY (play), 0); + + video_element = g_hash_table_lookup (play->priv->elements, "video_sink"); + if (!GST_IS_ELEMENT (video_element)) + return 0; + video_pad = gst_element_get_pad (video_element, "sink"); + if (!GST_IS_PAD (video_pad)) + return 0; + video_pad_caps = (GstCaps *) gst_pad_get_negotiated_caps (video_pad); + if (!GST_IS_CAPS (video_pad_caps)) + return 0; + + structure = gst_caps_get_structure (video_pad_caps, 0); + + if (structure) { + gdouble value; + + gst_structure_get_double (structure, "framerate", &value); + return value; + } + + return 0; +} + /** * gst_play_get_sink_element: * @play: a #GstPlay. @@ -1145,8 +1185,6 @@ gst_play_get_sink_element (GstPlay * play, const GList *pads = NULL; gboolean has_src, has_correct_type; - g_return_val_if_fail (play != NULL, NULL); - g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (GST_IS_PLAY (play), NULL); g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); diff --git a/gst-libs/gst/play/play.h b/gst-libs/gst/play/play.h index 8ccf827d79..55c12a365d 100644 --- a/gst-libs/gst/play/play.h +++ b/gst-libs/gst/play/play.h @@ -90,7 +90,9 @@ gboolean gst_play_seek_to_time (GstPlay *play, gint64 time_nanos); GstElement * gst_play_get_sink_element (GstPlay *play, - GstElement *element, - GstPlaySinkType sink_type); + GstElement *element, + GstPlaySinkType sink_type); + +gdouble gst_play_get_framerate (GstPlay *play); #endif /* __GST_PLAY_H__ */