+static int receive(struct sr_input *in, GString *buf)
+{
+ struct context *inc;
+ int ret;
+
+ g_string_append_len(in->buf, buf->str, buf->len);
+
+ inc = in->priv;
+ if (!inc->got_header) {
+ if (!have_header(in->buf))
+ return SR_OK;
+ if (!parse_header(in, in->buf))
+ /* There was a header in there, but it was malformed. */
+ return SR_ERR;
+
+ in->sdi_ready = TRUE;
+ /* sdi is ready, notify frontend. */
+ return SR_OK;
+ }
+
+ ret = process_buffer(in);
+
+ return ret;
+}
+
+static int end(struct sr_input *in)
+{
+ struct context *inc;
+ int ret;
+
+ inc = in->priv;
+
+ if (in->sdi_ready)
+ ret = process_buffer(in);
+ else
+ ret = SR_OK;
+
+ /* Send any samples that haven't been sent yet. */
+ send_buffer(in);
+
+ if (inc->started)
+ std_session_send_df_end(in->sdi);
+
+ return ret;
+}
+
+static void cleanup(struct sr_input *in)