diff options
Diffstat (limited to 'ext/kate/gstkateenc.c')
-rw-r--r-- | ext/kate/gstkateenc.c | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/ext/kate/gstkateenc.c b/ext/kate/gstkateenc.c index 80709eb3..42333509 100644 --- a/ext/kate/gstkateenc.c +++ b/ext/kate/gstkateenc.c @@ -68,7 +68,6 @@ * </refsect2> */ -/* FIXME: post appropriate GST_ELEMENT_ERROR when returning FLOW_ERROR */ /* FIXME: should we automatically pick up the language code from the * upstream event tags if none was set via the property? */ @@ -398,7 +397,7 @@ gst_kate_enc_create_buffer (GstKateEnc * ke, kate_packet * kp, { GstBuffer *buffer; - buffer = gst_buffer_new_and_alloc (kp->nbytes); + buffer = gst_buffer_try_new_and_alloc (kp->nbytes); if (G_UNLIKELY (!buffer)) { GST_WARNING_OBJECT (ke, "Failed to allocate buffer for %u bytes", kp->nbytes); @@ -426,7 +425,7 @@ gst_kate_enc_create_buffer (GstKateEnc * ke, kate_packet * kp, static GstFlowReturn gst_kate_enc_push_buffer (GstKateEnc * ke, GstBuffer * buffer) { - GstFlowReturn rflow; + GstFlowReturn flow; ke->last_timestamp = GST_BUFFER_TIMESTAMP (buffer); if (GST_BUFFER_TIMESTAMP (buffer) + GST_BUFFER_DURATION (buffer) > @@ -438,12 +437,12 @@ gst_kate_enc_push_buffer (GstKateEnc * ke, GstBuffer * buffer) /* Hack to flush each packet on its own page - taken off the CMML encoder element */ GST_BUFFER_DURATION (buffer) = G_MAXINT64; - rflow = gst_pad_push (ke->srcpad, buffer); - if (G_UNLIKELY (rflow != GST_FLOW_OK)) { - GST_ERROR_OBJECT (ke, "Failed to push buffer: %d", rflow); + flow = gst_pad_push (ke->srcpad, buffer); + if (G_UNLIKELY (flow != GST_FLOW_OK)) { + GST_WARNING_OBJECT (ke->srcpad, "push flow: %s", gst_flow_get_name (flow)); } - return rflow; + return flow; } static GstFlowReturn @@ -457,7 +456,8 @@ gst_kate_enc_push_and_free_kate_packet (GstKateEnc * ke, kate_packet * kp, buffer = gst_kate_enc_create_buffer (ke, kp, granpos, timestamp, duration, header); 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); return GST_FLOW_ERROR; } @@ -548,9 +548,12 @@ gst_kate_enc_send_headers (GstKateEnc * ke) kate_packet kp; int ret = kate_encode_headers (&ke->k, &ke->kc, &kp); if (ret == 0) { - GstBuffer *buffer = - gst_kate_enc_create_buffer (ke, &kp, 0ll, 0ll, 0ll, TRUE); + GstBuffer *buffer; + + buffer = gst_kate_enc_create_buffer (ke, &kp, 0, 0, 0, TRUE); if (!buffer) { + GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), + ("Failed to create buffer, %u bytes", kp.nbytes)); rflow = GST_FLOW_ERROR; break; } @@ -561,7 +564,8 @@ gst_kate_enc_send_headers (GstKateEnc * ke) GST_LOG_OBJECT (ke, "Last header encoded"); break; } 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; break; } @@ -634,7 +638,8 @@ gst_kate_enc_chain_push_packet (GstKateEnc * ke, kate_packet * kp, granpos = kate_encode_get_granule (&ke->k); 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); return GST_FLOW_ERROR; } @@ -685,6 +690,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)); rflow = GST_FLOW_ERROR; } else { rflow = @@ -747,7 +754,7 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf) g_free (kbitmap); if (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; } @@ -802,17 +809,20 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf) kbitmap->width, kbitmap->height, GST_BUFFER_SIZE (buf), t0, t1); ret = kate_encode_set_region (&ke->k, kregion); 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; } else { ret = kate_encode_set_palette (&ke->k, kpalette); 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; } else { ret = kate_encode_set_bitmap (&ke->k, kbitmap); 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; } else { /* Some SPUs have no hide time - so I'm going to delay the encoding of the packet @@ -833,8 +843,8 @@ gst_kate_enc_chain_spu (GstKateEnc * ke, GstBuffer * buf) } else { ret = kate_encode_text (&ke->k, t0, t1, "", 0, &kp); if (G_UNLIKELY (ret < 0)) { - GST_WARNING_OBJECT (ke, - "Failed to encode empty text for SPU buffer (%d)", ret); + GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), + ("Failed to encode empty text for SPU buffer: %d", ret)); rflow = GST_FLOW_ERROR; } else { rflow = @@ -875,7 +885,8 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf, } 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; } else { const char *text = (const char *) GST_BUFFER_DATA (buf); @@ -888,13 +899,17 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf, GST_BUFFER_SIZE (buf), t0, t1); 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)); rflow = GST_FLOW_ERROR; } else { rflow = gst_kate_enc_chain_push_packet (ke, &kp, start, stop - start + 1); } } 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; } } @@ -918,8 +933,8 @@ gst_kate_enc_chain (GstPad * pad, GstBuffer * buf) /* get the type of the data we're being sent */ caps = GST_PAD_CAPS (pad); if (G_UNLIKELY (caps == NULL)) { - GST_ERROR_OBJECT (ke, ": Could not get caps of pad"); - rflow = GST_FLOW_ERROR; + GST_WARNING_OBJECT (ke, "No input caps set"); + rflow = GST_FLOW_NOT_NEGOTIATED; } else { const GstStructure *structure = gst_caps_get_structure (caps, 0); if (structure) |