libmp3splt  0.8.2
Lossless library for splitting audio formats like mp3 and ogg vorbis.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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-2013 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 
84 #include "version.h"
85 
89 #define SPLT_TRUE 1
90 
93 #define SPLT_FALSE 0
94 
106 typedef enum {
107  SPLT_OK = 0,
108 
109  SPLT_OK_SPLIT = 1,
110  SPLT_SPLITPOINT_BIGGER_THAN_LENGTH = 4,
111  SPLT_SILENCE_OK = 5,
112  SPLT_TIME_SPLIT_OK = 6,
113  SPLT_NO_SILENCE_SPLITPOINTS_FOUND = 7,
114  SPLT_OK_SPLIT_EOF = 8,
115  SPLT_LENGTH_SPLIT_OK = 9,
116  SPLT_TRIM_SILENCE_OK = 10,
117 
118  SPLT_FREEDB_OK = 100,
119  SPLT_FREEDB_FILE_OK = 101,
120  SPLT_CDDB_OK = 102,
121  SPLT_CUE_OK = 103,
122  SPLT_FREEDB_MAX_CD_REACHED = 104,
123  SPLT_AUDACITY_OK = 105,
124 
125  SPLT_DEWRAP_OK = 200,
126 
127  SPLT_SYNC_OK = 300,
128  SPLT_MIGHT_BE_VBR = 301,
129 
130  SPLT_ERR_SYNC = -300,
131  SPLT_ERR_NO_SYNC_FOUND = -301,
132  SPLT_ERR_TOO_MANY_SYNC_ERR = -302,
133 
134  SPLT_OUTPUT_FORMAT_OK = 400,
135  SPLT_OUTPUT_FORMAT_AMBIGUOUS = 401,
136 
137  SPLT_REGEX_OK = 800,
138 
139  SPLT_ERROR_SPLITPOINTS = -1,
140  SPLT_ERROR_CANNOT_OPEN_FILE = -2,
141  SPLT_ERROR_INVALID = -3,
142  SPLT_ERROR_EQUAL_SPLITPOINTS = -5,
143  SPLT_ERROR_SPLITPOINTS_NOT_IN_ORDER = -6,
144  SPLT_ERROR_NEGATIVE_SPLITPOINT = -7,
145  SPLT_ERROR_INCORRECT_PATH = -8,
146  SPLT_ERROR_INCOMPATIBLE_OPTIONS = -10,
147  SPLT_ERROR_INPUT_OUTPUT_SAME_FILE = -12,
148  SPLT_ERROR_CANNOT_ALLOCATE_MEMORY = -15,
149  SPLT_ERROR_CANNOT_OPEN_DEST_FILE = -16,
150  SPLT_ERROR_CANT_WRITE_TO_OUTPUT_FILE = -17,
151  SPLT_ERROR_WHILE_READING_FILE = -18,
152  SPLT_ERROR_SEEKING_FILE = -19,
153  SPLT_ERROR_BEGIN_OUT_OF_FILE = -20,
154  SPLT_ERROR_INEXISTENT_FILE = -21,
155  SPLT_SPLIT_CANCELLED = -22,
156  SPLT_ERROR_LIBRARY_LOCKED = -24,
157  SPLT_ERROR_STATE_NULL = -25,
158  SPLT_ERROR_NEGATIVE_TIME_SPLIT = -26,
159  SPLT_ERROR_CANNOT_CREATE_DIRECTORY = -27,
160  SPLT_ERROR_CANNOT_CLOSE_FILE = -28,
161  SPLT_ERROR_NO_PLUGIN_FOUND = -29,
162  SPLT_ERROR_CANNOT_INIT_LIBLTDL = -30,
163  SPLT_ERROR_CRC_FAILED = -31,
164  SPLT_ERROR_NO_PLUGIN_FOUND_FOR_FILE = -32,
165  SPLT_ERROR_PLUGIN_ERROR = -33,
166  SPLT_ERROR_TIME_SPLIT_VALUE_INVALID = -34,
167  SPLT_ERROR_LENGTH_SPLIT_VALUE_INVALID = -35,
168  SPLT_ERROR_CANNOT_GET_TOTAL_TIME = -36,
169  SPLT_ERROR_LIBID3 = -37,
170 
171  SPLT_FREEDB_ERROR_INITIALISE_SOCKET = -101,
172  SPLT_FREEDB_ERROR_CANNOT_GET_HOST = -102,
173  SPLT_FREEDB_ERROR_CANNOT_OPEN_SOCKET = -103,
174  SPLT_FREEDB_ERROR_CANNOT_CONNECT = -104,
175  SPLT_FREEDB_ERROR_CANNOT_SEND_MESSAGE = -105,
176  SPLT_FREEDB_ERROR_INVALID_SERVER_ANSWER = -106,
177  SPLT_FREEDB_ERROR_SITE_201 = -107,
178  SPLT_FREEDB_ERROR_SITE_200 = -108,
179  SPLT_FREEDB_ERROR_BAD_COMMUNICATION = -109,
180  SPLT_FREEDB_ERROR_GETTING_INFOS = -110,
181  SPLT_FREEDB_NO_CD_FOUND = -111,
182  SPLT_FREEDB_ERROR_CANNOT_RECV_MESSAGE = -112,
183  SPLT_INVALID_CUE_FILE = -115,
184  SPLT_INVALID_CDDB_FILE = -116,
185  SPLT_FREEDB_NO_SUCH_CD_IN_DATABASE = -118,
186  SPLT_FREEDB_ERROR_SITE = -119,
187  SPLT_FREEDB_ERROR_CANNOT_DISCONNECT = -120,
188  SPLT_FREEDB_ERROR_PROXY_NOT_SUPPORTED = -121,
189 
190  SPLT_DEWRAP_ERR_FILE_LENGTH = -200,
191  SPLT_DEWRAP_ERR_VERSION_OLD = -201,
192  SPLT_DEWRAP_ERR_NO_FILE_OR_BAD_INDEX = -202,
193  SPLT_DEWRAP_ERR_FILE_DAMAGED_INCOMPLETE = -203,
194  SPLT_DEWRAP_ERR_FILE_NOT_WRAPED_DAMAGED = -204,
195 
196  SPLT_OUTPUT_FORMAT_ERROR = -400,
197 
198  SPLT_ERROR_INEXISTENT_SPLITPOINT = -500,
199 
200  SPLT_PLUGIN_ERROR_UNSUPPORTED_FEATURE = -600,
201 
202  SPLT_INVALID_AUDACITY_FILE = -700,
203 
204  SPLT_INVALID_REGEX = -800,
205  SPLT_REGEX_NO_MATCH = -801,
206  SPLT_REGEX_UNAVAILABLE = -802,
207 } splt_code;
208 
210 
215 
223 typedef struct _splt_state splt_state;
224 
236 
246 
256 splt_code mp3splt_append_plugins_scan_dir(splt_state *state, const char *directory);
257 
268 
270 
285 char *mp3splt_get_strerror(splt_state *state, splt_code error);
286 
288 
304 typedef enum {
663 } splt_options;
664 
668 typedef enum {
703 
707 typedef enum {
721 
725 typedef enum {
744 
748 #define SPLT_DEFAULT_PARAM_THRESHOLD -48.0
749 
752 #define SPLT_DEFAULT_PARAM_OFFSET 0.8
753 
756 #define SPLT_DEFAULT_PARAM_MINIMUM_LENGTH 0.0
757 
760 #define SPLT_DEFAULT_PARAM_MINIMUM_TRACK_LENGTH 0.0
761 
764 #define SPLT_DEFAULT_PARAM_MIN_TRACK_JOIN 0.0
765 
768 #define SPLT_DEFAULT_PARAM_GAP 30
769 
772 #define SPLT_DEFAULT_PARAM_TRACKS 0
773 
776 #define SPLT_DEFAULT_PARAM_SHOTS 25
777 
780 #define SPLT_DEFAULT_KEEP_SILENCE_LEFT 0
781 
784 #define SPLT_DEFAULT_KEEP_SILENCE_RIGHT 0
785 
789 typedef enum {
807 
812 #define SPLT_DEFAULT_OUTPUT "@f_@mm_@ss_@h0h__@Mm_@Ss_@H0h"
813 
818 #define SPLT_DEFAULT_CDDB_CUE_OUTPUT "@A - @n - @t"
819 
823 #define SPLT_DEFAULT_SYNCERROR_OUTPUT "@f_error_@n"
824 
828 #define SPLT_DEFAULT_SILENCE_OUTPUT "@f_silence_@n"
829 
833 #define SPLT_DEFAULT_TRIM_SILENCE_OUTPUT "@f_trimmed"
834 
840 typedef enum {
862 
871 splt_code mp3splt_set_int_option(splt_state *state, splt_options option, int value);
872 
881 splt_code mp3splt_set_long_option(splt_state *state, splt_options option, long value);
882 
891 splt_code mp3splt_set_float_option(splt_state *state, splt_options option, float value);
892 
901 int mp3splt_get_int_option(splt_state *state, splt_options option, splt_code *error);
902 
911 long mp3splt_get_long_option(splt_state *state, splt_options option, splt_code *error);
912 
921 float mp3splt_get_float_option(splt_state *state, splt_options option, splt_code *error);
922 
930 splt_code mp3splt_set_oformat(splt_state *state, const char *format);
931 
933 
947 splt_code mp3splt_set_filename_to_split(splt_state *state, const char *filename);
948 
956 splt_code mp3splt_set_path_of_split(splt_state *state, const char *path_of_split);
957 
969 const char *mp3splt_get_filename_to_split(splt_state *state);
970 
983 splt_code mp3splt_set_m3u_filename(splt_state *state, const char *m3u_filename);
984 
1010 splt_code mp3splt_set_silence_log_filename(splt_state *state, const char *filename);
1011 
1044 splt_code mp3splt_set_silence_full_log_filename(splt_state *state, const char *filename);
1045 
1047 
1059 typedef enum {
1069 
1087  void (*message_cb)(const char *message, splt_message_type type, void *cb_data), void *cb_data);
1088 
1103  void (*file_cb)(const char *filename, void *cb_data),
1104  void *cb_data);
1105 
1127  void (*write_cb)(const void *ptr, size_t size, size_t nmemb, void *cb_data),
1128  void *cb_data);
1129 
1134 typedef enum {
1153 
1169 typedef struct splt_progres splt_progress;
1170 
1185  void (*progress_cb)(splt_progress *p_bar, void *cb_data), void *cb_data);
1186 
1190 int mp3splt_progress_get_type(const splt_progress *p_bar);
1191 
1196 
1201 
1206 
1211 
1216 
1221 
1238  void (*get_silence_cb)(long time, float level, void *user_data),
1239  void *user_data);
1240 
1242 
1253 typedef enum {
1264 
1273 typedef struct _splt_point splt_point;
1274 
1288 splt_point *mp3splt_point_new(long splitpoint_value, splt_code *error);
1289 
1297 splt_code mp3splt_point_set_name(splt_point *splitpoint, const char *name);
1298 
1307 
1318 
1326 typedef struct _splt_points splt_points;
1327 
1339 
1347 void mp3splt_points_init_iterator(splt_points *splitpoints);
1348 
1359 const splt_point *mp3splt_points_next(splt_points *splitpoints);
1360 
1369 long mp3splt_point_get_value(const splt_point *point);
1370 
1381 
1390 char *mp3splt_point_get_name(const splt_point *point);
1391 
1399 
1401 
1411 #define SPLT_UNDEFINED_GENRE "Other"
1412 
1417 #define SPLT_ID3V1_NUMBER_OF_GENRES 127
1418 
1422 extern const char splt_id3v1_genres[SPLT_ID3V1_NUMBER_OF_GENRES][25];
1423 
1427 typedef enum {
1428  SPLT_TAGS_TITLE = 1,
1429  SPLT_TAGS_ARTIST = 2,
1430  SPLT_TAGS_ALBUM = 3,
1431  SPLT_TAGS_YEAR = 4,
1432  SPLT_TAGS_COMMENT = 5,
1433  SPLT_TAGS_TRACK = 6,
1434  SPLT_TAGS_GENRE = 7,
1435  SPLT_TAGS_PERFORMER = 8,
1441 } splt_tag_key;
1442 
1452 typedef struct _splt_tags splt_tags;
1453 
1464 
1485 
1499 
1504 typedef struct _splt_tags_group splt_tags_group;
1505 
1517 
1525 
1534 
1544 
1548 char *mp3splt_tags_get(splt_tags *tags, splt_tag_key key);
1549 
1578 int mp3splt_put_tags_from_string(splt_state *state, const char *tags, splt_code *error);
1579 
1589 
1597 
1611 splt_code mp3splt_set_input_filename_regex(splt_state *state, const char *regex);
1612 
1622 splt_code mp3splt_set_default_comment_tag(splt_state *state, const char *default_comment_tag);
1623 
1633 splt_code mp3splt_set_default_genre_tag(splt_state *state, const char *default_genre_tag);
1634 
1648 
1656 void mp3splt_free_one_tag(splt_tags *tags);
1657 
1659 
1679 
1689 
1701 char **mp3splt_find_filenames(splt_state *state, const char *filename,
1702  int *num_of_files_found, splt_code *error);
1703 
1705 
1717 typedef enum {
1718  CUE_IMPORT,
1719  CDDB_IMPORT,
1720  AUDACITY_LABELS_IMPORT
1722 
1733 splt_code mp3splt_import(splt_state *state, splt_import_type type, const char *file);
1734 
1740 #define SPLT_FREEDB_SEARCH_TYPE_CDDB_CGI 1
1741 
1747 #define SPLT_FREEDB_GET_FILE_TYPE_CDDB_CGI 3
1748 
1754 #define SPLT_FREEDB_GET_FILE_TYPE_CDDB 4
1755 
1762 #define SPLT_FREEDB_CDDB_CGI_PORT 80
1763 
1771 #define SPLT_FREEDB2_CGI_SITE "tracktype.org/~cddb/cddb.cgi"
1772 
1781 typedef struct _splt_freedb_results splt_freedb_results;
1782 
1790 typedef struct _splt_freedb_one_result splt_freedb_one_result;
1791 
1800 splt_code mp3splt_use_proxy(splt_state *state, const char *proxy_address, int proxy_port);
1801 
1814  const char *base64_authentification);
1815 
1826 char *mp3splt_encode_in_base64(splt_state *state, const char *input, int *error);
1827 
1834 void mp3splt_clear_proxy(splt_state *state);
1835 
1853  const char *searched_string, splt_code *error,
1854  int search_type, const char *search_server, int port);
1855 
1864 
1876 
1882 
1886 const char *mp3splt_freedb_get_name(const splt_freedb_one_result *result);
1887 
1892 
1910  int disc_id, const char *output_file,
1911  int cddb_get_type, const char *cddb_get_server, int port);
1912 
1914 
1926 typedef enum {
1927  CUE_EXPORT
1929 
1941  const char *file, int stop_at_total_time);
1942 
1944 
1959 typedef struct _splt_wrap splt_wrap;
1960 
1967 typedef struct _splt_one_wrap splt_one_wrap;
1968 
1981 
1990 
2000 
2004 char *mp3splt_wrap_get_wrapped_file(const splt_one_wrap *one_wrap);
2005 
2007 
2021 int mp3splt_set_silence_points(splt_state *state, splt_code *error);
2022 
2030 
2034 char *mp3splt_get_version();
2035 
2036 #ifdef __WIN32__
2037 
2040 char *mp3splt_win32_utf16_to_utf8(const wchar_t *source);
2041 #endif
2042 
2046 int mp3splt_check_if_directory(const char *filename);
2047 
2048 #ifndef SPLT_DIRCHAR
2049 #ifdef __WIN32__
2050 #define SPLT_DIRCHAR '\\'
2051 #define SPLT_DIRSTR "\\"
2052 #else
2053 
2056 #define SPLT_DIRCHAR '/'
2057 
2060 #define SPLT_DIRSTR "/"
2061 #endif
2062 #endif
2063 
2065 
2074 typedef struct {
2078  float version;
2082  char *name;
2086  char *extension;
2092 
2096 typedef struct _splt_original_tags splt_original_tags;
2097 
2112 typedef struct {
2122  void (*splt_pl_init)(splt_state *state, splt_code *error);
2131  void (*splt_pl_end)(splt_state *state, splt_code *error);
2141  int (*splt_pl_check_plugin_is_for_file)(splt_state *state, splt_code *error);
2150  void (*splt_pl_set_plugin_info)(splt_plugin_info *information, splt_code *error);
2164  double (*splt_pl_split)(splt_state *state, const char *final_fname, double begin_point,
2165  double end_point, splt_code *error, int save_end_point);
2177  void (*splt_pl_set_original_tags)(splt_state *state, splt_code *error);
2186  void (*splt_pl_clear_original_tags)(splt_original_tags *original_tags);
2198  int (*splt_pl_scan_silence)(splt_state *state, splt_code *error);
2210  int (*splt_pl_scan_trim_silence)(splt_state *state, splt_code *error);
2219  void (*splt_pl_search_syncerrors)(splt_state *state, splt_code *error);
2231  int (*splt_pl_offset_split)(splt_state *state, const char *output_fname, off_t begin, off_t end);
2243  void (*splt_pl_dewrap)(splt_state *state, int listonly, const char *dir, splt_code *error);
2245 
2247 
2251 #define MP3SPLT_MP3SPLT_H
2252 #endif
2253