mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
ext/mad/gstmad.c: Add convert function for proper timestamp calculations.
Original commit message from CVS: * ext/mad/gstmad.c: (gst_mad_src_query), (gst_mad_sink_event), (gst_mad_chain): Add convert function for proper timestamp calculations. * gst/avi/gstavidemux.c: (gst_avi_demux_send_event), (gst_avi_demux_stream_header), (gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry), (gst_avi_demux_loop): Send out initial discont.
This commit is contained in:
parent
fa9e9d985a
commit
865cfa3a5c
2 changed files with 34 additions and 62 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2005-07-16 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* ext/mad/gstmad.c: (gst_mad_src_query), (gst_mad_sink_event),
|
||||||
|
(gst_mad_chain):
|
||||||
|
Add convert function for proper timestamp calculations.
|
||||||
|
|
||||||
|
* gst/avi/gstavidemux.c: (gst_avi_demux_send_event),
|
||||||
|
(gst_avi_demux_stream_header), (gst_avi_demux_handle_seek),
|
||||||
|
(gst_avi_demux_process_next_entry), (gst_avi_demux_loop):
|
||||||
|
Send out initial discont.
|
||||||
|
|
||||||
2005-07-15 Wim Taymans <wim@fluendo.com>
|
2005-07-15 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/level/gstlevel.c: (gst_level_transform):
|
* gst/level/gstlevel.c: (gst_level_transform):
|
||||||
|
|
|
@ -610,6 +610,19 @@ gst_mad_src_query (GstPad * pad, GstQuery * query)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GST_QUERY_CONVERT:
|
||||||
|
{
|
||||||
|
GstFormat src_fmt, dest_fmt;
|
||||||
|
gint64 src_val, dest_val;
|
||||||
|
|
||||||
|
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
|
||||||
|
if (!(res =
|
||||||
|
gst_mad_convert_src (pad, src_fmt, src_val, &dest_fmt,
|
||||||
|
&dest_val)))
|
||||||
|
goto error;
|
||||||
|
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
break;
|
break;
|
||||||
|
@ -913,80 +926,24 @@ static gboolean
|
||||||
gst_mad_sink_event (GstPad * pad, GstEvent * event)
|
gst_mad_sink_event (GstPad * pad, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstMad *mad = GST_MAD (GST_PAD_PARENT (pad));
|
GstMad *mad = GST_MAD (GST_PAD_PARENT (pad));
|
||||||
gint64 total;
|
gboolean result;
|
||||||
|
|
||||||
GST_DEBUG ("handling event %d", GST_EVENT_TYPE (event));
|
GST_DEBUG ("handling event %d", GST_EVENT_TYPE (event));
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_DISCONTINUOUS:
|
case GST_EVENT_DISCONTINUOUS:
|
||||||
{
|
|
||||||
gint n = GST_EVENT_DISCONT_OFFSET_LEN (event);
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
mad->total_samples = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
const GstFormat formats[] = { GST_FORMAT_BYTES, GST_FORMAT_TIME, 0 };
|
|
||||||
#if 0
|
|
||||||
formats = gst_pad_get_formats (pad);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gst_formats_contains (formats, GST_EVENT_DISCONT_OFFSET (event,
|
|
||||||
i).format)) {
|
|
||||||
gint64 start_value = GST_EVENT_DISCONT_OFFSET (event, i).start_value;
|
|
||||||
|
|
||||||
//gint64 end_value = GST_EVENT_DISCONT_OFFSET (event, i).end_value;
|
|
||||||
gint64 time;
|
|
||||||
GstFormat format;
|
|
||||||
GstEvent *discont;
|
|
||||||
|
|
||||||
/* see how long the input bytes take */
|
|
||||||
if (GST_EVENT_DISCONT_OFFSET (event, i).format != GST_FORMAT_TIME) {
|
|
||||||
format = GST_FORMAT_TIME;
|
|
||||||
if (!gst_mad_convert_sink (pad,
|
|
||||||
GST_EVENT_DISCONT_OFFSET (event, i).format,
|
|
||||||
start_value, &format, &time)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
time = start_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* for now, this is the best we can do to get the total number
|
|
||||||
* of samples. This is suboptimal because the incoming event
|
|
||||||
* might contain this information already (although I believe
|
|
||||||
* that this doesn't happen anywhere so far). */
|
|
||||||
format = GST_FORMAT_DEFAULT;
|
|
||||||
if (!gst_mad_convert_src (mad->srcpad,
|
|
||||||
GST_FORMAT_TIME, time, &format, &total)) {
|
|
||||||
GST_DEBUG ("Failed to convert time to total_samples");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
mad->total_samples = total;
|
|
||||||
|
|
||||||
if (GST_PAD_IS_USABLE (mad->srcpad)) {
|
|
||||||
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
|
|
||||||
time, NULL);
|
|
||||||
gst_pad_push_event (mad->srcpad, discont);
|
|
||||||
}
|
|
||||||
gst_event_unref (event);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GST_WARNING ("Failed to retrieve sample position");
|
|
||||||
/* this isn't really correct? */
|
/* this isn't really correct? */
|
||||||
gst_pad_event_default (pad, event);
|
result = gst_pad_push_event (mad->srcpad, event);
|
||||||
done:
|
|
||||||
mad->tempsize = 0;
|
mad->tempsize = 0;
|
||||||
/* we don't need to restart when we get here */
|
/* we don't need to restart when we get here */
|
||||||
mad->restart = FALSE;
|
mad->restart = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case GST_EVENT_EOS:
|
case GST_EVENT_EOS:
|
||||||
mad->caps_set = FALSE; /* could be a new stream */
|
mad->caps_set = FALSE; /* could be a new stream */
|
||||||
gst_pad_event_default (pad, event);
|
result = gst_pad_push_event (mad->srcpad, event);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
gst_pad_event_default (pad, event);
|
result = gst_pad_push_event (mad->srcpad, event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1226,13 +1183,13 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GstFlowReturn result = GST_FLOW_OK;
|
GstFlowReturn result = GST_FLOW_OK;
|
||||||
|
|
||||||
mad = GST_MAD (GST_PAD_PARENT (pad));
|
mad = GST_MAD (GST_PAD_PARENT (pad));
|
||||||
g_return_val_if_fail (GST_IS_MAD (mad), GST_FLOW_ERROR);
|
|
||||||
|
|
||||||
/* restarts happen on discontinuities, ie. seek, flush, PAUSED to PLAYING */
|
/* restarts happen on discontinuities, ie. seek, flush, PAUSED to PLAYING */
|
||||||
if (gst_mad_check_restart (mad))
|
if (gst_mad_check_restart (mad))
|
||||||
GST_DEBUG ("mad restarted");
|
GST_DEBUG ("mad restarted");
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
GST_DEBUG ("mad in timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
|
||||||
|
|
||||||
/* handle timestamps */
|
/* handle timestamps */
|
||||||
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
|
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
|
||||||
|
@ -1252,6 +1209,7 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
new_pts = TRUE;
|
new_pts = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GST_DEBUG ("last_ts %" GST_TIME_FORMAT, GST_TIME_ARGS (mad->last_ts));
|
||||||
|
|
||||||
/* handle data */
|
/* handle data */
|
||||||
data = GST_BUFFER_DATA (buffer);
|
data = GST_BUFFER_DATA (buffer);
|
||||||
|
@ -1478,6 +1436,9 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
|
|
||||||
outdata = (gint16 *) GST_BUFFER_DATA (outbuffer);
|
outdata = (gint16 *) GST_BUFFER_DATA (outbuffer);
|
||||||
|
|
||||||
|
GST_DEBUG ("mad out timestamp %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (time_offset));
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuffer) = time_offset;
|
GST_BUFFER_TIMESTAMP (outbuffer) = time_offset;
|
||||||
GST_BUFFER_DURATION (outbuffer) = time_duration;
|
GST_BUFFER_DURATION (outbuffer) = time_duration;
|
||||||
GST_BUFFER_OFFSET (outbuffer) = mad->total_samples;
|
GST_BUFFER_OFFSET (outbuffer) = mad->total_samples;
|
||||||
|
|
Loading…
Reference in a new issue