should print out the same checksum as
md5sum music.mp3
+
+If the pipeline contains an md5sink element, gst-md5sum will query it
+for the md5sum at the end of pipeline iteration.
-The pipeline should be incomplete, that is, a final sink element
-should be omitted, so that gst\-md5sum can connect the pipeline to
-an md5sink element.
+If it doesn't contain an md5sink element, gst-md5sum will automatically
+connect an md5sink to the right hand side of the given pipeline.
See the man page for gst\-launch or the GStreamer docuementation for
more information on how to create a PARTIAL\-PIPELINE\-DESCRIPTION.
.BR gst\-launch (1)
.SH "AUTHOR"
The GStreamer team at http://gstreamer.net/
+***************
+*** 16,24 ****
+
+ md5sum music.mp3
+
+ The pipeline should be incomplete, that is, a final sink element
+- should be omitted, so that gst\-md5sum can connect the pipeline to
+- an md5sink element.
+
+ See the man page for gst\-launch or the GStreamer docuementation for
+ more information on how to create a PARTIAL\-PIPELINE\-DESCRIPTION.
+--- 16,27 ----
+
+ md5sum music.mp3
+
++ If the pipeline contains an md5sink element, gst-md5sum will query it
++ for the md5sum at the end of pipeline iteration.
++
++ If it doesn't contain an md5sink element, gst-md5sum will automatically
++ connect an md5sink to the right hand side of the given pipeline.
+ The pipeline should be incomplete, that is, a final sink element
+
+ See the man page for gst\-launch or the GStreamer docuementation for
+ more information on how to create a PARTIAL\-PIPELINE\-DESCRIPTION.
POPT_TABLEEND
};
- GstElement *pipeline;
+ GstElement *pipeline = NULL;
gchar **argvn;
GError *error = NULL;
GstElement *md5sink;
setlocale (LC_ALL, "");
gst_init_with_popt_table (&argc, &argv, options);
-
- /* make a null-terminated version of argv with ! md5sink appended
- * ! is stored in argvn[argc - 1], md5sink in argvn[argc],
- * NULL pointer in argvn[argc + 1] */
- argvn = g_new0 (char *, argc + 2);
+
+ /* make a parseable argvn array */
+ argvn = g_new0 (char *, argc);
memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
- argvn[argc - 1] = g_strdup_printf ("!");
- argvn[argc] = g_strdup_printf ("md5sink");
+ /* Check if we have an element already that is called md5sink0
+ in the pipeline; if not, add one */
pipeline = (GstElement*) gst_parse_launchv ((const gchar**) argvn, &error);
+ if (!pipeline) {
+ if (error)
+ {
+ g_warning ("pipeline could not be constructed: %s\n", error->message);
+ g_error_free (error);
+ }
+ else
+ g_warning ("pipeline could not be constructed\n");
+ return 1;
+ }
+
+ md5sink = gst_bin_get_by_name (GST_BIN (pipeline), "md5sink0");
+ if (md5sink == NULL)
+ {
+ g_print ("adding an md5sink element to the pipeline\n");
+ /* make a null-terminated version of argv with ! md5sink appended
+ * ! is stored in argvn[argc - 1], md5sink in argvn[argc],
+ * NULL pointer in argvn[argc + 1] */
+ g_free (argvn);
+ argvn = g_new0 (char *, argc + 2);
+ memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
+ argvn[argc - 1] = g_strdup_printf ("!");
+ argvn[argc] = g_strdup_printf ("md5sink");
+ pipeline = (GstElement*) gst_parse_launchv ((const gchar**) argvn, &error);
+ }
if (!pipeline) {
if (error)