Original commit message from CVS:
fixes #122059
This commit is contained in:
Thomas Vander Stichele 2003-09-11 22:42:13 +00:00
parent 2d2c02735a
commit d4e119ccb0
2 changed files with 37 additions and 11 deletions

View file

@ -16,9 +16,12 @@ 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.
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
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.

View file

@ -54,7 +54,7 @@ main (int argc, char *argv[])
POPT_TABLEEND
};
GstElement *pipeline;
GstElement *pipeline = NULL;
gchar **argvn;
GError *error = NULL;
GstElement *md5sink;
@ -63,16 +63,39 @@ main (int argc, char *argv[])
free (malloc (8)); /* -lefence */
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);
memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
argvn[argc - 1] = g_strdup_printf ("!");
argvn[argc] = g_strdup_printf ("md5sink");
/* make a parseable argvn array */
argvn = g_new0 (char *, argc);
memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
/* 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)