Krad Radio/FinalAPI

From MozillaWiki
Jump to: navigation, search

The Final Stable API

Of course the name final API is a real kneeslapper, but such as it is things have actually evolved to the point where we can have a stable API. By API I mean the client API in C, this of course informs the JSON API and all other languages. Currently we have something like 10,000 functions and thats too many. It was considered to just have a single function with the prototype int krad(void *), but thats probably too minimal.

We have gone thru a few jargons always looking to create the kind of system where one can reason about its capability from the namespace of structures and functions. We have ended up in a good place by trusting in evolution to guide us as we discover what Krad Radio really is. Two concepts stand out, one is the idea of the dynamic signal path, the route that audio and video energy bytes flow through the system. The other is that all paths and their controls have an address.. or path. Its not written out as a chain however, paths have links or hyperlinks if you will to other paths, just like a filesystem, or the web. Thus the majority of operations have to do with creating, unlinking paths and controlling their parameters. It also converges well with the idea of remote paths, aka streaming.

Krad_Radio/JSONAPI

Built in Paths:

/system/[info][
/station/[info]
/adapter/[api]/[path]
/devices/avail adapters]
/mixer/[input][bus][output]
/compositor/[input][subcomp][output] [sprite][text][vector]
/encoder/[codec] 
/muxponder[mux]
/interweb/[stream]

Short style:

/sys/[info]
/sta/[info]
/adp/[api]/[path]
/dev/[v4l2/decklink/jack/alsa/etc][avail adapters]
/mix/[input][bus][output]
/com/[input][subcomp][output] [sprite][text][vector]
/enc/[codec] 
/mux[mux]
/web/[stream]

Station Control / Path Management:

int krctl(kd, address, control);
int kr_ls(kd, address);
int kr_stat(kd, address, int subscribe);
int kr_mount(kd, adapter_info);
int kr_mkpath(kd, address[2], info[2]);
int kr_unlink(kd, address[1-2]);

Client Convienient:

int kr_crate_addr_path_match(kr_crate *crate, int unit, int subunit);
void kr_crate_recycle (kr_crate **crate);
int kr_crate_to_str(kr_crate *crate, char **string);
int kr_crate_to_int(kr_crate *crate, int *number);
int kr_crate_to_float(kr_crate *crate, float *number);
int kr_crate_loaded(kr_crate);
int kr_unpack(kr_crate *crate, kr_info *info);
void kr_crate_address(kr_crate *crate, kr_address_t **address);

Client I/O Management:

void kr_subscribe(kr_client *client, kr_address *addr);
void kr_subscribe_all(kr_client *client);
int kr_poll(kr_client *client, uint32_t timeout_ms);                                      
int kr_client_get_fd(kr_client *client);                                           
int kr_client_sync(kr_client *client);                                             
int kr_client_push(kr_client *client);                                             
int kr_client_want_out(kr_client *client);
void kr_delivery_recv(kr_client *client);

Client Management: (Station descriptor? Remote Control?)

kr_client *kr_client_create(char *client_name);                                 
int kr_connect(kr_client *client, char *sysname);                                  
int kr_connect_full(kr_client *client, char *sysname, int timeout_ms);             
int kr_connect_remote(kr_client *client, char *host, int port, int timeout_ms);    
int kr_connected(kr_client *client);                                               
int kr_disconnect(kr_client *client);                                              
int kr_client_destroy (kr_client **client);                                        
int kr_client_local(kr_client *client); 

Local SHM Audio/Video:

/* How about kr_path_connect() ? */
int kr_audioport_error(kr_audioport_t *audioport);
float *kr_audioport_get_buffer(kr_audioport_t *kr_audioport, int channel);
void kr_audioport_set_callback(kr_audioport_t *kr_audioport,
int callback(uint32_t, void *), void *pointer);
void kr_audioport_connect(kr_audioport_t *kr_audioport);
void kr_audioport_disconnect(kr_audioport_t *kr_audioport);
kr_audioport_t *kr_audioport_create(kr_client_t *client, char *name, int direction);
void kr_audioport_destroy(kr_audioport_t *kr_audioport);
int kr_videoport_error (kr_videoport_t *videoport);
void kr_videoport_set_callback (kr_videoport_t *kr_videoport, int callback (void *, void *), void *pointer);
void kr_videoport_activate (kr_videoport_t *kr_videoport);
void kr_videoport_deactivate (kr_videoport_t *kr_videoport);
kr_videoport_t *kr_videoport_create (kr_client_t *client, int32_t direction);
void kr_videoport_destroy (kr_videoport_t *kr_videoport);

Local station sysadmin functions:

 void krad_radio_launch(char *sysname);
 int krad_radio_destroy(char *sysname);
 int krad_radio_running(char *sysname);
 char *krad_radio_ls();