kate: better error/debug reporting

Include text messages instead of error codes.
This commit is contained in:
Vincent Penquerc'h 2012-02-02 10:59:53 +00:00
parent fac39bae51
commit ea28347bb6
5 changed files with 106 additions and 31 deletions

View file

@ -618,7 +618,8 @@ gst_kate_enc_send_headers (GstKateEnc * ke)
break; break;
} else { } else {
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_headers: %d", ret)); ("Failed encoding headers: %s",
gst_kate_util_get_error_message (ret)));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
break; break;
} }
@ -676,7 +677,8 @@ gst_kate_enc_flush_headers (GstKateEnc * ke)
ke->headers_sent = TRUE; ke->headers_sent = TRUE;
GST_INFO_OBJECT (ke, "headers flushed"); GST_INFO_OBJECT (ke, "headers flushed");
} else { } else {
GST_WARNING_OBJECT (ke, "Failed to flush headers: %d", rflow); GST_WARNING_OBJECT (ke, "Failed to flush headers: %s",
gst_flow_get_name (rflow));
} }
} }
return rflow; return rflow;
@ -714,7 +716,8 @@ gst_kate_enc_generate_keepalive (GstKateEnc * ke, GstClockTime timestamp)
GST_DEBUG_OBJECT (ke, "keepalive at %f", t); GST_DEBUG_OBJECT (ke, "keepalive at %f", t);
ret = kate_encode_keepalive (&ke->k, t, &kp); ret = kate_encode_keepalive (&ke->k, t, &kp);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (ke, "Failed to encode keepalive packet: %d", ret); GST_WARNING_OBJECT (ke, "Failed to encode keepalive packet: %s",
gst_kate_util_get_error_message (ret));
} else { } else {
kate_int64_t granpos = kate_encode_get_granule (&ke->k); kate_int64_t granpos = kate_encode_get_granule (&ke->k);
GST_LOG_OBJECT (ke, "Keepalive packet encoded"); GST_LOG_OBJECT (ke, "Keepalive packet encoded");
@ -744,7 +747,8 @@ gst_kate_enc_flush_waiting (GstKateEnc * ke, GstClockTime now)
ret = kate_encode_text (&ke->k, t0, t1, "", 0, &kp); ret = kate_encode_text (&ke->k, t0, t1, "", 0, &kp);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_text: %d", ret)); ("Failed to encode text packet: %s",
gst_kate_util_get_error_message (ret)));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
rflow = rflow =
@ -755,7 +759,8 @@ gst_kate_enc_flush_waiting (GstKateEnc * ke, GstClockTime now)
if (rflow == GST_FLOW_OK) { if (rflow == GST_FLOW_OK) {
GST_DEBUG_OBJECT (ke, "delayed SPU packet flushed"); GST_DEBUG_OBJECT (ke, "delayed SPU packet flushed");
} else { } else {
GST_WARNING_OBJECT (ke, "Failed to flush delayed SPU packet: %d", rflow); GST_WARNING_OBJECT (ke, "Failed to flush delayed SPU packet: %s",
gst_flow_get_name (rflow));
} }
/* forget it even if we couldn't flush it */ /* forget it even if we couldn't flush it */
@ -865,19 +870,21 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf)
ret = kate_encode_set_region (&ke->k, kregion); ret = kate_encode_set_region (&ke->k, kregion);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_set_region: %d", ret)); ("Failed to set region: %s", gst_kate_util_get_error_message (ret)));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
ret = kate_encode_set_palette (&ke->k, kpalette); ret = kate_encode_set_palette (&ke->k, kpalette);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_set_palette: %d", ret)); ("Failed to set palette: %s",
gst_kate_util_get_error_message (ret)));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
ret = kate_encode_set_bitmap (&ke->k, kbitmap); ret = kate_encode_set_bitmap (&ke->k, kbitmap);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_set_bitmap: %d", ret)); ("Failed to set bitmap: %s",
gst_kate_util_get_error_message (ret)));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
/* Some SPUs have no hide time - so I'm going to delay the encoding of the packet /* Some SPUs have no hide time - so I'm going to delay the encoding of the packet
@ -899,7 +906,8 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf)
ret = kate_encode_text (&ke->k, t0, t1, "", 0, &kp); ret = kate_encode_text (&ke->k, t0, t1, "", 0, &kp);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("Failed to encode empty text for SPU buffer: %d", ret)); ("Failed to encode empty text for SPU buffer: %s",
gst_kate_util_get_error_message (ret)));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
rflow = rflow =
@ -941,7 +949,8 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf,
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_set_markup_type: %d", ret)); ("Failed to set markup type: %s",
gst_kate_util_get_error_message (ret)));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
const char *text = (const char *) GST_BUFFER_DATA (buf); const char *text = (const char *) GST_BUFFER_DATA (buf);
@ -960,7 +969,7 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf,
ret = kate_encode_text (&ke->k, t0, t1, text, text_len, &kp); ret = kate_encode_text (&ke->k, t0, t1, text, text_len, &kp);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("Failed to encode text: %d", ret)); ("Failed to encode text: %s", gst_kate_util_get_error_message (ret)));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
rflow = gst_kate_enc_chain_push_packet (ke, &kp, start, stop - start + 1); rflow = gst_kate_enc_chain_push_packet (ke, &kp, start, stop - start + 1);
@ -1044,21 +1053,23 @@ gst_kate_enc_change_state (GstElement * element, GstStateChange transition)
GST_DEBUG_OBJECT (ke, "READY -> PAUSED, initializing kate state"); GST_DEBUG_OBJECT (ke, "READY -> PAUSED, initializing kate state");
ret = kate_info_init (&ke->ki); ret = kate_info_init (&ke->ki);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (ke, "failed to initialize kate info structure: %d", GST_WARNING_OBJECT (ke, "failed to initialize kate info structure: %s",
ret); gst_kate_util_get_error_message (ret));
break; break;
} }
if (ke->language) { if (ke->language) {
ret = kate_info_set_language (&ke->ki, ke->language); ret = kate_info_set_language (&ke->ki, ke->language);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (ke, "failed to set stream language: %d", ret); GST_WARNING_OBJECT (ke, "failed to set stream language: %s",
gst_kate_util_get_error_message (ret));
break; break;
} }
} }
if (ke->category) { if (ke->category) {
ret = kate_info_set_category (&ke->ki, ke->category); ret = kate_info_set_category (&ke->ki, ke->category);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (ke, "failed to set stream category: %d", ret); GST_WARNING_OBJECT (ke, "failed to set stream category: %s",
gst_kate_util_get_error_message (ret));
break; break;
} }
} }
@ -1066,18 +1077,21 @@ gst_kate_enc_change_state (GstElement * element, GstStateChange transition)
kate_info_set_original_canvas_size (&ke->ki, kate_info_set_original_canvas_size (&ke->ki,
ke->original_canvas_width, ke->original_canvas_height); ke->original_canvas_width, ke->original_canvas_height);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (ke, "failed to set original canvas size: %d", ret); GST_WARNING_OBJECT (ke, "failed to set original canvas size: %s",
gst_kate_util_get_error_message (ret));
break; break;
} }
ret = kate_comment_init (&ke->kc); ret = kate_comment_init (&ke->kc);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (ke, GST_WARNING_OBJECT (ke,
"failed to initialize kate comment structure: %d", ret); "failed to initialize kate comment structure: %s",
gst_kate_util_get_error_message (ret));
break; break;
} }
ret = kate_encode_init (&ke->k, &ke->ki); ret = kate_encode_init (&ke->k, &ke->ki);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (ke, "failed to initialize kate state: %d", ret); GST_WARNING_OBJECT (ke, "failed to initialize kate state: %s",
gst_kate_util_get_error_message (ret));
break; break;
} }
ke->headers_sent = FALSE; ke->headers_sent = FALSE;
@ -1381,7 +1395,8 @@ gst_kate_enc_sink_event (GstPad * pad, GstEvent * event)
ret = kate_encode_finish (&ke->k, -1, &kp); ret = kate_encode_finish (&ke->k, -1, &kp);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (ke, "Failed to encode EOS packet: %d", ret); GST_WARNING_OBJECT (ke, "Failed to encode EOS packet: %s",
gst_kate_util_get_error_message (ret));
} else { } else {
kate_int64_t granpos = kate_encode_get_granule (&ke->k); kate_int64_t granpos = kate_encode_get_granule (&ke->k);
GST_LOG_OBJECT (ke, "EOS packet encoded"); GST_LOG_OBJECT (ke, "EOS packet encoded");

View file

@ -189,7 +189,8 @@ gst_kate_parse_push_headers (GstKateParse * parse)
GST_BUFFER_DATA (outbuf)); GST_BUFFER_DATA (outbuf));
ret = kate_decode_headerin (&parse->ki, &parse->kc, &packet); ret = kate_decode_headerin (&parse->ki, &parse->kc, &packet);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (parse, "kate_decode_headerin returned %d", ret); GST_WARNING_OBJECT (parse, "Failed to decode header: %s",
gst_kate_util_get_error_message (ret));
} }
/* takes ownership of outbuf, which was previously in parse->streamheader */ /* takes ownership of outbuf, which was previously in parse->streamheader */
outbuf_list = g_list_append (outbuf_list, outbuf); outbuf_list = g_list_append (outbuf_list, outbuf);

