Home/docs/reference/C ABI overview

C ABI overview

C ABI Overview

Global conventions and type definitions for the C ABI. The function lists are split by entry family: ErikaHandle (23), ErikaPresenterHandle (82), and general and standalone entry points (20). crates/erika_capi/include/erika.h is the sole authority.

Entry points and conventions#

There are two independent entry families. Integrate one or the other, not both:

  • ErikaHandle — pull model. The host renders and polls state.
  • ErikaPresenterHandle — push model. The engine manages decoding, timing, audio, and rendering; the host provides a surface and calls render_tick. Available on macOS / iOS / tvOS / Windows / Android / OpenHarmony / Linux; on other targets create returns NULL.

Global conventions:

  • Functions that return a status use ErikaStatus: Ok (0) and NoEvent (5) are non-error results. Other functions return pointers, values, or nothing; consult the header for their failure conventions. Many status-returning operations catch panics as ErikaStatus_Panic, but not every entry point catches panics, and panic-abort builds can terminate the process.
  • Some failures set a thread-local error message, but not every failure guarantees one; the slot may be empty or retain an earlier message. On the thread where the call failed, before making another call, read any available message with erika_last_error_message() and free a non-null result with erika_string_free(). For example, erika_add_external_subtitle returns NullPointer directly when out_track_id is NULL, without updating the slot.
  • A char* returned by liberika belongs to the caller. Free independent strings with erika_string_free(); release strings inside ErikaTrackInfo / ErikaDanmakuTrackInfo with the matching *_info_free().
  • const char* parameters are borrowed only for the duration of the call and must be NUL-terminated UTF-8.
  • List queries use the counted-array idiom (buf, capacity, &len). len is set to the total count, and at most capacity entries are written. When capacity is 0 and buf is NULL, the call only queries the count.
  • The width and height passed to attach and resize are in physical pixels. scale is the DPI ratio for logical content such as UI and danmaku; it does not scale the surface extent.
  • A handle has no internal synchronization and must not be called concurrently from multiple threads.

ErikaStatus#

ValueNameDescription
0OkSuccess.
1NullPointerA parameter is a null pointer.
2InvalidUtf8A string parameter is not valid UTF-8.
3PlayerErrorPlayer error.
4PanicInternal panic, caught.
5NoEventThe event queue is empty (not an error).

ErikaState#

ValueNameDescription
0IdleThe initial state after creation.
1OpeningOpening.
2ReadyReady, not playing.
3PlayingPlaying.
4PausedPaused.
5StoppedStopped.
6ClosedClosed.
7ErrorError state.

ErikaEventKind#

The enum has 14 values: 13 event kinds and None. Value 13 is reserved for host use and is not emitted by the engine.

Events are retrieved with poll_event. The queue is unbounded: a host that never polls only accumulates events and stops observing state; no events are dropped. Only one group of fields in ErikaEvent is valid, as determined by kind. VideoDecoderChanged and AudioOutputChanged have no payload fields, but they write a structured message to the thread-local error slot, which you can read with erika_last_error_message.

ValueNameDescriptionPayload
0NoneNo event.—
1StateChangedPlayback state changed.state
2DurationChangedDuration determined or changed.duration_micros
3PositionChangedPlayback position advanced. Sent about every 100 ms during playback, and separately on seek, play, and EOF.position_micros
4TracksChangedTrack list changed.tracks; re-query the tracks afterward
5BufferingChangedBuffering state toggled.buffering
6VideoParamsChangedVideo parameters changed.video
7SurfaceAttachedSurface attached.—
8SurfaceDetachedSurface detached.—
9ErrorError.status; last_error_message on the same thread returns details
10TrackSelectionChangedSelected track changed.—
11VideoDecoderChangedVideo decoding backend switched.—
12AudioOutputChangedAudio output state changed.—
14EndedNatural playback completion, after Stopped; an explicit stop does not emit it.—

Type inventory#

All 50 type definitions are in erika.h. The tables below list the fields of the main structs; for complete field and enumeration definitions, the header of the same version is authoritative.

Handles

  • ErikaHandle — Pull-model handle.
  • ErikaPresenterHandle — Push-model handle.
  • ErikaFrameExportSession — Standalone frame export session handle.
  • ErikaColdOpenCancellation — One-shot ticket for cancelling an open (0.3.8, experimental).

Structs

TypePurpose
ErikaHttpHeaderHTTP request header used when opening (name / value).
ErikaPresenterConfigOutput mode, EDR headroom, upscaling, and video alpha mode.
ErikaSubtitleStyleSubtitle style override, including override_mask.
ErikaSurfaceOutputCapabilitiesSurface output capabilities (extended-linear, direct composition, headroom).
ErikaUpscalerStatusUpscaling status and frame counts.
ErikaOutputStatusOutput encoding, headroom, and fallback state.
ErikaPresenterResourceStatusRenderer memory snapshot.
ErikaSubtitleMemoryFontStatusIn-memory font registration status.
ErikaSubtitleMemoryFontFace / InfoIn-memory font face and metadata.
ErikaDanmakuConfigDanmaku layout and display parameters.
ErikaDanmakuTrackInfoDanmaku track information.
ErikaVideoParamsVideo size, color primaries, and transfer.
ErikaTrackCounts / Selection / InfoTrack counts, current selection, track info.
ErikaEventEvent payload.
ErikaPresenterStatsRendering statistics; fields are listed in the table below.

New types in 0.3.0

ErikaFrameExportFormat defines RGBA (0) and PNG (1). ErikaFrameExportOptions, ErikaFrameExportResult, ErikaFrameExportSessionOptions, and ErikaFrameExportRequest describe a single export, its result, opening a session, and per-frame requests, respectively. ErikaFrameExportSession is an opaque session handle. ErikaLogLevel runs from Trace (0) to Error (4). For the full declarations and ownership rules, see Frame export and logging.

Struct fields

The tables below list the fields, types, and semantics of the commonly used structs. Field names match erika.h.

ErikaSubtitleStyle

Fallback subtitle appearance defaults to opaque white text (0xFFFFFFFF) with a translucent black outline (0x0000007F). Out-of-range numeric metrics are clamped rather than rejected; an out-of-range border_style or alignment is replaced with its default (1 and 2, respectively). How the fields take effect depends on the subtitle type. On container ASS tracks, these fields have no effect when override_mask is 0, except for font-family fallback; setting a bit makes the corresponding field override the style declared by the ASS dialogue. For plain-text subtitles (SRT/WebVTT), liberika bakes the whole style into the ASS header it generates, regardless of override_mask. All dimensions are in ASS script units and are multiplied by the set_subtitle_scale factor.

FieldTypeDescription
font_familyconst char*NULL or an empty string keeps the platform default.
font_file_pathconst char*Font file path.
primary_color_rgbauint32_tText color, 0xRRGGBBAA.
outline_color_rgbauint32_tOutline color, 0xRRGGBBAA.
font_sizedouble8..400, default 48.
outline_widthdouble0..32, default 2.
bold / italic / underline / strike_outboolGlyph attributes.
spacingdouble-100..100.
scale_x_percent / scale_y_percentdouble1..1000, 100 = no scaling.
border_styleint32_t1 = outline + shadow, 3 = opaque box.
shadow_depthdouble0..32.
blurdouble0..100.
alignmentint32_t1..9, numeric keypad layout; 2 = bottom center.
margin_left / margin_right / margin_verticalint32_tMargins, clamped to 0..10000.
override_maskuint32_tOverride bitmask; see the bit table below.

When an override bit is set, dimensions stay resolution-independent: a font_size of 48 yields the same pixel size regardless of the PlayResY the script declares. Margins are the exception: on container ASS tracks they scale with the script’s PlayResY, while on plain-text subtitles they are in pixels (liberika generates that script to match the frame size). With a zero mask, all fields stay fallback-only: they have no effect on container tracks, and erika_presenter_set_subtitle_style only influences font selection.

ErikaDanmakuConfig

Scroll duration formula: milliseconds to cross the screen = scroll_duration_seconds × clamp(logical width / 1280, 0.9, 1.3) × 1000 / scroll_speed_factor; speed = (viewport width + text width) / duration. max_quantity is a density filter on the number of items on screen at once within the scroll window, and applies only to scrolling danmaku. For max_lines_per_mode, “per mode” means one limit each for scroll-left, scroll-right, top, and bottom. set_danmaku_config replaces the fields visible from C; block_words and the custom font fields are inherited from the current configuration.

