Extended Data Service (XDS) demultiplexer
Low Level Decoding

Separating XDS data from a Closed Caption stream (EIA 608). More...

## Data Structures

struct | vbi_xds_packet
| XDS Packet. A pointer to this structure is passed to the XDS demux callback. More...

## Macros

#define | VBI_XDS_MAX_CLASSES (VBI_XDS_CLASS_UNDEFINED + 1)
#define | VBI_XDS_MAX_SUBCLASSES (0x18)

## Typedefs

typedef unsigned int | vbi_xds_subclass
| Generic XDS subclass. You must cast to the appropriate subclass type depending on the XDS class.
typedef struct _vbi_xds_demux | vbi_xds_demux
| XDS demultiplexer.
typedef vbi_bool | vbi_xds_demux_cb(vbi_xds_demux *xd, const vbi_xds_packet *xp, void *user_data)

## Enumerations

enum | vbi_xds_class { VBI_XDS_CLASS_CURRENT = 0x00 , VBI_XDS_CLASS_FUTURE , VBI_XDS_CLASS_CHANNEL , VBI_XDS_CLASS_MISC , VBI_XDS_CLASS_PUBLIC_SERVICE , VBI_XDS_CLASS_RESERVED , VBI_XDS_CLASS_UNDEFINED }
| XDS packet class. XDS data is transmitted in packets. Each packet belongs to one of seven classes.

enum

vbi_xds_subclass_program {
VBI_XDS_PROGRAM_ID = 0x01 ,
VBI_XDS_PROGRAM_LENGTH ,
VBI_XDS_PROGRAM_NAME ,
VBI_XDS_PROGRAM_TYPE ,
VBI_XDS_PROGRAM_RATING ,
VBI_XDS_PROGRAM_AUDIO_SERVICES ,
VBI_XDS_PROGRAM_CAPTION_SERVICES ,
VBI_XDS_PROGRAM_CGMS ,
VBI_XDS_PROGRAM_ASPECT_RATIO ,
VBI_XDS_PROGRAM_DATA = 0x0C ,
VBI_XDS_PROGRAM_MISC_DATA ,
VBI_XDS_PROGRAM_DESCRIPTION_BEGIN = 0x10 ,
VBI_XDS_PROGRAM_DESCRIPTION_END = 0x18
}

| `VBI_XDS_CLASS_CURRENT` and `VBI_XDS_CLASS_FUTURE` subclass. More...
enum | vbi_xds_subclass_channel { VBI_XDS_CHANNEL_NAME = 0x01 , VBI_XDS_CHANNEL_CALL_LETTERS , VBI_XDS_CHANNEL_TAPE_DELAY , VBI_XDS_CHANNEL_TSID }
| `VBI_XDS_CLASS_CHANNEL` subclass. More...
enum | vbi_xds_subclass_misc { VBI_XDS_TIME_OF_DAY = 0x01 , VBI_XDS_IMPULSE_CAPTURE_ID , VBI_XDS_SUPPLEMENTAL_DATA_LOCATION , VBI_XDS_LOCAL_TIME_ZONE , VBI_XDS_OUT_OF_BAND_CHANNEL = 0x40 , VBI_XDS_CHANNEL_MAP_POINTER , VBI_XDS_CHANNEL_MAP_HEADER , VBI_XDS_CHANNEL_MAP }
| `VBI_XDS_CLASS_MISC` subclass. More...
enum | vbi_xds_subclass_public_service { VBI_XDS_WEATHER_BULLETIN = 0x01 , VBI_XDS_WEATHER_MESSAGE }
| `VBI_XDS_CLASS_PUBLIC_SERVICE` subclass. More...

## Functions

void | vbi_xds_demux_reset (vbi_xds_demux *xd)
vbi_bool | vbi_xds_demux_feed (vbi_xds_demux *xd, const uint8_t buffer[2])
vbi_bool | vbi_xds_demux_feed_frame (vbi_xds_demux *xd, const vbi_sliced *sliced, unsigned int n_lines)
void | vbi_xds_demux_delete (vbi_xds_demux *xd)
vbi_xds_demux * | vbi_xds_demux_new (vbi_xds_demux_cb *callback, void *user_data) _vbi_alloc

## Detailed Description

Separating XDS data from a Closed Caption stream (EIA 608).

## Typedef Documentation

## vbi_xds_demux

typedef struct _vbi_xds_demux vbi_xds_demux

XDS demultiplexer.

The contents of this structure are private. Call vbi_xds_demux_new() to allocate a XDS demultiplexer.

## vbi_xds_demux_cb

