/* scorpiox-scorpioplayer-subtitle-model — pure C99 subtitle lifecycle model. * See SPEC.md. No parsing, no rendering, no network. */ #ifndef SPSUBM_H #define SPSUBM_H #ifdef __cplusplus extern "C" { #endif #include enum { SPSUBM_OK = 0, SPSUBM_ERR_NO_SUCH_ID = 1, SPSUBM_ERR_NO_CUES = 2, SPSUBM_ERR_NO_DETECTOR = 3, SPSUBM_ERR_DUPLICATE = 4, /* normal: collection rejected identical Index */ SPSUBM_ERR_INVALID_ARG = 5, SPSUBM_ERR_OOM = 6 }; typedef const char *(*spsubm_lang_detect_fn)(void *ctx, const char *utf8_line); typedef const char *(*spsubm_translate_fn)(void *ctx, const char *utf8_text); /* download backend: return 0 on success; fill *out_path. No network in this lib. */ typedef int (*spsubm_download_fn)(void *ctx, const char *query, char *out_path, size_t out_sz); /* lifecycle */ int spsubm_create(const char *parent_file_hash, int index, int delay_ms, int is_embedded, int is_image, const char *extension); int spsubm_destroy(int id); void spsubm_clear(void); /* feeding cues (already parsed UTF-8) */ int spsubm_add_cue(int id, int start_ms, int end_ms); int spsubm_add_cue_line(int id, int cue, const char *utf8); int spsubm_finalize(int id); /* identity */ const char *spsubm_file_hash(int id); int spsubm_index(int id); const char *spsubm_parent_file_hash(int id); /* language */ void spsubm_set_detector(spsubm_lang_detect_fn fn, void *ctx); void spsubm_set_translator(spsubm_translate_fn fn, void *ctx); int spsubm_detect_languages(int id); const char *spsubm_language1(int id); const char *spsubm_language2(int id); int spsubm_language1_lines(int id); int spsubm_language2_lines(int id); double spsubm_confidence(int id); int spsubm_is_bilingual(int id); void spsubm_set_bilingual_threshold(double t); const char *spsubm_display_name(int id); /* cue selection hot path */ int spsubm_cue_at(int id, int ms); int spsubm_active_cues(int id, int ms); int spsubm_active_count(void); int spsubm_active_index(int n); int spsubm_cue_start_ms(int id, int c); int spsubm_cue_end_ms(int id, int c); int spsubm_cue_line_count(int id, int c); const char *spsubm_cue_line(int id, int c, int n); int spsubm_cue_set_consumed(int id, int c, int consumed); int spsubm_cue_consumed(int id, int c); int spsubm_cue_char_score(int id, int c); /* nonempty line char sum; -1 if empty */ /* delay — explicit; never the C# ?? expression */ int spsubm_set_delay_ms(int id, int ms); int spsubm_delay_ms(int id); int spsubm_effective_ms(int id, int position_ms, int global_delay_ms, int skip_begin_ms, int segment_start_ms); /* collection */ int spsubm_collection_add(int id); int spsubm_collection_remove(int id); int spsubm_collection_count(void); int spsubm_collection_at(int n); int spsubm_set_primary(int id); int spsubm_set_secondary(int id); int spsubm_primary(void); int spsubm_secondary(void); void spsubm_close_tracks(void); /* clear primary+secondary selection */ /* line cleanup */ int spsubm_clean_line(const char *utf8); int spsubm_clean_part_count(void); const char *spsubm_clean_part(int n); /* encoding list — data; chosen encoding state */ int spsubm_codepage_count(void); const char *spsubm_codepage(int n); int spsubm_set_encoding(int id, const char *name); const char *spsubm_encoding(int id); /* download backend hook (no I/O here) */ void spsubm_set_download_fn(spsubm_download_fn fn, void *ctx); int spsubm_download(const char *query, char *out_path, size_t out_sz); /* scorpiox server / flags */ int spsubm_set_scorpio_server_file(int id, int yes); /* JSON / diagnostics — yyjson only */ const char *spsubm_result_json(void); const char *spsubm_last_error(void); int spsubm_warning_count(void); const char *spsubm_warning(int n); /* test/bench helpers */ int spsubm_cue_at_linear(int id, int ms); /* literal LINQ transcription */ int spsubm_stable_hash_utf8(const char *utf8, int *out); /* reimpl of media-hash */ #ifdef __cplusplus } #endif #endif