mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
validate: Improve perf when writing the XML file
+ Pass the file into gst-indent
This commit is contained in:
parent
dae0c4ef81
commit
92d390bc5d
1 changed files with 38 additions and 37 deletions
|
@ -28,9 +28,7 @@ G_DEFINE_TYPE (GstMediaDescriptorWriter,
|
||||||
gst_media_descriptor_writer, GST_TYPE_MEDIA_DESCRIPTOR);
|
gst_media_descriptor_writer, GST_TYPE_MEDIA_DESCRIPTOR);
|
||||||
|
|
||||||
#define STR_APPEND(arg, nb_white) \
|
#define STR_APPEND(arg, nb_white) \
|
||||||
tmpstr = res; \
|
g_string_append_printf (res, "%*s%s%s", (nb_white), " ", (arg), "\n"); \
|
||||||
res = g_strdup_printf ("%s%*s%s%s", res, (nb_white), " ", (arg), "\n"); \
|
|
||||||
g_free (tmpstr);
|
|
||||||
|
|
||||||
#define STR_APPEND0(arg) STR_APPEND((arg), 0)
|
#define STR_APPEND0(arg) STR_APPEND((arg), 0)
|
||||||
#define STR_APPEND1(arg) STR_APPEND((arg), 2)
|
#define STR_APPEND1(arg) STR_APPEND((arg), 2)
|
||||||
|
@ -64,8 +62,8 @@ finalize (GstMediaDescriptorWriter * writer)
|
||||||
if (writer->priv->parsers)
|
if (writer->priv->parsers)
|
||||||
gst_plugin_feature_list_free (writer->priv->parsers);
|
gst_plugin_feature_list_free (writer->priv->parsers);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_media_descriptor_writer_parent_class)->
|
G_OBJECT_CLASS (gst_media_descriptor_writer_parent_class)->finalize (G_OBJECT
|
||||||
finalize (G_OBJECT (writer));
|
(writer));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -120,12 +118,13 @@ static void
|
||||||
static gchar *
|
static gchar *
|
||||||
serialize_filenode (GstMediaDescriptorWriter * writer)
|
serialize_filenode (GstMediaDescriptorWriter * writer)
|
||||||
{
|
{
|
||||||
gchar *res, *tmpstr, *caps_str, *tmpnode;
|
GString *res;
|
||||||
|
gchar *tmpstr, *caps_str;
|
||||||
GList *tmp, *tmp2;
|
GList *tmp, *tmp2;
|
||||||
TagsNode *tagsnode;
|
TagsNode *tagsnode;
|
||||||
FileNode *filenode = ((GstMediaDescriptor *) writer)->filenode;
|
FileNode *filenode = ((GstMediaDescriptor *) writer)->filenode;
|
||||||
|
|
||||||
res = g_markup_printf_escaped ("<file duration=\"%" G_GUINT64_FORMAT
|
tmpstr = g_markup_printf_escaped ("<file duration=\"%" G_GUINT64_FORMAT
|
||||||
"\" frame-detection=\"%i\" uri=\"%s\" seekable=\"%s\">\n",
|
"\" frame-detection=\"%i\" uri=\"%s\" seekable=\"%s\">\n",
|
||||||
filenode->duration, filenode->frame_detection, filenode->uri,
|
filenode->duration, filenode->frame_detection, filenode->uri,
|
||||||
filenode->seekable ? "true" : "false");
|
filenode->seekable ? "true" : "false");
|
||||||
|
@ -135,11 +134,8 @@ serialize_filenode (GstMediaDescriptorWriter * writer)
|
||||||
else
|
else
|
||||||
caps_str = g_strdup ("");
|
caps_str = g_strdup ("");
|
||||||
|
|
||||||
tmpnode = g_strdup_printf ("<streams caps=\"%s\">", caps_str);
|
res = g_string_new (tmpstr);
|
||||||
STR_APPEND1 (tmpnode);
|
g_string_append_printf (res, " <streams caps=\"%s\">", caps_str);
|
||||||
g_free (caps_str);
|
|
||||||
g_free (tmpnode);
|
|
||||||
|
|
||||||
for (tmp = filenode->streams; tmp; tmp = tmp->next) {
|
for (tmp = filenode->streams; tmp; tmp = tmp->next) {
|
||||||
GList *tmp3;
|
GList *tmp3;
|
||||||
StreamNode *snode = ((StreamNode *) tmp->data);
|
StreamNode *snode = ((StreamNode *) tmp->data);
|
||||||
|
@ -168,11 +164,9 @@ serialize_filenode (GstMediaDescriptorWriter * writer)
|
||||||
}
|
}
|
||||||
STR_APPEND1 (tagsnode->str_close);
|
STR_APPEND1 (tagsnode->str_close);
|
||||||
|
|
||||||
tmpstr = res;
|
g_string_append (res, filenode->str_close);
|
||||||
res = g_strdup_printf ("%s%s", res, filenode->str_close);
|
|
||||||
g_free (tmpstr);
|
|
||||||
|
|
||||||
return res;
|
return g_string_free (res, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public methods */
|
/* Public methods */
|
||||||
|
@ -222,8 +216,7 @@ gst_media_descriptor_writer_add_stream (GstMediaDescriptorWriter * writer,
|
||||||
|
|
||||||
g_slice_free (StreamNode, snode);
|
g_slice_free (StreamNode, snode);
|
||||||
GST_VALIDATE_REPORT (writer, FILE_NO_STREAM_ID,
|
GST_VALIDATE_REPORT (writer, FILE_NO_STREAM_ID,
|
||||||
"Stream with caps: %s has no stream ID",
|
"Stream with caps: %s has no stream ID", capsstr);
|
||||||
capsstr);
|
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
g_free (capsstr);
|
g_free (capsstr);
|
||||||
|
|
||||||
|
@ -274,7 +267,8 @@ gst_media_descriptor_writer_add_stream (GstMediaDescriptorWriter * writer,
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadProbeReturn
|
static GstPadProbeReturn
|
||||||
_uridecodebin_probe (GstPad * pad, GstPadProbeInfo * info, GstMediaDescriptorWriter *writer)
|
_uridecodebin_probe (GstPad * pad, GstPadProbeInfo * info,
|
||||||
|
GstMediaDescriptorWriter * writer)
|
||||||
{
|
{
|
||||||
gst_media_descriptor_writer_add_frame (writer, pad, info->data);
|
gst_media_descriptor_writer_add_frame (writer, pad, info->data);
|
||||||
|
|
||||||
|
@ -282,7 +276,8 @@ _uridecodebin_probe (GstPad * pad, GstPadProbeInfo * info, GstMediaDescriptorWri
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_find_stream_id (GstPad *pad, GstEvent **event, GstMediaDescriptorWriter *writer)
|
_find_stream_id (GstPad * pad, GstEvent ** event,
|
||||||
|
GstMediaDescriptorWriter * writer)
|
||||||
{
|
{
|
||||||
if (GST_EVENT_TYPE (*event) == GST_EVENT_STREAM_START) {
|
if (GST_EVENT_TYPE (*event) == GST_EVENT_STREAM_START) {
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
|
@ -316,7 +311,7 @@ _find_stream_id (GstPad *pad, GstEvent **event, GstMediaDescriptorWriter *writer
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline GstElement *
|
static inline GstElement *
|
||||||
_get_parser (GstMediaDescriptorWriter *writer, GstPad *pad)
|
_get_parser (GstMediaDescriptorWriter * writer, GstPad * pad)
|
||||||
{
|
{
|
||||||
GList *parsers1, *parsers;
|
GList *parsers1, *parsers;
|
||||||
GstElement *parser = NULL;
|
GstElement *parser = NULL;
|
||||||
|
@ -353,7 +348,8 @@ beach:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pad_added_cb (GstElement * decodebin, GstPad * pad, GstMediaDescriptorWriter *writer)
|
pad_added_cb (GstElement * decodebin, GstPad * pad,
|
||||||
|
GstMediaDescriptorWriter * writer)
|
||||||
{
|
{
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
StreamNode *snode = NULL;
|
StreamNode *snode = NULL;
|
||||||
|
@ -379,10 +375,11 @@ pad_added_cb (GstElement * decodebin, GstPad * pad, GstMediaDescriptorWriter *wr
|
||||||
gst_bin_add (GST_BIN (writer->priv->pipeline), fakesink);
|
gst_bin_add (GST_BIN (writer->priv->pipeline), fakesink);
|
||||||
gst_element_sync_state_with_parent (fakesink);
|
gst_element_sync_state_with_parent (fakesink);
|
||||||
gst_pad_link (srcpad, sinkpad);
|
gst_pad_link (srcpad, sinkpad);
|
||||||
gst_pad_sticky_events_foreach (pad, (GstPadStickyEventsForeachFunction) _find_stream_id,
|
gst_pad_sticky_events_foreach (pad,
|
||||||
writer);
|
(GstPadStickyEventsForeachFunction) _find_stream_id, writer);
|
||||||
|
|
||||||
for (tmp = ((GstMediaDescriptor *) writer)->filenode->streams; tmp; tmp = tmp->next) {
|
for (tmp = ((GstMediaDescriptor *) writer)->filenode->streams; tmp;
|
||||||
|
tmp = tmp->next) {
|
||||||
snode = tmp->data;
|
snode = tmp->data;
|
||||||
if (snode->pad == pad && srcpad != pad) {
|
if (snode->pad == pad && srcpad != pad) {
|
||||||
gst_object_unref (pad);
|
gst_object_unref (pad);
|
||||||
|
@ -396,7 +393,8 @@ pad_added_cb (GstElement * decodebin, GstPad * pad, GstMediaDescriptorWriter *wr
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
bus_callback (GstBus * bus, GstMessage * message, GstMediaDescriptorWriter *writer)
|
bus_callback (GstBus * bus, GstMessage * message,
|
||||||
|
GstMediaDescriptorWriter * writer)
|
||||||
{
|
{
|
||||||
GMainLoop *loop = writer->priv->loop;
|
GMainLoop *loop = writer->priv->loop;
|
||||||
|
|
||||||
|
@ -454,8 +452,8 @@ bus_callback (GstBus * bus, GstMessage * message, GstMediaDescriptorWriter *writ
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_run_frame_analisis (GstMediaDescriptorWriter *writer, GstValidateRunner *runner,
|
_run_frame_analisis (GstMediaDescriptorWriter * writer,
|
||||||
const gchar *uri)
|
GstValidateRunner * runner, const gchar * uri)
|
||||||
{
|
{
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
GstStateChangeReturn sret;
|
GstStateChangeReturn sret;
|
||||||
|
@ -465,12 +463,14 @@ _run_frame_analisis (GstMediaDescriptorWriter *writer, GstValidateRunner *runner
|
||||||
|
|
||||||
writer->priv->pipeline = gst_pipeline_new ("frame-analisis");
|
writer->priv->pipeline = gst_pipeline_new ("frame-analisis");
|
||||||
|
|
||||||
monitor = gst_validate_monitor_factory_create (
|
monitor =
|
||||||
GST_OBJECT_CAST (writer->priv->pipeline), runner, NULL);
|
gst_validate_monitor_factory_create (GST_OBJECT_CAST (writer->priv->
|
||||||
|
pipeline), runner, NULL);
|
||||||
gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor));
|
gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor));
|
||||||
|
|
||||||
g_object_set (uridecodebin, "uri", uri, "caps", writer->priv->raw_caps, NULL);
|
g_object_set (uridecodebin, "uri", uri, "caps", writer->priv->raw_caps, NULL);
|
||||||
g_signal_connect (uridecodebin, "pad-added", G_CALLBACK (pad_added_cb), writer);
|
g_signal_connect (uridecodebin, "pad-added", G_CALLBACK (pad_added_cb),
|
||||||
|
writer);
|
||||||
gst_bin_add (GST_BIN (writer->priv->pipeline), uridecodebin);
|
gst_bin_add (GST_BIN (writer->priv->pipeline), uridecodebin);
|
||||||
|
|
||||||
writer->priv->loop = g_main_loop_new (NULL, FALSE);
|
writer->priv->loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
@ -545,8 +545,9 @@ gst_media_descriptor_writer_new_discover (GstValidateRunner * runner,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streams == NULL)
|
if (streams == NULL)
|
||||||
writer->priv->raw_caps = gst_caps_copy (((GstMediaDescriptor *) writer)->filenode->caps);
|
writer->priv->raw_caps =
|
||||||
gst_discoverer_stream_info_list_free(streams);
|
gst_caps_copy (((GstMediaDescriptor *) writer)->filenode->caps);
|
||||||
|
gst_discoverer_stream_info_list_free (streams);
|
||||||
|
|
||||||
|
|
||||||
if (full == TRUE)
|
if (full == TRUE)
|
||||||
|
@ -735,10 +736,10 @@ gst_media_descriptor_writer_add_frame (GstMediaDescriptorWriter
|
||||||
fnode->str_open =
|
fnode->str_open =
|
||||||
g_markup_printf_escaped (" <frame duration=\"%" G_GUINT64_FORMAT
|
g_markup_printf_escaped (" <frame duration=\"%" G_GUINT64_FORMAT
|
||||||
"\" id=\"%i\" is-keyframe=\"%i\" offset=\"%" G_GUINT64_FORMAT
|
"\" id=\"%i\" is-keyframe=\"%i\" offset=\"%" G_GUINT64_FORMAT
|
||||||
"\" offset-end=\"%" G_GUINT64_FORMAT "\" pts=\"%"
|
"\" offset-end=\"%" G_GUINT64_FORMAT "\" pts=\"%" G_GUINT64_FORMAT
|
||||||
G_GUINT64_FORMAT "\" dts=\"%" G_GUINT64_FORMAT "\" />",
|
"\" dts=\"%" G_GUINT64_FORMAT "\" />", fnode->duration, id,
|
||||||
fnode->duration, id, fnode->is_keyframe,
|
fnode->is_keyframe, fnode->offset, fnode->offset_end, fnode->pts,
|
||||||
fnode->offset, fnode->offset_end, fnode->pts, fnode->dts);
|
fnode->dts);
|
||||||
|
|
||||||
fnode->str_close = NULL;
|
fnode->str_close = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue