libkate 0.4.3
Functions
Encoding

Functions

int kate_encode_init (kate_state *k, kate_info *ki)
 
int kate_encode_text_raw_times (kate_state *k, kate_int64_t t0, kate_int64_t t1, const char *text, size_t sz, kate_packet *kp)
 
int kate_encode_text (kate_state *k, kate_float t0, kate_float t1, const char *text, size_t sz, kate_packet *kp)
 
int kate_encode_keepalive_raw_times (kate_state *k, kate_int64_t t, kate_packet *kp)
 
int kate_encode_keepalive (kate_state *k, kate_float t, kate_packet *kp)
 
int kate_encode_repeat_raw_times (kate_state *k, kate_int64_t t, kate_int64_t threshold, kate_packet *kp)
 
int kate_encode_repeat (kate_state *k, kate_float t, kate_float threshold, kate_packet *kp)
 
int kate_encode_finish_raw_times (kate_state *k, kate_int64_t t, kate_packet *kp)
 
int kate_encode_finish (kate_state *k, kate_float t, kate_packet *kp)
 
int kate_encode_headers (kate_state *k, kate_comment *kc, kate_packet *kp)
 
int kate_encode_add_motion (kate_state *k, kate_motion *km, int destroy)
 
int kate_encode_add_motion_index (kate_state *k, size_t motion)
 
int kate_encode_add_bitmap (kate_state *k, const kate_bitmap *kb)
 
int kate_encode_add_bitmap_index (kate_state *k, size_t bitmap)
 
int kate_encode_set_region_index (kate_state *k, size_t region)
 
int kate_encode_set_region (kate_state *k, const kate_region *kr)
 
int kate_encode_set_style_index (kate_state *k, size_t style)
 
int kate_encode_set_style (kate_state *k, const kate_style *ks)
 
int kate_encode_set_secondary_style_index (kate_state *k, size_t style)
 
int kate_encode_set_secondary_style (kate_state *k, const kate_style *ks)
 
int kate_encode_set_palette_index (kate_state *k, size_t palette)
 
int kate_encode_set_palette (kate_state *k, const kate_palette *kp)
 
int kate_encode_set_bitmap_index (kate_state *k, size_t bitmap)
 
int kate_encode_set_bitmap (kate_state *k, const kate_bitmap *kb)
 
int kate_encode_set_font_mapping_index (kate_state *k, size_t font_mapping)
 
int kate_encode_set_text_encoding (kate_state *k, kate_text_encoding text_encoding)
 
int kate_encode_set_text_directionality (kate_state *k, kate_text_directionality text_directionality)
 
int kate_encode_set_id (kate_state *k, kate_int32_t id)
 
int kate_encode_set_language (kate_state *k, const char *language)
 
int kate_encode_set_markup_type (kate_state *k, int text_markup_type)
 
int kate_encode_add_meta (kate_state *k, const kate_meta *km)
 
int kate_encode_merge_meta (kate_state *k, kate_meta *km)
 
kate_int64_t kate_encode_get_granule (const kate_state *k)
 

Detailed Description

Function Documentation

◆ kate_encode_add_bitmap()

int kate_encode_add_bitmap ( kate_state k,
const kate_bitmap kb 
)

Adds a bitmap to the currently encoded event.

Parameters
kthe kate_state to add the bitmap to
kbthe bitmap to add
Returns
0 success
KATE_E_* error

References KATE_E_INIT, and KATE_E_INVALID_PARAMETER.

◆ kate_encode_add_bitmap_index()

int kate_encode_add_bitmap_index ( kate_state k,
size_t  bitmap 
)

Adds a bitmap to the currently encoded event by its index into the list of predefined bitmaps.

Parameters
kthe kate_state to add the bitmap to
bitmapthe index of the bitmap to add
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, kate_state::ki, and kate_info::nbitmaps.

◆ kate_encode_add_meta()

int kate_encode_add_meta ( kate_state k,
const kate_meta *  km 
)

Adds a set of metadata to this event

Parameters
kthe kate_state to encode to
kmthe metadata to add (a reference is taken, km must be live until the event is encoded)
Returns
0 success
KATE_E_* error

References KATE_E_INIT, and KATE_E_INVALID_PARAMETER.

◆ kate_encode_add_motion()

int kate_encode_add_motion ( kate_state k,
kate_motion km,
int  destroy 
)

Adds a motion to the currently encoded event. If destroy is set, the motion will be automatically destroyed after the current event has been encoded.

Parameters
kthe kate_state to add the motion to
kmthe motion to add
destroyif true, the motion will be destroyed when the event is fully encoded
Returns
0 success
KATE_E_* error

References KATE_E_INIT, and KATE_E_INVALID_PARAMETER.

