validate: Add a way to pass a MediaDescriptor around monitors

And add an option in gst-validate so that the user can define what
media descriptor file to use.

https://bugzilla.gnome.org/show_bug.cgi?id=736138
This commit is contained in:
Thibault Saunier 2014-09-15 17:22:52 +02:00 committed by Mathieu Duponchelle
parent c8a99218de
commit c5dfd9c8c8
5 changed files with 122 additions and 3 deletions

View file

@ -64,6 +64,22 @@ static void
_validate_bin_element_added (GstBin * bin, GstElement * pad, _validate_bin_element_added (GstBin * bin, GstElement * pad,
GstValidateBinMonitor * monitor); GstValidateBinMonitor * monitor);
static void
gst_validate_bin_set_media_descriptor (GstValidateMonitor * monitor,
GstMediaDescriptor * media_descriptor)
{
GList *tmp;
GST_VALIDATE_MONITOR_LOCK (monitor);
for (tmp = GST_VALIDATE_BIN_MONITOR_CAST (monitor)->element_monitors; tmp;
tmp = tmp->next)
gst_validate_monitor_set_media_descriptor (tmp->data, media_descriptor);
GST_VALIDATE_MONITOR_UNLOCK (monitor);
GST_VALIDATE_MONITOR_CLASS (parent_class)->set_media_descriptor (monitor,
media_descriptor);
}
static void static void
gst_validate_bin_monitor_set_property (GObject * object, guint prop_id, gst_validate_bin_monitor_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
@ -143,6 +159,8 @@ gst_validate_bin_monitor_class_init (GstValidateBinMonitorClass * klass)
FALSE, G_PARAM_READABLE)); FALSE, G_PARAM_READABLE));
validatemonitor_class->setup = gst_validate_bin_monitor_setup; validatemonitor_class->setup = gst_validate_bin_monitor_setup;
validatemonitor_class->set_media_descriptor =
gst_validate_bin_set_media_descriptor;
} }
static void static void

View file

@ -54,6 +54,49 @@ static void
_validate_element_pad_added (GstElement * element, GstPad * pad, _validate_element_pad_added (GstElement * element, GstPad * pad,
GstValidateElementMonitor * monitor); GstValidateElementMonitor * monitor);
static void
gst_validate_element_set_media_descriptor (GstValidateMonitor * monitor,
GstMediaDescriptor * media_descriptor)
{
gboolean done;
GstPad *pad;
GstValidateMonitor *pmonitor;
GstIterator *iterator;
iterator =
gst_element_iterate_pads (GST_ELEMENT (GST_VALIDATE_MONITOR_GET_OBJECT
(monitor)));
done = FALSE;
while (!done) {
GValue value = { 0, };
switch (gst_iterator_next (iterator, &value)) {
case GST_ITERATOR_OK:
pad = g_value_get_object (&value);
pmonitor = g_object_get_data ((GObject *) pad, "validate-monitor");
if (pmonitor)
gst_validate_monitor_set_media_descriptor (pmonitor,
media_descriptor);
g_value_reset (&value);
break;
case GST_ITERATOR_RESYNC:
/* TODO how to handle this? */
gst_iterator_resync (iterator);
break;
case GST_ITERATOR_ERROR:
done = TRUE;
break;
case GST_ITERATOR_DONE:
done = TRUE;
break;
}
}
gst_iterator_free (iterator);
}
static void static void
gst_validate_element_monitor_dispose (GObject * object) gst_validate_element_monitor_dispose (GObject * object)
{ {
@ -83,6 +126,8 @@ gst_validate_element_monitor_class_init (GstValidateElementMonitorClass * klass)
monitor_klass->setup = gst_validate_element_monitor_do_setup; monitor_klass->setup = gst_validate_element_monitor_do_setup;
monitor_klass->get_element = gst_validate_element_monitor_get_element; monitor_klass->get_element = gst_validate_element_monitor_get_element;
monitor_klass->set_media_descriptor =
gst_validate_element_set_media_descriptor;
} }
static void static void

View file

@ -99,6 +99,9 @@ gst_validate_monitor_dispose (GObject * object)
g_object_weak_unref (G_OBJECT (monitor->target), g_object_weak_unref (G_OBJECT (monitor->target),
(GWeakNotify) _target_freed_cb, monitor); (GWeakNotify) _target_freed_cb, monitor);
if (monitor->media_descriptor)
gst_object_unref (monitor->media_descriptor);
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
@ -151,6 +154,13 @@ gst_validate_monitor_constructor (GType type, guint n_construct_params,
(type, (type,
n_construct_params, n_construct_params,
construct_params)); construct_params));
if (monitor->parent) {
gst_validate_monitor_set_media_descriptor (monitor,
monitor->parent->media_descriptor);
}
gst_validate_monitor_setup (monitor); gst_validate_monitor_setup (monitor);
return (GObject *) monitor; return (GObject *) monitor;
} }
@ -360,3 +370,22 @@ gst_validate_monitor_get_property (GObject * object, guint prop_id,
break; break;
} }
} }
void
gst_validate_monitor_set_media_descriptor (GstValidateMonitor * monitor,
GstMediaDescriptor * media_descriptor)
{
GstValidateMonitorClass *klass = GST_VALIDATE_MONITOR_GET_CLASS (monitor);
GST_DEBUG_OBJECT (monitor->target, "Set media desc: %" GST_PTR_FORMAT,
media_descriptor);
if (monitor->media_descriptor)
gst_object_unref (monitor->media_descriptor);
if (media_descriptor)
gst_object_ref (media_descriptor);
monitor->media_descriptor = media_descriptor;
if (klass->set_media_descriptor)
klass->set_media_descriptor (monitor, media_descriptor);
}

