mpegtsbase: Check before getting descriptors from structure

Avoids spurious warnings. Not having those descriptors is nothing
fatal, so check their presence before trying to get them.
This commit is contained in:
Edward Hervey 2012-05-26 14:11:24 +02:00
parent b6732a27d3
commit 7784c0d350

View file

@ -322,9 +322,13 @@ mpegts_get_descriptor_from_stream (MpegTSBaseStream * stream, guint8 tag)
guint8 *retval = NULL; guint8 *retval = NULL;
int i; int i;
if (!gst_structure_has_field_typed (stream_info, "descriptors",
G_TYPE_VALUE_ARRAY))
goto beach;
gst_structure_get (stream_info, "descriptors", G_TYPE_VALUE_ARRAY, gst_structure_get (stream_info, "descriptors", G_TYPE_VALUE_ARRAY,
&descriptors, NULL); &descriptors, NULL);
if (descriptors) {
for (i = 0; i < descriptors->n_values; i++) { for (i = 0; i < descriptors->n_values; i++) {
GValue *value = g_value_array_get_nth (descriptors, i); GValue *value = g_value_array_get_nth (descriptors, i);
GString *desc = g_value_dup_boxed (value); GString *desc = g_value_dup_boxed (value);
@ -336,7 +340,8 @@ mpegts_get_descriptor_from_stream (MpegTSBaseStream * stream, guint8 tag)
g_string_free (desc, FALSE); g_string_free (desc, FALSE);
} }
g_value_array_free (descriptors); g_value_array_free (descriptors);
}
beach:
return retval; return retval;
} }
@ -381,11 +386,16 @@ mpegts_get_descriptor_from_program (MpegTSBaseProgram * program, guint8 tag)
int i; int i;
if (G_UNLIKELY (program == NULL)) if (G_UNLIKELY (program == NULL))
return NULL; goto beach;
program_info = program->pmt_info; program_info = program->pmt_info;
if (!gst_structure_has_field_typed (program_info, "descriptors",
G_TYPE_VALUE_ARRAY))
goto beach;
gst_structure_get (program_info, "descriptors", G_TYPE_VALUE_ARRAY, gst_structure_get (program_info, "descriptors", G_TYPE_VALUE_ARRAY,
&descriptors, NULL); &descriptors, NULL);
if (descriptors) {
for (i = 0; i < descriptors->n_values; i++) { for (i = 0; i < descriptors->n_values; i++) {
GValue *value = g_value_array_get_nth (descriptors, i); GValue *value = g_value_array_get_nth (descriptors, i);
GString *desc = g_value_dup_boxed (value); GString *desc = g_value_dup_boxed (value);
@ -397,7 +407,8 @@ mpegts_get_descriptor_from_program (MpegTSBaseProgram * program, guint8 tag)
g_string_free (desc, FALSE); g_string_free (desc, FALSE);
} }
g_value_array_free (descriptors); g_value_array_free (descriptors);
}
beach:
return retval; return retval;
} }