View file

@ -682,7 +682,8 @@ gst_kate_tiger_kate_chain (GstPad * pad, GstBuffer * buf)
ev->ki, ev->start_time, ev->end_time, ev->bitmap, ev->text); ev->ki, ev->start_time, ev->end_time, ev->bitmap, ev->text);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger, GST_WARNING_OBJECT (tiger,
"failed to add Kate event to Tiger renderer: %d", ret); "failed to add Kate event to Tiger renderer: %s",
gst_kate_util_get_error_message (ret));
} }
} }
} }
@ -824,7 +825,8 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf)
tiger->video_height, tiger->video_width * 4, tiger->swap_rgb); tiger->video_height, tiger->video_width * 4, tiger->swap_rgb);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger, GST_WARNING_OBJECT (tiger,
"Tiger renderer failed to set buffer to video frame: %d", ret); "Tiger renderer failed to set buffer to video frame: %s",
gst_kate_util_get_error_message (ret));
goto pass; goto pass;
} }
@ -834,7 +836,8 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf)
(long) tiger->video_segment.last_stop, t); (long) tiger->video_segment.last_stop, t);
ret = tiger_renderer_update (tiger->tr, t, 1); ret = tiger_renderer_update (tiger->tr, t, 1);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger, "Tiger renderer failed to update: %d", ret); GST_WARNING_OBJECT (tiger, "Tiger renderer failed to update: %s",
gst_kate_util_get_error_message (ret));
goto pass; goto pass;
} }
@ -866,13 +869,15 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf)
tiger->video_height, tiger->video_width * 4, tiger->swap_rgb); tiger->video_height, tiger->video_width * 4, tiger->swap_rgb);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger, GST_WARNING_OBJECT (tiger,
"Tiger renderer failed to set buffer to video frame: %d", ret); "Tiger renderer failed to set buffer to video frame: %s",
gst_kate_util_get_error_message (ret));
goto pass; goto pass;
} }
ret = tiger_renderer_render (tiger->tr); ret = tiger_renderer_render (tiger->tr);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger, GST_WARNING_OBJECT (tiger,
"Tiger renderer failed to render to video frame: %d", ret); "Tiger renderer failed to render to video frame: %s",
gst_kate_util_get_error_message (ret));
} else { } else {
GST_LOG_OBJECT (tiger, "Tiger renderer rendered on video frame at %f", t); GST_LOG_OBJECT (tiger, "Tiger renderer rendered on video frame at %f", t);
} }
@ -928,15 +933,16 @@ gst_kate_tiger_change_state (GstElement * element, GstStateChange transition)
if (tiger->decoder.initialized) { if (tiger->decoder.initialized) {
int ret = tiger_renderer_create (&tiger->tr); int ret = tiger_renderer_create (&tiger->tr);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (tiger, "failed to create tiger renderer: %d", GST_WARNING_OBJECT (tiger, "failed to create tiger renderer: %s",
ret); gst_kate_util_get_error_message (ret));
} else { } else {
ret = ret =
tiger_renderer_set_default_font_description (tiger->tr, tiger_renderer_set_default_font_description (tiger->tr,
tiger->default_font_desc); tiger->default_font_desc);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (tiger, GST_WARNING_OBJECT (tiger,
"failed to set tiger default font description: %d", ret); "failed to set tiger default font description: %s",
gst_kate_util_get_error_message (ret));
} }
gst_kate_tiger_update_default_font_color (tiger); gst_kate_tiger_update_default_font_color (tiger);
gst_kate_tiger_update_default_background_color (tiger); gst_kate_tiger_update_default_background_color (tiger);

