From: <tho...@fr...> - 2004-08-05 17:51:21
|
CVS Root: /home/cvs/gstreamer Module: gst-plugins Changes by: thomasvs Date: Fri Aug 06 2004 03:51:19 EST Log message: handle changing framerate while PLAYING Modified files: . : ChangeLog gst/videotestsrc: gstvideotestsrc.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ChangeLog.diff?r1=1.971&r2=1.972 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/videotestsrc/gstvideotestsrc.c.diff?r1=1.63&r2=1.64 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /home/cvs/gstreamer/gst-plugins/ChangeLog,v retrieving revision 1.971 retrieving revision 1.972 diff -u -d -r1.971 -r1.972 --- ChangeLog 5 Aug 2004 14:40:59 -0000 1.971 +++ ChangeLog 5 Aug 2004 17:51:06 -0000 1.972 @@ -1,5 +1,13 @@ 2004-08-05 Thomas Vander Stichele <thomas at apestaart dot org> + * gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_src_link), + (gst_videotestsrc_change_state), (gst_videotestsrc_src_query), + (gst_videotestsrc_handle_src_event), (gst_videotestsrc_get): + decouple running_time and n_frames so it can handle changing + framerate while running + +2004-08-05 Thomas Vander Stichele <thomas at apestaart dot org> * po/nl.po: * po/sv.po: updated translations Index: gstvideotestsrc.c RCS file: /home/cvs/gstreamer/gst-plugins/gst/videotestsrc/gstvideotestsrc.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- gstvideotestsrc.c 5 Aug 2004 17:41:33 -0000 1.63 +++ gstvideotestsrc.c 5 Aug 2004 17:51:07 -0000 1.64 @@ -251,8 +251,8 @@ videotestsrc->bpp = videotestsrc->fourcc->bitspp; - GST_DEBUG_OBJECT (videotestsrc, "size %dx%d", videotestsrc->width, - videotestsrc->height); + GST_DEBUG_OBJECT (videotestsrc, "size %dx%d, %f fps", videotestsrc->width, + videotestsrc->height, videotestsrc->rate); return GST_PAD_LINK_OK; } @@ -284,6 +284,7 @@ break; case GST_STATE_PAUSED_TO_READY: videotestsrc->timestamp_offset = 0; + videotestsrc->running_time = 0; videotestsrc->n_frames = 0; case GST_STATE_READY_TO_NULL: @@ -411,8 +412,7 @@ case GST_QUERY_POSITION: switch (*format) { case GST_FORMAT_TIME: - *value = - videotestsrc->n_frames * GST_SECOND / (double) videotestsrc->rate; + *value = videotestsrc->running_time; res = TRUE; break; case GST_FORMAT_DEFAULT: /* frames */ @@ -447,6 +447,7 @@ gboolean res = TRUE; GstVideotestsrc *videotestsrc; gint64 new_n_frames; + GstClockTime new_running_time; g_return_val_if_fail (pad != NULL, FALSE); g_return_val_if_fail (GST_IS_PAD (pad), FALSE); @@ -457,8 +458,11 @@ switch (GST_EVENT_TYPE (event)) { case GST_EVENT_SEEK: { + /* since we don't do bookkeeping, we just assign a useful meaning + * to the time/frame relation after seeking based on current fps */ switch (GST_EVENT_SEEK_FORMAT (event)) { + new_running_time = GST_EVENT_SEEK_OFFSET (event); new_n_frames = GST_EVENT_SEEK_OFFSET (event) * (double) videotestsrc->rate / GST_SECOND; @@ -467,6 +471,8 @@ case GST_FORMAT_DEFAULT: new_n_frames = GST_EVENT_SEEK_OFFSET (event); + new_running_time = GST_EVENT_SEEK_OFFSET (event) / + (double) videotestsrc->rate * GST_SECOND; videotestsrc->segment_start_frame = -1; videotestsrc->segment_end_frame = -1; @@ -576,16 +582,16 @@ videotestsrc->width, videotestsrc->height); GST_BUFFER_TIMESTAMP (buf) = videotestsrc->timestamp_offset + - (videotestsrc->n_frames * GST_SECOND) / (double) videotestsrc->rate; - videotestsrc->n_frames++; + videotestsrc->running_time; + GST_BUFFER_DURATION (buf) = GST_SECOND / (double) videotestsrc->rate; if (videotestsrc->sync) { /* FIXME this is not correct if we do QoS */ if (videotestsrc->clock) { gst_element_wait (GST_ELEMENT (videotestsrc), GST_BUFFER_TIMESTAMP (buf)); } } - GST_BUFFER_DURATION (buf) = GST_SECOND / (double) videotestsrc->rate; - + videotestsrc->n_frames++; + videotestsrc->running_time += GST_BUFFER_DURATION (buf); return GST_DATA (buf); |