2013-07-09 19:08:30 +00:00
|
|
|
/* GStreamer
|
2013-08-28 19:58:11 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Collabora Ltd.
|
|
|
|
* Author: Thiago Sousa Santos <thiago.sousa.santos@collabora.com>
|
|
|
|
*
|
|
|
|
* gst-validate.c - Validate CLI launch line tool
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
2013-07-09 19:08:30 +00:00
|
|
|
*/
|
|
|
|
|
2013-07-11 16:41:25 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2014-05-01 16:20:25 +00:00
|
|
|
#include <gio/gio.h>
|
2013-08-14 19:30:39 +00:00
|
|
|
#include <gst/validate/validate.h>
|
2013-08-27 14:56:33 +00:00
|
|
|
#include <gst/validate/gst-validate-scenario.h>
|
2014-05-01 16:19:50 +00:00
|
|
|
#include <gst/validate/gst-validate-utils.h>
|
2014-09-15 15:22:52 +00:00
|
|
|
#include <gst/validate/media-descriptor-parser.h>
|
2015-08-17 12:27:33 +00:00
|
|
|
#include <gst/validate/gst-validate-bin-monitor.h>
|
2016-07-28 07:47:42 +00:00
|
|
|
#include <gst/validate/gst-validate-pipeline-monitor.h>
|
2013-07-09 19:08:30 +00:00
|
|
|
|
2013-08-22 13:08:13 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
#include <glib-unix.h>
|
|
|
|
#endif
|
2015-07-29 07:42:48 +00:00
|
|
|
#include <locale.h> /* for LC_ALL */
|
2013-08-22 13:08:13 +00:00
|
|
|
|
2014-12-03 10:28:28 +00:00
|
|
|
static gint ret = 0;
|
2013-07-11 16:41:25 +00:00
|
|
|
static GMainLoop *mainloop;
|
|
|
|
static GstElement *pipeline;
|
2014-05-04 07:30:14 +00:00
|
|
|
static gboolean buffering = FALSE;
|
2013-07-11 16:41:25 +00:00
|
|
|
|
2014-01-24 10:29:50 +00:00
|
|
|
static gboolean is_live = FALSE;
|
|
|
|
|
2013-08-22 13:08:13 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
static gboolean
|
|
|
|
intr_handler (gpointer user_data)
|
|
|
|
{
|
|
|
|
g_print ("interrupt received.\n");
|
|
|
|
|
2014-07-19 07:48:17 +00:00
|
|
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
2016-10-07 04:42:02 +00:00
|
|
|
GST_DEBUG_GRAPH_SHOW_ALL, "gst-validate.interrupted");
|
2014-07-19 07:48:17 +00:00
|
|
|
|
2013-08-22 13:08:13 +00:00
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
|
2014-12-03 10:28:28 +00:00
|
|
|
ret = SIGINT;
|
|
|
|
|
|
|
|
/* Keep signal handler, it will be removed later anyway */
|
|
|
|
return TRUE;
|
2013-08-22 13:08:13 +00:00
|
|
|
}
|
|
|
|
#endif /* G_OS_UNIX */
|
|
|
|
|
2015-08-17 12:27:33 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GMainLoop *mainloop;
|
|
|
|
GstValidateMonitor *monitor;
|
|
|
|
} BusCallbackData;
|
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
static gboolean
|
|
|
|
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
|
|
|
{
|
2015-08-17 12:27:33 +00:00
|
|
|
BusCallbackData *bus_callback_data = data;
|
|
|
|
GMainLoop *loop = bus_callback_data->mainloop;
|
|
|
|
GstValidateMonitor *monitor = bus_callback_data->monitor;
|
2013-08-15 10:18:56 +00:00
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
switch (GST_MESSAGE_TYPE (message)) {
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
{
|
2014-06-18 13:57:14 +00:00
|
|
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
|
|
|
GST_DEBUG_GRAPH_SHOW_ALL, "gst-validate.error");
|
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
g_main_loop_quit (loop);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_MESSAGE_EOS:
|
2015-04-10 11:29:47 +00:00
|
|
|
if (!g_getenv ("GST_VALIDATE_SCENARIO"))
|
|
|
|
g_main_loop_quit (loop);
|
2013-08-22 14:51:49 +00:00
|
|
|
break;
|
2014-03-19 16:43:43 +00:00
|
|
|
case GST_MESSAGE_ASYNC_DONE:
|
|
|
|
break;
|
2013-08-22 14:51:49 +00:00
|
|
|
case GST_MESSAGE_STATE_CHANGED:
|
|
|
|
if (GST_MESSAGE_SRC (message) == GST_OBJECT (pipeline)) {
|
|
|
|
GstState oldstate, newstate, pending;
|
2014-06-18 13:57:14 +00:00
|
|
|
gchar *dump_name;
|
|
|
|
gchar *state_transition_name;
|
2013-08-22 14:51:49 +00:00
|
|
|
|
|
|
|
gst_message_parse_state_changed (message, &oldstate, &newstate,
|
|
|
|
&pending);
|
|
|
|
|
|
|
|
GST_DEBUG ("State changed (old: %s, new: %s, pending: %s)",
|
|
|
|
gst_element_state_get_name (oldstate),
|
|
|
|
gst_element_state_get_name (newstate),
|
|
|
|
gst_element_state_get_name (pending));
|
2014-01-24 10:29:50 +00:00
|
|
|
|
2014-06-18 13:57:14 +00:00
|
|
|
state_transition_name = g_strdup_printf ("%s_%s",
|
|
|
|
gst_element_state_get_name (oldstate),
|
|
|
|
gst_element_state_get_name (newstate));
|
|
|
|
dump_name = g_strconcat ("ges-launch.", state_transition_name, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
|
|
|
GST_DEBUG_GRAPH_SHOW_ALL, dump_name);
|
|
|
|
|
|
|
|
g_free (dump_name);
|
|
|
|
g_free (state_transition_name);
|
2013-08-22 14:51:49 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
break;
|
2014-06-18 13:57:14 +00:00
|
|
|
case GST_MESSAGE_WARNING:{
|
|
|
|
GError *gerror;
|
|
|
|
gchar *debug;
|
|
|
|
gchar *name = gst_object_get_path_string (GST_MESSAGE_SRC (message));
|
|
|
|
|
|
|
|
/* dump graph on warning */
|
|
|
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
|
|
|
GST_DEBUG_GRAPH_SHOW_ALL, "gst-validate.warning");
|
|
|
|
|
|
|
|
gst_message_parse_warning (message, &gerror, &debug);
|
|
|
|
g_print ("WARNING: from element %s: %s\n", name, gerror->message);
|
|
|
|
if (debug)
|
|
|
|
g_print ("Additional debug info:\n%s\n", debug);
|
|
|
|
|
2015-08-20 07:51:03 +00:00
|
|
|
g_clear_error (&gerror);
|
2014-06-18 13:57:14 +00:00
|
|
|
g_free (debug);
|
|
|
|
g_free (name);
|
|
|
|
break;
|
|
|
|
}
|
2014-01-24 10:29:50 +00:00
|
|
|
case GST_MESSAGE_BUFFERING:{
|
|
|
|
gint percent;
|
2014-08-14 08:57:33 +00:00
|
|
|
GstBufferingMode mode;
|
2015-08-17 12:27:33 +00:00
|
|
|
GstState target_state = GST_STATE_PLAYING;
|
|
|
|
gboolean monitor_handles_state;
|
|
|
|
|
|
|
|
g_object_get (monitor, "handles-states", &monitor_handles_state, NULL);
|
|
|
|
if (monitor_handles_state && GST_IS_VALIDATE_BIN_MONITOR (monitor)) {
|
|
|
|
target_state =
|
|
|
|
gst_validate_scenario_get_target_state (GST_VALIDATE_BIN_MONITOR
|
|
|
|
(monitor)->scenario);
|
|
|
|
}
|
2014-01-24 10:29:50 +00:00
|
|
|
|
|
|
|
if (!buffering) {
|
|
|
|
g_print ("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_message_parse_buffering (message, &percent);
|
2014-08-14 08:57:33 +00:00
|
|
|
gst_message_parse_buffering_stats (message, &mode, NULL, NULL, NULL);
|
2014-01-24 10:29:50 +00:00
|
|
|
|
|
|
|
/* no state management needed for live pipelines */
|
2014-08-14 08:57:33 +00:00
|
|
|
if (mode == GST_BUFFERING_LIVE) {
|
|
|
|
is_live = TRUE;
|
2014-01-24 10:29:50 +00:00
|
|
|
break;
|
2014-08-14 08:57:33 +00:00
|
|
|
}
|
2014-01-24 10:29:50 +00:00
|
|
|
|
|
|
|
if (percent == 100) {
|
|
|
|
/* a 100% message means buffering is done */
|
|
|
|
if (buffering) {
|
|
|
|
buffering = FALSE;
|
2015-08-17 12:27:33 +00:00
|
|
|
|
|
|
|
if (target_state == GST_STATE_PLAYING) {
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
}
|
2014-01-24 10:29:50 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* buffering... */
|
|
|
|
if (!buffering) {
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
|
|
|
buffering = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-04-23 11:24:23 +00:00
|
|
|
case GST_MESSAGE_REQUEST_STATE:
|
|
|
|
{
|
|
|
|
GstState state;
|
|
|
|
|
|
|
|
gst_message_parse_request_state (message, &state);
|
|
|
|
|
|
|
|
if (GST_IS_VALIDATE_SCENARIO (GST_MESSAGE_SRC (message))
|
2014-06-03 08:02:10 +00:00
|
|
|
&& state == GST_STATE_NULL) {
|
|
|
|
gst_validate_printf (GST_MESSAGE_SRC (message),
|
2017-02-17 21:23:34 +00:00
|
|
|
"State change request NULL, quiting mainloop\n");
|
2014-04-23 11:24:23 +00:00
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-07-09 19:08:30 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-05-01 16:19:50 +00:00
|
|
|
static gboolean
|
2014-06-03 08:02:10 +00:00
|
|
|
_is_playbin_pipeline (int argc, gchar ** argv)
|
2014-05-01 16:19:50 +00:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < argc; i++) {
|
2015-11-05 09:19:22 +00:00
|
|
|
if (g_ascii_strncasecmp (argv[i], "playbin", 7) == 0) {
|
2014-05-01 16:19:50 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-05-01 16:20:25 +00:00
|
|
|
static gboolean
|
2014-06-03 08:02:10 +00:00
|
|
|
_execute_set_subtitles (GstValidateScenario * scenario,
|
|
|
|
GstValidateAction * action)
|
2014-05-01 16:20:25 +00:00
|
|
|
{
|
|
|
|
gchar *uri, *fname;
|
2014-06-03 08:02:10 +00:00
|
|
|
GFile *tmpfile, *folder;
|
2014-05-01 16:20:25 +00:00
|
|
|
const gchar *subtitle_file, *subtitle_dir;
|
|
|
|
|
|
|
|
subtitle_file = gst_structure_get_string (action->structure, "subtitle-file");
|
|
|
|
g_return_val_if_fail (subtitle_file != NULL, FALSE);
|
|
|
|
subtitle_dir = gst_structure_get_string (action->structure, "subtitle-dir");
|
|
|
|
|
|
|
|
g_object_get (scenario->pipeline, "current-uri", &uri, NULL);
|
|
|
|
tmpfile = g_file_new_for_uri (uri);
|
|
|
|
g_free (uri);
|
|
|
|
|
|
|
|
folder = g_file_get_parent (tmpfile);
|
|
|
|
|
|
|
|
fname = g_strdup_printf ("%s%s%s%s",
|
|
|
|
subtitle_dir ? subtitle_dir : "",
|
|
|
|
subtitle_dir ? G_DIR_SEPARATOR_S : "",
|
2014-06-03 08:02:10 +00:00
|
|
|
g_file_get_basename (tmpfile), subtitle_file);
|
2014-05-01 16:20:25 +00:00
|
|
|
gst_object_unref (tmpfile);
|
|
|
|
|
|
|
|
tmpfile = g_file_get_child (folder, fname);
|
|
|
|
g_free (fname);
|
|
|
|
gst_object_unref (folder);
|
|
|
|
|
|
|
|
uri = g_file_get_uri (tmpfile);
|
2014-12-02 14:39:09 +00:00
|
|
|
gst_validate_printf (action, "Setting subtitle file to: %s", uri);
|
2014-05-01 16:20:25 +00:00
|
|
|
g_object_set (scenario->pipeline, "suburi", uri, NULL);
|
|
|
|
g_free (uri);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-08-13 21:07:47 +00:00
|
|
|
static void
|
|
|
|
_register_playbin_actions (void)
|
|
|
|
{
|
|
|
|
/* *INDENT-OFF* */
|
2014-10-12 18:07:58 +00:00
|
|
|
gst_validate_register_action_type ("set-subtitle", "validate-launcher", _execute_set_subtitles,
|
2014-08-14 08:55:44 +00:00
|
|
|
(GstValidateActionParameter []) {
|
|
|
|
{
|
|
|
|
.name = "subtitle-file",
|
|
|
|
.description = "Sets a subtitles file on a playbin pipeline",
|
|
|
|
.mandatory = TRUE,
|
|
|
|
.types = "string (A URI)",
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{NULL}
|
2014-08-13 21:07:47 +00:00
|
|
|
},
|
|
|
|
"Action to set a subtitle file to use on a playbin pipeline.\n"
|
2016-09-26 01:03:45 +00:00
|
|
|
"The subtitles file that will be used should be specified\n"
|
|
|
|
"relative to the playbin URI in use thanks to the subtitle-file\n"
|
2014-08-13 21:07:47 +00:00
|
|
|
"action property. You can also specify a folder with subtitle-dir\n"
|
2017-02-17 21:23:34 +00:00
|
|
|
"For example if playbin.uri='file://some/uri.mov'\n"
|
2014-08-13 21:07:47 +00:00
|
|
|
"and action looks like 'set-subtitle, subtitle-file=en.srt'\n"
|
|
|
|
"the subtitle URI will be set to 'file:///some/uri.mov.en.srt'\n",
|
|
|
|
FALSE);
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
}
|
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
int
|
|
|
|
main (int argc, gchar ** argv)
|
|
|
|
{
|
|
|
|
GError *err = NULL;
|
2015-03-20 11:15:03 +00:00
|
|
|
gchar *scenario = NULL, *configs = NULL, *media_info = NULL;
|
2014-08-13 21:07:47 +00:00
|
|
|
gboolean list_scenarios = FALSE, monitor_handles_state,
|
2014-10-12 17:46:39 +00:00
|
|
|
inspect_action_type = FALSE;
|
2014-01-24 10:29:50 +00:00
|
|
|
GstStateChangeReturn sret;
|
2014-02-11 23:28:18 +00:00
|
|
|
gchar *output_file = NULL;
|
2015-08-17 12:27:33 +00:00
|
|
|
BusCallbackData bus_callback_data = { 0, };
|
2014-01-24 10:29:50 +00:00
|
|
|
|
2013-08-22 13:08:13 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
guint signal_watch_id;
|
|
|
|
#endif
|
2013-09-05 08:34:42 +00:00
|
|
|
int rep_err;
|
2013-07-24 23:09:14 +00:00
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
GOptionEntry options[] = {
|
2015-08-11 01:05:41 +00:00
|
|
|
{"set-scenario", '\0', 0, G_OPTION_ARG_FILENAME, &scenario,
|
2014-09-04 21:54:34 +00:00
|
|
|
"Let you set a scenario, it can be a full path to a scenario file"
|
|
|
|
" or the name of the scenario (name of the file without the"
|
|
|
|
" '.scenario' extension).", NULL},
|
2013-08-16 10:50:51 +00:00
|
|
|
{"list-scenarios", 'l', 0, G_OPTION_ARG_NONE, &list_scenarios,
|
2016-06-09 20:57:33 +00:00
|
|
|
"List the available scenarios that can be run", NULL},
|
2014-02-11 23:28:18 +00:00
|
|
|
{"scenarios-defs-output-file", '\0', 0, G_OPTION_ARG_FILENAME,
|
2014-06-03 08:02:10 +00:00
|
|
|
&output_file, "The output file to store scenarios details. "
|
|
|
|
"Implies --list-scenario",
|
2014-02-11 23:28:18 +00:00
|
|
|
NULL},
|
2014-10-12 17:46:39 +00:00
|
|
|
{"inspect-action-type", 't', 0, G_OPTION_ARG_NONE, &inspect_action_type,
|
2016-06-09 20:57:33 +00:00
|
|
|
"Inspect the available action types with which to write scenarios."
|
|
|
|
" Specify an action type if you want its full description."
|
|
|
|
" If no action type is given the full list of available ones gets printed.",
|
2014-10-12 17:46:39 +00:00
|
|
|
NULL},
|
2015-07-29 07:42:48 +00:00
|
|
|
{"set-media-info", '\0', 0, G_OPTION_ARG_FILENAME, &media_info,
|
2014-09-15 15:22:52 +00:00
|
|
|
"Set a media_info XML file descriptor to share information about the"
|
|
|
|
" media file that will be reproduced.",
|
|
|
|
NULL},
|
2013-10-19 16:41:01 +00:00
|
|
|
{"set-configs", '\0', 0, G_OPTION_ARG_STRING, &configs,
|
2014-06-03 08:02:10 +00:00
|
|
|
"Let you set a config scenario, the scenario needs to be set as 'config"
|
|
|
|
"' you can specify a list of scenario separated by ':'"
|
2014-09-15 15:22:52 +00:00
|
|
|
" it will override the GST_VALIDATE_SCENARIO environment variable.",
|
2013-10-19 16:41:01 +00:00
|
|
|
NULL},
|
2013-07-09 19:08:30 +00:00
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
GOptionContext *ctx;
|
|
|
|
gchar **argvn;
|
2013-08-14 19:30:39 +00:00
|
|
|
GstValidateRunner *runner;
|
|
|
|
GstValidateMonitor *monitor;
|
2013-07-09 19:08:30 +00:00
|
|
|
GstBus *bus;
|
|
|
|
|
2015-07-29 07:42:48 +00:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
2013-08-14 21:04:23 +00:00
|
|
|
g_set_prgname ("gst-validate-" GST_API_VERSION);
|
|
|
|
ctx = g_option_context_new ("PIPELINE-DESCRIPTION");
|
2013-07-09 19:08:30 +00:00
|
|
|
g_option_context_add_main_entries (ctx, options, NULL);
|
2013-08-14 21:04:23 +00:00
|
|
|
g_option_context_set_summary (ctx, "Runs a gst launch pipeline, adding "
|
2013-08-21 15:11:40 +00:00
|
|
|
"monitors to it to identify issues in the used elements. At the end"
|
|
|
|
" a report will be printed. To view issues as they are created, set"
|
2014-05-02 20:53:51 +00:00
|
|
|
" the env var GST_DEBUG=validate:2 and it will be printed "
|
2013-08-21 15:11:40 +00:00
|
|
|
"as gstreamer debugging");
|
2013-07-09 19:08:30 +00:00
|
|
|
|
2013-07-23 15:14:26 +00:00
|
|
|
if (argc == 1) {
|
|
|
|
g_print ("%s", g_option_context_get_help (ctx, FALSE, NULL));
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
|
|
|
|
g_printerr ("Error initializing: %s\n", err->message);
|
|
|
|
g_option_context_free (ctx);
|
2014-08-20 13:29:26 +00:00
|
|
|
g_clear_error (&err);
|
2013-07-09 19:08:30 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2013-10-19 16:41:01 +00:00
|
|
|
if (scenario || configs) {
|
|
|
|
gchar *scenarios;
|
|
|
|
|
|
|
|
if (scenario)
|
|
|
|
scenarios = g_strjoin (":", scenario, configs, NULL);
|
|
|
|
else
|
|
|
|
scenarios = g_strdup (configs);
|
|
|
|
|
|
|
|
g_setenv ("GST_VALIDATE_SCENARIO", scenarios, TRUE);
|
|
|
|
g_free (scenarios);
|
2015-03-20 11:15:03 +00:00
|
|
|
g_free (scenario);
|
|
|
|
g_free (configs);
|
2013-07-24 23:09:14 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
gst_init (&argc, &argv);
|
2013-08-14 22:14:18 +00:00
|
|
|
gst_validate_init ();
|
2013-07-09 19:08:30 +00:00
|
|
|
|
2014-02-11 23:28:18 +00:00
|
|
|
if (list_scenarios || output_file) {
|
2014-04-30 07:35:03 +00:00
|
|
|
if (gst_validate_list_scenarios (argv + 1, argc - 1, output_file))
|
2014-06-03 08:02:10 +00:00
|
|
|
return 1;
|
2013-10-25 09:33:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-12 17:46:39 +00:00
|
|
|
if (inspect_action_type) {
|
2014-08-13 21:07:47 +00:00
|
|
|
_register_playbin_actions ();
|
|
|
|
|
2014-09-05 21:15:29 +00:00
|
|
|
if (!gst_validate_print_action_types ((const gchar **) argv + 1, argc - 1)) {
|
2014-08-13 21:07:47 +00:00
|
|
|
GST_ERROR ("Could not print all wanted types");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-09-04 14:50:11 +00:00
|
|
|
if (argc == 1) {
|
|
|
|
g_print ("%s", g_option_context_get_help (ctx, FALSE, NULL));
|
2013-09-30 13:51:21 +00:00
|
|
|
g_option_context_free (ctx);
|
2013-09-04 14:50:11 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
2013-08-16 10:50:51 +00:00
|
|
|
|
2013-09-30 13:51:21 +00:00
|
|
|
g_option_context_free (ctx);
|
|
|
|
|
2015-10-24 07:28:51 +00:00
|
|
|
runner = gst_validate_runner_new ();
|
|
|
|
if (!runner) {
|
|
|
|
g_printerr ("Failed to setup Validate Runner\n");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
/* Create the pipeline */
|
|
|
|
argvn = g_new0 (char *, argc);
|
|
|
|
memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
|
|
|
|
pipeline = (GstElement *) gst_parse_launchv ((const gchar **) argvn, &err);
|
|
|
|
g_free (argvn);
|
2013-09-04 15:05:48 +00:00
|
|
|
if (!pipeline) {
|
|
|
|
g_print ("Failed to create pipeline: %s\n",
|
|
|
|
err ? err->message : "unknown reason");
|
2014-08-20 13:29:26 +00:00
|
|
|
g_clear_error (&err);
|
2015-10-24 07:28:51 +00:00
|
|
|
g_object_unref (runner);
|
|
|
|
|
2013-09-04 15:05:48 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
2013-09-04 15:09:50 +00:00
|
|
|
if (!GST_IS_PIPELINE (pipeline)) {
|
|
|
|
GstElement *new_pipeline = gst_pipeline_new ("");
|
2014-04-22 07:42:57 +00:00
|
|
|
|
2013-09-04 15:09:50 +00:00
|
|
|
gst_bin_add (GST_BIN (new_pipeline), pipeline);
|
|
|
|
pipeline = new_pipeline;
|
|
|
|
}
|
2014-07-17 10:17:31 +00:00
|
|
|
|
|
|
|
gst_pipeline_set_auto_flush_bus (GST_PIPELINE (pipeline), FALSE);
|
2013-08-22 13:08:13 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
signal_watch_id =
|
|
|
|
g_unix_signal_add (SIGINT, (GSourceFunc) intr_handler, pipeline);
|
|
|
|
#endif
|
|
|
|
|
2016-05-17 08:03:26 +00:00
|
|
|
if (_is_playbin_pipeline (argc - 1, argv + 1)) {
|
2014-08-13 21:07:47 +00:00
|
|
|
_register_playbin_actions ();
|
2014-05-01 16:19:50 +00:00
|
|
|
}
|
|
|
|
|
2014-04-22 07:42:57 +00:00
|
|
|
monitor = gst_validate_monitor_factory_create (GST_OBJECT_CAST (pipeline),
|
|
|
|
runner, NULL);
|
|
|
|
gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor));
|
|
|
|
|
2014-09-15 15:22:52 +00:00
|
|
|
if (media_info) {
|
|
|
|
GError *err = NULL;
|
2016-01-22 19:14:16 +00:00
|
|
|
GstValidateMediaDescriptorParser *parser =
|
|
|
|
gst_validate_media_descriptor_parser_new (runner,
|
2014-09-15 15:22:52 +00:00
|
|
|
media_info, &err);
|
|
|
|
|
|
|
|
if (parser == NULL) {
|
|
|
|
GST_ERROR ("Could not use %s as a media-info file (error: %s)",
|
|
|
|
media_info, err ? err->message : "Unknown error");
|
|
|
|
|
2015-03-20 11:15:03 +00:00
|
|
|
g_free (media_info);
|
2014-09-15 15:22:52 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_validate_monitor_set_media_descriptor (monitor,
|
2016-01-22 19:14:16 +00:00
|
|
|
GST_VALIDATE_MEDIA_DESCRIPTOR (parser));
|
2014-09-15 15:22:52 +00:00
|
|
|
gst_object_unref (parser);
|
2015-03-20 11:15:03 +00:00
|
|
|
g_free (media_info);
|
2014-09-15 15:22:52 +00:00
|
|
|
}
|
|
|
|
|
2014-04-22 07:42:57 +00:00
|
|
|
mainloop = g_main_loop_new (NULL, FALSE);
|
2013-07-09 19:08:30 +00:00
|
|
|
bus = gst_element_get_bus (pipeline);
|
2013-08-15 10:18:56 +00:00
|
|
|
gst_bus_add_signal_watch (bus);
|
2015-08-17 12:27:33 +00:00
|
|
|
bus_callback_data.mainloop = mainloop;
|
|
|
|
bus_callback_data.monitor = monitor;
|
|
|
|
g_signal_connect (bus, "message", (GCallback) bus_callback,
|
|
|
|
&bus_callback_data);
|
2013-07-09 19:08:30 +00:00
|
|
|
|
2013-07-11 16:41:25 +00:00
|
|
|
g_print ("Starting pipeline\n");
|
2014-07-02 09:27:22 +00:00
|
|
|
g_object_get (monitor, "handles-states", &monitor_handles_state, NULL);
|
|
|
|
if (monitor_handles_state == FALSE) {
|
|
|
|
sret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
switch (sret) {
|
|
|
|
case GST_STATE_CHANGE_FAILURE:
|
|
|
|
/* ignore, we should get an error message posted on the bus */
|
|
|
|
g_print ("Pipeline failed to go to PLAYING state\n");
|
2014-07-22 01:01:27 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
2014-07-02 09:27:22 +00:00
|
|
|
ret = -1;
|
|
|
|
goto exit;
|
|
|
|
case GST_STATE_CHANGE_NO_PREROLL:
|
|
|
|
g_print ("Pipeline is live.\n");
|
|
|
|
is_live = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_ASYNC:
|
|
|
|
g_print ("Prerolling...\r");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_print ("Pipeline started\n");
|
|
|
|
} else {
|
|
|
|
g_print ("Letting scenario handle set state\n");
|
2013-08-26 23:31:22 +00:00
|
|
|
}
|
2013-08-21 15:11:40 +00:00
|
|
|
|
2013-07-09 19:08:30 +00:00
|
|
|
g_main_loop_run (mainloop);
|
2014-07-17 10:17:31 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
|
|
|
|
|
|
|
|
/* Clean the bus */
|
|
|
|
gst_bus_set_flushing (bus, TRUE);
|
2015-03-23 12:35:41 +00:00
|
|
|
gst_bus_remove_signal_watch (bus);
|
2014-07-17 10:17:31 +00:00
|
|
|
gst_object_unref (bus);
|
2013-07-09 19:08:30 +00:00
|
|
|
|
2015-05-27 11:18:33 +00:00
|
|
|
rep_err = gst_validate_runner_exit (runner, TRUE);
|
2014-01-10 17:00:27 +00:00
|
|
|
if (ret == 0) {
|
2013-09-05 08:34:42 +00:00
|
|
|
ret = rep_err;
|
2014-01-24 10:29:50 +00:00
|
|
|
if (rep_err != 0)
|
2017-02-16 21:30:06 +00:00
|
|
|
g_print ("Returning %d as errors were found\n", rep_err);
|
2014-01-10 17:00:27 +00:00
|
|
|
}
|
2013-07-09 19:08:30 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
g_main_loop_unref (mainloop);
|
2013-07-12 05:10:06 +00:00
|
|
|
g_object_unref (pipeline);
|
2014-01-13 08:41:16 +00:00
|
|
|
g_object_unref (runner);
|
2016-05-27 13:37:00 +00:00
|
|
|
gst_validate_reporter_purge_reports (GST_VALIDATE_REPORTER (monitor));
|
2014-01-13 08:41:16 +00:00
|
|
|
g_object_unref (monitor);
|
2014-08-20 13:29:26 +00:00
|
|
|
g_clear_error (&err);
|
2013-08-22 13:08:13 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
g_source_remove (signal_watch_id);
|
|
|
|
#endif
|
2013-08-19 18:13:10 +00:00
|
|
|
|
2014-06-19 11:03:48 +00:00
|
|
|
g_print ("\n=======> Test %s (Return value: %i)\n\n",
|
|
|
|
ret == 0 ? "PASSED" : "FAILED", ret);
|
2015-05-11 11:54:15 +00:00
|
|
|
|
|
|
|
gst_validate_deinit ();
|
2016-05-20 12:46:19 +00:00
|
|
|
gst_deinit ();
|
2013-08-19 18:13:10 +00:00
|
|
|
return ret;
|
2013-07-09 19:08:30 +00:00
|
|
|
}
|