void OPJ_CALLCONV opj_plugin_stop_batch_decode(void) { minpf_plugin_manager* mgr = NULL; PLUGIN_STOP_BATCH_DECODE func = NULL; if (!pluginInitialized) return; mgr = minpf_get_plugin_manager(); if (mgr && mgr->num_libraries > 0) { func = (PLUGIN_STOP_BATCH_DECODE)minpf_get_symbol(mgr->dynamic_libraries[0], plugin_stop_batch_decode_method_name); if (func) { func(); } } }
uint32_t OPJ_CALLCONV opj_plugin_get_debug_state() { minpf_plugin_manager* mgr = NULL; PLUGIN_GET_DEBUG_STATE func = NULL; uint32_t rc = OPJ_PLUGIN_STATE_NO_DEBUG; if (!pluginInitialized) return rc; mgr = minpf_get_plugin_manager(); if (mgr && mgr->num_libraries > 0) { func = (PLUGIN_GET_DEBUG_STATE)minpf_get_symbol(mgr->dynamic_libraries[0], plugin_get_debug_state_method_name); if (func) { rc = func(); } } return rc; }
int32_t OPJ_CALLCONV opj_plugin_encode(opj_cparameters_t* encode_parameters, OPJ_PLUGIN_ENCODE_USER_CALLBACK callback) { minpf_plugin_manager* mgr = NULL; PLUGIN_ENCODE func = NULL; if (!pluginInitialized) return -1; userEncodeCallback = callback; mgr = minpf_get_plugin_manager(); if (mgr && mgr->num_libraries > 0) { func = (PLUGIN_ENCODE)minpf_get_symbol(mgr->dynamic_libraries[0], plugin_encode_method_name); if (func) { return func((opj_cparameters_t*)encode_parameters, opj_plugin_internal_encode_callback); } } return -1; }
int32_t OPJ_CALLCONV opj_plugin_decode(opj_decompress_parameters* decode_parameters, opj_plugin_decode_callback preDecode, opj_plugin_decode_callback postDecode) { minpf_plugin_manager* mgr = NULL; PLUGIN_DECODE func = NULL; if (!pluginInitialized) return -1; userPreDecodeCallback = preDecode; userPostDecodeCallback = postDecode; mgr = minpf_get_plugin_manager(); func = NULL; if (mgr && mgr->num_libraries > 0) { func = (PLUGIN_DECODE)minpf_get_symbol(mgr->dynamic_libraries[0], plugin_decode_method_name); if (func) { return func((opj_decompress_parameters*)decode_parameters, opj_plugin_internal_decode_callback); } } return -1; }
static int32_t minpf_load(const char* path) { minpf_post_load_func postLoadFunc = NULL; minpf_dynamic_library* lib = NULL; int32_t res = 0; minpf_plugin_manager* mgr = minpf_get_plugin_manager(); if (!mgr || mgr->num_libraries == MINPF_MAX_PLUGINS) { return -1; } lib = minpf_load_dynamic_library(path, NULL); if (!lib) { return -1; } printf("Plugin %s successfully loaded\n", path); postLoadFunc = (minpf_post_load_func)(minpf_get_symbol(lib, "minpf_post_load_plugin")); if (!postLoadFunc) { free(lib); return -1; } char fullPath[4096]; if (minpf_get_full_path(path, (void*)postLoadFunc, lib->handle, fullPath, 4096)) { printf("Full library path: %s\n", fullPath); } else { return -1; } mgr->dynamic_libraries[mgr->num_libraries++] = lib; auto rc = minpf_post_load_plugin(fullPath, postLoadFunc); if (rc) fprintf(stderr, "Plugin %s failed to initialize \n", path); else fprintf(stdout, "Plugin %s successfully initialized \n", path); return rc; }