FieldTypeDefaultDescription
enabledbooltrueDanmaku master switch.
font_sizefloat30NipaPlay/Flutter logical font size; converted to glyph pixels using the surface scale.
opacityfloat1.0Opacity.
display_areafloat1.0Fraction of the viewport height used by the danmaku area, clamped to 0.1..1.0.
scroll_duration_secondsfloat10.0Baseline time for scrolling danmaku to cross the screen, clamped to 1..60 seconds.
scroll_speed_factorfloat1.0Scroll speed factor, clamped to 0.2..4.0; larger is faster.
track_gap_ratiofloat0.15Track line spacing = danmaku height × this ratio, clamped to 0..2.
outline_widthfloat1.0Outline width.
shadow_offset_x / shadow_offset_yfloat1.0 / 1.0Shadow offset.
merge_duplicatesboolfalseMerge duplicate danmaku.
allow_stackingboolfalseAllow stacking within the same track.
allow_scroll_overwriteboolfalseAllow scrolling danmaku to overwrite one another.
max_quantityuint32_t0Upper limit on scrolling danmaku density; 0 = unlimited.
max_lines_per_modeuint32_t0Maximum number of lines per danmaku mode; 0 = unlimited.
block_top / block_bottom / block_scrollboolfalseBlock top / bottom / scrolling danmaku.
shadow_styleint32_t30 None / 1 Soft / 2 Medium / 3 Strong; unknown values fall back to 3.

ErikaPresenterConfig

FieldTypeDescription
output_modeint32_tErikaPresenterOutputMode.
edr_headroomfloatEDR headroom; 0 = automatic.
luma_upscalerint32_tErikaLumaUpscalerMode.
video_alpha_modeint32_tErikaVideoAlphaMode: 0 = Opaque, 1 = PackedAlphaRight.

ErikaSurfaceOutputCapabilities

Display and surface probe results that the host provides at attach.

FieldTypeDescription
extended_linearboolThe surface supports extended-linear.
direct_compositionboolDirect composition is supported.
desired_headroomfloatDesired headroom; 0 = system automatic.
fallback_reasonint32_tErikaOutputFallbackReason.

ErikaUpscalerStatus

FieldTypeDescription
requested_modeint32_tRequested mode, ErikaLumaUpscalerMode.
active_backendint32_tActive backend, ErikaUpscalerBackendStatus.
fallback_countuint64_tFallback count.
upscaled_framesuint64_tNumber of upscaled frames.
last_encode_microsuint64_tDuration of the last encode, in microseconds.
last_gpu_microsuint64_tDuration of the last GPU pass, in microseconds.

ErikaOutputStatus

FieldTypeDescription
requested_modeint32_tErikaPresenterOutputMode.
active_encodingint32_tErikaActiveOutputEncoding.
surface_formatint32_tErikaOutputSurfaceFormat.
native_data_spaceint32_tNative data-space handle.
requested_headroomfloatRequested headroom.
active_headroomfloatHeadroom currently in effect.
active_headroom_knownboolWhether the headroom is known.
extended_linear_activeboolWhether extended-linear is active.
fallback_reasonint32_tErikaOutputFallbackReason.
fallback_countuint64_tFallback count.
data_space_failuresuint64_tNumber of data-space failures.
headroom_updatesuint64_tNumber of headroom updates.
extended_linear_framesuint64_tNumber of extended-linear frames.

ErikaPresenterResourceStatus

Renderer memory snapshot. device_current_allocated_bytes is the Metal device-level process counter and may include allocations made by other Presenters.

FieldTypeDescription
device_current_allocated_bytesuint64_tBytes currently allocated on the device.
device_recommended_working_set_bytesuint64_tDevice-recommended working set, in bytes.
drawable_estimated_bytesuint64_tEstimated drawable bytes.
video_frame_bytesuint64_tVideo frame bytes.
overlay_atlas_bytesuint64_tSubtitle atlas bytes.
danmaku_atlas_bytesuint64_tDanmaku atlas bytes.
danmaku_vertex_buffer_bytesuint64_tDanmaku vertex buffer bytes.
upscaler_bytesuint64_tUpscaler bytes.
renderer_tracked_bytesuint64_tTotal bytes tracked by the renderer.
presenter_cpu_danmaku_atlas_bytesuint64_tCPU-side danmaku atlas bytes in the Presenter.
drawable_countuint32_tDrawable count.
output_mode_switchesuint64_tNumber of output mode switches.