◆ kate_encode_add_motion_index()

int kate_encode_add_motion_index ( kate_state k,
size_t  motion 
)

Adds a motion to the currently encoded event by its index into the list of predefined motions.

Parameters
kthe kate_state to add the motion to
motionthe index of the motion to add
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, kate_state::ki, and kate_info::nmotions.

◆ kate_encode_finish()

int kate_encode_finish ( kate_state k,
kate_float  t,
kate_packet kp 
)

Finalizes the currently encoded stream. No more events may be added after this is called.

Parameters
kthe kate_state to encode to
tthe timestamp for the end (if negative, the end time of the last event will be used)
kpthe packet to encode to
Returns
0 success
KATE_E_* error

References kate_duration_granule(), KATE_E_INVALID_PARAMETER, kate_encode_finish_raw_times(), and kate_state::ki.

Referenced by kate_ogg_encode_finish().

◆ kate_encode_finish_raw_times()

int kate_encode_finish_raw_times ( kate_state k,
kate_int64_t  t,
kate_packet kp 
)

Finalizes the currently encoded stream. No more events may be added after this is called.

Parameters
kthe kate_state to encode to
tthe timestamp (in granule rate units) for the end (if negative, the end time of the last event will be used)
kpthe packet to encode to
Returns
0 success
KATE_E_* error

References kate_info::granule_shift, KATE_E_BAD_GRANULE, KATE_E_INIT, KATE_E_INVALID_PARAMETER, KATE_E_NOT_FOUND, and kate_state::ki.

Referenced by kate_encode_finish(), and kate_ogg_encode_finish_raw_times().

◆ kate_encode_get_granule()

kate_int64_t kate_encode_get_granule ( const kate_state k)

Retrieves the current granulepos

Parameters
kthe kate_state to encode to
Returns
>=0 the current granulepos (the one of the last encoded packet)
KATE_E_* error

References KATE_E_INIT, and KATE_E_INVALID_PARAMETER.

◆ kate_encode_headers()

int kate_encode_headers ( kate_state k,
kate_comment kc,
kate_packet kp 
)

Encodes a header. This should be repeatedly called at the beginning of encoding, until a positive value is returned, marking the encoding of the last header.

Parameters
kthe kate_state to encode to
kcthe list of comments to add to the headers
kpthe packet to encode to
Returns
0 success
1 success, and all headers have been encoded
KATE_E_* error

References KATE_E_INIT, and KATE_E_INVALID_PARAMETER.

Referenced by kate_ogg_encode_headers().

◆ kate_encode_init()

int kate_encode_init ( kate_state k,
kate_info ki 
)

Initializes a kate_state structure for encoding using the supplied kate_info structure. When done, the kate_state structure should be cleared using kate_clear.

Parameters
kthe kate_state structure to initialize for encoding
kithe kate_info structure containing the encoding parameters
Returns
0 success
KATE_E_* error

References KATE_E_INVALID_PARAMETER, KATE_E_OUT_OF_MEMORY, kate_state::ki, and kate_info::num_headers.

◆ kate_encode_keepalive()

int kate_encode_keepalive ( kate_state k,
kate_float  t,
kate_packet kp 
)

Emits a keepalive packet, to help with seeking.

Parameters
kthe kate_state to encode to
tthe timestamp for the keepalive packet
kpthe packet to encode to
Returns
0 success
KATE_E_* error

References kate_duration_granule(), KATE_E_INVALID_PARAMETER, kate_encode_keepalive_raw_times(), and kate_state::ki.

Referenced by kate_ogg_encode_keepalive().

◆ kate_encode_keepalive_raw_times()

int kate_encode_keepalive_raw_times ( kate_state k,
kate_int64_t  t,
kate_packet kp 
)

Emits a keepalive packet, to help with seeking.

Parameters
kthe kate_state to encode to
tthe timestamp (in granule rate units) for the keepalive packet
kpthe packet to encode to
Returns
0 success
KATE_E_* error

References kate_info::granule_shift, KATE_E_BAD_GRANULE, KATE_E_INIT, KATE_E_INVALID_PARAMETER, KATE_E_NOT_FOUND, and kate_state::ki.

Referenced by kate_encode_keepalive(), and kate_ogg_encode_keepalive_raw_times().

◆ kate_encode_merge_meta()

int kate_encode_merge_meta ( kate_state k,
kate_meta *  km 
)

Adds a set of metadata to this event

Parameters
kthe kate_state to encode to
kmthe metadata to add (will become invalid after this call returns successfully)
Returns
0 success
KATE_E_* error

References KATE_E_INIT, and KATE_E_INVALID_PARAMETER.

◆ kate_encode_repeat()