View file

@ -32,6 +32,7 @@ typedef struct _GstValidateMonitorClass GstValidateMonitorClass;
#include <gst/validate/gst-validate-reporter.h> #include <gst/validate/gst-validate-reporter.h>
#include <gst/validate/gst-validate-runner.h> #include <gst/validate/gst-validate-runner.h>
#include <gst/validate/gst-validate-override.h> #include <gst/validate/gst-validate-override.h>
#include <gst/validate/media-descriptor-parser.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -90,6 +91,7 @@ struct _GstValidateMonitor {
GMutex overrides_mutex; GMutex overrides_mutex;
GQueue overrides; GQueue overrides;
GstMediaDescriptor *media_descriptor;
GstValidateReportingLevel level; GstValidateReportingLevel level;
@ -108,6 +110,8 @@ struct _GstValidateMonitorClass {
gboolean (* setup) (GstValidateMonitor * monitor); gboolean (* setup) (GstValidateMonitor * monitor);
GstElement *(* get_element) (GstValidateMonitor * monitor); GstElement *(* get_element) (GstValidateMonitor * monitor);
void (*set_media_descriptor) (GstValidateMonitor * monitor,
GstMediaDescriptor * media_descriptor);
}; };
/* normal GObject stuff */ /* normal GObject stuff */
@ -118,7 +122,8 @@ void gst_validate_monitor_attach_override (GstValidateMonitor * moni
GstElement * gst_validate_monitor_get_element (GstValidateMonitor * monitor); GstElement * gst_validate_monitor_get_element (GstValidateMonitor * monitor);
const gchar * gst_validate_monitor_get_element_name (GstValidateMonitor * monitor); const gchar * gst_validate_monitor_get_element_name (GstValidateMonitor * monitor);
void gst_validate_monitor_set_media_descriptor (GstValidateMonitor * monitor,
GstMediaDescriptor *media_descriptor);
G_END_DECLS G_END_DECLS
#endif /* __GST_VALIDATE_MONITOR_H__ */ #endif /* __GST_VALIDATE_MONITOR_H__ */

View file

@ -33,6 +33,7 @@
#include <gst/validate/validate.h> #include <gst/validate/validate.h>
#include <gst/validate/gst-validate-scenario.h> #include <gst/validate/gst-validate-scenario.h>
#include <gst/validate/gst-validate-utils.h> #include <gst/validate/gst-validate-utils.h>
#include <gst/validate/media-descriptor-parser.h>
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
#include <glib-unix.h> #include <glib-unix.h>
@ -365,7 +366,7 @@ int
main (int argc, gchar ** argv) main (int argc, gchar ** argv)
{ {
GError *err = NULL; GError *err = NULL;
const gchar *scenario = NULL, *configs = NULL; const gchar *scenario = NULL, *configs = NULL, *media_info = NULL;
gboolean list_scenarios = FALSE, monitor_handles_state, gboolean list_scenarios = FALSE, monitor_handles_state,
inspect_action_type = FALSE; inspect_action_type = FALSE;
GstStateChangeReturn sret; GstStateChangeReturn sret;
@ -393,10 +394,14 @@ main (int argc, gchar ** argv)
" if no parameter passed, it will list all avalaible action types" " if no parameter passed, it will list all avalaible action types"
" otherwize will print the full description of the wanted types", " otherwize will print the full description of the wanted types",
NULL}, NULL},
{"set-media-info", '\0', 0, G_OPTION_ARG_STRING, &media_info,
"Set a media_info XML file descriptor to share information about the"
" media file that will be reproduced.",
NULL},
{"set-configs", '\0', 0, G_OPTION_ARG_STRING, &configs, {"set-configs", '\0', 0, G_OPTION_ARG_STRING, &configs,
"Let you set a config scenario, the scenario needs to be set as 'config" "Let you set a config scenario, the scenario needs to be set as 'config"
"' you can specify a list of scenario separated by ':'" "' you can specify a list of scenario separated by ':'"
" it will override the GST_VALIDATE_SCENARIO environment variable,", " it will override the GST_VALIDATE_SCENARIO environment variable.",
NULL}, NULL},
{NULL} {NULL}
}; };
@ -505,6 +510,23 @@ main (int argc, gchar ** argv)
runner, NULL); runner, NULL);
gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor)); gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor));
if (media_info) {
GError *err = NULL;
GstMediaDescriptorParser *parser = gst_media_descriptor_parser_new (runner,
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");
exit (1);
}
gst_validate_monitor_set_media_descriptor (monitor,
GST_MEDIA_DESCRIPTOR (parser));
gst_object_unref (parser);
}
mainloop = g_main_loop_new (NULL, FALSE); mainloop = g_main_loop_new (NULL, FALSE);
bus = gst_element_get_bus (pipeline); bus = gst_element_get_bus (pipeline);
gst_bus_add_signal_watch (bus); gst_bus_add_signal_watch (bus);