WinGui: Fix another instance of the Caliburn vs Json.net sillyness where objects...
[HandBrake.git] / libhb / preset.h
blob62ce3d361ada8ff7228b0da011c4ea2950c6839f
1 /* preset.h
3 Copyright (c) 2003-2015 HandBrake Team
4 This file is part of the HandBrake source code
5 Homepage: <http://handbrake.fr/>.
6 It may be used under the terms of the GNU General Public License v2.
7 For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
8 */
9 #if !defined(HB_PRESET_H)
10 #define HB_PRESET_H
12 #include "common.h"
13 #include "hb_dict.h"
15 #define HB_MAX_PRESET_FOLDER_DEPTH 8
17 typedef struct hb_preset_index_s hb_preset_index_t;
19 // A preset index is a list of indexes that specifies a path to a
20 // specific preset in a preset list. Since a preset list can have
21 // folders that contain sub-lists, multiple index values are needed
22 // to create a complete path.
23 struct hb_preset_index_s
25 int depth;
26 int index[HB_MAX_PRESET_FOLDER_DEPTH];
29 #ifdef __LIBHB__
30 // Preset APIs reserved for libhb
32 // Initialize the hb_value_array_t that holds HandBrake builtin presets
33 // These presets come from a json string embedded in libhb and can be
34 // retrieved with hb_presets_builtin_get() after initialization.
35 void hb_presets_builtin_init(void);
37 // Free all libhb presets. This should only be called when closing
38 // an hb_handle_t.
39 void hb_presets_free(void);
41 #endif // __LIBHB__
43 // Get the currently supported preset format version
44 void hb_presets_current_version(int *major, int* minor, int *micro);
46 // Get the format version of a preset dict
47 int hb_presets_version(hb_value_t *preset, int *major, int *minor, int *micro);
49 // Initialize a new preset index. "index" may be NULL
50 hb_preset_index_t * hb_preset_index_init(const int *index, int depth);
52 // Duplicate a preset index
53 hb_preset_index_t * hb_preset_index_dup(const hb_preset_index_t *path);
55 // Append one index to another
56 void hb_preset_index_append(hb_preset_index_t *dst,
57 const hb_preset_index_t *src);
59 // Load presets list from GUI presets file if it exists. This should probably
60 // only be used by the CLI.
61 int hb_presets_gui_init(void);
63 // Get HandBrake builtin presets list as hb_value_array_t
64 hb_value_t * hb_presets_builtin_get(void);
66 // Get HandBrake builtin presets list as json string
67 char * hb_presets_builtin_get_json(void);
69 // Load default builtin presets list over the top of any builtins in the
70 // current preset list. This should be used by a frontend when it recognizes
71 // that it's preset file is from an older version of HandBrake.
72 void hb_presets_builtin_update(void);
74 // Clean presets. Removes unknown keys and normalizes values.
75 // This should be applied before exporting a preset and is applied
76 // for you by hb_presets_write_json() and hb_preset_package_json().
77 void hb_presets_clean(hb_value_t *preset);
79 // Clean json presets. Removes unknown keys and normalizes values.
80 // This should be applied before exporting a preset and is applied
81 // for you by hb_presets_write_json() and hb_preset_package_json().
82 char * hb_presets_clean_json(const char *json);
84 // Import a preset. Sanitizes and converts old key/value pairs
85 // to new key/value pairs. This is applied for you by hb_presets_add(),
86 // hb_presets_add_json(), hb_presets_add_file(), and hb_presets_add_path()
87 void hb_presets_import(hb_value_t *preset);
89 // Import a json preset. Sanitizes and converts old key/value pairs
90 // to new key/value pairs.
91 char * hb_presets_import_json(const char *json);
93 // Register new presets with libhb from json string
94 int hb_presets_add_json(const char *json);
96 // Read a preset file. Does not add to internal preset list.
97 hb_value_t * hb_presets_read_file(const char *filename);
99 // Read a preset file. Does not add to internal preset list.
100 // Returns a json string.
101 char * hb_presets_read_file_json(const char *filename);
103 // Register new presets with libhb from a preset dict
104 int hb_presets_add(hb_value_t *preset);
106 // Register new presets with libhb from json file
107 int hb_presets_add_file(const char *filename);
109 // Register new presets with libhb from json file(s)
110 // path can be a directory, in which case all *.json files in the
111 // directory will be added
112 int hb_presets_add_path(char * path);
114 // Get list of all presets registered with libhb as hb_value_array_t
115 hb_value_t * hb_presets_get(void);
118 // Get list of all presets registered with libhb as json string
119 char * hb_presets_get_json(void);
121 // Apply preset Muxer settings to a job
122 int hb_preset_apply_mux(const hb_dict_t *preset, hb_dict_t *job_dict);
124 // Apply preset Video settings to a job
125 int hb_preset_apply_video(const hb_dict_t *preset, hb_dict_t *job_dict);
127 // Apply preset Filter settings to a job
129 // Note that this does not apply scale filter settings. A title is
130 // required to set the default scale filter settings, so this filter
131 // is applied in hb_preset_apply_title()
132 int hb_preset_apply_filters(const hb_dict_t *preset, hb_dict_t *job_dict);
134 // Apply preset settings that require a title to a job
135 int hb_preset_apply_title(hb_handle_t *h, int title_index,
136 const hb_dict_t *preset, hb_dict_t *job_dict);
138 // Initialize a job from the given title and preset
139 hb_dict_t * hb_preset_job_init(hb_handle_t *h, int title_index,
140 const hb_dict_t *preset);
142 // Reinitialize subtitles from preset defaults.
143 int hb_preset_job_add_subtitles(hb_handle_t *h, int title_index,
144 const hb_dict_t *preset, hb_dict_t *job_dict);
146 // Reinitialize audio from preset defaults.
147 int hb_preset_job_add_audio(hb_handle_t *h, int title_index,
148 const hb_dict_t *preset, hb_dict_t *job_dict);
150 // Lookup a preset in the preset list. The "name" may contain '/'
151 // separators to explicitely specify a preset within the preset lists
152 // folder structure.
154 // If 'recurse' is specified, a recursive search for the first component
155 // in the name will be performed.
157 // I assume that the actual preset name does not include any '/'
158 hb_preset_index_t * hb_preset_search_index(const char *name, int recurse);
159 hb_value_t * hb_preset_search(const char *name, int recurse);
160 char * hb_preset_search_json(const char *name, int recurse);
162 hb_value_t * hb_presets_get_folder_children(const hb_preset_index_t *path);
163 hb_value_t * hb_preset_get(const hb_preset_index_t *path);
164 int hb_preset_delete(const hb_preset_index_t *path);
165 int hb_preset_set(const hb_preset_index_t *path,
166 const hb_value_t *dict);
167 int hb_preset_insert(const hb_preset_index_t *path,
168 const hb_value_t *dict);
169 int hb_preset_append(const hb_preset_index_t *path,
170 const hb_value_t *dict);
171 int hb_preset_move(const hb_preset_index_t *src_path,
172 const hb_preset_index_t *dst_path);
174 // Recursively lookup the preset that is marked as 'Default'
175 hb_dict_t * hb_presets_get_default(void);
176 char * hb_presets_get_default_json(void);
177 hb_preset_index_t * hb_presets_get_default_index(void);
179 // Package the provided preset (wrap in dict and add version etc)
180 // and write to json file
181 int hb_presets_write_json(const hb_value_t *preset, const char *path);
183 // Package the provided preset (wrap in dict and add version etc)
184 // and return as json string
185 char * hb_presets_package_json(const hb_value_t *presets);
187 // Package the provided json presets list (wrap in dict and add version etc)
188 // and return as json string
189 char * hb_presets_json_package(const char *json_presets);
191 #endif // HB_PRESET_H