int kate_encode_repeat ( kate_state k,
kate_float  t,
kate_float  threshold,
kate_packet kp 
)

Emits a repeat packet, to help with seeking. The first active event at time t, if it or its latest repeat (whichever is the latest) was emitted more than threshold ago, of if threshold is zero, will have a repeat packet emitted. kate_encode_repeat is designed to be called in a loop, as it will return a repeat packet for only one event even if more than one event needs a repeat. When the returned value is 0, no more events need repeating at time t.

Parameters
kthe kate_state to encode to
tthe timestamp for the the packets, if any
thresholdthe time threshold at which to emit a repeat packets (zero to force a repeat)
kpthe packet to encode to
Returns
0 success, and no repeat packet was encoded
1 success, and a repeat packet was encoded
KATE_E_* error

References kate_duration_granule(), KATE_E_INVALID_PARAMETER, kate_encode_repeat_raw_times(), and kate_state::ki.

Referenced by kate_ogg_encode_repeat().

◆ kate_encode_repeat_raw_times()

int kate_encode_repeat_raw_times ( kate_state k,
kate_int64_t  t,
kate_int64_t  threshold,
kate_packet kp 
)

Emits a repeat packet, to help with seeking. The first active event at time t, if it or its latest repeat (whichever is the latest) was emitted more than threshold ago, of if threshold is zero, will have a repeat packet emitted. kate_encode_repeat is designed to be called in a loop, as it will return a repeat packet for only one event even if more than one event needs a repeat. When the returned value is 0, no more events need repeating at time t.

Parameters
kthe kate_state to encode to
tthe timestamp (in granule rate units) for the the packets, if any
thresholdthe time threshold (in granule rate units) at which to emit a repeat packets (zero to force a repeat)
kpthe packet to encode to
Returns
0 success, and no repeat packet was encoded
1 success, and a repeat packet was encoded
KATE_E_* error

References kate_info::granule_shift, KATE_E_BAD_GRANULE, KATE_E_INIT, KATE_E_INVALID_PARAMETER, KATE_E_NOT_FOUND, and kate_state::ki.

Referenced by kate_encode_repeat(), and kate_ogg_encode_repeat_raw_times().

◆ kate_encode_set_bitmap()

int kate_encode_set_bitmap ( kate_state k,
const kate_bitmap kb 
)

Adds a bitmap to the currently encoded event.

Parameters
kthe kate_state to set the bitmap for
kbthe bitmap to set
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, and kate_state::ki.

◆ kate_encode_set_bitmap_index()

int kate_encode_set_bitmap_index ( kate_state k,
size_t  bitmap 
)

Sets the bitmap the event should use, by its index in the predefined bitmap list.

Parameters
kthe kate_state to encode to
bitmapthe index of the predefined bitmap to use
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, kate_state::ki, and kate_info::nbitmaps.

◆ kate_encode_set_font_mapping_index()

int kate_encode_set_font_mapping_index ( kate_state k,
size_t  font_mapping 
)

Sets the font mapping this event's text should be displayed with, by its index into the predefined font mappings list.

Parameters
kthe kate_state to encode to
font_mappingthe font mapping to use
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, kate_state::ki, and kate_info::nfont_mappings.

◆ kate_encode_set_id()

int kate_encode_set_id ( kate_state k,
kate_int32_t  id 
)

This function is obsolete and should not be used. An event identifier is automatically generated for each event. It used to set a unique identifier for the currently encoded event, so it can be referred to later, but not does nothing.

Parameters
kthe kate_state to encode to
idunused
Returns
KATE_E_* error

References KATE_E_IMPL, KATE_E_INIT, and KATE_E_INVALID_PARAMETER.

◆ kate_encode_set_language()

int kate_encode_set_language ( kate_state k,
const char *  language 
)

Sets the language used in this event's text, overriding the default language

Parameters
kthe kate_state to encode to
languagethe language for this event's text - may be NULL (use the default language)
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, and KATE_E_OUT_OF_MEMORY.

◆ kate_encode_set_markup_type()

int kate_encode_set_markup_type ( kate_state k,
int  text_markup_type 
)

Sets the markup type of this event

Parameters
kthe kate_state to encode to
text_markup_typethe markup type of this event
Returns
0 success
KATE_E_* error

References KATE_E_INIT, and KATE_E_INVALID_PARAMETER.

◆ kate_encode_set_palette()

int kate_encode_set_palette ( kate_state k,
const kate_palette kp 
)

Adds a palette to the currently encoded event.

Parameters
kthe kate_state to set the palette for
kpthe palette to set
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, and kate_state::ki.

◆ kate_encode_set_palette_index()

int kate_encode_set_palette_index ( kate_state k,
size_t  palette 
)