ErikaSubtitleMemoryFont*

TypeFieldTypeDescription
Statusregistered_countuintptr_tNumber of registered fonts.
registered_bytesuintptr_tTotal registered bytes.
selected_countuintptr_tNumber of selected fonts.
generationuint64_tRegistration generation; a change means the registry was updated.
selected_idsuint64_t*Array of selected font ids.
Faceindexuint32_tIndex within the font collection.
families_jsonchar*Family list, as JSON.
post_script_namechar*PostScript name.
weightuint16_tFont weight.
italicboolWhether the face is italic.
monospacedboolWhether the face is monospaced.
Infoiduint64_tFont id.
byte_lenuintptr_tFont data size, in bytes.
facesFace*Array of faces.
face_countuintptr_tNumber of faces.

ErikaDanmakuTrackInfo

The caller owns the strings after the call returns. Release them with erika_danmaku_track_info_free.

FieldTypeDescription
iduint64_tTrack id.
enabledboolWhether the track is enabled.
offset_microsint64_tTrack time offset, in microseconds.
item_countuintptr_tNumber of danmaku items.
namechar*Track name.
sourcechar*Source description.

ErikaVideoParams

Video size and color metadata, reported through the VideoParamsChanged event. primaries and transfer are the project’s own enumeration values, converted from FFmpeg enumerations; they are not FFmpeg’s raw constants.

FieldTypeDescription
width / heightuint32_tVideo pixel size.
primariesuint32_t0 Unknown / 1 Bt709 / 2 DisplayP3 / 3 Bt2020.
transferuint32_t0 Unknown / 1 Srgb / 2 Bt1886 / 3 Pq / 4 Hlg.

Mapping: the BT.709 transfer function maps to Bt1886, and anything unrecognized maps to 0. The values come from the color information in the video track’s AVCodecParameters.

ErikaTrackCounts / ErikaTrackSelection

TypeFieldTypeDescription
Countsvideo / audio / subtitleuint32_tNumber of tracks of each kind.
Selectionvideo / audio / subtitleint64_tId of the selected track of each kind; -1 = none.

ErikaTrackInfo

The caller owns the six string fields; release them with erika_track_info_free. bit_rate (bit/s) is populated for all track kinds; the frame rate fields apply only to video tracks (frame_rate_numerator / frame_rate_denominator, 0 = unknown).

FieldTypeDescription
idint64_tTrack id.
kindErikaTrackKindVideo / Audio / Subtitle.
sourceErikaTrackSourceEmbedded / external.
selectedboolWhether the track is selected.
can_removeboolWhether the track can be removed (true for external tracks).
titlechar*Title.
languagechar*Language code.
codecchar*Codec name.
width / heightuint32_tVideo track pixel size.
sample_rate / channelsuint32_tAudio track sample rate / channel count.
pixel_formatchar*Video pixel format.
sample_formatchar*Audio sample format.
profilechar*Codec profile.
levelint32_tCodec level.
bit_rateuint64_tBit rate, bit/s.
frame_rate_numerator / frame_rate_denominatoruint32_tFrame rate as a fraction; 0/0 = unknown.

ErikaEvent

The valid fields form a union selected by kind; see the event table.

FieldTypeDescription
kindErikaEventKindEvent kind; determines which other fields are valid.
statusErikaStatusError code carried by an Error event.
stateErikaStateNew state carried by StateChanged.
duration_microsint64_tDuration carried by DurationChanged.
position_microsuint64_tPosition carried by PositionChanged.
bufferingboolBuffering state carried by BufferingChanged.
videoErikaVideoParamsParameters carried by VideoParamsChanged.
tracksErikaTrackCountsCounts carried by TracksChanged.

ErikaPresenterStats

Render pipeline counters: decode, render, audio, and overlay counts; software versus hardware decoding and zero-copy breakdowns; and HDR and audio recovery breakdowns. audio_recovery_state values: 0 stable / 1 disconnected / 2 recovering / 3 failed.

FieldTypeDescription
decoded_video_framesuint64_tDecoded video frames.
rendered_video_framesuint64_tRendered video frames.
rendered_test_framesuint64_tRendered test frames.
pushed_audio_framesuint64_tPushed audio frames.
overlay_framesuint64_tSubtitle overlay frames.
danmaku_frames / danmaku_itemsuint64_tDanmaku rendered frames / item count.
import_failures / render_failures / audio_failuresuint64_tImport / render / audio failure counts.
software_video_frames / hardware_video_framesuint64_tSoftware-decoded / hardware-decoded frames.
zero_copy_video_framesuint64_tZero-copy frames.
cpu_video_frame_fallbacksuint64_tNumber of frames that fell back to the CPU.
last_render_micros / last_render_current_microsuint64_tDuration of the last full tick / renderer call, in microseconds.
audio_clock_read_frames / audio_clock_queued_frames / audio_clock_underflow_framesuint64_tAudio clock frames read / queued / underrun.
audio_recovery_stateint32_t0 stable / 1 disconnected / 2 recovering / 3 failed.
audio_last_error_codeint32_tLast audio error code.
audio_recovery_attempts / audio_recovery_count / audio_recovery_failuresuint64_tAudio recovery attempts / successes / failures.
direct_zero_copy_video_frames / shared_handle_video_framesuint64_tDirect zero-copy / shared-handle frames.
hdr_source_frames / hdr10_output_frames / sdr_tonemap_framesuint64_tHDR source / HDR10 output / SDR tone-mapped frames.
hdr10_metadata_updates / hdr10_metadata_failures / hdr10_output_failuresuint64_tHDR10 metadata updates / metadata failures / output failures.
hdr10_output_activeboolWhether HDR10 output is active.
video_frame_backpressure_dropsuint64_tFrames dropped due to backpressure.

Platform differences: on the wgpu backend, last_gpu_micros and direct_zero_copy_video_frames are always 0 (only Metal reports GPU time, and the direct-import count increments only on D3D11). shared_handle_video_frames increments only on wgpu (Android / OpenHarmony), and hdr10_output_frames increments only on D3D11. decoded_video_frames counts decoded frames sent to the renderer for upload; rendered_video_frames counts frames successfully drawn to the surface. The difference is the number of frames that were never presented.

Subtitle style override mask

override_mask is a bitwise OR of ERIKA_SUBTITLE_OVERRIDE_* values, which mirror libass’s ASS_OVERRIDE_BIT_* values. Setting a bit makes the corresponding fields override the style that an ASS dialogue event requests, instead of acting as a fallback; 0 keeps all fields as fallbacks. Unknown bits are discarded.

MacroBitFields covered
ERIKA_SUBTITLE_OVERRIDE_FONT_SIZE_FIELDS1u<<2font_size, spacing, scale_x_percent, scale_y_percent
ERIKA_SUBTITLE_OVERRIDE_FONT_NAME1u<<3font_family
ERIKA_SUBTITLE_OVERRIDE_COLORS1u<<4primary_color_rgba, outline_color_rgba
ERIKA_SUBTITLE_OVERRIDE_ATTRIBUTES1u<<5bold, italic, underline, strike_out
ERIKA_SUBTITLE_OVERRIDE_BORDER1u<<6border_style, outline_width, shadow_depth
ERIKA_SUBTITLE_OVERRIDE_ALIGNMENT1u<<7alignment
ERIKA_SUBTITLE_OVERRIDE_MARGINS1u<<8margin_left, margin_right, margin_vertical
ERIKA_SUBTITLE_OVERRIDE_BLUR1u<<11blur
ERIKA_SUBTITLE_OVERRIDE_ALLAll bitsAll of the above

Enumerations

TypePurpose
ErikaStatus / ErikaState / ErikaEventKindSee the sections above.
ErikaTrackKindVideo / Audio / Subtitle.
ErikaTrackSourceEmbedded / external.
ErikaWgpuSurfaceKindwgpu surface kind, 9 members.
ErikaFlutterTextureKindFlutter texture kind, 6 members.
ErikaPresenterOutputModeSDR / Apple EDR / extended-linear / Auto.
ErikaActiveOutputEncodingSDR sRGB / Apple EDR / Android scRGB / HDR10 PQ / Linux scRGB.
ErikaOutputFallbackReasonHDR fallback reason, 9 members.
ErikaOutputSurfaceFormat8-bit UNORM / 10-bit UNORM / 16-bit float.
ErikaLumaUpscalerModeOff / ArtCNN / Anime4K / FSR 1.0 / platform video super resolution / MetalFX / custom model.
ErikaUpscalerBackendStatusUpscaler backend status, 11 values.

