validate: Gracefully handle absence of TAG on streams

Summary: And do not segfault when it happens!

Reviewers: Mathieu_Du

Differential Revision: http://phabricator.freedesktop.org/D99
This commit is contained in:
Thibault Saunier 2015-04-16 13:40:08 +02:00
parent adbe811175
commit 5d6fcb5727
2 changed files with 49 additions and 9 deletions

View file

@ -162,11 +162,13 @@ serialize_filenode (GstMediaDescriptorWriter * writer)
STR_APPEND1 ("</streams>"); STR_APPEND1 ("</streams>");
tagsnode = filenode->tags; tagsnode = filenode->tags;
STR_APPEND1 (tagsnode->str_open); if (tagsnode) {
for (tmp2 = tagsnode->tags; tmp2; tmp2 = tmp2->next) { STR_APPEND1 (tagsnode->str_open);
STR_APPEND2 (((TagNode *) tmp2->data)->str_open); for (tmp2 = tagsnode->tags; tmp2; tmp2 = tmp2->next) {
STR_APPEND2 (((TagNode *) tmp2->data)->str_open);
}
STR_APPEND1 (tagsnode->str_close);
} }
STR_APPEND1 (tagsnode->str_close);
g_string_append (res, filenode->str_close); g_string_append (res, filenode->str_close);
@ -467,8 +469,8 @@ _run_frame_analisis (GstMediaDescriptorWriter * writer,
writer->priv->pipeline = gst_pipeline_new ("frame-analisis"); writer->priv->pipeline = gst_pipeline_new ("frame-analisis");
monitor = monitor =
gst_validate_monitor_factory_create (GST_OBJECT_CAST (writer->priv-> gst_validate_monitor_factory_create (GST_OBJECT_CAST (writer->
pipeline), runner, NULL); 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);

View file

@ -215,10 +215,48 @@ compare_tags (GstMediaDescriptor * ref, StreamNode * rstream,
TagsNode *rtags, *ctags; TagsNode *rtags, *ctags;
rtags = rstream->tags; rtags = rstream->tags;
if (rtags == NULL)
return 1;
ctags = cstream->tags; ctags = cstream->tags;
if (rtags == NULL && ctags)
return 1;
else if (!rtags && ctags) {
GList *taglist;
GString *all_tags = g_string_new (NULL);
for (taglist = ctags->tags; taglist; taglist = taglist->next) {
gchar *stags =
gst_tag_list_to_string (((TagNode *) taglist->data)->taglist);
g_string_append_printf (all_tags, "%s\n", stags);
g_free (stags);
}
GST_VALIDATE_REPORT (ref, FILE_TAG_DETECTION_INCORRECT,
"Reference descriptor for stream %s has NO tags"
" but tags found: %s", all_tags->str);
g_string_free (all_tags, TRUE);
return 0;
} else if (rtags && !ctags) {
GList *taglist;
GString *all_tags = g_string_new (NULL);
for (taglist = rtags->tags; taglist; taglist = taglist->next) {
gchar *stags =
gst_tag_list_to_string (((TagNode *) taglist->data)->taglist);
g_string_append_printf (all_tags, "%s\n", stags);
g_free (stags);
}
GST_VALIDATE_REPORT (ref, FILE_TAG_DETECTION_INCORRECT,
"Reference descriptor for stream %s has tags:\n %s\n"
" but NO tags found on the stream");
g_string_free (all_tags, TRUE);
return 0;
}
for (rtag_list = rtags->tags; rtag_list; rtag_list = rtag_list->next) { for (rtag_list = rtags->tags; rtag_list; rtag_list = rtag_list->next) {
rtag = rtag_list->data; rtag = rtag_list->data;
found = FALSE; found = FALSE;