+#include <string.h>
+#include <dirent.h>
+
+/* Re-define some string functions for Python >= 3.0. */
+#if PY_VERSION_HEX >= 0x03000000
+#define PyString_AsString PyBytes_AsString
+#define PyString_FromString PyBytes_FromString
+#define PyString_Check PyBytes_Check
+#endif
+
+/* The list of protocol decoders. */
+static GSList *list_pds = NULL;
+
+/*
+ * Here's a quick overview of Python/C API reference counting.
+ *
+ * Check the Python/C API docs for what type of reference a function returns.
+ *
+ * - If it returns a "new reference", you're responsible to Py_XDECREF() it.
+ *
+ * - If it returns a "borrowed reference", you MUST NOT Py_XDECREF() it.
+ *
+ * - If a function "steals" a reference, you no longer are responsible for
+ * Py_XDECREF()ing it (someone else will do it for you at some point).
+ */
+
+static int srd_load_decoder(const char *name, struct srd_decoder **dec);
+
+static int _unitsize = 1;
+
+static PyObject*
+emb_getmeta(PyObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":get"))
+ return NULL;
+
+ return Py_BuildValue("{sssisd}",
+ "driver", "demo",
+ "unitsize", _unitsize,
+ "starttime", 129318231823.0 //TODO: Fill with something reasonable.
+ );
+}
+
+#if 0
+static PyObject*
+emb_get(PyObject *self, PyObject *args)
+{
+ PyObject *r;
+ if (!PyArg_ParseTuple(args, ":get"))
+ return NULL;
+
+ fprintf(stderr, "get called, returns %d\n", _bufoffset);
+ if ((_bufoffset + _unitsize) <= _buflen) {
+ r = Py_BuildValue("{sisiss#}",
+ "time", _bufoffset / _unitsize,
+ "duration", 10,
+ "data", &_buf[_bufoffset], _unitsize
+ );
+ _bufoffset += _unitsize;
+ return r;
+ }
+ Py_RETURN_NONE;
+}
+#endif
+
+static PyObject*
+emb_put(PyObject *self, PyObject *args)
+{
+ PyObject *arg;
+
+ if (!PyArg_ParseTuple(args, "O:put", &arg))
+ return NULL;
+
+ fprintf(stderr, "put called, got passed %d\n", arg);
+ Py_RETURN_NONE;
+}
+
+static PyMethodDef EmbMethods[] = {
+ {"get_meta", emb_getmeta, METH_VARARGS,
+ "Returns information about the stream."},
+ /*{"get", emb_get, METH_VARARGS,
+ "Returns a dictionary with the following keys: time, duration, data"},*/
+ {"put", emb_put, METH_VARARGS,
+ "Accepts a dictionary with the following keys: time, duration, data"},
+ {NULL, NULL, 0, NULL}
+};