* Create a new protocol decoder instance.
*
* TODO: this should be a decoder name, as decoder ids will disappear.
- * @param id Decoder 'id' field.
- * @param instance_id optional unique identifier for this instance. If NULL,
- * the id parameter is used.
*
- * @returns Pointer to a newly allocated struct srd_decoder_instance, or
- * NULL in case of failure.
+ * @param id Decoder 'id' field.
+ * @param instance_id Optional unique identifier for this instance. If NULL,
+ * the 'id' parameter is used.
+ * @return Pointer to a newly allocated struct srd_decoder_instance, or
+ * NULL in case of failure.
*/
struct srd_decoder_instance *srd_instance_new(const char *id,
const char *instance_id)
}
/* Create an instance of the 'Decoder' class. */
- di->py_instance = PyObject_Call(dec->py_decobj, py_args, NULL);
+ di->py_instance = PyObject_Call(dec->py_dec, py_args, NULL);
if (!di->py_instance) {
if (PyErr_Occurred())
PyErr_Print();
return SRD_OK;
}
+/* TODO: this should go into the PD stack */
struct srd_decoder_instance *srd_instance_find(char *instance_id)
{
GSList *l;
*
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
-int srd_instance_decode(uint64_t timeoffset, uint64_t duration,
+int srd_instance_decode(uint64_t start_samplenum,
struct srd_decoder_instance *di, uint8_t *inbuf, uint64_t inbuflen)
{
PyObject *py_instance, *py_res;
srd_logic *logic;
+ uint64_t end_samplenum;
/* Return an error upon unusable input. */
if (di == NULL)
logic = PyObject_New(srd_logic, &srd_logic_type);
Py_INCREF(logic);
logic->di = di;
+ logic->start_samplenum = start_samplenum;
logic->itercnt = 0;
logic->inbuf = inbuf;
logic->inbuflen = inbuflen;
logic->sample = PyList_New(2);
Py_INCREF(logic->sample);
+ end_samplenum = start_samplenum + inbuflen / di->unitsize;
if (!(py_res = PyObject_CallMethod(py_instance, "decode",
- "KKO", timeoffset, duration, logic))) {
+ "KKO", logic->start_samplenum, end_samplenum, logic))) {
if (PyErr_Occurred())
PyErr_Print(); /* Returns void. */
}
/* Feed logic samples to decoder session. */
-int srd_session_feed(uint64_t timeoffset, uint64_t duration, uint8_t *inbuf,
- uint64_t inbuflen)
+int srd_session_feed(uint64_t start_samplenum, uint8_t *inbuf, uint64_t inbuflen)
{
GSList *d;
int ret;
for (d = di_list; d; d = d->next) {
- if ((ret = srd_instance_decode(timeoffset, duration, d->data, inbuf,
+ if ((ret = srd_instance_decode(start_samplenum, d->data, inbuf,
inbuflen)) != SRD_OK)
return ret;
}
int pd_add(struct srd_decoder_instance *di, int output_type,
- char *protocol_id)
+ char *proto_id)
{
struct srd_pd_output *pdo;
pdo->pdo_id = g_slist_length(di->pd_output);
pdo->output_type = output_type;
pdo->decoder = di->decoder;
- pdo->protocol_id = g_strdup(protocol_id);
+ pdo->proto_id = g_strdup(proto_id);
di->pd_output = g_slist_append(di->pd_output, pdo);
return pdo->pdo_id;