mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
mpegaudioparse: Provide SEEKING query handling.
Since SEEK event handling might perform some conversion from TIME to BYTES, do not let upstream fool application into (TIME) seeking not being possible.
This commit is contained in:
parent
d61498d842
commit
d950699d2e
1 changed files with 40 additions and 0 deletions
|
@ -1914,6 +1914,8 @@ mp3parse_src_query (GstPad * pad, GstQuery * query)
|
|||
|
||||
g_return_val_if_fail (mp3parse != NULL, FALSE);
|
||||
|
||||
GST_LOG_OBJECT (pad, "%s query", GST_QUERY_TYPE_NAME (query));
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_POSITION:
|
||||
gst_query_parse_position (query, &format, NULL);
|
||||
|
@ -1959,6 +1961,44 @@ mp3parse_src_query (GstPad * pad, GstQuery * query)
|
|||
res = TRUE;
|
||||
}
|
||||
break;
|
||||
case GST_QUERY_SEEKING:
|
||||
gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
|
||||
|
||||
/* does upstream handle ? */
|
||||
if ((peer = gst_pad_get_peer (mp3parse->sinkpad)) != NULL) {
|
||||
res = gst_pad_query (peer, query);
|
||||
gst_object_unref (peer);
|
||||
}
|
||||
/* we may be able to help if in TIME */
|
||||
if (format == GST_FORMAT_TIME) {
|
||||
gboolean seekable;
|
||||
|
||||
gst_query_parse_seeking (query, &format, &seekable, NULL, NULL);
|
||||
/* already OK if upstream takes care */
|
||||
if (res && !seekable) {
|
||||
gint64 pos;
|
||||
|
||||
seekable = TRUE;
|
||||
if (!mp3parse_total_time (mp3parse, &total) || total == -1) {
|
||||
seekable = FALSE;
|
||||
} else if (!mp3parse_time_to_bytepos (mp3parse, 0, &pos)) {
|
||||
seekable = FALSE;
|
||||
} else {
|
||||
GstQuery *q;
|
||||
|
||||
q = gst_query_new_seeking (GST_FORMAT_BYTES);
|
||||
if (!gst_pad_peer_query (mp3parse->sinkpad, q)) {
|
||||
seekable = FALSE;
|
||||
} else {
|
||||
gst_query_parse_seeking (q, &format, &seekable, NULL, NULL);
|
||||
}
|
||||
gst_query_unref (q);
|
||||
}
|
||||
gst_query_set_seeking (query, GST_FORMAT_TIME, seekable, 0, total);
|
||||
res = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
res = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue