kate: use GST_ELEMENT_ERROR for error reporting

See #525743.
This commit is contained in:
Vincent Penquerc'h 2009-07-24 21:54:59 +01:00 committed by Tim-Philipp Müller
parent 2641cd9d94
commit aaed93e126
7 changed files with 55 additions and 39 deletions

View file

@ -74,8 +74,6 @@
* </refsect2> * </refsect2>
*/ */
/* FIXME: post appropriate GST_ELEMENT_ERROR when returning FLOW_ERROR */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
@ -298,7 +296,8 @@ gst_kate_dec_chain (GstPad * pad, GstBuffer * buf)
gst_flow_get_name (rflow)); gst_flow_get_name (rflow));
} }
} else { } else {
GST_WARNING_OBJECT (kd, "failed to create buffer"); GST_ELEMENT_ERROR (kd, STREAM, DECODE, (NULL),
("Failed to create buffer"));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} }
} else { } else {
@ -307,7 +306,8 @@ gst_kate_dec_chain (GstPad * pad, GstBuffer * buf)
} }
g_free (escaped); g_free (escaped);
} else { } else {
GST_WARNING_OBJECT (kd, "failed to allocate string"); GST_ELEMENT_ERROR (kd, STREAM, DECODE, (NULL),
("Failed to allocate string"));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} }
@ -329,7 +329,8 @@ gst_kate_dec_chain (GstPad * pad, GstBuffer * buf)
gst_flow_get_name (rflow)); gst_flow_get_name (rflow));
} }
} else { } else {
GST_WARNING_OBJECT (kd, "failed to create SPU from paletted bitmap"); GST_ELEMENT_ERROR (kd, STREAM, DECODE, (NULL),
("failed to create SPU from paletted bitmap"));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} }
} }

View file

@ -68,7 +68,6 @@
* </refsect2> * </refsect2>
*/ */
/* FIXME: post appropriate GST_ELEMENT_ERROR when returning FLOW_ERROR */
/* FIXME: should we automatically pick up the language code from the /* FIXME: should we automatically pick up the language code from the
* upstream event tags if none was set via the property? */ * upstream event tags if none was set via the property? */
@ -457,7 +456,8 @@ gst_kate_enc_push_and_free_kate_packet (GstKateEnc * ke, kate_packet * kp,
buffer = buffer =
gst_kate_enc_create_buffer (ke, kp, granpos, timestamp, duration, header); gst_kate_enc_create_buffer (ke, kp, granpos, timestamp, duration, header);
if (G_UNLIKELY (!buffer)) { if (G_UNLIKELY (!buffer)) {
GST_WARNING_OBJECT (ke, "Failed to create buffer, %u bytes", kp->nbytes); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("Failed to create buffer, %u bytes", kp->nbytes));
kate_packet_clear (kp); kate_packet_clear (kp);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -561,7 +561,8 @@ gst_kate_enc_send_headers (GstKateEnc * ke)
GST_LOG_OBJECT (ke, "Last header encoded"); GST_LOG_OBJECT (ke, "Last header encoded");
break; break;
} else { } else {
GST_LOG_OBJECT (ke, "Error encoding header: %d", ret); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_headers: %d", ret));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
break; break;
} }
@ -634,7 +635,8 @@ gst_kate_enc_chain_push_packet (GstKateEnc * ke, kate_packet * kp,
granpos = kate_encode_get_granule (&ke->k); granpos = kate_encode_get_granule (&ke->k);
if (G_UNLIKELY (granpos < 0)) { if (G_UNLIKELY (granpos < 0)) {
GST_WARNING_OBJECT (ke, "Negative granpos for packet"); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("Negative granpos for packet"));
kate_packet_clear (kp); kate_packet_clear (kp);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -685,6 +687,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),
("kate_encode_text: %d", ret));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
rflow = rflow =
@ -747,7 +751,7 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf)
g_free (kbitmap); g_free (kbitmap);
if (kpalette) if (kpalette)
g_free (kpalette); g_free (kpalette);
GST_ERROR_OBJECT (ke, "Out of memory"); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), ("Out of memory"));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -802,17 +806,20 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf)
kbitmap->width, kbitmap->height, GST_BUFFER_SIZE (buf), t0, t1); kbitmap->width, kbitmap->height, GST_BUFFER_SIZE (buf), t0, t1);
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_WARNING_OBJECT (ke, "Failed to set event region (%d)", ret); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_set_region: %d", 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_WARNING_OBJECT (ke, "Failed to set event palette (%d)", ret); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_set_palette: %d", 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_WARNING_OBJECT (ke, "Failed to set event bitmap (%d)", ret); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_set_bitmap: %d", 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
@ -833,8 +840,8 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf)
} else { } else {
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_WARNING_OBJECT (ke, 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: %d", ret));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
rflow = rflow =
@ -875,7 +882,8 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf,
} }
if (G_UNLIKELY (ret < 0)) { if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (ke, "Failed to set markup type (%d)", ret); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("kate_encode_set_markup_type: %d", 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);
@ -888,13 +896,17 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf,
GST_BUFFER_SIZE (buf), t0, t1); GST_BUFFER_SIZE (buf), t0, t1);
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),
("Failed to encode text: %d", ret));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
rflow = rflow =
gst_kate_enc_chain_push_packet (ke, &kp, start, stop - start + 1); gst_kate_enc_chain_push_packet (ke, &kp, start, stop - start + 1);
} }
} else { } else {
GST_WARNING_OBJECT (ke, "No text in text packet"); /* FIXME: this should not be an error, we should ignore it and move on */
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("no text in text packet"));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} }
} }
@ -918,8 +930,8 @@ gst_kate_enc_chain (GstPad * pad, GstBuffer * buf)
/* get the type of the data we're being sent */ /* get the type of the data we're being sent */
caps = GST_PAD_CAPS (pad); caps = GST_PAD_CAPS (pad);
if (G_UNLIKELY (caps == NULL)) { if (G_UNLIKELY (caps == NULL)) {
GST_ERROR_OBJECT (ke, ": Could not get caps of pad"); GST_WARNING_OBJECT (ke, "No input caps set");
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_NOT_NEGOTIATED;
} else { } else {
const GstStructure *structure = gst_caps_get_structure (caps, 0); const GstStructure *structure = gst_caps_get_structure (caps, 0);
if (structure) if (structure)

View file

@ -58,8 +58,6 @@
* *
*/ */
/* FIXME: post appropriate GST_ELEMENT_ERROR when returning FLOW_ERROR */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
@ -174,7 +172,8 @@ gst_kate_parse_push_headers (GstKateParse * parse)
gst_pad_get_negotiated_caps (parse->sinkpad), parse->streamheader); gst_pad_get_negotiated_caps (parse->sinkpad), parse->streamheader);
if (G_UNLIKELY (!caps)) { if (G_UNLIKELY (!caps)) {
GST_ERROR_OBJECT (parse, "Failed to set headers on caps"); GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL),
("Failed to set headers on caps"));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -182,8 +181,8 @@ gst_kate_parse_push_headers (GstKateParse * parse)
res = gst_pad_set_caps (parse->srcpad, caps); res = gst_pad_set_caps (parse->srcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
if (G_UNLIKELY (!res)) { if (G_UNLIKELY (!res)) {
GST_WARNING_OBJECT (parse, "Failed to set pad caps"); GST_WARNING_OBJECT (parse->srcpad, "Failed to set caps on source pad");
return GST_FLOW_ERROR; return GST_FLOW_NOT_NEGOTIATED;
} }
headers = parse->streamheader; headers = parse->streamheader;
@ -343,7 +342,8 @@ gst_kate_parse_queue_buffer (GstKateParse * parse, GstBuffer * buf)
if (granpos >= 0) { if (granpos >= 0) {
ret = gst_kate_parse_drain_queue (parse, granpos); ret = gst_kate_parse_drain_queue (parse, granpos);
} else { } else {
GST_WARNING_OBJECT (parse, "granulepos < 0 (%lld)", granpos); GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL),
("Bad granulepos %" G_GINT64_FORMAT, granpos));
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
} }
#endif #endif

View file

