/* chain function * this function does the actual processing */ static GstFlowReturn gst_kate_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) { GstKateEnc *ke = GST_KATE_ENC (parent); GstFlowReturn rflow; GST_DEBUG_OBJECT (ke, "got packet, %" G_GSIZE_FORMAT " bytes", gst_buffer_get_size (buf)); /* first push headers if we haven't done that yet */ rflow = gst_kate_enc_flush_headers (ke); if (G_LIKELY (rflow == GST_FLOW_OK)) { /* flush any packet we had waiting */ rflow = gst_kate_enc_flush_waiting (ke, GST_BUFFER_TIMESTAMP (buf)); if (G_LIKELY (rflow == GST_FLOW_OK)) { if (ke->format == GST_KATE_FORMAT_SPU) { /* encode a kate_bitmap */ rflow = gst_kate_enc_chain_spu (ke, buf); } else { /* encode text */ rflow = gst_kate_enc_chain_text (ke, buf); } } } gst_buffer_unref (buf); return rflow; }
/* chain function * this function does the actual processing */ static GstFlowReturn gst_kate_enc_chain (GstPad * pad, GstBuffer * buf) { GstKateEnc *ke = GST_KATE_ENC (gst_pad_get_parent (pad)); GstFlowReturn rflow = GST_FLOW_OK; GstCaps *caps; const gchar *mime_type = NULL; GST_DEBUG_OBJECT (ke, "got packet, %u bytes", GST_BUFFER_SIZE (buf)); /* get the type of the data we're being sent */ caps = GST_PAD_CAPS (pad); if (G_UNLIKELY (caps == NULL)) { 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) mime_type = gst_structure_get_name (structure); if (mime_type) { GST_LOG_OBJECT (ke, "Packet has MIME type %s", mime_type); /* first push headers if we haven't done that yet */ rflow = gst_kate_enc_flush_headers (ke); if (G_LIKELY (rflow == GST_FLOW_OK)) { /* flush any packet we had waiting */ rflow = gst_kate_enc_flush_waiting (ke, GST_BUFFER_TIMESTAMP (buf)); if (G_LIKELY (rflow == GST_FLOW_OK)) { if (!strcmp (mime_type, GST_KATE_SPU_MIME_TYPE)) { /* encode a kate_bitmap */ rflow = gst_kate_enc_chain_spu (ke, buf); } else { /* encode text */ rflow = gst_kate_enc_chain_text (ke, buf, mime_type); } } } } else { GST_WARNING_OBJECT (ke, "Packet has no MIME type, ignored"); } } gst_buffer_unref (buf); gst_object_unref (ke); GST_LOG_OBJECT (ke, "Leaving chain function"); return rflow; }