Main Page | Modules | Data Structures | Data Fields | Related Pages | Examples

VBI capture proxy interface
[Raw VBI]

Receiving sliced or raw data from VBI proxy daemon. More...

Data Structures

struct  vbi_channel_profile
 Proxy scheduler parameters for background channel switching. More...


Defines

#define VBIPROXY_VERSION   0x00000100
 Proxy protocol version: major, minor and patchlevel.


Typedefs

typedef 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 by the proxy daemon to clients 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 by clients to the proxy daemon 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. More...


Functions

vbi_proxy_clientvbi_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_capturevbi_proxy_client_get_capture_if (vbi_proxy_client *vpc)
 Returns capture interface for an initialized proxy client.

VBI_PROXY_CLIENT_CALLBACKvbi_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.


Detailed Description

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 Documentation

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.


Enumeration Type Documentation

enum VBI_PROXY_EV_TYPE
 

Bits in event mask parameter to proxy client callback function.

Enumeration values:
VBI_PROXY_EV_CHN_GRANTED  Channel control token was granted, client may now change the channel. Note: client should return the token after the channel change was completed (the channel will still remain reserved for the requested time)
VBI_PROXY_EV_CHN_CHANGED  Channel (e.g. TV tuner frequency) was changed by another client.
VBI_PROXY_EV_NORM_CHANGED  Norm was changed by another client (in a way which affects VBI, e.g. changes between PAL/SECAM are ignored.) The client must update its services, else no data will be forwarded by the proxy until the norm is changed back.
VBI_PROXY_EV_CHN_RECLAIMED  Proxy requests to return the channel control token. The client is no longer allowed to switch the channel and must immediately reply with a channel notification with flag VBI_PROXY_CHN_TOKEN
VBI_PROXY_EV_NONE  Empty event mask

enum VBI_PROXY_SUSPEND
 

Modes for channel suspend requests.

Enumeration values:
VBI_PROXY_SUSPEND_START  Request proxy daemon to stop acquisition (e.g. required by some device drivers to allow a norm change.) Depending on the driver this may result in the proxy closing the device file handle or just stopping the VBI data stream. Note this command is only allowed when the client is in control of the channel.
VBI_PROXY_SUSPEND_STOP  Restart data acquisition after a previous suspension.

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".

Enumeration values:
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:

Enumeration values:
VBI_CHN_SUBPRIO_MINIMAL  Minimal priority level. Client will get channel control only after all other clients.
VBI_CHN_SUBPRIO_CHECK  After phases "initial" or "check" are completed, clients can use this level to continuously check for change marks.
VBI_CHN_SUBPRIO_UPDATE  A change in the data transmission has been detected or a long time has passed since the initial reading, so data needs to be read newly.
VBI_CHN_SUBPRIO_INITIAL  Initial reading of data after program start (and long pause since last start); once all data is read the client should lower it's priority.
VBI_CHN_SUBPRIO_VPS_PDC  Scanning for VPS/PDC labels to wait for the start of a recording.

enum VBI_PROXY_DAEMON_FLAGS
 

General flags sent by the proxy daemon to clients during connect.

Enumeration values:
VBI_PROXY_DAEMON_NO_TIMEOUTS  Don't drop connection upon timeouts in socket I/O or message response; Intended for debugging, i.e. when remote party runs in a debugger

enum VBI_PROXY_CLIENT_FLAGS
 

General flags sent by clients to the proxy daemon during connect.

Enumeration values:
VBI_PROXY_CLIENT_NO_TIMEOUTS  Don't drop connection upon timeouts in socket I/O or message response (e.g. when waiting for connect confirm) Intended for debugging, i.e. when remote party runs in a debugger
VBI_PROXY_CLIENT_NO_STATUS_IND  Suppress sending of channel change and similar indications, i.e. limit messages to slicer data forward and synchronous messages (i.e. RPC reply). Used to make sure that the proxy client socket only becomes readable when data is available for applications which are not proxy-aware.

enum VBI_PROXY_CHN_FLAGS
 

Channel notification flags.

Enumeration values:
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.

enum VBI_DRIVER_API_REV
 

Identification of the VBI device driver type.

Enumeration values:
VBI_API_UNKNOWN  Unknown device API - only used in error cases. Normally the proxy will always be aware of the driver API as it's determined by the type of capture context creation function used when the device is opened.
VBI_API_V4L1  Video4Linux version 1 (i.e. Linux kernels 2.4 or older or old device drivers which have not been ported yet)
VBI_API_V4L2  Video4Linux version 2 (i.e. Linux kernels 2.6 and later)
VBI_API_BKTR  BSD Brooktree capture driver.


Function Documentation

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
 

Parameters:
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.)

Returns:
Initialized proxy client context, NULL on failure
Since:
0.2.9

void vbi_proxy_client_destroy vbi_proxy_client vpc  ) 
 

Parameters:
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.

Since:
0.2.9

vbi_capture* vbi_proxy_client_get_capture_if vbi_proxy_client vpc  ) 
 

Returns capture interface for an initialized proxy client.

Parameters:
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)

Returns:
Pointer to a vbi_capture structure, should be treated as void * by caller, i.e. acessed neither for read nor write. Returns NULL upon error (i.e. if the client is not connected to the daemon)
Since:
0.2.9

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.

Parameters:
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.

Returns:
Returns pointer to the previous callback or NULL if none.
Since:
0.2.9

VBI_DRIVER_API_REV vbi_proxy_client_get_driver_api vbi_proxy_client vpc  ) 
 

Returns the driver type behind the actual capture device.

Parameters:
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.

Returns:
Driver type or -1 on error.
Since:
0.2.9

int vbi_proxy_client_channel_request vbi_proxy_client vpc,
VBI_CHN_PRIO  chn_prio,
vbi_channel_profile p_chn_profile
 

Parameters:
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.

Returns:
1 if change is allowed, 0 if not allowed, -1 on error, examine errno for details.
Since:
0.2.9

int vbi_proxy_client_channel_notify vbi_proxy_client vpc,
VBI_PROXY_CHN_FLAGS  notify_flags,
unsigned int  scanning
 

Parameters:
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.

Returns:
0 upon success, -1 on error, examine errno for details.
Since:
0.2.9

int vbi_proxy_client_channel_suspend vbi_proxy_client vpc,
VBI_PROXY_SUSPEND  cmd
 

Parameters:
vpc Pointer to initialized proxy client context
cmd Control command
Request to temporarily suspend capturing

Returns:
0 upon success, -1 on error, examine errno for details.
Since:
0.2.9

int vbi_proxy_client_device_ioctl vbi_proxy_client vpc,
int  request,
void *  p_arg
 

Wrapper for ioctl requests on the VBI device.

Parameters:
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.

Returns:
Same as for the ioctl, i.e. -1 on error and errno set appropriately. The funtion also will fail with errno EBUSY if the client doesn't have permission to control the channel.
Since:
0.2.9

int vbi_proxy_client_get_channel_desc vbi_proxy_client vpc,
unsigned int *  p_scanning,
vbi_bool *  p_granted
 

Parameters:
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.

Returns:
0 upon success, -1 on error.
Since:
0.2.9

vbi_bool vbi_proxy_client_has_channel_control vbi_proxy_client vpc  ) 
 

Query if the client is currently allowed to switch channels.

Parameters:
vpc Pointer to initialized proxy client context

Returns:
Returns TRUE if client is currently allowed to switch channels.
Since:
0.2.9


Generated on Mon Jun 9 21:44:14 2008 for ZVBI Library by doxygen 1.3.5