Sets the palette the event should use for its bitmap, by its index in the predefined palette list.

Parameters
kthe kate_state to encode to
palettethe index of the predefined palette to use
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, kate_state::ki, and kate_info::npalettes.

◆ kate_encode_set_region()

int kate_encode_set_region ( kate_state k,
const kate_region kr 
)

Sets the region the event should be displayed in.

Parameters
kthe kate_state to encode to
krthe region to use
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, and kate_state::ki.

◆ kate_encode_set_region_index()

int kate_encode_set_region_index ( kate_state k,
size_t  region 
)

Sets the region the event should be displayed in, by its index in the predefined regions list.

Parameters
kthe kate_state to encode to
regionthe index of the predefined region to use
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, kate_state::ki, and kate_info::nregions.

◆ kate_encode_set_secondary_style()

int kate_encode_set_secondary_style ( kate_state k,
const kate_style ks 
)

Sets the secondary style the event should be displayed with.

Parameters
kthe kate_state to encode to
ksthe style to use
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, and kate_state::ki.

◆ kate_encode_set_secondary_style_index()

int kate_encode_set_secondary_style_index ( kate_state k,
size_t  style 
)

Sets the secondary style the event should be displayed with, by its index in the predefined styles list.

Parameters
kthe kate_state to encode to
stylethe index of the predefined style to use
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, kate_state::ki, and kate_info::nstyles.

◆ kate_encode_set_style()

int kate_encode_set_style ( kate_state k,
const kate_style ks 
)

Sets the style the event should be displayed with.

Parameters
kthe kate_state to encode to
ksthe style to use
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, and kate_state::ki.

◆ kate_encode_set_style_index()

int kate_encode_set_style_index ( kate_state k,
size_t  style 
)

Sets the style the event should be displayed with, by its index in the predefined styles list.

Parameters
kthe kate_state to encode to
stylethe index of the predefined style to use
Returns
0 success
KATE_E_* error

References KATE_E_INIT, KATE_E_INVALID_PARAMETER, kate_state::ki, and kate_info::nstyles.

◆ kate_encode_set_text_directionality()

int kate_encode_set_text_directionality ( kate_state k,
kate_text_directionality  text_directionality 
)

Sets the text directionality used in this event's text, overriding the default text directionality.

Parameters
kthe kate_state to encode to
text_directionalitythe text directionality for this event's text
Returns
0 success
KATE_E_* error

References KATE_E_INIT, and KATE_E_INVALID_PARAMETER.

◆ kate_encode_set_text_encoding()

int kate_encode_set_text_encoding ( kate_state k,
kate_text_encoding  text_encoding 
)

Sets the character encoding used in this event's text, overriding the default character encoding.

Parameters
kthe kate_state to encode to
text_encodingthe text encoding for this event's text
Returns
0 success
KATE_E_* error

References KATE_E_INIT, and KATE_E_INVALID_PARAMETER.

◆ kate_encode_text()

int kate_encode_text ( kate_state k,
kate_float  t0,
kate_float  t1,
const char *  text,
size_t  sz,
kate_packet kp 
)

Encodes a text (which may be NULL) of the given size, starting at t0 and ending at t1. This should always be called when encoding an event, even if the text is NULL. After this is called, the event is fully encoded and cannot be added to anymore.

Parameters
kthe kate_state to add the text to
t0the start time in seconds of the text
t1the end time in seconds of the text
textthe text to add (may be NULL)
szthe length in bytes of the text to add
kpthe packet to encode to
Returns
0 success
KATE_E_* error

References kate_duration_granule(), KATE_E_INVALID_PARAMETER, kate_encode_text_raw_times(), and kate_state::ki.

Referenced by kate_ogg_encode_text().

◆ kate_encode_text_raw_times()

int kate_encode_text_raw_times ( kate_state k,
kate_int64_t  t0,
kate_int64_t  t1,
const char *  text,
size_t  sz,
kate_packet kp 
)

Encodes a text (which may be NULL) of the given size, starting at t0 and ending at t1. This should always be called when encoding an event, even if the text is NULL. After this is called, the event is fully encoded and cannot be added to anymore.

Parameters
kthe kate_state to add the text to
t0the start time in granule units of the text
t1the end time in granule units of the text
textthe text to add (may be NULL)
szthe length in bytes of the text to add
kpthe packet to encode to
Returns
0 success
KATE_E_* error

References kate_packet::data, kate_info::granule_shift, KATE_E_BAD_GRANULE, KATE_E_INIT, KATE_E_INVALID_PARAMETER, kate_text_validate(), kate_state::ki, and kate_packet::nbytes.

Referenced by kate_encode_text(), and kate_ogg_encode_text_raw_times().