mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-07-19 21:08:24 +00:00
handle changing framerate while PLAYING
Original commit message from CVS: handle changing framerate while PLAYING
This commit is contained in:
parent
43b6b750c6
commit
fa9cca2cc4
|
@ -1,3 +1,11 @@
|
||||||
|
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>
|
2004-08-05 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* po/nl.po:
|
* po/nl.po:
|
||||||
|
|
|
@ -251,8 +251,8 @@ gst_videotestsrc_src_link (GstPad * pad, const GstCaps * caps)
|
||||||
|
|
||||||
videotestsrc->bpp = videotestsrc->fourcc->bitspp;
|
videotestsrc->bpp = videotestsrc->fourcc->bitspp;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (videotestsrc, "size %dx%d", videotestsrc->width,
|
GST_DEBUG_OBJECT (videotestsrc, "size %dx%d, %f fps", videotestsrc->width,
|
||||||
videotestsrc->height);
|
videotestsrc->height, videotestsrc->rate);
|
||||||
|
|
||||||
return GST_PAD_LINK_OK;
|
return GST_PAD_LINK_OK;
|
||||||
}
|
}
|
||||||
|
@ -284,6 +284,7 @@ gst_videotestsrc_change_state (GstElement * element)
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED_TO_READY:
|
case GST_STATE_PAUSED_TO_READY:
|
||||||
videotestsrc->timestamp_offset = 0;
|
videotestsrc->timestamp_offset = 0;
|
||||||
|
videotestsrc->running_time = 0;
|
||||||
videotestsrc->n_frames = 0;
|
videotestsrc->n_frames = 0;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_READY_TO_NULL:
|
case GST_STATE_READY_TO_NULL:
|
||||||
|
@ -411,8 +412,7 @@ gst_videotestsrc_src_query (GstPad * pad,
|
||||||
case GST_QUERY_POSITION:
|
case GST_QUERY_POSITION:
|
||||||
switch (*format) {
|
switch (*format) {
|
||||||
case GST_FORMAT_TIME:
|
case GST_FORMAT_TIME:
|
||||||
*value =
|
*value = videotestsrc->running_time;
|
||||||
videotestsrc->n_frames * GST_SECOND / (double) videotestsrc->rate;
|
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
break;
|
break;
|
||||||
case GST_FORMAT_DEFAULT: /* frames */
|
case GST_FORMAT_DEFAULT: /* frames */
|
||||||
|
@ -447,6 +447,7 @@ gst_videotestsrc_handle_src_event (GstPad * pad, GstEvent * event)
|
||||||
gboolean res = TRUE;
|
gboolean res = TRUE;
|
||||||
GstVideotestsrc *videotestsrc;
|
GstVideotestsrc *videotestsrc;
|
||||||
gint64 new_n_frames;
|
gint64 new_n_frames;
|
||||||
|
GstClockTime new_running_time;
|
||||||
|
|
||||||
g_return_val_if_fail (pad != NULL, FALSE);
|
g_return_val_if_fail (pad != NULL, FALSE);
|
||||||
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
|
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
|
||||||
|
@ -457,8 +458,11 @@ gst_videotestsrc_handle_src_event (GstPad * pad, GstEvent * event)
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_SEEK:
|
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)) {
|
switch (GST_EVENT_SEEK_FORMAT (event)) {
|
||||||
case GST_FORMAT_TIME:
|
case GST_FORMAT_TIME:
|
||||||
|
new_running_time = GST_EVENT_SEEK_OFFSET (event);
|
||||||
new_n_frames =
|
new_n_frames =
|
||||||
GST_EVENT_SEEK_OFFSET (event) * (double) videotestsrc->rate /
|
GST_EVENT_SEEK_OFFSET (event) * (double) videotestsrc->rate /
|
||||||
GST_SECOND;
|
GST_SECOND;
|
||||||
|
@ -467,6 +471,8 @@ gst_videotestsrc_handle_src_event (GstPad * pad, GstEvent * event)
|
||||||
break;
|
break;
|
||||||
case GST_FORMAT_DEFAULT:
|
case GST_FORMAT_DEFAULT:
|
||||||
new_n_frames = GST_EVENT_SEEK_OFFSET (event);
|
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_start_frame = -1;
|
||||||
videotestsrc->segment_end_frame = -1;
|
videotestsrc->segment_end_frame = -1;
|
||||||
break;
|
break;
|
||||||
|
@ -576,16 +582,16 @@ gst_videotestsrc_get (GstPad * pad)
|
||||||
videotestsrc->width, videotestsrc->height);
|
videotestsrc->width, videotestsrc->height);
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (buf) = videotestsrc->timestamp_offset +
|
GST_BUFFER_TIMESTAMP (buf) = videotestsrc->timestamp_offset +
|
||||||
(videotestsrc->n_frames * GST_SECOND) / (double) videotestsrc->rate;
|
videotestsrc->running_time;
|
||||||
videotestsrc->n_frames++;
|
GST_BUFFER_DURATION (buf) = GST_SECOND / (double) videotestsrc->rate;
|
||||||
if (videotestsrc->sync) {
|
if (videotestsrc->sync) {
|
||||||
/* FIXME this is not correct if we do QoS */
|
/* FIXME this is not correct if we do QoS */
|
||||||
if (videotestsrc->clock) {
|
if (videotestsrc->clock) {
|
||||||
gst_element_wait (GST_ELEMENT (videotestsrc), GST_BUFFER_TIMESTAMP (buf));
|
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);
|
return GST_DATA (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue