Re: Querying stream position/duration with gstmm



Murray Cumming wrote:
On Wed, 2007-12-12 at 23:22 -0500, José Alburquerque wrote:
I worked a little on querying stream positions and duration so I modified the player example to print a "status line" showing the position/duration of the ogg stream. Would you be able to look at/check in this patch if it's ok? Thanks.

I have checked that in, though I made some small changes.

You wrapped
  gboolean gst_element_query_position(GstElement *element, GstFormat
*format, gint64 *cur);
as
  bool query_position(Format& format, ClockTime& position)

Why the change of type for position? Is that an error in the gstreamer C
API?

I'm sorry. I made a mistake with this. I sort of leaped before looking. I shouldn't have changed the wrapping of gst_element_query_position (and gst_element_query_duration) because it was right the way it was. What I misunderstood about the function is that the GstFormat requests the format of the information returned in the "curr" variable. The GstFormat is updated with the format of the information in "curr" when the function returns (see http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html#gst-element-query-position).

There are several formats available such as GST_FORMAT_TIME, GST_FORMAT_PERCENT and GST_FORMAT_BYTE. All the formats, however are returned as a gint64. So the function should have remained as it was. The gstreamer code does not need to be patched because it's been developed with this in mind.

Again, it will take a little time before I get into the flow of wrapping without making these mistakes. Here's a patch that fixes it back the way it was. Sorry about that.

-Jose
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 108)
+++ ChangeLog	(working copy)
@@ -1,3 +1,14 @@
+2007-12-13  José Alburquerque  <jaalburquerque cox com>
+
+	* examples/ogg_player/main.cc: Changed pos and len of type gint64
+	instead of Gst::ClockTime (required by Element::query_duration() and
+	Element::query_position()
+	* gst/src/element.hg: re-wrapped query_duration() and query_position()
+	to use gint64 for position and duration as before (format can be
+	something other than ClockTime)
+	* tools/m4/convert_gst.m4: removed unused coversion from
+	Gst::ClockTime& to gint64*
+
 2007-12-13  Siavash Safi  <siavash safi gmail com>
 
 	* configure.ac: updated AC_CONFIG_FILES() to add the new examples
Index: gst/src/element.hg
===================================================================
--- gst/src/element.hg	(revision 108)
+++ gst/src/element.hg	(working copy)
@@ -85,9 +85,9 @@
 
   _WRAP_METHOD(bool query_convert(Format src_format, gint64 src_value, Format& dst_format, gint64& dst_value) const, gst_element_query_convert)
   bool query_position(Format& format) const;
-  _WRAP_METHOD(bool query_position(Format& format, ClockTime& position) const, gst_element_query_position)
+  _WRAP_METHOD(bool query_position(Format& format, gint64& position) const, gst_element_query_position)
   bool query_duration(Format& format) const;
-  _WRAP_METHOD(bool query_duration(Format& format, ClockTime& duration) const, gst_element_query_duration)
+  _WRAP_METHOD(bool query_duration(Format& format, gint64& duration) const, gst_element_query_duration)
 
   _WRAP_METHOD(bool seek_simple(Format format, SeekFlags flags, const gint64& position), gst_element_seek_simple)
   _WRAP_METHOD(bool seek(const double& rate, Format format, SeekFlags flags, SeekType current_type, const gint64& current_position, SeekType stop_type, const gint64& stop_position), gst_element_seek)
Index: tools/m4/convert_gst.m4
===================================================================
--- tools/m4/convert_gst.m4	(revision 108)
+++ tools/m4/convert_gst.m4	(working copy)
@@ -17,7 +17,6 @@
 _CONVERSION(`State&',`GstState*',`((GstState*) (&($3)))')
 _CONVERSION(`GstClockTime',`ClockTime',`$3')
 _CONVERSION(`ClockTime',`GstClockTime',`(GstClockTime ($3))')
-_CONVERSION(`ClockTime&',`gint64*',`((gint64*) &(($3)))')
 _CONVERSION(`GstClockID',`Glib::RefPtr<ClockID>',`$3')
 _CONVERSION(`Glib::RefPtr<ClockID>',`GstClockID',`(GstClockID ($3))')
 _CONVERSION(`GstClock*',`Clock',`Glib::wrap($3)')
Index: examples/ogg_player/main.cc
===================================================================
--- examples/ogg_player/main.cc	(revision 108)
+++ examples/ogg_player/main.cc	(working copy)
@@ -10,8 +10,8 @@
 bool print_stream_position(void)
 {
  Gst::Format fmt = Gst::FORMAT_TIME;
- Gst::ClockTime pos = 0;
- Gst::ClockTime len = 0;
+ gint64 pos = 0;
+ gint64 len = 0;
 
  if (pipeline->query_position(fmt, pos)
    && pipeline->query_duration(fmt, len)) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]