 +          break;
 +      }
 +      break;
-+    case GST_FORMAT_TIME:
-+      switch (*dest_fmt) {
-+        case GST_FORMAT_DEFAULT:
-+          // TODO
-+          GST_DEBUG_OBJECT(kd, "can't convert time to granpos - backlink needed");
-+          res = FALSE;
-+          break;
-+        default:
-+          res = FALSE;
-+          break;
-+      }
-+      break;
 +    default:
 +      res = FALSE;
 +      break;
 +  }
 +
-+  gst_object_unref(kd);
++  if (!res) {
++    GST_WARNING_OBJECT (kd, "unsupported format");
++  }
++
++  gst_object_unref (kd);
 +  return res;
 +}
 +

+  int ret;
+  GstFlowReturn rflow = GST_FLOW_OK;
+
+  GST_LOG_OBJECT(kd, "got packet, %u bytes, type %02x",
+      GST_BUFFER_SIZE(buf), GST_BUFFER_SIZE(buf)==0 ? -1 : GST_BUFFER_DATA(buf)[0]);
+  kate_packet_wrap(&kp, GST_BUFFER_SIZE(buf), GST_BUFFER_DATA(buf));
+  ret = kate_high_decode_packetin(&kd->k, &kp, &ev);
+  if (ret < 0) {
+    GST_WARNING_OBJECT(kd, "kate_high_decode_packetin failed (%d)", ret);
+    gst_object_unref(kd);
+    return GST_FLOW_ERROR;
+  }
+  else if (ret>0) {
+    GST_DEBUG_OBJECT(kd, "kate_high_decode_packetin has received EOS packet");
+    gst_object_unref(kd);
+    return GST_FLOW_OK;
+  }
+
+  /* headers may be interesting to retrieve information from */
+  if (GST_BUFFER_SIZE(buf) > 0) switch (GST_BUFFER_DATA(buf)[0]) {
+    GstCaps *caps;
+    case 0x80: /* ID header */
+      GST_INFO_OBJECT(kd, "Parsed ID header: language %s, category %s", kd->k.ki->language, kd->k.ki->category);
+      caps = gst_caps_new_simple(kd->remove_markup ? "text/plain" : "text/x-pango-markup", NULL);
+      gst_pad_set_caps(kd->srcpad, caps);
+      gst_caps_unref(caps);
+      if (kd->k.ki->language && *kd->k.ki->language) {
+        GstTagList *tags = gst_tag_list_new();
+        if (tags) {
+          gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_LANGUAGE_CODE, kd->k.ki->language, NULL);
+          gst_element_found_tags_for_pad(GST_ELEMENT_CAST(kd), kd->srcpad, tags);
+        }
+      }
+      break;

+static GstStateChangeReturn gst_kate_enc_change_state (GstElement * element,
+    GstStateChange transition);
+static gboolean gst_kate_enc_sink_event(GstPad * pad, GstEvent * event);
+static gboolean gst_kate_enc_source_query(GstPad * pad, GstQuery * query);
+
+static void
+gst_kate_enc_base_init (gpointer gclass)
