mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 19:31:12 +00:00
Tutorial5: Fix live streams
Switching from PAUSED to PLAYING with a live stream returns ASYNC, not NO_PREROLL. It would reset the is_live state back to FALSE.
This commit is contained in:
parent
f106d6e264
commit
861f9c96a8
1 changed files with 7 additions and 4 deletions
|
@ -214,7 +214,7 @@ static void error_cb (GstBus *bus, GstMessage *msg, CustomData *data) {
|
|||
/* Called when the End Of the Stream is reached. Just move to the beginning of the media and pause. */
|
||||
static void eos_cb (GstBus *bus, GstMessage *msg, CustomData *data) {
|
||||
data->target_state = GST_STATE_PAUSED;
|
||||
data->is_live = (gst_element_set_state (data->pipeline, GST_STATE_PAUSED) == GST_STATE_CHANGE_NO_PREROLL);
|
||||
data->is_live |= (gst_element_set_state (data->pipeline, GST_STATE_PAUSED) == GST_STATE_CHANGE_NO_PREROLL);
|
||||
execute_seek (0, data);
|
||||
}
|
||||
|
||||
|
@ -292,6 +292,9 @@ static void state_changed_cb (GstBus *bus, GstMessage *msg, CustomData *data) {
|
|||
set_ui_message(message, data);
|
||||
g_free (message);
|
||||
|
||||
if (new_state == GST_STATE_NULL || new_state == GST_STATE_READY)
|
||||
data->is_live = FALSE;
|
||||
|
||||
/* The Ready to Paused state change is particularly interesting: */
|
||||
if (old_state == GST_STATE_READY && new_state == GST_STATE_PAUSED) {
|
||||
/* By now the sink already knows the media size */
|
||||
|
@ -442,7 +445,7 @@ void gst_native_set_uri (JNIEnv* env, jobject thiz, jstring uri) {
|
|||
g_object_set(data->pipeline, "uri", char_uri, NULL);
|
||||
(*env)->ReleaseStringUTFChars (env, uri, char_uri);
|
||||
data->duration = GST_CLOCK_TIME_NONE;
|
||||
data->is_live = (gst_element_set_state (data->pipeline, data->target_state) == GST_STATE_CHANGE_NO_PREROLL);
|
||||
data->is_live |= (gst_element_set_state (data->pipeline, data->target_state) == GST_STATE_CHANGE_NO_PREROLL);
|
||||
}
|
||||
|
||||
/* Set pipeline to PLAYING state */
|
||||
|
@ -451,7 +454,7 @@ static void gst_native_play (JNIEnv* env, jobject thiz) {
|
|||
if (!data) return;
|
||||
GST_DEBUG ("Setting state to PLAYING");
|
||||
data->target_state = GST_STATE_PLAYING;
|
||||
data->is_live = (gst_element_set_state (data->pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_NO_PREROLL);
|
||||
data->is_live |= (gst_element_set_state (data->pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_NO_PREROLL);
|
||||
}
|
||||
|
||||
/* Set pipeline to PAUSED state */
|
||||
|
@ -460,7 +463,7 @@ static void gst_native_pause (JNIEnv* env, jobject thiz) {
|
|||
if (!data) return;
|
||||
GST_DEBUG ("Setting state to PAUSED");
|
||||
data->target_state = GST_STATE_PAUSED;
|
||||
data->is_live = (gst_element_set_state (data->pipeline, GST_STATE_PAUSED) == GST_STATE_CHANGE_NO_PREROLL);
|
||||
data->is_live |= (gst_element_set_state (data->pipeline, GST_STATE_PAUSED) == GST_STATE_CHANGE_NO_PREROLL);
|
||||
}
|
||||
|
||||
/* Instruct the pipeline to seek to a different position */
|
||||
|
|
Loading…
Reference in a new issue