ZVBI Library
0.2.35
|
Functions to decode VPS/PDC Program IDs and helper functions. More...
Data Structures | |
struct | vbi_program_id |
Program Identification. More... | |
Macros | |
#define | VBI_PIL(month, day, hour, minute) (((day) << 15) | ((month) << 11) | ((hour) << 6) | (minute)) |
Macro to create a PIL. More... | |
#define | VBI_PIL_MONTH(pil) (((pil) >> 11) & 15) |
#define | VBI_PIL_DAY(pil) (((pil) >> 15) & 31) |
#define | VBI_PIL_HOUR(pil) (((pil) >> 6) & 31) |
#define | VBI_PIL_MINUTE(pil) ((pil) & 63) |
Typedefs | |
typedef unsigned int | vbi_pil |
Program Identification Label. More... | |
Enumerations | |
enum | { VBI_PIL_TIMER_CONTROL = VBI_PIL (15, 0, 31, 63), VBI_PIL_INHIBIT_TERMINATE = VBI_PIL (15, 0, 30, 63), VBI_PIL_INTERRUPTION = VBI_PIL (15, 0, 29, 63), VBI_PIL_CONTINUE = VBI_PIL (15, 0, 28, 63), VBI_PIL_NSPV = VBI_PIL (15, 15, 31, 63), VBI_PIL_END = VBI_PIL (15, 15, 31, 63) } |
PIL Service Codes. More... | |
enum | vbi_pid_channel { VBI_PID_CHANNEL_LCI_0 = 0, VBI_PID_CHANNEL_LCI_1, VBI_PID_CHANNEL_LCI_2, VBI_PID_CHANNEL_LCI_3, VBI_PID_CHANNEL_VPS, VBI_PID_CHANNEL_PDC_DESCRIPTOR, VBI_PID_CHANNEL_XDS_CURRENT, VBI_PID_CHANNEL_XDS_FUTURE, VBI_MAX_PID_CHANNELS } |
Sources of PIDs. More... | |
enum | vbi_pcs_audio { VBI_PCS_AUDIO_UNKNOWN = 0, VBI_PCS_AUDIO_MONO, VBI_PCS_AUDIO_STEREO, VBI_PCS_AUDIO_BILINGUAL } |
PDC Program Control Status - Audio. More... | |
Functions | |
vbi_bool | vbi_pil_is_valid_date (vbi_pil pil) |
time_t | vbi_pil_to_time (vbi_pil pil, time_t start, const char *tz) |
time_t | vbi_pil_lto_to_time (vbi_pil pil, time_t start, int seconds_east) |
vbi_bool | vbi_pty_validity_window (time_t *begin, time_t *end, time_t time, const char *tz) |
vbi_bool | vbi_pil_validity_window (time_t *begin, time_t *end, vbi_pil pil, time_t start, const char *tz) |
vbi_bool | vbi_pil_lto_validity_window (time_t *begin, time_t *end, vbi_pil pil, time_t start, int seconds_east) |
Functions to decode VPS/PDC Program IDs and helper functions.
Program IDs are transmitted by networks to remotely control video recorders. They can be used to
The basic principle is to transmit a label along with the program containing the originally announced start date and time. When the label is no longer transmitted the program has ended. When two programs on different channels are scheduled for recording the recorder may have to scan the channels alternately. Better accuracy than a few seconds within the actual start should not be expected.
Libzvbi supports Program IDs transmitted in Teletext packet 8/30 format 2 and in VPS packets as defined in EN 300 231 "Television systems; Specification of the domestic video Programme Delivery Control system (PDC)", and DVB PDC descriptors as defined in EN 300 468 "Specification for Service Information (SI) in DVB systems". Support for XDS Current/Future Program ID packets as defined in EIA 608-B "Recommended Practice for Line 21 Data Service" is planned but not implemented yet.
Program IDs are available through the low level functions vbi_decode_teletext_8302_pdc(), vbi_decode_vps_pdc(), vbi_decode_dvb_pdc_descriptor() and the vbi_decoder event VBI_EVENT_PROG_ID
.
#define VBI_PIL | ( | month, | |
day, | |||
hour, | |||
minute | |||
) | (((day) << 15) | ((month) << 11) | ((hour) << 6) | (minute)) |
Macro to create a PIL.
Valid values for month are 1 ... 12, for day 1 ... 31, for hour 0 ... 23 and for minute 0 ... 59.
Note in the PDC system (EN 300 231) networks may also transmit unreal dates or times like 14-00 25:63. You can determine if a PIL represents a valid date and time with the vbi_pil_is_valid_date() function.
#define VBI_PIL_MONTH | ( | pil | ) | (((pil) >> 11) & 15) |
Extract the month from a PIL. Valid values are in range 1 ... 12.
Referenced by vbi_pil_is_valid_date(), vbi_pil_lto_validity_window(), and vbi_pil_validity_window().
#define VBI_PIL_DAY | ( | pil | ) | (((pil) >> 15) & 31) |
Extract the day from a PIL. Valid values are in range 1 ... 31.
Referenced by vbi_pil_is_valid_date(), vbi_pil_lto_validity_window(), and vbi_pil_validity_window().
#define VBI_PIL_HOUR | ( | pil | ) | (((pil) >> 6) & 31) |
Extract the hour from a PIL. Valid values are in range 0 ... 23.
Referenced by vbi_pil_is_valid_date(), and vbi_pil_to_time().
#define VBI_PIL_MINUTE | ( | pil | ) | ((pil) & 63) |
Extract the minute from a PIL. Valid values are in range 0 ... 59.
Referenced by vbi_pil_is_valid_date(), and vbi_pil_to_time().
typedef unsigned int vbi_pil |
Program Identification Label.
This is a packed representation of the originally announced start date and time ("AT-2" in EN 300 231 parlance, "Scheduled Start Time" in EIA 608-B) of a program.
anonymous enum |
PIL Service Codes.
PILs can be zero, or specify a valid date and time, or an unreal time such as 31:00 if a new label has been assigned to a program but no transmission time has been decided yet. Some PILs with unreal date and time have a special meaning.
These codes are defined in EN 300 231 Section 6.2, Annex E.3 and Annex F, and in EIA 608-B Section 9.5.1.1.
enum vbi_pid_channel |
Sources of PIDs.
A program identification can be transmitted on different logical channels. Teletext packet 8/30 format 2 contains a Label Channel Identifier. XDS Program ID packets can refer to the current or next program.
This information is returned in struct vbi_program_id by the low level functions vbi_decode_teletext_8302_pdc(), vbi_decode_vps_pdc(), vbi_decode_dvb_pdc_descriptor() and the vbi_decoder event VBI_EVENT_PROG_ID
.
enum vbi_pcs_audio |
PDC Program Control Status - Audio.
This information is available with Teletext and VPS program IDs and returned in struct vbi_program_id by the low level functions vbi_decode_teletext_8302_pdc(), vbi_decode_vps_pdc() and the vbi_decoder event VBI_EVENT_PROG_ID
.
vbi_bool vbi_pil_is_valid_date | ( | vbi_pil | pil | ) |
pil | Program Identification Label. |
Determines if pil represents a valid date and time.
Since PILs have no year field February 29th is considered valid. You can find out if this date is valid in a given year with the vbi_pil_to_time() function.
24:00 is not valid (an unreal hour) as defined in EN 300 231 Annex F and EIA 608-B Section 9.5.1.1.
TRUE
if pil represents a valid date and time, FALSE
if pil contains an unreal date or time (e.g. Jan 0 27:61), a service code or unallocated code.References VBI_PIL_DAY, VBI_PIL_HOUR, VBI_PIL_MINUTE, and VBI_PIL_MONTH.
Referenced by vbi_pil_lto_to_time(), and vbi_pil_to_time().
time_t vbi_pil_to_time | ( | vbi_pil | pil, |
time_t | start, | ||
const char * | tz | ||
) |
pil | Program Identification Label (PIL) to convert. |
start | The most recently announced start time of the program. If zero the current system time will be used. |
tz | A time zone name in the same format as the TZ environment variable. If NULL the current value of TZ will be used. |
This function converts a PIL to a time_t in the same manner localtime() converts a broken-down time to time_t.
Since PILs do not contain a year field, the year is determined from the start parameter, that is the most recently announced start time of the program or "AT-1" in EN 300 231 parlance. If pil contains a month more than five months after start, pil is assumed to refer to an earlier date than start.
pil is assumed to be a time in the time zone tz. start will be converted to a local time in the same time zone to determine the correct year.
Teletext packet 8/30 format 2, VPS and DVB PDC descriptors give a PIL relative to the time zone of the intended audience of the program. Ideally the time zone would be specified as a geographic area like "Europe/London", such that the function can determine the correct offset from UTC and if daylight-saving time is in effect at the specified date. See the documentation of the localtime() function and the TZ environment variable for details.
XDS Current/Future Program ID packets give a PIL relative to UTC. Just specify time zone "UTC" in this case.
NULL
. That is a limitation of the C library which permits the conversion of a broken-down time in an arbitrary time zone only by setting the TZ environment variable. The function may also fail to restore the value of TZ if insufficient memory is available. References VBI_PIL_HOUR, vbi_pil_is_valid_date(), and VBI_PIL_MINUTE.
time_t vbi_pil_lto_to_time | ( | vbi_pil | pil, |
time_t | start, | ||
int | seconds_east | ||
) |
pil | Program Identification Label (PIL) to convert. |
start | The most recently announced start time of the program. If zero the current system time will be used. |
seconds_east | A time zone specified as an offset in seconds east of UTC, for example +1 * 60 * 60 for CET. seconds_east may include a daylight-saving time (DST) offset. |
This function converts a PIL to a time_t in the same manner localtime() converts a broken-down time to time_t.
Since PILs do not contain a year field, the year is determined from the start parameter, that is the most recently announced start time of the program or "AT-1" in EN 300 231 parlance. If pil contains a month more than five months after start, pil is assumed to refer to an earlier date than start.
pil is assumed to be a time in the time zone specified by seconds_east. start will be converted to a local time in the same time zone to determine the correct year.
Teletext packet 8/30 format 2, VPS and DVB PDC descriptors give a PIL relative to the time zone of the intended audience of the program. An offset from UTC including the DST offset in effect at the specified date may be available on Teletext program announcement pages (see struct vbi_preselection). Another offset from UTC including the current DST offset is available as VBI_EVENT_LOCAL_TIME
, but of course that information is insufficient to determine if DST is in effect at other dates.
XDS Current/Future Program ID packets give a PIL relative to UTC, so seconds_east should be zero.
References vbi_pil_is_valid_date().
vbi_bool vbi_pty_validity_window | ( | time_t * | begin, |
time_t * | end, | ||
time_t | last_transm, | ||
const char * | tz | ||
) |
begin | The begin of the validity of the PTY will be stored here. |
end | The end of the validity of the PTY will be stored here. |
last_transm | The last time when a program ID with the PTY in question was broadcast by the network. |
tz | A time zone name in the same format as the TZ environment variable. If NULL the current value of TZ will be used. |
This function calculates the validity time window of a Program Type (PTY) code according to EN 300 231. That is the time window where a network can be expected to broadcast another program with the same PTY, approximately up to four weeks after its last transmission. When the PTY is a series code (>= 0x80) and not transmitted again before end, the network may assign the code to another series.
tz is the time zone of the intended audience of the program. Ideally the time zone would be specified as a geographic area like "Europe/London", such that the function can determine if daylight-saving time is in effect at time or at the end of the validity time window. See the documentation of the localtime() function and the TZ environment variable for details. If no time zone name is available "UTC" should be specified, the returned end time may be off by one hour in this case.
FALSE
and *begin and *end remain unchanged:NULL
. That is a limitation of the C library which permits the conversion of a broken-down time in an arbitrary time zone only by setting the TZ environment variable. The function may also fail to restore the value of TZ if insufficient memory is available. Referenced by vbi_pil_validity_window().
vbi_bool vbi_pil_validity_window | ( | time_t * | begin, |
time_t * | end, | ||
vbi_pil | pil, | ||
time_t | start, | ||
const char * | tz | ||
) |
begin | The start of the validity of the PIL will be stored here. |
end | The end of the validity of the PIL will be stored here. |
pil | Program Identification Label (PIL). |
start | The most recently announced start time of the program. If zero the current system time will be used. |
tz | A time zone name in the same format as the TZ environment variable. If NULL the current value of TZ will be used. |
This function calculates the validity time window of a PIL according to EN 300 231. That is the time window where a network can be expected to broadcast this PIL, usually from 00:00 on the same day until 04:00 on the next day.
Since PILs do not contain a year field, the year is determined from the start parameter, that is the most recently announced start time of the program or "AT-1" in EN 300 231 parlance. If pil contains a month more than five months after start, pil is assumed to refer to an earlier date than start.
pil is assumed to be a time in the time zone specified by seconds_east. start will be converted to a local time in the same time zone to determine the correct year.
Teletext packet 8/30 format 2, VPS and DVB PDC descriptors give a PIL relative to the time zone of the intended audience of the program. Ideally the time zone would be specified as a geographic area like "Europe/London", such that the function can determine the correct offset from UTC and if daylight-saving time is in effect at any time within the validity window. See the documentation of the localtime() function and the TZ environment variable for details.
If pil is VBI_PIL_NSPV
this function returns the same values as vbi_pty_validity_window().
FALSE:
VBI_PIL_NSPV
and does not contain a valid date or time. February 29th is a valid date only if the estimated year is a leap year.NULL
. That is a limitation of the C library which permits the conversion of a broken-down time in an arbitrary time zone only by setting the TZ environment variable. The function may also fail to restore the value of TZ if insufficient memory is available. References VBI_PIL_CONTINUE, VBI_PIL_DAY, VBI_PIL_INHIBIT_TERMINATE, VBI_PIL_INTERRUPTION, VBI_PIL_MONTH, VBI_PIL_NSPV, VBI_PIL_TIMER_CONTROL, and vbi_pty_validity_window().
vbi_bool vbi_pil_lto_validity_window | ( | time_t * | begin, |
time_t * | end, | ||
vbi_pil | pil, | ||
time_t | start, | ||
int | seconds_east | ||
) |
begin | The start of the validity of the PIL will be stored here. |
end | The end of the validity of the PIL will be stored here. |
pil | Program Identification Label (PIL). |
start | The most recently announced start time of the program. If zero the current system time will be used. |
seconds_east | A time zone specified as an offset in seconds east of UTC, for example +1 * 60 * 60 for CET. seconds_east may include a daylight-saving time (DST) offset. |
This function calculates the validity time window of a PIL according to EN 300 231. That is the time window where a network can be expected to broadcast this PIL, usually from 00:00 on the same day until exclusive 04:00 on the next day.
Since PILs do not contain a year field, the year is determined from the start parameter, that is the most recently announced start time of the program or "AT-1" in EN 300 231 parlance. If pil contains a month more than five months after start, pil is assumed to refer to an earlier date than start.
pil is assumed to be a time in the time zone specified by seconds_east. start will be converted to a local time in the same time zone to determine the correct year.
Teletext packet 8/30 format 2, VPS and DVB PDC descriptors give a PIL relative to the time zone of the intended audience of the program. An offset from UTC including the DST offset in effect at the specified date may be available on Teletext program announcement pages (see struct vbi_preselection). Another offset from UTC including the current DST offset is available as VBI_EVENT_LOCAL_TIME
. But of course these offsets are insufficient to determine if DST is in effect at any given date, so the returned begin or end may be off by one hour if the validity window straddles a DST discontinuity.
If pil is VBI_PIL_NSPV
this function ignores seconds_east and returns the same values as vbi_pty_validity_window().
FALSE:
VBI_PIL_NSPV
and does not contain a valid date or time. February 29th is a valid date only if the estimated year is a leap year.References VBI_PIL_CONTINUE, VBI_PIL_DAY, VBI_PIL_INHIBIT_TERMINATE, VBI_PIL_INTERRUPTION, VBI_PIL_MONTH, VBI_PIL_NSPV, and VBI_PIL_TIMER_CONTROL.