mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
adaptivedemux2: Handle early SEEKING query
No pads are present yet, but we can still answer the query Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3914>
This commit is contained in:
parent
597b684cd6
commit
4b5352570a
1 changed files with 88 additions and 75 deletions
|
@ -1427,38 +1427,6 @@ gst_adaptive_demux_reset (GstAdaptiveDemux * demux)
|
|||
gst_flow_combiner_reset (demux->priv->flowcombiner);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_adaptive_demux_query (GstElement * element, GstQuery * query)
|
||||
{
|
||||
GstAdaptiveDemux *demux = GST_ADAPTIVE_DEMUX_CAST (element);
|
||||
|
||||
GST_LOG_OBJECT (demux, "%" GST_PTR_FORMAT, query);
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_BUFFERING:
|
||||
{
|
||||
GstFormat format;
|
||||
gst_query_parse_buffering_range (query, &format, NULL, NULL, NULL);
|
||||
|
||||
if (!demux->output_period) {
|
||||
if (format != GST_FORMAT_TIME) {
|
||||
GST_DEBUG_OBJECT (demux,
|
||||
"No period setup yet, can't answer non-TIME buffering queries");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (demux,
|
||||
"No period setup yet, but still answering buffering query");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return GST_ELEMENT_CLASS (parent_class)->query (element, query);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_adaptive_demux_send_event (GstElement * element, GstEvent * event)
|
||||
{
|
||||
|
@ -2610,56 +2578,13 @@ gst_adaptive_demux_src_event (GstPad * pad, GstObject * parent,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_adaptive_demux_src_query (GstPad * pad, GstObject * parent,
|
||||
gst_adaptive_demux_handle_query_seeking (GstAdaptiveDemux * demux,
|
||||
GstQuery * query)
|
||||
{
|
||||
GstAdaptiveDemux *demux = GST_ADAPTIVE_DEMUX_CAST (parent);
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (query == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
||||
switch (query->type) {
|
||||
case GST_QUERY_DURATION:{
|
||||
GstFormat fmt;
|
||||
GstClockTime duration = GST_CLOCK_TIME_NONE;
|
||||
|
||||
gst_query_parse_duration (query, &fmt, NULL);
|
||||
|
||||
if (gst_adaptive_demux_is_live (demux)) {
|
||||
/* We are able to answer this query: the duration is unknown */
|
||||
gst_query_set_duration (query, fmt, -1);
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (fmt == GST_FORMAT_TIME
|
||||
&& g_atomic_int_get (&demux->priv->have_manifest)) {
|
||||
|
||||
GST_MANIFEST_LOCK (demux);
|
||||
duration = demux->priv->duration;
|
||||
GST_MANIFEST_UNLOCK (demux);
|
||||
|
||||
if (GST_CLOCK_TIME_IS_VALID (duration) && duration > 0) {
|
||||
gst_query_set_duration (query, GST_FORMAT_TIME, duration);
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GST_LOG_OBJECT (demux, "GST_QUERY_DURATION returns %s with duration %"
|
||||
GST_TIME_FORMAT, ret ? "TRUE" : "FALSE", GST_TIME_ARGS (duration));
|
||||
break;
|
||||
}
|
||||
case GST_QUERY_LATENCY:{
|
||||
gst_query_set_latency (query, FALSE, 0, -1);
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
case GST_QUERY_SEEKING:{
|
||||
GstFormat fmt;
|
||||
GstFormat fmt = GST_FORMAT_UNDEFINED;
|
||||
gint64 stop = -1;
|
||||
gint64 start = 0;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (!g_atomic_int_get (&demux->priv->have_manifest)) {
|
||||
GST_INFO_OBJECT (demux,
|
||||
|
@ -2697,8 +2622,58 @@ gst_adaptive_demux_src_query (GstPad * pad, GstObject * parent,
|
|||
GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
|
||||
}
|
||||
GST_MANIFEST_UNLOCK (demux);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_adaptive_demux_src_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query)
|
||||
{
|
||||
GstAdaptiveDemux *demux = GST_ADAPTIVE_DEMUX_CAST (parent);
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (query == NULL)
|
||||
return FALSE;
|
||||
|
||||
switch (query->type) {
|
||||
case GST_QUERY_DURATION:{
|
||||
GstFormat fmt;
|
||||
GstClockTime duration = GST_CLOCK_TIME_NONE;
|
||||
|
||||
gst_query_parse_duration (query, &fmt, NULL);
|
||||
|
||||
if (gst_adaptive_demux_is_live (demux)) {
|
||||
/* We are able to answer this query: the duration is unknown */
|
||||
gst_query_set_duration (query, fmt, -1);
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (fmt == GST_FORMAT_TIME
|
||||
&& g_atomic_int_get (&demux->priv->have_manifest)) {
|
||||
|
||||
GST_MANIFEST_LOCK (demux);
|
||||
duration = demux->priv->duration;
|
||||
GST_MANIFEST_UNLOCK (demux);
|
||||
|
||||
if (GST_CLOCK_TIME_IS_VALID (duration) && duration > 0) {
|
||||
gst_query_set_duration (query, GST_FORMAT_TIME, duration);
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GST_LOG_OBJECT (demux, "GST_QUERY_DURATION returns %s with duration %"
|
||||
GST_TIME_FORMAT, ret ? "TRUE" : "FALSE", GST_TIME_ARGS (duration));
|
||||
break;
|
||||
}
|
||||
case GST_QUERY_LATENCY:{
|
||||
gst_query_set_latency (query, FALSE, 0, -1);
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
case GST_QUERY_SEEKING:
|
||||
ret = gst_adaptive_demux_handle_query_seeking (demux, query);
|
||||
break;
|
||||
case GST_QUERY_URI:
|
||||
|
||||
GST_MANIFEST_LOCK (demux);
|
||||
|
@ -2728,6 +2703,44 @@ gst_adaptive_demux_src_query (GstPad * pad, GstObject * parent,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_adaptive_demux_query (GstElement * element, GstQuery * query)
|
||||
{
|
||||
GstAdaptiveDemux *demux = GST_ADAPTIVE_DEMUX_CAST (element);
|
||||
|
||||
GST_LOG_OBJECT (demux, "%" GST_PTR_FORMAT, query);
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_BUFFERING:
|
||||
{
|
||||
GstFormat format;
|
||||
gst_query_parse_buffering_range (query, &format, NULL, NULL, NULL);
|
||||
|
||||
if (!demux->output_period) {
|
||||
if (format != GST_FORMAT_TIME) {
|
||||
GST_DEBUG_OBJECT (demux,
|
||||
"No period setup yet, can't answer non-TIME buffering queries");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (demux,
|
||||
"No period setup yet, but still answering buffering query");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
case GST_QUERY_SEEKING:
|
||||
{
|
||||
/* Source pads might not be present early on which would cause the default
|
||||
* element query handler to fail, yet we can answer this query */
|
||||
return gst_adaptive_demux_handle_query_seeking (demux, query);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return GST_ELEMENT_CLASS (parent_class)->query (element, query);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_adaptive_demux_handle_lost_sync (GstAdaptiveDemux * demux)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue