ZVBI Library
0.2.33
|
Receiving sliced or raw data from VBI proxy daemon. More...
Data Structures | |
struct | vbi_channel_profile |
Proxy scheduler parameters for background channel switching. More... |
Macros | |
#define | VBIPROXY_VERSION 0x00000100 |
Proxy protocol version: major, minor and patchlevel. |
Typedefs | |
typedef struct vbi_proxy_client | vbi_proxy_client |
Proxy client context. | |
typedef void | VBI_PROXY_CLIENT_CALLBACK (void *p_client_data, VBI_PROXY_EV_TYPE ev_mask) |
Function prototype for proxy client callback. |
Functions | |
vbi_proxy_client * | vbi_proxy_client_create (const char *dev_name, const char *p_client_name, VBI_PROXY_CLIENT_FLAGS client_flags, char **pp_errorstr, int trace_level) |
void | vbi_proxy_client_destroy (vbi_proxy_client *vpc) |
vbi_capture * | vbi_proxy_client_get_capture_if (vbi_proxy_client *vpc) |
Returns capture interface for an initialized proxy client. | |
VBI_PROXY_CLIENT_CALLBACK * | vbi_proxy_client_set_callback (vbi_proxy_client *vpc, VBI_PROXY_CLIENT_CALLBACK *p_callback, void *p_data) |
Installs callback function for asynchronous events. | |
VBI_DRIVER_API_REV | vbi_proxy_client_get_driver_api (vbi_proxy_client *vpc) |
Returns the driver type behind the actual capture device. | |
int | vbi_proxy_client_channel_request (vbi_proxy_client *vpc, VBI_CHN_PRIO chn_prio, vbi_channel_profile *chn_profile) |
int | vbi_proxy_client_channel_notify (vbi_proxy_client *vpc, VBI_PROXY_CHN_FLAGS notify_flags, unsigned int scanning) |
int | vbi_proxy_client_channel_suspend (vbi_proxy_client *vpc, VBI_PROXY_SUSPEND cmd) |
int | vbi_proxy_client_device_ioctl (vbi_proxy_client *vpc, int request, void *p_arg) |
Wrapper for ioctl requests on the VBI device. | |
int | vbi_proxy_client_get_channel_desc (vbi_proxy_client *vpc, unsigned int *p_scanning, vbi_bool *p_granted) |
vbi_bool | vbi_proxy_client_has_channel_control (vbi_proxy_client *vpc) |
Query if the client is currently allowed to switch channels. |
Receiving sliced or raw data from VBI proxy daemon.
Using the VBI proxy daemon instead of capturing directly from a VBI device allows multiple clients to capture concurrently, e.g. to decode multiple data services.
typedef struct vbi_proxy_client vbi_proxy_client |
Proxy client context.
A reference to this anonymous structure is returned by vbi_proxy_client_create and must be passed to the device capture interface and/or all subsequent calls to proxy client interface functions. The contents of this structure are private and must not be accessed or changed by the caller.
typedef void VBI_PROXY_CLIENT_CALLBACK(void *p_client_data, VBI_PROXY_EV_TYPE ev_mask) |
Function prototype for proxy client callback.
The first parameter is the value which the client passed when installing the callback; it's just passed through to the callback unmodified. The second parameter contains one or more bits to describe which events occured wince the last call.
enum VBI_PROXY_EV_TYPE |
Bits in event mask parameter to proxy client callback function.
enum VBI_PROXY_SUSPEND |
Modes for channel suspend requests.
enum VBI_CHN_PRIO |
Priority levels for channel switching (equivalent to enum v4l2_priority)
These priorities are used to cooperativly resolve conflicts between channel requests of multiple capture applications. While a capture application with a higher priority has opened a device, channel change requests of applications with lower priority will fail with error "EBUSY".
enum VBI_CHN_SUBPRIO |
Sub-priorities for channel scheduling at "background" priority.
This enum describes recommended sub-priority levels for channel profiles. They're intended for channel switching through a VBI proxy at background priority level. The daemon uses this priority to decide which request to grant first if there are multiple outstanding requests. To the daemon these are just numbers (highest wins) but for successful cooperation clients need to use agree on values for similar tasks. Hence the following values are recommended:
General flags sent by clients to the proxy daemon during connect.
enum VBI_PROXY_CHN_FLAGS |
Channel notification flags.
enum VBI_DRIVER_API_REV |
Identification of the VBI device driver type.
vbi_proxy_client* vbi_proxy_client_create | ( | const char * | p_dev_name, |
const char * | p_client_name, | ||
VBI_PROXY_CLIENT_FLAGS | client_flags, | ||
char ** | pp_errorstr, | ||
int | trace_level | ||
) |
p_dev_name | Name of the device to open, usually one of /dev/vbi or /dev/vbi0 and up. Note: should be the same path as used by the proxy daemon, else the client may not be able to connect. |
p_client_name | Name of the client application, typically identical to argv[0] (without the path though) Can be used by the proxy daemon to fine-tune scheduling or to present the user with a list of currently connected applications. |
client_flags | Can contain one or more members of VBI_PROXY_CLIENT_FLAGS |
pp_errorstr | If not NULL this function stores a pointer to an error description here. You must free() this string when no longer needed. |
trace_level | Enable debug output to stderr if non-zero. Larger values produce more output. |
This function initializes a proxy daemon client context with the given parameters. (Note this function does not yet connect the daemon.)
NULL
on failurevoid vbi_proxy_client_destroy | ( | vbi_proxy_client * | vpc | ) |
vpc | Pointer to initialized proxy client context |
This function closes the connection to the proxy daemon and frees all resources. The given context must no longer be used after this function was called. If the context was used via the capture device interface, the vbi_capture context must be destroyed first.
vbi_capture* vbi_proxy_client_get_capture_if | ( | vbi_proxy_client * | vpc | ) |
Returns capture interface for an initialized proxy client.
vpc | Pointer to initialized and active proxy client context |
This function is for convenience only: it returns the same pointer as the previous call to vbi_capture_proxy_new(), so that the client need not store it. This pointer is required for function calls through the capture device API (e.g. reading raw or sliced data)
NULL
upon error (i.e. if the client is not connected to the daemon)VBI_PROXY_CLIENT_CALLBACK* vbi_proxy_client_set_callback | ( | vbi_proxy_client * | vpc, |
VBI_PROXY_CLIENT_CALLBACK * | p_callback, | ||
void * | p_data | ||
) |
Installs callback function for asynchronous events.
vpc | Pointer to initialized proxy client context |
p_callback | Pointer to callback function |
p_data | Void pointer which will be passed through to the callback function unmodified. |
This function installs a callback function which will be invoked upon asynchronous events (e.g. channel changes by other clients.) Since the proxy client has no "life" on it's own (i.e. it's not using an internal thread or process) callbacks will only occur from inside other proxy client function calls. The client's file description will become readable when an asynchronous message has arrived from the daemon. Typically the application then will call read to obtain sliced data and the callback will be invoked from inside the read function. Usually in this case the read call will return zero, i.e. indicate an timeout since no actual sliced data has arrived.
Note for channel requests the callback to grant channel control may be invoked before the request function returns. Note you can call any interface function from inside the callback, including the destroy operator.
NULL
if none.VBI_DRIVER_API_REV vbi_proxy_client_get_driver_api | ( | vbi_proxy_client * | vpc | ) |
Returns the driver type behind the actual capture device.
vpc | Pointer to initialized proxy client context |
This function can be used to query which driver is behind the device which is currently opened by the VBI proxy daemon. Applications which use libzvbi's capture API only need not care about this. The information is only relevant to applications which need to change channels or norms.
The function will fail if the client is currently not connected to the daemon, i.e. VPI capture has to be started first.
int vbi_proxy_client_channel_request | ( | vbi_proxy_client * | vpc, |
VBI_CHN_PRIO | chn_prio, | ||
vbi_channel_profile * | p_chn_profile | ||
) |
vpc | Pointer to initialized proxy client context |
chn_prio | Channel change priority level. If there are other clients with higher priority the client will be refused any channel changes. |
p_chn_profile | Channel profile for scheduling at background priority level. |
This function is used to request permission to switch channels or norm. Since the VBI device can be shared with other proxy clients, clients should wait for permission, so that the proxy daemon can fairly schedule channel requests.
Scheduling differs at the 3 priority levels. For an explanation of priorities see enum VBI_CHN_PRIO. At background level channel changes are coordinated by introduction of a virtual token: only the one client which holds the token is allowed to switch channels. The daemon will wait for the token to be returned before it's granted to another client. This way conflicting channel changes are avoided.
At the upper level the latest request always wins. To avoid interference the application still might wait until it gets indicated that the token has been returned to the daemon.
The token may be granted right away or at a later time, e.g. when it has to be reclaimed from another client first, or if there are other clients with higher priority. If a callback has been registered, it will be invoked when the token arrives; otherwise vbi_proxy_client_has_channel_control() can be used to poll for it.
Note: to set the priority level to "background" only without requesting a channel, set the is_valid member in the profile to FALSE
.
errno
for details.int vbi_proxy_client_channel_notify | ( | vbi_proxy_client * | vpc, |
VBI_PROXY_CHN_FLAGS | notify_flags, | ||
unsigned int | scanning | ||
) |
vpc | Pointer to initialized proxy client context |
notify_flags | Combination of event notification bits |
scanning | New norm, if norm event bit is set |
Send channel control request to proxy daemon. See description of the flags for details.
errno
for details.int vbi_proxy_client_channel_suspend | ( | vbi_proxy_client * | vpc, |
VBI_PROXY_SUSPEND | cmd | ||
) |
vpc | Pointer to initialized proxy client context |
cmd | Control command |
Request to temporarily suspend capturing
errno
for details.int vbi_proxy_client_device_ioctl | ( | vbi_proxy_client * | vpc, |
int | request, | ||
void * | p_arg | ||
) |
Wrapper for ioctl requests on the VBI device.
vpc | Pointer to initialized proxy client context |
request | Ioctl request code to be passed to driver |
p_arg | Ioctl argument buffer to be passed to driver. For ioctls which return data, the buffer will by modified by the call (i.e. same as if the ioctl had ben called directly) Note the required buffer size depends on the request code. |
This function allows to manipulate parameters of the underlying VBI device. Not all ioctls are allowed here. It's mainly intended to be used for channel enumeration and channel/norm changes. The request codes and parameters are the same as for the actual device. The caller has to query the driver API first and use the respective ioctl codes, same as if the device would be used directly.
EBUSY
if the client doesn't have permission to control the channel.int vbi_proxy_client_get_channel_desc | ( | vbi_proxy_client * | vpc, |
unsigned int * | p_scanning, | ||
vbi_bool * | p_granted | ||
) |
vpc | Pointer to initialized proxy client context |
p_scanning | Returns new scanning after channel change |
p_granted | ReturnsTRUE if client is currently allowed to switch channels |
Retrieve info sent by the proxy daemon in a channel change indication.
vbi_bool vbi_proxy_client_has_channel_control | ( | vbi_proxy_client * | vpc | ) |
Query if the client is currently allowed to switch channels.
vpc | Pointer to initialized proxy client context |
TRUE
if client is currently allowed to switch channels.