ErikaTrackKind / ErikaTrackSource

ValueTrackKindValueTrackSource
0Video0Embedded (in the container)
1Audio1External (sideloaded)
2Subtitle

ErikaWgpuSurfaceKind

ValueNamePlatform
0UnknownUnknown.
1MacOsNsViewmacOS NSView.
2MacOsCaMetalLayermacOS CAMetalLayer.
3IosUiViewiOS UIView.
4WindowsHwndWindows HWND.
5XlibWindowX11 (Xlib) window.
6WaylandSurfaceWayland surface.
7AndroidNativeWindowAndroid ANativeWindow.
8OhosNativeWindowOpenHarmony native window.

ErikaFlutterTextureKind

ValueNamePlatform
0UnknownUnknown.
1MacOsTextureRegistrarmacOS Flutter texture registrar.
2IosTextureRegistrariOS Flutter texture registrar.
3AndroidSurfaceTextureAndroid SurfaceTexture.
4WindowsTextureRegistrarWindows Flutter texture registrar.
5LinuxTextureRegistrarLinux Flutter texture registrar.

ErikaPresenterOutputMode / ErikaActiveOutputEncoding

ValuePresenterOutputModeValueActiveOutputEncoding
0Sdr0SdrSrgb
1AppleEdr1AppleEdr
2ExtendedLinear2AndroidExtendedLinearScRgb
3Auto3Hdr10Pq
——4LinuxExtendedLinearScRgb

ErikaOutputFallbackReason

ValueNameDescription
0NoneNo fallback.
1DisplayHdrUnsupportedThe display does not support HDR.
2HybridCompositionRequiredHybrid composition is required.
3WgpuBackendNotVulkanThe wgpu backend is not Vulkan.
4Rgba16FloatSurfaceFormatUnavailableRGBA16F surface format is not available.
5NativeWindowDataSpaceApiUnavailableThe native window data-space API is unavailable.
6ScrgbDataSpaceVerificationFailedscRGB data-space verification failed.
7SurfaceConfigureFailedSurface configuration failed.
8LegacyAppleEdrUnsupportedLegacy Apple EDR is not supported.

ErikaOutputSurfaceFormat / ErikaLumaUpscalerMode / ErikaUpscalerBackendStatus

ValueOutputSurfaceFormatValueLumaUpscalerModeValueUpscalerBackendStatus
0EightBitUnorm0Off0Off
1TenBitUnorm1ArtCnnC4F161Inactive (the selected mode cannot run on this backend; native sampling is retained)
2SixteenBitFloat2ArtCnnC4F322Building
3ArtCnnC4F16Ds3Scalar
4ArtCnnC4F16Dn4SimdgroupMatrix
5ArtCnnC4F32Ds5CooperativeMatrix
6ArtCnnC4F32Dn6LinalgMatrix
7ArtCnnR8F647VideoProcessor
16Anime4kS8VideoToolbox
17Anime4kM9MetalFx
18Anime4kL10TensorOps
19Anime4kVl
20Anime4kUl
21Anime4kDenoiseS
22Anime4kDenoiseM
23Anime4kDenoiseL
24Anime4kDenoiseVl
25Anime4kDenoiseUl
32Fsr1
48PlatformVideo
49MetalFxSpatial
64Custom

Open options and GIF export types#

The following definitions come from erika.h in 0.3.1. They give the complete fields for the HTTP read-ahead window and GIF export:

ErikaOpenOptions

typedef struct ErikaOpenOptions {
  const ErikaHttpHeader *headers;
  uintptr_t header_count;
  uint64_t http_read_ahead_bytes;
  uint64_t http_back_buffer_bytes;
  uint64_t start_position_micros;
  uint64_t reserved[1];
} ErikaOpenOptions;

start_position_micros is the starting time in microseconds; 0 opens at the beginning. It occupies the first former reserved slot, so zero-initialized older structs still open at the beginning.

ErikaVideoAlphaMode

typedef enum ErikaVideoAlphaMode {
  ErikaVideoAlphaMode_Opaque = 0,
  ErikaVideoAlphaMode_PackedAlphaRight = 1,
} ErikaVideoAlphaMode;

ErikaGifExportQuality

typedef enum ErikaGifExportQuality {
  ErikaGifExportQuality_Normal = 0,
  ErikaGifExportQuality_High = 1,
} ErikaGifExportQuality;

