Receiving sliced or raw data from VBI proxy daemon. More...
Data Structures | |
struct | vbi_channel_profile |
Proxy scheduler configuration for background channel switching. More... | |
Defines | |
#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. | |
Enumerations | |
enum | VBI_PROXY_EV_TYPE { VBI_PROXY_EV_CHN_GRANTED = 1<<0, VBI_PROXY_EV_CHN_CHANGED = 1<<1, VBI_PROXY_EV_NORM_CHANGED = 1<<2, VBI_PROXY_EV_CHN_RECLAIMED = 1<<3, VBI_PROXY_EV_NONE = 0 } |
Bits in event mask parameter to proxy client callback function. More... | |
enum | VBI_PROXY_SUSPEND { VBI_PROXY_SUSPEND_START, VBI_PROXY_SUSPEND_STOP } |
Modes for channel suspend requests. More... | |
enum | VBI_CHN_PRIO { VBI_CHN_PRIO_BACKGROUND = 1, VBI_CHN_PRIO_INTERACTIVE = 2, VBI_CHN_PRIO_DEFAULT = VBI_CHN_PRIO_INTERACTIVE, VBI_CHN_PRIO_RECORD = 3 } |
Priority levels for channel switching (equivalent to enum v4l2_priority). More... | |
enum | VBI_CHN_SUBPRIO { VBI_CHN_SUBPRIO_MINIMAL = 0x00, VBI_CHN_SUBPRIO_CHECK = 0x10, VBI_CHN_SUBPRIO_UPDATE = 0x20, VBI_CHN_SUBPRIO_INITIAL = 0x30, VBI_CHN_SUBPRIO_VPS_PDC = 0x40 } |
Sub-priorities for channel scheduling at "background" priority. More... | |
enum | VBI_PROXY_DAEMON_FLAGS { VBI_PROXY_DAEMON_NO_TIMEOUTS = 1<<0 } |
General flags sent from clients to daemon during connect. More... | |
enum | VBI_PROXY_CLIENT_FLAGS { VBI_PROXY_CLIENT_NO_TIMEOUTS = 1<<0, VBI_PROXY_CLIENT_NO_STATUS_IND = 1<<1 } |
General flags sent from daemon to clients during connect. More... | |
enum | VBI_PROXY_CHN_FLAGS { VBI_PROXY_CHN_RELEASE = 1<<0, VBI_PROXY_CHN_TOKEN = 1<<1, VBI_PROXY_CHN_FLUSH = 1<<2, VBI_PROXY_CHN_NORM = 1<<3, VBI_PROXY_CHN_FAIL = 1<<4, VBI_PROXY_CHN_NONE = 0 } |
Channel notification flags. More... | |
enum | VBI_DRIVER_API_REV { VBI_API_UNKNOWN, VBI_API_V4L1, VBI_API_V4L2, VBI_API_BKTR } |
Identification of the VBI device driver type. | |
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".
VBI_CHN_PRIO_BACKGROUND |
Priority level to be used for non-interactive, background data harvesting, i.e. applications which permanently run in the background (e.g. teletext cache, EPG data acquisition) |
VBI_CHN_PRIO_INTERACTIVE |
Interactive (default): should be used when channels are changed on request of the user (e.g. TV viewer, Radio, teletext reader) |
VBI_CHN_PRIO_DEFAULT |
Default priority for client which have not (yet) set a priority. |
VBI_CHN_PRIO_RECORD |
Scheduled recording (e.g. PVR): usually only one application should run at this level (although this is not enforced by the proxy daemon, must be checked by the user or applications) |
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 from daemon to clients during connect.
enum VBI_PROXY_CHN_FLAGS |
Channel notification flags.
VBI_PROXY_CHN_RELEASE |
Revoke a previous channel request and return the channel switch token to the daemon. |
VBI_PROXY_CHN_TOKEN |
Return the channel token to the daemon without releasing the channel; This should always be done when the channel switch has been completed to allow faster scheduling in the daemon (i.e. the daemon can grant the token to a different client without having to reclaim it first.) |
VBI_PROXY_CHN_FLUSH |
Indicate that the channel was changed and VBI buffer queue must be flushed; Should be called as fast as possible after the channel and/or norm was changed. Note this affects other clients' capturing too, so use with care. Other clients will be informed about this change by a channel change indication. |
VBI_PROXY_CHN_NORM |
Indicate a norm change. The new norm should be supplied in the scanning parameter in cae the daemon is not able to determine it from the device directly. |
VBI_PROXY_CHN_FAIL |
Indicate that the client failed to switch the channel because the device was busy. Used to notify the channel scheduler that the current time slice cannot be used by the client. If the client isn't able to schedule periodic re-attempts it should also return the token. |
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 activity carrier 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 to be passed to driver |
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.