typedef vbi_bool vbi_xds_demux_cb(vbi_xds_demux *xd, const vbi_xds_packet *xp, void *user_data)

Parameters

  xd | XDS demultiplexer context allocated with vbi_xds_demux_new().
  user_data | User data pointer given to vbi_xds_demux_new().
  xp | Pointer to the received XDS data packet.

The XDS demux calls a function of this type when an XDS packet has been completely received, all bytes have correct parity and the packet checksum is correct. Other packets are discarded.

Returns
  FALSE on error, will be returned by vbi_xds_demux_feed().

## Enumeration Type Documentation

## vbi_xds_subclass_program

enum vbi_xds_subclass_program

`VBI_XDS_CLASS_CURRENT` and `VBI_XDS_CLASS_FUTURE` subclass.

Enumerator

VBI_XDS_PROGRAM_DATA

Since
  0.2.17

VBI_XDS_PROGRAM_MISC_DATA

Since
  0.2.17

## vbi_xds_subclass_channel

enum vbi_xds_subclass_channel

`VBI_XDS_CLASS_CHANNEL` subclass.

Enumerator

VBI_XDS_CHANNEL_TSID

Since
  0.2.17

## vbi_xds_subclass_misc

enum vbi_xds_subclass_misc

`VBI_XDS_CLASS_MISC` subclass.

Enumerator

VBI_XDS_OUT_OF_BAND_CHANNEL

Since
  0.2.17

VBI_XDS_CHANNEL_MAP_POINTER

Since
  0.2.17

VBI_XDS_CHANNEL_MAP_HEADER

Since
  0.2.17

VBI_XDS_CHANNEL_MAP

Since
  0.2.17

## vbi_xds_subclass_public_service

enum vbi_xds_subclass_public_service

`VBI_XDS_CLASS_PUBLIC_SERVICE` subclass.

Since
  0.2.17

## Function Documentation

## vbi_xds_demux_reset()

void vbi_xds_demux_reset | ( | vbi_xds_demux * | xd | ) |

extern

Parameters

  xd | XDS demultiplexer context allocated with vbi_xds_demux_new().

Resets the XDS demux, useful for example after a channel change.

Since
  0.2.16

## vbi_xds_demux_feed()

vbi_bool vbi_xds_demux_feed | ( | vbi_xds_demux * | xd,
|  | const uint8_t | buffer[2] )

extern

Parameters

  xd | XDS demultiplexer context allocated with vbi_xds_demux_new().
  buffer | Closed Caption character pair, as in struct vbi_sliced.

This function takes two successive bytes of a raw Closed Caption stream, filters out XDS data and calls the output function given to vbi_xds_demux_new() when a new packet is complete.

You should feed only data from NTSC line 284.

Returns
  `FALSE` if the buffer contained parity errors.

Since
  0.2.16

References vbi_xds_packet::buffer, vbi_xds_packet::buffer_size, and vbi_unpar8().

Referenced by vbi_xds_demux_feed_frame().

## vbi_xds_demux_feed_frame()

vbi_bool vbi_xds_demux_feed_frame | ( | vbi_xds_demux * | xd,
|  | const vbi_sliced * | sliced,
|  | unsigned int | n_lines )

extern

Parameters

  xd | XDS demultiplexer context allocated with vbi_xds_demux_new().
  sliced | Sliced VBI data.
  n_lines | Number of lines in the sliced array.

This function works like vbi_xds_demux_feed() but operates on sliced VBI data and filters out `VBI_SLICED_CAPTION_525` on NTSC line 284.

Returns
  `FALSE` if any of the Caption lines contained parity errors.

Since
  0.2.26

References vbi_sliced::data, vbi_sliced::id, vbi_sliced::line, and vbi_xds_demux_feed().

## vbi_xds_demux_delete()

void vbi_xds_demux_delete | ( | vbi_xds_demux * | xd | ) |

extern

Parameters

  xd | XDS demultiplexer context allocated with vbi_xds_demux_new(), can be `NULL`.

Frees all resources associated with xd.

Since
  0.2.16

## vbi_xds_demux_new()

vbi_xds_demux * vbi_xds_demux_new | ( | vbi_xds_demux_cb * | callback,
|  | void * | user_data )

extern

Parameters

  callback | Function to be called by vbi_xds_demux_feed() when a new packet is available.
  user_data | User pointer passed through to callback function.

Allocates a new Extended Data Service (EIA 608) demultiplexer.

Returns
  Pointer to newly allocated XDS demux context which must be freed with vbi_xds_demux_delete() when done. `NULL` on failure (out of memory).

Since
  0.2.16