ErikaGifExportOptions

typedef struct ErikaGifExportOptions {
  const char *input_uri;
  const char *output_path;
  uint64_t start_millis;
  uint64_t end_millis;
  uint32_t frames_per_second;
  uint32_t output_width;
  uint32_t output_height;
  int32_t quality;
  int32_t loop_count;
  bool overwrite;
  const ErikaHttpHeader *headers;
  uintptr_t header_count;
  uint64_t http_read_ahead_bytes;
  uint64_t reserved[3];
} ErikaGifExportOptions;

ErikaGifExportResult

typedef struct ErikaGifExportResult {
  uint32_t width;
  uint32_t height;
  uint64_t frame_count;
  uint64_t file_size;
} ErikaGifExportResult;

http_read_ahead_bytes sets how many bytes to read ahead (default 2 MiB). http_back_buffer_bytes sets how much already-played data to keep (default 16 MiB). Omit either one or pass 0 to use its default. You can also set the read-ahead default with ERIKA_HTTP_READAHEAD_BYTES.

A backward seek that lands inside the back buffer reuses the data already downloaded. High-bitrate video needs a larger budget: keeping about 10 seconds of an 80 Mbit/s stream takes roughly 100 MB. The cache is limited by bytes, not by a fixed number of seconds of playback.

Native texture types · 0.3.1#

typedef struct ErikaTextureFrame ErikaTextureFrame;
typedef enum ErikaExternalTextureKind {
  ErikaExternalTextureKind_Metal = 1,
  ErikaExternalTextureKind_VulkanOpaqueFd = 2,
} ErikaExternalTextureKind;
typedef enum ErikaExternalTextureFormat {
  ErikaExternalTextureFormat_Rgba8Unorm = 1,
} ErikaExternalTextureFormat;
typedef struct ErikaExternalTextureInfo {
  ErikaExternalTextureKind kind;
  ErikaExternalTextureFormat format;
  uint32_t width;
  uint32_t height;
  uint64_t native_handle;
  uint64_t device_id;
  uint64_t allocation_size;
  uint32_t memory_type_index;
  uint32_t vulkan_format;
  uint32_t vulkan_usage;
  uint32_t vulkan_tiling;
  uint8_t device_uuid[16];
  uint8_t driver_uuid[16];
} ErikaExternalTextureInfo;

A texture frame can outlive its presenter. Release only after consumer GPU work and imported aliases retire. get_info returns borrowed handles: a Metal consumer may independently retain the texture through all GPU use; duplicate the Vulkan OPAQUE_FD before import (0 is valid), match device and driver UUIDs, and import the dedicated allocation with identical properties. Acquire queue ownership from EXTERNAL with old layout GENERAL before reading. Read-only pixels are sRGB-encoded RGBA in UNORM storage. liberika texture guide.

Cancellable open · 0.3.8 (experimental)#

ErikaColdOpenCancellation is a one-shot cancellation ticket that holds no presenter pointer. It lets another thread abort a synchronous open that is still connecting or waiting to retry. Use it with erika_presenter_open_with_options_cancellable.

ErikaStatus erika_open_validate(const char *uri, const ErikaOpenOptions *options)

Returns ErikaStatus::Ok when the URI is not empty and the ErikaOpenOptions are valid. It borrows no presenter and consumes no ticket, so a host can validate new arguments before replacing an open that is still in flight. Strings must be valid NUL-terminated C strings.

ErikaColdOpenCancellation *erika_cold_open_cancellation_create(void)

Creates a cancellation ticket. Use a new one for each open.

void erika_cold_open_cancellation_cancel(const ErikaColdOpenCancellation *ticket)

Requests cancellation from any thread. NULL is a no-op.

void erika_cold_open_cancellation_release(ErikaColdOpenCancellation *ticket)

Releases the ticket. Call it after every canceller and the synchronous open it served have finished. NULL is a no-op.

Embedded fallback font#

const uint8_t *erika_embedded_fallback_font(uintptr_t *out_length)

Returns borrowed embedded font bytes and their length, or NULL when the font is not compiled in. The bytes live for the process lifetime and must not be freed. out_length is uintptr_t, matching the platform pointer width. Native hosts can pass the data to a Web nofont runtime.

liberika v0.3.8 Section Reference License MPL-2.0