summaryrefslogtreecommitdiff
blob: bc592edfc4a755222171de84f13a94ac09c0fa67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 23dbd4ce2e492152a4d21b8043f353d224dfe355 Mon Sep 17 00:00:00 2001
From: Rob Clark <rob@ti.com>
Date: Sat, 13 Feb 2010 15:29:13 -0600
Subject: [PATCH 1/5] gst-launch: add --loop argument

if --loop is specified, automatically seek to beginning of clip when EOS is received
---
 tools/gst-launch.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/tools/gst-launch.c b/tools/gst-launch.c
index 10b7fae..d5b17f8 100644
--- a/tools/gst-launch.c
+++ b/tools/gst-launch.c
@@ -716,6 +716,7 @@ main (int argc, char *argv[])
   gboolean no_sigusr_handler = FALSE;
   gboolean trace = FALSE;
   gboolean eos_on_shutdown = FALSE;
+  gboolean loop = FALSE;
   gchar *savefile = NULL;
   gchar *exclude_args = NULL;
 #ifndef GST_DISABLE_OPTION_PARSING
@@ -742,6 +743,8 @@ main (int argc, char *argv[])
         N_("Print alloc trace (if enabled at compile time)"), NULL},
     {"eos-on-shutdown", 'e', 0, G_OPTION_ARG_NONE, &eos_on_shutdown,
         N_("Force EOS on sources before shutting the pipeline down"), NULL},
+    {"loop", 'l', 0, G_OPTION_ARG_NONE, &loop,
+        N_("Repeat clip in loop without rebuilding pipeline"), NULL},
     GST_TOOLS_GOPTION_VERSION,
     {NULL}
   };
@@ -926,7 +929,18 @@ main (int argc, char *argv[])
       }
 
       tfthen = gst_util_get_timestamp ();
-      caught_error = event_loop (pipeline, TRUE, GST_STATE_PLAYING);
+      do {
+        caught_error = event_loop (pipeline, TRUE, GST_STATE_PLAYING);
+        if (loop && (caught_error == ELR_NO_ERROR)) {
+          PRINT (_("Looping ...\n"));
+          gst_element_seek (pipeline, 1.0,
+              GST_FORMAT_TIME,
+              GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
+              GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
+        } else {
+          break;
+        }
+      } while (TRUE);
       if (eos_on_shutdown && caught_error == ELR_INTERRUPT) {
         PRINT (_("EOS on shutdown enabled -- Forcing EOS on the pipeline\n"));
         waiting_eos = TRUE;
-- 
1.7.1