mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-06 02:32:23 +00:00
examples: Add a looping feature to playlist example
Allows playing the timeline repeatedly a certain number of times
This commit is contained in:
parent
8193fe5b4c
commit
89b0739512
1 changed files with 17 additions and 3 deletions
|
@ -26,6 +26,10 @@
|
||||||
#include <ges/ges.h>
|
#include <ges/ges.h>
|
||||||
#include <gst/profile/gstprofile.h>
|
#include <gst/profile/gstprofile.h>
|
||||||
|
|
||||||
|
/* GLOBAL VARIABLE */
|
||||||
|
static guint repeat = 0;
|
||||||
|
GESTimelinePipeline *pipeline = NULL;
|
||||||
|
|
||||||
static GstEncodingProfile *
|
static GstEncodingProfile *
|
||||||
make_encoding_profile (gchar * audio, gchar * video, gchar * video_restriction,
|
make_encoding_profile (gchar * audio, gchar * video, gchar * video_restriction,
|
||||||
gchar * container)
|
gchar * container)
|
||||||
|
@ -109,8 +113,17 @@ bus_message_cb (GstBus * bus, GstMessage * message, GMainLoop * mainloop)
|
||||||
g_main_loop_quit (mainloop);
|
g_main_loop_quit (mainloop);
|
||||||
break;
|
break;
|
||||||
case GST_MESSAGE_EOS:
|
case GST_MESSAGE_EOS:
|
||||||
|
if (repeat > 0) {
|
||||||
|
g_print ("Looping again\n");
|
||||||
|
/* No need to change state before */
|
||||||
|
gst_element_seek_simple (GST_ELEMENT (pipeline), GST_FORMAT_TIME,
|
||||||
|
GST_SEEK_FLAG_FLUSH, 0);
|
||||||
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
||||||
|
repeat -= 1;
|
||||||
|
} else {
|
||||||
g_print ("Done\n");
|
g_print ("Done\n");
|
||||||
g_main_loop_quit (mainloop);
|
g_main_loop_quit (mainloop);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -143,10 +156,11 @@ main (int argc, gchar ** argv)
|
||||||
"Audio format", "<GstCaps>"},
|
"Audio format", "<GstCaps>"},
|
||||||
{"vrestriction", 'x', 0, G_OPTION_ARG_STRING, &video_restriction,
|
{"vrestriction", 'x', 0, G_OPTION_ARG_STRING, &video_restriction,
|
||||||
"Video restriction", "<GstCaps>"},
|
"Video restriction", "<GstCaps>"},
|
||||||
|
{"repeat", 't', 0, G_OPTION_ARG_INT, &repeat,
|
||||||
|
"Number of time to repeat timeline", NULL},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
GOptionContext *ctx;
|
GOptionContext *ctx;
|
||||||
GESTimelinePipeline *pipeline;
|
|
||||||
GMainLoop *mainloop;
|
GMainLoop *mainloop;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue