Libkstreamer
From VoiSmart Open Source Wiki
libkstreamer is a C library to abstract the application from the burden of implementing the Kstreamer Netlink Interface, synchronizing the local topology database, maintaining the synchronization and performing routing.
This is an example on how to create a pipeline from a textual description in pipeline_descr:
glob.conn = ks_conn_create();
if (!glob.conn) {
fprintf(stderr, "Cannot initialize kstreamer library\n");
return 1;
}
int err;
err = ks_conn_establish(conn);
if (err < 0) {
fprintf(stderr, "Cannot connect kstreamer library\n");
return 1;
}
ks_update_topology(conn);
struct ks_pd *pd;
pd = ks_pd_parse(pipeline_descr);
if (!pd || pd->failed) {
fprintf(stderr, "Cannot parse pipeline description\n");
return 1;
}
struct ks_pipeline *pipeline;
pipeline = ks_pipeline_alloc();
if (!pipeline) {
fprintf(stderr, "Cannot allocate pipeline\n");
return 1;
}
struct ks_pd_channel *pd_chan;
list_for_each_entry(pd_chan, &pd->pipeline->channels->list, node) {
struct ks_chan *chan;
chan = ks_chan_get_by_token(conn, pd_chan->name);
if (!chan) {
fprintf(stderr,
"Cannot find channel '%s'\n",
pd_chan->name->text);
return 1;
}
pipeline->chans[pipeline->chans_cnt] = chan;
pipeline->chans_cnt++;
}
pipeline->status = KS_PIPELINE_STATUS_CONNECTED;
err = ks_pipeline_create(pipeline, conn);
if (err < 0) {
fprintf(stderr,
"Cannot create pipeline: %s\n",
strerror(-err));
return 1;
}
A connection to kstreamer is firstly created with ks_conn_create() and ks_conn_establish() and topology is synchronized by invoking ks_update_topology().
The textual description of the pipeline is parsed with ks_pd_parse() obtaining a pipeline description pd which in turn is translated to a pipeline and then connected invoking ks_pipeline_create(). The above code is taken from kstool but does not support autorouting and specific attribute setting.

