static int cand_add(struct flow *flow, struct json_object *jcand)
{
	const char *mid = jzon_str(jcand, "sdp_mid");
	const char *rcand = jzon_str(jcand, "sdp");
	int idx;
	int err;

	err = jzon_int(&idx, jcand, "sdp_mline_index");
	if (err)
		return err;

	debug("cand_add: mid=%s idx=%d sdp=%s\n", mid, idx, rcand);

	if (flow->got_sdp) {
		struct mediaflow *mf = userflow_mediaflow(flow->userflow);
		return mediaflow_add_rcand(mf, rcand, mid, idx);
	}
	else {
		struct cand *cand = mem_zalloc(sizeof(*cand), cand_destructor);
		if (!cand)
			return ENOMEM;

		str_ncpy(cand->sdp, rcand, sizeof(cand->sdp));
		str_ncpy(cand->mid, mid, sizeof(cand->mid));
		cand->idx = idx;

		list_append(&flow->pendingl, &cand->le, cand);
		return 0;
	}
}
int jzon_int_opt(int *dst, struct json_object *obj, const char *key, int dflt)
{
	int err;

	err = jzon_int(dst, obj, key);
	if (err == ENOENT) {
		*dst = dflt;
		return 0;
	}
	return err;
}