summaryrefslogtreecommitdiff
path: root/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst-libs/gst/adaptivedemux/gstadaptivedemux.c')
-rw-r--r--gst-libs/gst/adaptivedemux/gstadaptivedemux.c76
1 files changed, 45 insertions, 31 deletions
diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
index 5e8a9ff4c..e2eb2cd94 100644
--- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
+++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
@@ -108,11 +108,12 @@ threads that use only the manifest_lock and not the api_lock. These threads run
one of the following functions: gst_adaptive_demux_stream_download_loop,
gst_adaptive_demux_updates_loop, _src_chain, _src_event. In order to guarantee
that all operations during an API call are not impacted by other writes, the
-above mentioned functions must check a cancelled flag every time they reacquire
-the manifest_lock. If the flag is set, they must exit immediately, without
-performing any changes on the shared data. In this way, an API call (eg seek
-request) can set the cancel flag before releasing the manifest_lock and be sure
-that the demux object and its streams are not changed by anybody else.
+above mentioned functions must check a possible cancel reason every time
+they reacquire the manifest_lock. If the flag is set, they must exit
+immediately, without performing any changes on the shared data.
+In this way, an API call (eg seek request) can set the cancel flag before
+releasing the manifest_lock and be sure that the demux object and its streams
+are not changed by anybody else.
*/
#ifdef HAVE_CONFIG_H
@@ -710,6 +711,7 @@ gst_adaptive_demux_sink_event (GstPad * pad, GstObject * parent,
}
if (demux->next_streams) {
+ GST_ERROR ("NEXT STREAMS EVENT");
gst_adaptive_demux_prepare_streams (demux,
gst_adaptive_demux_is_live (demux));
gst_adaptive_demux_start_tasks (demux, TRUE);
@@ -1240,11 +1242,11 @@ gst_adaptive_demux_expose_streams (GstAdaptiveDemux * demux)
GST_MANIFEST_UNLOCK (demux);
- GST_DEBUG_OBJECT (pad, "Pushing EOS");
+ GST_ERROR_OBJECT (pad, "Pushing EOS");
gst_pad_push_event (pad, gst_event_ref (eos));
gst_pad_set_active (pad, FALSE);
- GST_LOG_OBJECT (pad, "Removing stream");
+ GST_ERROR_OBJECT (pad, "Removing stream");
gst_element_remove_pad (GST_ELEMENT (demux), pad);
GST_MANIFEST_LOCK (demux);
@@ -1262,10 +1264,11 @@ gst_adaptive_demux_expose_streams (GstAdaptiveDemux * demux)
* Even if it doesn't do that, we will change its state later in
* gst_adaptive_demux_stop_tasks.
*/
- GST_LOG_OBJECT (stream, "Marking stream as cancelled");
+ GST_ERROR_OBJECT (stream, "Marking stream as cancelled");
gst_task_stop (stream->download_task);
g_mutex_lock (&stream->fragment_download_lock);
- stream->cancelled = TRUE;
+ GST_ERROR ("CANCELLING EXPOSING STREAMS");
+ stream->cancelled = GST_ADAPTIVE_DEMUX_CANCEL_SWITCH;
g_cond_signal (&stream->fragment_download_cond);
g_mutex_unlock (&stream->fragment_download_lock);
}
@@ -1368,7 +1371,7 @@ gst_adaptive_demux_stream_free (GstAdaptiveDemuxStream * stream)
gst_task_stop (stream->download_task);
g_mutex_lock (&stream->fragment_download_lock);
- stream->cancelled = TRUE;
+ stream->cancelled = GST_ADAPTIVE_DEMUX_CANCEL_STOP;
g_cond_signal (&stream->fragment_download_cond);
g_mutex_unlock (&stream->fragment_download_lock);
}
@@ -2009,7 +2012,7 @@ gst_adaptive_demux_start_tasks (GstAdaptiveDemux * demux,
if (!start_preroll_streams) {
g_mutex_lock (&stream->fragment_download_lock);
- stream->cancelled = FALSE;
+ stream->cancelled = GST_ADAPTIVE_DEMUX_NO_CANCEL;
g_mutex_unlock (&stream->fragment_download_lock);
}
@@ -2076,7 +2079,7 @@ gst_adaptive_demux_stop_tasks (GstAdaptiveDemux * demux, gboolean stop_updates)
GstAdaptiveDemuxStream *stream = iter->data;
g_mutex_lock (&stream->fragment_download_lock);
- stream->cancelled = TRUE;
+ stream->cancelled = GST_ADAPTIVE_DEMUX_CANCEL_STOP;
gst_task_stop (stream->download_task);
g_cond_signal (&stream->fragment_download_cond);
g_mutex_unlock (&stream->fragment_download_lock);
@@ -2293,7 +2296,7 @@ gst_adaptive_demux_handle_preroll (GstAdaptiveDemux * demux,
if (demux->priv->preroll_pending == 0) {
/* That was the last one, time to release all streams
* and expose them */
- GST_DEBUG_OBJECT (demux, "All streams prerolled. exposing");
+ GST_ERROR_OBJECT (demux, "All streams prerolled. exposing");
gst_adaptive_demux_expose_streams (demux);
g_cond_broadcast (&demux->priv->preroll_cond);
}
@@ -2374,6 +2377,7 @@ gst_adaptive_demux_stream_push_buffer (GstAdaptiveDemuxStream * stream,
}
if (stream->do_block) {
+ GST_ERROR ("DO BLOCK");
g_mutex_lock (&demux->priv->preroll_lock);
@@ -2828,7 +2832,7 @@ gst_adaptive_demux_stream_wait_manifest_update (GstAdaptiveDemux * demux,
* us to download in the playlist or the playlist
* became non-live */
while (TRUE) {
- GST_DEBUG_OBJECT (demux, "No fragment left but live playlist, wait a bit");
+ GST_ERROR_OBJECT (demux, "No fragment left but live playlist, wait a bit");
/* get the manifest_update_lock while still holding the manifest_lock.
* This will prevent other threads to signal the condition (they will need
@@ -2859,20 +2863,22 @@ gst_adaptive_demux_stream_wait_manifest_update (GstAdaptiveDemux * demux,
/* Got a new fragment or not live anymore? */
if (gst_adaptive_demux_stream_update_fragment_info (demux, stream) ==
GST_FLOW_OK) {
- GST_DEBUG_OBJECT (demux, "new fragment available, "
+ GST_ERROR_OBJECT (demux, "new fragment available, "
"not waiting for manifest update");
ret = TRUE;
break;
}
if (!gst_adaptive_demux_is_live (demux)) {
- GST_DEBUG_OBJECT (demux, "Not live anymore, "
+ GST_ERROR_OBJECT (demux, "Not live anymore, "
"not waiting for manifest update");
ret = FALSE;
break;
}
+
+ GST_ERROR ("NOTHING HAPPENS, FEIJOADA");
}
- GST_DEBUG_OBJECT (demux, "Retrying now");
+ GST_ERROR_OBJECT (demux, "Retrying now %d", ret);
return ret;
}
@@ -3322,7 +3328,7 @@ gst_adaptive_demux_stream_download_fragment (GstAdaptiveDemuxStream * stream)
stream->last_ret = GST_FLOW_OK;
stream->first_fragment_buffer = TRUE;
- GST_DEBUG_OBJECT (stream->pad, "Downloading %s%s%s",
+ GST_ERROR_OBJECT (stream->pad, "Downloading %s%s%s",
stream->fragment.uri ? "FRAGMENT " : "",
stream->fragment.header_uri ? "HEADER " : "",
stream->fragment.index_uri ? "INDEX" : "");
@@ -3778,6 +3784,10 @@ gst_adaptive_demux_stream_download_loop (GstAdaptiveDemuxStream * stream)
goto end;
}
gst_task_stop (stream->download_task);
+ if (stream->cancelled == GST_ADAPTIVE_DEMUX_CANCEL_SWITCH) {
+ GST_ERROR ("GOTO END");
+ goto end;
+ }
} else {
gst_task_stop (stream->download_task);
if (gst_adaptive_demux_combine_flows (demux) == GST_FLOW_EOS) {
@@ -3971,7 +3981,7 @@ gst_adaptive_demux_updates_loop (GstAdaptiveDemux * demux)
GstFlowReturn ret = GST_FLOW_OK;
/* Wait here until we should do the next update or we're cancelled */
- GST_DEBUG_OBJECT (demux, "Wait for next playlist update");
+ GST_ERROR_OBJECT (demux, "Wait for next playlist update");
GST_MANIFEST_UNLOCK (demux);
@@ -3980,9 +3990,11 @@ gst_adaptive_demux_updates_loop (GstAdaptiveDemux * demux)
g_mutex_unlock (&demux->priv->updates_timed_lock);
goto quit;
}
+ GST_ERROR ("WAIT UNTIL %" G_GUINT64_FORMAT " - %" G_GINT64_FORMAT,
+ (guint64) next_update, klass->get_manifest_update_interval (demux));
gst_adaptive_demux_wait_until (demux->realtime_clock,
- &demux->priv->updates_timed_cond,
- &demux->priv->updates_timed_lock, next_update);
+ &demux->priv->updates_timed_cond, &demux->priv->updates_timed_lock,
+ next_update);
g_mutex_unlock (&demux->priv->updates_timed_lock);
g_mutex_lock (&demux->priv->updates_timed_lock);
@@ -3994,10 +4006,12 @@ gst_adaptive_demux_updates_loop (GstAdaptiveDemux * demux)
GST_MANIFEST_LOCK (demux);
- GST_DEBUG_OBJECT (demux, "Updating playlist");
+ GST_ERROR_OBJECT (demux, "Updating playlist");
ret = gst_adaptive_demux_update_manifest (demux);
+ GST_ERROR_OBJECT (demux, "Update result: %d %s", ret,
+ gst_flow_get_name (ret));
if (ret == GST_FLOW_EOS) {
} else if (ret != GST_FLOW_OK) {
/* update_failed_count is used only here, no need to protect it */
@@ -4016,7 +4030,7 @@ gst_adaptive_demux_updates_loop (GstAdaptiveDemux * demux)
goto end;
}
} else {
- GST_DEBUG_OBJECT (demux, "Updated playlist successfully");
+ GST_ERROR_OBJECT (demux, "Updated playlist successfully");
demux->priv->update_failed_count = 0;
next_update =
gst_adaptive_demux_get_monotonic_time (demux) +
@@ -4201,6 +4215,7 @@ gst_adaptive_demux_stream_advance_fragment_unlocked (GstAdaptiveDemux * demux,
GST_TIME_AS_USECONDS (gst_adaptive_demux_get_monotonic_time (demux));
if (ret == GST_FLOW_OK) {
+ GST_ERROR ("ADVANCE FRAGMENT SELECT BITRATE");
if (gst_adaptive_demux_stream_select_bitrate (demux, stream,
gst_adaptive_demux_stream_update_current_bitrate (demux, stream))) {
stream->need_header = TRUE;
@@ -4221,14 +4236,13 @@ gst_adaptive_demux_stream_advance_fragment_unlocked (GstAdaptiveDemux * demux,
GstAdaptiveDemuxStream *other = iter->data;
if (other != stream) {
g_mutex_lock (&other->fragment_download_lock);
- can_expose &= (other->cancelled == TRUE
- || other->download_finished == TRUE);
+ can_expose &= (other->cancelled || other->download_finished == TRUE);
g_mutex_unlock (&other->fragment_download_lock);
}
}
if (can_expose) {
- GST_DEBUG_OBJECT (demux, "Subclass wants new pads "
+ GST_ERROR_OBJECT (demux, "Subclass wants new pads "
"to do bitrate switching");
gst_adaptive_demux_prepare_streams (demux, FALSE);
gst_adaptive_demux_start_tasks (demux, TRUE);
@@ -4269,19 +4283,19 @@ gst_adaptive_demux_stream_update_fragment_info (GstAdaptiveDemux * demux,
stream->fragment.bitrate = 0;
stream->fragment.finished = FALSE;
- GST_LOG_OBJECT (stream->pad, "position %" GST_TIME_FORMAT,
+ GST_ERROR_OBJECT (stream->pad, "position %" GST_TIME_FORMAT,
GST_TIME_ARGS (stream->segment.position));
ret = klass->stream_update_fragment_info (stream);
- GST_LOG_OBJECT (stream->pad, "ret:%s uri:%s", gst_flow_get_name (ret),
+ GST_ERROR_OBJECT (stream->pad, "ret:%s uri:%s", gst_flow_get_name (ret),
stream->fragment.uri);
if (ret == GST_FLOW_OK) {
- GST_LOG_OBJECT (stream->pad,
+ GST_ERROR_OBJECT (stream->pad,
"timestamp %" GST_TIME_FORMAT " duration:%" GST_TIME_FORMAT,
GST_TIME_ARGS (stream->fragment.timestamp),
GST_TIME_ARGS (stream->fragment.duration));
- GST_LOG_OBJECT (stream->pad,
+ GST_ERROR_OBJECT (stream->pad,
"range start:%" G_GUINT64_FORMAT " end:%" G_GUINT64_FORMAT,
stream->fragment.range_start, stream->fragment.range_end);
}
@@ -4422,7 +4436,7 @@ gst_adaptive_demux_advance_period (GstAdaptiveDemux * demux)
g_return_if_fail (klass->advance_period != NULL);
- GST_DEBUG_OBJECT (demux, "Advancing to next period");
+ GST_ERROR_OBJECT (demux, "Advancing to next period");
klass->advance_period (demux);
gst_adaptive_demux_prepare_streams (demux, FALSE);
gst_adaptive_demux_start_tasks (demux, TRUE);