@ -253,7 +253,8 @@ gst_kate_spu_crop_bitmap (GstKateEnc * ke, kate_bitmap * kb, guint16 * dx,
kb->height = h; kb->height = h;
} }
#define CHECK(x) do { guint16 _ = (x); if (G_UNLIKELY((_) > sz)) { GST_WARNING_OBJECT (ke, "SPU overflow"); return GST_FLOW_ERROR; } } while (0) /* FIXME: fix macros */
#define CHECK(x) do { guint16 _ = (x); if (G_UNLIKELY((_) > sz)) { GST_ELEMENT_ERROR (ke, STREAM, ENCODE, ("Attempt to read outide buffer"), (NULL)); return GST_FLOW_ERROR; } } while (0)
#define ADVANCE(x) do { guint16 _ = (x); ptr += (_); sz -= (_); } while (0) #define ADVANCE(x) do { guint16 _ = (x); ptr += (_); sz -= (_); } while (0)
#define IGNORE(x) do { guint16 __ = (x); CHECK (__); ADVANCE (__); } while (0) #define IGNORE(x) do { guint16 __ = (x); CHECK (__); ADVANCE (__); } while (0)
@ -267,8 +268,9 @@ gst_kate_spu_decode_command_sequence (GstKateEnc * ke, GstBuffer * buf,
guint16 sz; guint16 sz;
if (command_sequence_offset >= GST_BUFFER_SIZE (buf)) { if (command_sequence_offset >= GST_BUFFER_SIZE (buf)) {
GST_WARNING_OBJECT (ke, "Command sequence offset %u is out of range %u", GST_ELEMENT_ERROR (ke, STREAM, DECODE, (NULL),
command_sequence_offset, GST_BUFFER_SIZE (buf)); ("Command sequence offset %u is out of range %u",
command_sequence_offset, GST_BUFFER_SIZE (buf)));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -348,10 +350,12 @@ gst_kate_spu_decode_command_sequence (GstKateEnc * ke, GstBuffer * buf,
} }
break; break;
default: default:
GST_WARNING_OBJECT (ke, "invalid SPU command: %u", cmd); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("Invalid SPU command: %u", cmd));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
} }
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), ("Error parsing SPU"));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -395,9 +399,10 @@ gst_kate_spu_create_spu_palette (GstKateEnc * ke, kate_palette * kp)
kate_palette_init (kp); kate_palette_init (kp);
kp->ncolors = 4; kp->ncolors = 4;
kp->colors = (kate_color *) g_malloc (kp->ncolors * sizeof (kate_color)); kp->colors = (kate_color *) g_malloc (kp->ncolors * sizeof (kate_color));
if (G_UNLIKELY (!kp->colors)) if (G_UNLIKELY (!kp->colors)) {
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), ("Out of memory"));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
}
#if 1 #if 1
for (n = 0; n < kp->ncolors; ++n) { for (n = 0; n < kp->ncolors; ++n) {
int idx = ke->spu_colormap[n]; int idx = ke->spu_colormap[n];
@ -478,7 +483,8 @@ gst_kate_spu_decode_spu (GstKateEnc * ke, GstBuffer * buf, kate_region * kr,
if (G_UNLIKELY (ke->spu_right - ke->spu_left < 0 if (G_UNLIKELY (ke->spu_right - ke->spu_left < 0
|| ke->spu_bottom - ke->spu_top < 0 || ke->spu_pix_data[0] == 0 || ke->spu_bottom - ke->spu_top < 0 || ke->spu_pix_data[0] == 0
|| ke->spu_pix_data[1] == 0)) { || ke->spu_pix_data[1] == 0)) {
GST_WARNING_OBJECT (ke, "SPU area is empty, nothing to encode"); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("SPU area is empty, nothing to encode"));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -495,7 +501,8 @@ gst_kate_spu_decode_spu (GstKateEnc * ke, GstBuffer * buf, kate_region * kr,
kb->type = kate_bitmap_type_paletted; kb->type = kate_bitmap_type_paletted;
kb->pixels = (unsigned char *) g_malloc (kb->width * kb->height); kb->pixels = (unsigned char *) g_malloc (kb->width * kb->height);
if (G_UNLIKELY (!kb->pixels)) { if (G_UNLIKELY (!kb->pixels)) {
GST_WARNING_OBJECT (ke, "Failed to allocate memory for pixel data"); GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("Failed to allocate memory for pixel data"));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }

View file

@ -63,8 +63,6 @@
* </refsect2> * </refsect2>
*/ */
/* FIXME: post appropriate GST_ELEMENT_ERROR when returning FLOW_ERROR */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif

View file

@ -73,8 +73,6 @@
* </refsect2> * </refsect2>
*/ */
/* FIXME: post appropriate GST_ELEMENT_ERROR when returning FLOW_ERROR */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif

View file

@ -17,7 +17,6 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
/* FIXME: post appropriate GST_ELEMENT_ERROR when returning FLOW_ERROR */
/* FIXME: shouldn't all this GstKateDecoderBase stuff really be a base class? */ /* FIXME: shouldn't all this GstKateDecoderBase stuff really be a base class? */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -165,7 +164,8 @@ gst_kate_util_decoder_base_chain_kate_packet (GstKateDecoderBase * decoder,
kate_packet_wrap (&kp, GST_BUFFER_SIZE (buf), GST_BUFFER_DATA (buf)); kate_packet_wrap (&kp, GST_BUFFER_SIZE (buf), GST_BUFFER_DATA (buf));
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_WARNING_OBJECT (element, "kate_high_decode_packetin failed (%d)", ret); GST_ELEMENT_ERROR (element, STREAM, DECODE, (NULL),
("Failed to decode Kate packet: %d", ret));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} else if (G_UNLIKELY (ret > 0)) { } else if (G_UNLIKELY (ret > 0)) {
GST_DEBUG_OBJECT (element, GST_DEBUG_OBJECT (element,