mp3splt-gtk
mp3splt.h
Go to the documentation of this file.
1 /**********************************************************
2  *
3  * libmp3splt -- library based on mp3splt v2.1c,
4  * for mp3/ogg splitting without decoding
5  *
6  * Copyright (c) 2002-2005 M. Trotta - <mtrotta@users.sourceforge.net>
7  * Copyright (c) 2005-2012 Alexandru Munteanu - m@ioalex.net
8  *
9  * And others ... see the AUTHORS file provided with libmp3splt source.
10  *
11  * http://mp3splt.sourceforge.net
12  *
13  *********************************************************/
14 
15 /**********************************************************
16  *
17  * This program is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU General Public License
19  * as published by the Free Software Foundation; either version 2
20  * of the License, or (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
30  * USA.
31  *
32  *********************************************************/
33 
80 #ifndef MP3SPLT_MP3SPLT_H
81 
82 #include <sys/types.h>
83 
87 #define SPLT_TRUE 1
88 
91 #define SPLT_FALSE 0
92 
104 typedef enum {
105  SPLT_OK = 0,
106 
107  SPLT_OK_SPLIT = 1,
108  SPLT_SPLITPOINT_BIGGER_THAN_LENGTH = 4,
109  SPLT_SILENCE_OK = 5,
110  SPLT_TIME_SPLIT_OK = 6,
111  SPLT_NO_SILENCE_SPLITPOINTS_FOUND = 7,
112  SPLT_OK_SPLIT_EOF = 8,
113  SPLT_LENGTH_SPLIT_OK = 9,
114  SPLT_TRIM_SILENCE_OK = 10,
115 
116  SPLT_FREEDB_OK = 100,
117  SPLT_FREEDB_FILE_OK = 101,
118  SPLT_CDDB_OK = 102,
119  SPLT_CUE_OK = 103,
120  SPLT_FREEDB_MAX_CD_REACHED = 104,
121  SPLT_AUDACITY_OK = 105,
122 
123  SPLT_DEWRAP_OK = 200,
124 
125  SPLT_SYNC_OK = 300,
126  SPLT_MIGHT_BE_VBR = 301,
127 
128  SPLT_ERR_SYNC = -300,
129  SPLT_ERR_NO_SYNC_FOUND = -301,
130  SPLT_ERR_TOO_MANY_SYNC_ERR = -302,
131 
132  SPLT_OUTPUT_FORMAT_OK = 400,
133  SPLT_OUTPUT_FORMAT_AMBIGUOUS = 401,
134 
135  SPLT_REGEX_OK = 800,
136 
137  SPLT_ERROR_SPLITPOINTS = -1,
138  SPLT_ERROR_CANNOT_OPEN_FILE = -2,
139  SPLT_ERROR_INVALID = -3,
140  SPLT_ERROR_EQUAL_SPLITPOINTS = -5,
141  SPLT_ERROR_SPLITPOINTS_NOT_IN_ORDER = -6,
142  SPLT_ERROR_NEGATIVE_SPLITPOINT = -7,
143  SPLT_ERROR_INCORRECT_PATH = -8,
144  SPLT_ERROR_INCOMPATIBLE_OPTIONS = -10,
145  SPLT_ERROR_INPUT_OUTPUT_SAME_FILE = -12,
146  SPLT_ERROR_CANNOT_ALLOCATE_MEMORY = -15,
147  SPLT_ERROR_CANNOT_OPEN_DEST_FILE = -16,
148  SPLT_ERROR_CANT_WRITE_TO_OUTPUT_FILE = -17,
149  SPLT_ERROR_WHILE_READING_FILE = -18,
150  SPLT_ERROR_SEEKING_FILE = -19,
151  SPLT_ERROR_BEGIN_OUT_OF_FILE = -20,
152  SPLT_ERROR_INEXISTENT_FILE = -21,
153  SPLT_SPLIT_CANCELLED = -22,
154  SPLT_ERROR_LIBRARY_LOCKED = -24,
155  SPLT_ERROR_STATE_NULL = -25,
156  SPLT_ERROR_NEGATIVE_TIME_SPLIT = -26,
157  SPLT_ERROR_CANNOT_CREATE_DIRECTORY = -27,
158  SPLT_ERROR_CANNOT_CLOSE_FILE = -28,
159  SPLT_ERROR_NO_PLUGIN_FOUND = -29,
160  SPLT_ERROR_CANNOT_INIT_LIBLTDL = -30,
161  SPLT_ERROR_CRC_FAILED = -31,
162  SPLT_ERROR_NO_PLUGIN_FOUND_FOR_FILE = -32,
163  SPLT_ERROR_PLUGIN_ERROR = -33,
164  SPLT_ERROR_TIME_SPLIT_VALUE_INVALID = -34,
165  SPLT_ERROR_LENGTH_SPLIT_VALUE_INVALID = -35,
166  SPLT_ERROR_CANNOT_GET_TOTAL_TIME = -36,
167  SPLT_ERROR_LIBID3 = -37,
168 
169  SPLT_FREEDB_ERROR_INITIALISE_SOCKET = -101,
170  SPLT_FREEDB_ERROR_CANNOT_GET_HOST = -102,
171  SPLT_FREEDB_ERROR_CANNOT_OPEN_SOCKET = -103,
172  SPLT_FREEDB_ERROR_CANNOT_CONNECT = -104,
173  SPLT_FREEDB_ERROR_CANNOT_SEND_MESSAGE = -105,
174  SPLT_FREEDB_ERROR_INVALID_SERVER_ANSWER = -106,
175  SPLT_FREEDB_ERROR_SITE_201 = -107,
176  SPLT_FREEDB_ERROR_SITE_200 = -108,
177  SPLT_FREEDB_ERROR_BAD_COMMUNICATION = -109,
178  SPLT_FREEDB_ERROR_GETTING_INFOS = -110,
179  SPLT_FREEDB_NO_CD_FOUND = -111,
180  SPLT_FREEDB_ERROR_CANNOT_RECV_MESSAGE = -112,
181  SPLT_INVALID_CUE_FILE = -115,
182  SPLT_INVALID_CDDB_FILE = -116,
183  SPLT_FREEDB_NO_SUCH_CD_IN_DATABASE = -118,
184  SPLT_FREEDB_ERROR_SITE = -119,
185  SPLT_FREEDB_ERROR_CANNOT_DISCONNECT = -120,
186  SPLT_FREEDB_ERROR_PROXY_NOT_SUPPORTED = -121,
187 
188  SPLT_DEWRAP_ERR_FILE_LENGTH = -200,
189  SPLT_DEWRAP_ERR_VERSION_OLD = -201,
190  SPLT_DEWRAP_ERR_NO_FILE_OR_BAD_INDEX = -202,
191  SPLT_DEWRAP_ERR_FILE_DAMAGED_INCOMPLETE = -203,
192  SPLT_DEWRAP_ERR_FILE_NOT_WRAPED_DAMAGED = -204,
193 
194  SPLT_OUTPUT_FORMAT_ERROR = -400,
195 
196  SPLT_ERROR_INEXISTENT_SPLITPOINT = -500,
197 
198  SPLT_PLUGIN_ERROR_UNSUPPORTED_FEATURE = -600,
199 
200  SPLT_INVALID_AUDACITY_FILE = -700,
201 
202  SPLT_INVALID_REGEX = -800,
203  SPLT_REGEX_NO_MATCH = -801,
204  SPLT_REGEX_UNAVAILABLE = -802,
205 } splt_code;
206 
208 
213 
221 typedef struct _splt_state splt_state;
222 
234 
244 
254 splt_code mp3splt_append_plugins_scan_dir(splt_state *state, const char *directory);
255 
266 
268 
283 char *mp3splt_get_strerror(splt_state *state, splt_code error);
284 
286 
302 typedef enum {
644 } splt_options;
645 
649 typedef enum {
684 
685 typedef enum {
699 
703 typedef enum {
722 
726 #define SPLT_DEFAULT_PARAM_THRESHOLD -48.0
727 
730 #define SPLT_DEFAULT_PARAM_OFFSET 0.8
731 
734 #define SPLT_DEFAULT_PARAM_MINIMUM_LENGTH 0.0
735 
738 #define SPLT_DEFAULT_PARAM_MINIMUM_TRACK_LENGTH 0.0
739 
742 #define SPLT_DEFAULT_PARAM_MIN_TRACK_JOIN 0.0
743 
746 #define SPLT_DEFAULT_PARAM_GAP 30
747 
750 #define SPLT_DEFAULT_PARAM_TRACKS 0
751 
754 #define SPLT_DEFAULT_PARAM_SHOTS 25
755 
758 #define SPLT_DEFAULT_KEEP_SILENCE_LEFT 0
759 
762 #define SPLT_DEFAULT_KEEP_SILENCE_RIGHT 0
763 
767 typedef enum {
785 
790 #define SPLT_DEFAULT_OUTPUT "@f_@mm_@ss_@h0h__@Mm_@Ss_@H0h"
791 
796 #define SPLT_DEFAULT_CDDB_CUE_OUTPUT "@A - @n - @t"
797 
801 #define SPLT_DEFAULT_SYNCERROR_OUTPUT "@f_error_@n"
802 
806 #define SPLT_DEFAULT_SILENCE_OUTPUT "@f_silence_@n"
807 
811 #define SPLT_DEFAULT_TRIM_SILENCE_OUTPUT "@f_trimmed"
812 
818 typedef enum {
840 
849 splt_code mp3splt_set_int_option(splt_state *state, splt_options option, int value);
850 
859 splt_code mp3splt_set_long_option(splt_state *state, splt_options option, long value);
860 
869 splt_code mp3splt_set_float_option(splt_state *state, splt_options option, float value);
870 
879 int mp3splt_get_int_option(splt_state *state, splt_options option, splt_code *error);
880 
889 long mp3splt_get_long_option(splt_state *state, splt_options option, splt_code *error);
890 
899 float mp3splt_get_float_option(splt_state *state, splt_options option, splt_code *error);
900 
908 splt_code mp3splt_set_oformat(splt_state *state, const char *format);
909 
911 
925 splt_code mp3splt_set_filename_to_split(splt_state *state, const char *filename);
926 
934 splt_code mp3splt_set_path_of_split(splt_state *state, const char *path_of_split);
935 
947 const char *mp3splt_get_filename_to_split(splt_state *state);
948 
961 splt_code mp3splt_set_m3u_filename(splt_state *state, const char *m3u_filename);
962 
988 splt_code mp3splt_set_silence_log_filename(splt_state *state, const char *filename);
989 
1022 splt_code mp3splt_set_silence_full_log_filename(splt_state *state, const char *filename);
1023 
1025 
1037 typedef enum {
1047 
1065  void (*message_cb)(const char *message, splt_message_type type, void *cb_data), void *cb_data);
1066 
1081  void (*file_cb)(const char *filename, void *cb_data),
1082  void *cb_data);
1083 
1088 typedef enum {
1107 
1123 typedef struct splt_progres splt_progress;
1124 
1139  void (*progress_cb)(splt_progress *p_bar, void *cb_data), void *cb_data);
1140 
1144 int mp3splt_progress_get_type(const splt_progress *p_bar);
1145 
1150 
1155 
1160 
1165 
1170 
1175 
1192  void (*get_silence_cb)(long time, float level, void *user_data),
1193  void *user_data);
1194 
1196 
1207 typedef enum {
1218 
1227 typedef struct _splt_point splt_point;
1228 
1242 splt_point *mp3splt_point_new(long splitpoint_value, splt_code *error);
1243 
1251 splt_code mp3splt_point_set_name(splt_point *splitpoint, const char *name);
1252 
1261 
1272 
1280 typedef struct _splt_points splt_points;
1281 
1293 
1301 void mp3splt_points_init_iterator(splt_points *splitpoints);
1302 
1313 const splt_point *mp3splt_points_next(splt_points *splitpoints);
1314 
1323 long mp3splt_point_get_value(const splt_point *point);
1324 
1335 
1344 char *mp3splt_point_get_name(const splt_point *point);
1345 
1353 
1355 
1365 #define SPLT_UNDEFINED_GENRE "Other"
1366 
1371 #define SPLT_ID3V1_NUMBER_OF_GENRES 127
1372 
1376 extern const char splt_id3v1_genres[SPLT_ID3V1_NUMBER_OF_GENRES][25];
1377 
1381 typedef enum {
1382  SPLT_TAGS_TITLE = 1,
1383  SPLT_TAGS_ARTIST = 2,
1384  SPLT_TAGS_ALBUM = 3,
1385  SPLT_TAGS_YEAR = 4,
1386  SPLT_TAGS_COMMENT = 5,
1387  SPLT_TAGS_TRACK = 6,
1388  SPLT_TAGS_GENRE = 7,
1389  SPLT_TAGS_PERFORMER = 8,
1390 } splt_tag_key;
1391 
1401 typedef struct _splt_tags splt_tags;
1402 
1413 
1431 
1445 
1450 typedef struct _splt_tags_group splt_tags_group;
1451 
1463 
1471 
1480 
1490 
1494 char *mp3splt_tags_get(splt_tags *tags, splt_tag_key key);
1495 
1524 int mp3splt_put_tags_from_string(splt_state *state, const char *tags, splt_code *error);
1525 
1533 
1547 splt_code mp3splt_set_input_filename_regex(splt_state *state, const char *regex);
1548 
1558 splt_code mp3splt_set_default_comment_tag(splt_state *state, const char *default_comment_tag);
1559 
1569 splt_code mp3splt_set_default_genre_tag(splt_state *state, const char *default_genre_tag);
1570 
1584 
1592 void mp3splt_free_one_tag(splt_tags *tags);
1593 
1595 
1615 
1625 
1637 char **mp3splt_find_filenames(splt_state *state, const char *filename,
1638  int *num_of_files_found, splt_code *error);
1639 
1641 
1653 typedef enum {
1654  CUE_IMPORT,
1655  CDDB_IMPORT,
1656  AUDACITY_LABELS_IMPORT
1658 
1669 splt_code mp3splt_import(splt_state *state, splt_import_type type, const char *file);
1670 
1676 #define SPLT_FREEDB_SEARCH_TYPE_CDDB_CGI 1
1677 
1683 #define SPLT_FREEDB_GET_FILE_TYPE_CDDB_CGI 3
1684 
1690 #define SPLT_FREEDB_GET_FILE_TYPE_CDDB 4
1691 
1698 #define SPLT_FREEDB_CDDB_CGI_PORT 80
1699 
1707 #define SPLT_FREEDB2_CGI_SITE "tracktype.org/~cddb/cddb.cgi"
1708 
1717 typedef struct _splt_freedb_results splt_freedb_results;
1718 
1726 typedef struct _splt_freedb_one_result splt_freedb_one_result;
1727 
1736 splt_code mp3splt_use_proxy(splt_state *state, const char *proxy_address, int proxy_port);
1737 
1750  const char *base64_authentification);
1751 
1762 char *mp3splt_encode_in_base64(splt_state *state, const char *input, int *error);
1763 
1770 void mp3splt_clear_proxy(splt_state *state);
1771 
1789  const char *searched_string, splt_code *error,
1790  int search_type, const char *search_server, int port);
1791 
1800 
1812 
1818 
1822 const char *mp3splt_freedb_get_name(const splt_freedb_one_result *result);
1823 
1828 
1846  int disc_id, const char *output_file,
1847  int cddb_get_type, const char *cddb_get_server, int port);
1848 
1850 
1862 typedef enum {
1863  CUE_EXPORT
1865 
1877  const char *file, int stop_at_total_time);
1878 
1880 
1895 typedef struct _splt_wrap splt_wrap;
1896 
1903 typedef struct _splt_one_wrap splt_one_wrap;
1904 
1917 
1926 
1936 
1940 char *mp3splt_wrap_get_wrapped_file(const splt_one_wrap *one_wrap);
1941 
1943 
1957 int mp3splt_set_silence_points(splt_state *state, splt_code *error);
1958 
1966 
1970 char *mp3splt_get_version();
1971 
1972 #ifdef __WIN32__
1973 
1976 char *mp3splt_win32_utf16_to_utf8(const wchar_t *source);
1977 #endif
1978 
1982 int mp3splt_check_if_directory(const char *filename);
1983 
1984 #ifndef SPLT_DIRCHAR
1985 #ifdef __WIN32__
1986 #define SPLT_DIRCHAR '\\'
1987 #define SPLT_DIRSTR "\\"
1988 #else
1989 
1992 #define SPLT_DIRCHAR '/'
1993 
1996 #define SPLT_DIRSTR "/"
1997 #endif
1998 #endif
1999 
2001 
2010 typedef struct {
2014  float version;
2018  char *name;
2022  char *extension;
2028 
2032 typedef struct _splt_original_tags splt_original_tags;
2033 
2048 typedef struct {
2058  void (*splt_pl_init)(splt_state *state, splt_code *error);
2067  void (*splt_pl_end)(splt_state *state, splt_code *error);
2077  int (*splt_pl_check_plugin_is_for_file)(splt_state *state, splt_code *error);
2086  void (*splt_pl_set_plugin_info)(splt_plugin_info *information, splt_code *error);
2100  double (*splt_pl_split)(splt_state *state, const char *final_fname, double begin_point,
2101  double end_point, splt_code *error, int save_end_point);
2113  void (*splt_pl_set_original_tags)(splt_state *state, splt_code *error);
2122  void (*splt_pl_clear_original_tags)(splt_original_tags *original_tags);
2134  int (*splt_pl_scan_silence)(splt_state *state, splt_code *error);
2146  int (*splt_pl_scan_trim_silence)(splt_state *state, splt_code *error);
2155  void (*splt_pl_search_syncerrors)(splt_state *state, splt_code *error);
2167  int (*splt_pl_offset_split)(splt_state *state, const char *output_fname, off_t begin, off_t end);
2179  void (*splt_pl_dewrap)(splt_state *state, int listonly, const char *dir, splt_code *error);
2181 
2183 
2187 #define MP3SPLT_MP3SPLT_H
2188 #endif
2189