mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
kate: better error/debug reporting
Include text messages instead of error codes.
This commit is contained in:
parent
fac39bae51
commit
ea28347bb6
5 changed files with 106 additions and 31 deletions
|
@ -618,7 +618,8 @@ gst_kate_enc_send_headers (GstKateEnc * ke)
|
|||
break;
|
||||
} else {
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -676,7 +677,8 @@ gst_kate_enc_flush_headers (GstKateEnc * ke)
|
|||
ke->headers_sent = TRUE;
|
||||
GST_INFO_OBJECT (ke, "headers flushed");
|
||||
} 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;
|
||||
|
@ -714,7 +716,8 @@ gst_kate_enc_generate_keepalive (GstKateEnc * ke, GstClockTime timestamp)
|
|||
GST_DEBUG_OBJECT (ke, "keepalive at %f", t);
|
||||
ret = kate_encode_keepalive (&ke->k, t, &kp);
|
||||
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 {
|
||||
kate_int64_t granpos = kate_encode_get_granule (&ke->k);
|
||||
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);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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;
|
||||
} else {
|
||||
rflow =
|
||||
|
@ -755,7 +759,8 @@ gst_kate_enc_flush_waiting (GstKateEnc * ke, GstClockTime now)
|
|||
if (rflow == GST_FLOW_OK) {
|
||||
GST_DEBUG_OBJECT (ke, "delayed SPU packet flushed");
|
||||
} 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 */
|
||||
|
@ -865,19 +870,21 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf)
|
|||
ret = kate_encode_set_region (&ke->k, kregion);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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;
|
||||
} else {
|
||||
ret = kate_encode_set_palette (&ke->k, kpalette);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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;
|
||||
} else {
|
||||
ret = kate_encode_set_bitmap (&ke->k, kbitmap);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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;
|
||||
} else {
|
||||
/* 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);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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;
|
||||
} else {
|
||||
rflow =
|
||||
|
@ -941,7 +949,8 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf,
|
|||
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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;
|
||||
} else {
|
||||
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);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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;
|
||||
} else {
|
||||
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");
|
||||
ret = kate_info_init (&ke->ki);
|
||||
if (ret < 0) {
|
||||
GST_WARNING_OBJECT (ke, "failed to initialize kate info structure: %d",
|
||||
ret);
|
||||
GST_WARNING_OBJECT (ke, "failed to initialize kate info structure: %s",
|
||||
gst_kate_util_get_error_message (ret));
|
||||
break;
|
||||
}
|
||||
if (ke->language) {
|
||||
ret = kate_info_set_language (&ke->ki, ke->language);
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (ke->category) {
|
||||
ret = kate_info_set_category (&ke->ki, ke->category);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1066,18 +1077,21 @@ gst_kate_enc_change_state (GstElement * element, GstStateChange transition)
|
|||
kate_info_set_original_canvas_size (&ke->ki,
|
||||
ke->original_canvas_width, ke->original_canvas_height);
|
||||
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;
|
||||
}
|
||||
ret = kate_comment_init (&ke->kc);
|
||||
if (ret < 0) {
|
||||
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;
|
||||
}
|
||||
ret = kate_encode_init (&ke->k, &ke->ki);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
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 {
|
||||
kate_int64_t granpos = kate_encode_get_granule (&ke->k);
|
||||
GST_LOG_OBJECT (ke, "EOS packet encoded");
|
||||
|
|
|
@ -189,7 +189,8 @@ gst_kate_parse_push_headers (GstKateParse * parse)
|
|||
GST_BUFFER_DATA (outbuf));
|
||||
ret = kate_decode_headerin (&parse->ki, &parse->kc, &packet);
|
||||
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 */
|
||||
outbuf_list = g_list_append (outbuf_list, outbuf);
|
||||
|
|
|
@ -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);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -834,7 +836,8 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf)
|
|||
(long) tiger->video_segment.last_stop, t);
|
||||
ret = tiger_renderer_update (tiger->tr, t, 1);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -866,13 +869,15 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf)
|
|||
tiger->video_height, tiger->video_width * 4, tiger->swap_rgb);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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;
|
||||
}
|
||||
ret = tiger_renderer_render (tiger->tr);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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 {
|
||||
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) {
|
||||
int ret = tiger_renderer_create (&tiger->tr);
|
||||
if (ret < 0) {
|
||||
GST_WARNING_OBJECT (tiger, "failed to create tiger renderer: %d",
|
||||
ret);
|
||||
GST_WARNING_OBJECT (tiger, "failed to create tiger renderer: %s",
|
||||
gst_kate_util_get_error_message (ret));
|
||||
} else {
|
||||
ret =
|
||||
tiger_renderer_set_default_font_description (tiger->tr,
|
||||
tiger->default_font_desc);
|
||||
if (ret < 0) {
|
||||
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_background_color (tiger);
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#ifdef HAVE_TIGER
|
||||
#include <tiger/tiger.h>
|
||||
#endif
|
||||
#include <gst/tag/tag.h>
|
||||
#include "gstkate.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);
|
||||
if (G_UNLIKELY (ret < 0)) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -436,8 +440,8 @@ gst_kate_decoder_base_change_state (GstKateDecoderBase * decoder,
|
|||
GST_DEBUG_OBJECT (element, "READY -> PAUSED, initializing kate state");
|
||||
ret = kate_high_decode_init (&decoder->k);
|
||||
if (ret < 0) {
|
||||
GST_WARNING_OBJECT (element, "failed to initialize kate state: %d",
|
||||
ret);
|
||||
GST_WARNING_OBJECT (element, "failed to initialize kate state: %s",
|
||||
gst_kate_util_get_error_message (ret));
|
||||
}
|
||||
gst_segment_init (&decoder->kate_segment, GST_FORMAT_UNDEFINED);
|
||||
decoder->kate_flushing = FALSE;
|
||||
|
@ -635,3 +639,50 @@ gst_kate_decoder_base_sink_query (GstKateDecoderBase * decoder,
|
|||
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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,8 @@ extern gboolean gst_kate_decoder_base_sink_query (GstKateDecoderBase * decoder,
|
|||
GstElement * element, GstPad * pad, GstQuery * query);
|
||||
extern gboolean
|
||||
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
|
||||
#endif /* __GST_KATE_UTIL_H__ */
|
||||
|
|
Loading…
Reference in a new issue