View file

@ -24,6 +24,9 @@
#endif #endif
#include <string.h> #include <string.h>
#ifdef HAVE_TIGER
#include <tiger/tiger.h>
#endif
#include <gst/tag/tag.h> #include <gst/tag/tag.h>
#include "gstkate.h" #include "gstkate.h"
#include "gstkateutil.h" #include "gstkateutil.h"
@ -266,7 +269,8 @@ gst_kate_util_decoder_base_chain_kate_packet (GstKateDecoderBase * decoder,
ret = kate_high_decode_packetin (&decoder->k, &kp, ev); ret = kate_high_decode_packetin (&decoder->k, &kp, ev);
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_ELEMENT_ERROR (element, STREAM, DECODE, (NULL), GST_ELEMENT_ERROR (element, STREAM, DECODE, (NULL),
("Failed to decode Kate packet: %d", ret)); ("Failed to decode Kate packet: %s",
gst_kate_util_get_error_message (ret)));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -436,8 +440,8 @@ gst_kate_decoder_base_change_state (GstKateDecoderBase * decoder,
GST_DEBUG_OBJECT (element, "READY -> PAUSED, initializing kate state"); GST_DEBUG_OBJECT (element, "READY -> PAUSED, initializing kate state");
ret = kate_high_decode_init (&decoder->k); ret = kate_high_decode_init (&decoder->k);
if (ret < 0) { if (ret < 0) {
GST_WARNING_OBJECT (element, "failed to initialize kate state: %d", GST_WARNING_OBJECT (element, "failed to initialize kate state: %s",
ret); gst_kate_util_get_error_message (ret));
} }
gst_segment_init (&decoder->kate_segment, GST_FORMAT_UNDEFINED); gst_segment_init (&decoder->kate_segment, GST_FORMAT_UNDEFINED);
decoder->kate_flushing = FALSE; decoder->kate_flushing = FALSE;
@ -635,3 +639,50 @@ gst_kate_decoder_base_sink_query (GstKateDecoderBase * decoder,
return gst_pad_query_default (pad, query); return gst_pad_query_default (pad, query);
} }
} }
const char *
gst_kate_util_get_error_message (int ret)
{
switch (ret) {
case KATE_E_NOT_FOUND:
return "value not found";
case KATE_E_INVALID_PARAMETER:
return "invalid parameter";
case KATE_E_OUT_OF_MEMORY:
return "out of memory";
case KATE_E_BAD_GRANULE:
return "bad granule";
case KATE_E_INIT:
return "initialization error";
case KATE_E_BAD_PACKET:
return "bad packet";
case KATE_E_TEXT:
return "invalid/truncated text";
case KATE_E_LIMIT:
return "a limit was exceeded";
case KATE_E_VERSION:
return "unsupported bitstream version";
case KATE_E_NOT_KATE:
return "not a kate bitstream";
case KATE_E_BAD_TAG:
return "bad tag";
case KATE_E_IMPL:
return "not implemented";
#ifdef HAVE_TIGER
case TIGER_E_NOT_FOUND:
return "value not found";
case TIGER_E_INVALID_PARAMETER:
return "invalid parameter";
case TIGER_E_OUT_OF_MEMORY:
return "out of memory";
case TIGER_E_CAIRO_ERROR:
return "Cairo error";
case TIGER_E_BAD_SURFACE_TYPE:
return "bad surface type";
#endif
default:
return "unknown error";
}
}

View file

@ -98,6 +98,8 @@ extern gboolean gst_kate_decoder_base_sink_query (GstKateDecoderBase * decoder,
GstElement * element, GstPad * pad, GstQuery * query); GstElement * element, GstPad * pad, GstQuery * query);
extern gboolean extern gboolean
gst_kate_util_decoder_base_queue_event (GstKateDecoderBase * decoder, GstEvent * event, gboolean (*handler)(GstPad *, GstEvent *), GstPad * pad); gst_kate_util_decoder_base_queue_event (GstKateDecoderBase * decoder, GstEvent * event, gboolean (*handler)(GstPad *, GstEvent *), GstPad * pad);
extern const char *
gst_kate_util_get_error_message (int ret);
G_END_DECLS G_END_DECLS
#endif /* __GST_KATE_UTIL_H__ */ #endif /* __GST_KATE_UTIL_H__ */