diff --git a/gst/gstvalue.h b/gst/gstvalue.h index de01abc55a..2e15642e97 100644 --- a/gst/gstvalue.h +++ b/gst/gstvalue.h @@ -80,12 +80,14 @@ G_BEGIN_DECLS * Can be used together with #GST_FOURCC_FORMAT to properly output a * #guint32 fourcc value in a printf()-style text message. */ -#define GST_FOURCC_ARGS(fourcc) \ - ((gchar) ((fourcc) &0xff)), \ - ((gchar) (((fourcc)>>8 )&0xff)), \ - ((gchar) (((fourcc)>>16)&0xff)), \ - ((gchar) (((fourcc)>>24)&0xff)) +#define __GST_PRINT_CHAR(c) \ + g_ascii_isprint(c) ? (c) : '.' +#define GST_FOURCC_ARGS(fourcc) \ + __GST_PRINT_CHAR((fourcc) & 0xff), \ + __GST_PRINT_CHAR(((fourcc) >> 8) & 0xff), \ + __GST_PRINT_CHAR(((fourcc) >> 16) & 0xff), \ + __GST_PRINT_CHAR(((fourcc) >> 24) & 0xff) /** * GST_VALUE_HOLDS_INT_RANGE: * @x: the #GValue to check diff --git a/tests/check/gst/gstinfo.c b/tests/check/gst/gstinfo.c index cd9b018a88..595b90845e 100644 --- a/tests/check/gst/gstinfo.c +++ b/tests/check/gst/gstinfo.c @@ -332,6 +332,23 @@ GST_START_TEST (info_register_same_debug_category_twice) GST_END_TEST; #endif +GST_START_TEST (info_fourcc) +{ + gchar *res; + const gchar *cmp; + + cmp = "abcd"; + res = g_strdup_printf ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (0x64636261)); + fail_unless_equals_string (res, cmp); + g_free (res); + + cmp = ".bcd"; + res = g_strdup_printf ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (0x646362a9)); + fail_unless_equals_string (res, cmp); +} + +GST_END_TEST; + static Suite * gst_info_suite (void) { @@ -341,6 +358,7 @@ gst_info_suite (void) tcase_set_timeout (tc_chain, 30); suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, info_fourcc); #ifndef GST_DISABLE_GST_DEBUG tcase_add_test (tc_chain, info_segment_format_printf_extension); tcase_add_test (tc_chain, info_ptr_format_printf_extension);