diff options
author | jstebbins <[email protected]> | 2015-05-14 17:11:48 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2015-05-14 17:11:48 +0000 |
commit | 9ae7e30dc8daace92d17ea36a4f0bdede00b9471 (patch) | |
tree | 9485255c993389a6740b833e7aa30c5b5b2622aa /libhb/preset.h | |
parent | 90cafad3e4c610b8b009769f922fabc283979231 (diff) |
lingui: use libhb preset management from linux gui
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7179 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/preset.h')
-rw-r--r-- | libhb/preset.h | 130 |
1 files changed, 108 insertions, 22 deletions
diff --git a/libhb/preset.h b/libhb/preset.h index 5e7c460b6..a24b45cf2 100644 --- a/libhb/preset.h +++ b/libhb/preset.h @@ -1,4 +1,4 @@ -/* hb_preset.h +/* preset.h Copyright (c) 2003-2015 HandBrake Team This file is part of the HandBrake source code @@ -12,28 +12,93 @@ #include "common.h" #include "hb_dict.h" +#define HB_MAX_PRESET_FOLDER_DEPTH 8 + +typedef struct hb_preset_index_s hb_preset_index_t; + +// A preset index is a list of indexes that specifies a path to a +// specific preset in a preset list. Since a preset list can have +// folders that contain sub-lists, multiple index values are needed +// to create a complete path. +struct hb_preset_index_s +{ + int depth; + int index[HB_MAX_PRESET_FOLDER_DEPTH]; +}; + +#ifdef __LIBHB__ +// Preset APIs reserved for libhb + // Initialize the hb_value_array_t that holds HandBrake builtin presets +// These presets come from a json string embedded in libhb and can be +// retrieved with hb_presets_builtin_get() after initialization. void hb_presets_builtin_init(void); -// Load presets from GUI presets file if possible -int hb_presets_gui_init(void); - -// Free all libhb presets +// Free all libhb presets. This should only be called when closing +// an hb_handle_t. void hb_presets_free(void); -// Get list of HandBrake builtin presets as hb_value_array_t +#endif // __LIBHB__ + +// Get the currently supported preset format version +void hb_presets_current_version(int *major, int* minor, int *micro); + +// Get the format version of a preset dict +int hb_presets_version(hb_value_t *preset, int *major, int *minor, int *micro); + +// Initialize a new preset index. "index" may be NULL +hb_preset_index_t * hb_preset_index_init(const int *index, int depth); + +// Duplicate a preset index +hb_preset_index_t * hb_preset_index_dup(const hb_preset_index_t *path); + +// Append one index to another +void hb_preset_index_append(hb_preset_index_t *dst, + const hb_preset_index_t *src); + +// Load presets list from GUI presets file if it exists. This should probably +// only be used by the CLI. +int hb_presets_gui_init(void); + +// Get HandBrake builtin presets list as hb_value_array_t hb_value_t * hb_presets_builtin_get(void); -// Get list of HandBrake builtin presets as json string +// Get HandBrake builtin presets list as json string char * hb_presets_builtin_get_json(void); -// Register new presets with libhb from -// hb_dict_t (single preset) or hb_value_array_t (list of presets) -int hb_presets_add(hb_value_t *preset); +// Load default builtin presets list over the top of any builtins in the +// current preset list. This should be used by a frontend when it recognizes +// that it's preset file is from an older version of HandBrake. +void hb_presets_builtin_update(void); + +// Clean presets. Removes unknown keys and normalizes values. +// This should be applied before exporting a preset and is applied +// for you by hb_presets_write_json() and hb_preset_package_json(). +void hb_presets_clean(hb_value_t *preset); + +// Clean json presets. Removes unknown keys and normalizes values. +// This should be applied before exporting a preset and is applied +// for you by hb_presets_write_json() and hb_preset_package_json(). +char * hb_presets_clean_json(const char *json); + +// Import a preset. Sanitizes and converts old key/value pairs +// to new key/value pairs. This is applied for you by hb_presets_add(), +// hb_presets_add_json(), hb_presets_add_file(), and hb_presets_add_path() +void hb_presets_import(hb_value_t *preset); + +// Import a json preset. Sanitizes and converts old key/value pairs +// to new key/value pairs. +char * hb_presets_import_json(const char *json); // Register new presets with libhb from json string int hb_presets_add_json(const char *json); +// Read a preset file. Does not add to internal preset list. +hb_value_t* hb_presets_read_file(const char *filename); + +// Register new presets with libhb from a preset dict +int hb_presets_add(hb_value_t *preset); + // Register new presets with libhb from json file int hb_presets_add_file(const char *filename); @@ -45,16 +110,21 @@ int hb_presets_add_path(char * path); // Get list of all presets registered with libhb as hb_value_array_t hb_value_t * hb_presets_get(void); + // Get list of all presets registered with libhb as json string char * hb_presets_get_json(void); // Initialize a job from the given title and preset hb_dict_t * hb_preset_job_init(hb_handle_t *h, int title_index, - hb_dict_t *preset); + const hb_dict_t *preset); + +// Reinitialize subtitles from preset defaults. int hb_preset_job_add_subtitles(hb_handle_t *h, int title_index, - hb_dict_t *preset, hb_dict_t *job_dict); + const hb_dict_t *preset, hb_dict_t *job_dict); + +// Reinitialize audio from preset defaults. int hb_preset_job_add_audio(hb_handle_t *h, int title_index, - hb_dict_t *preset, hb_dict_t *job_dict); + const hb_dict_t *preset, hb_dict_t *job_dict); // Lookup a preset in the preset list. The "name" may contain '/' // separators to explicitely specify a preset within the preset lists @@ -64,21 +134,37 @@ int hb_preset_job_add_audio(hb_handle_t *h, int title_index, // in the name will be performed. // // I assume that the actual preset name does not include any '/' -hb_value_t * hb_preset_get(const char *name, int recurse); -char * hb_preset_get_json(const char *name, int recurse); +hb_preset_index_t * hb_preset_search_index(const char *name, int recurse); +hb_value_t * hb_preset_search(const char *name, int recurse); +char * hb_preset_search_json(const char *name, int recurse); + +hb_value_t * hb_presets_get_folder_children(const hb_preset_index_t *path); +hb_value_t * hb_preset_get(const hb_preset_index_t *path); +int hb_preset_delete(const hb_preset_index_t *path); +int hb_preset_set(const hb_preset_index_t *path, + const hb_value_t *dict); +int hb_preset_insert(const hb_preset_index_t *path, + const hb_value_t *dict); +int hb_preset_append(const hb_preset_index_t *path, + const hb_value_t *dict); +int hb_preset_move(const hb_preset_index_t *src_path, + const hb_preset_index_t *dst_path); // Recursively lookup the preset that is marked as 'Default' -hb_dict_t * hb_presets_get_default(void); -char * hb_presets_get_default_json(void); - -// Set the preset that is marked as 'Default' -int hb_presets_set_default(const char *name, int recurse); +hb_dict_t * hb_presets_get_default(void); +char * hb_presets_get_default_json(void); +hb_preset_index_t * hb_presets_get_default_index(void); // Package the provided preset (wrap in dict and add version etc) // and write to json file -int hb_preset_write_json(hb_value_t *preset, const char *path); +int hb_presets_write_json(const hb_value_t *preset, const char *path); + // Package the provided preset (wrap in dict and add version etc) // and return as json string -char * hb_preset_package_json(hb_value_t *preset); +char * hb_presets_package_json(const hb_value_t *presets); + +// Package the provided json presets list (wrap in dict and add version etc) +// and return as json string +char * hb_presets_json_package(const char *json_presets); #endif // HB_PRESET_H |