mp3splt.h
Go to the documentation of this file.
/**********************************************************
*
* libmp3splt -- library based on mp3splt v2.1c,
* for mp3/ogg splitting without decoding
*
* Copyright (c) 2002-2005 M. Trotta - <mtrotta@users.sourceforge.net>
* Copyright (c) 2005-2013 Alexandru Munteanu - m@ioalex.net
*
* And others ... see the AUTHORS file provided with libmp3splt source.
*
* http://mp3splt.sourceforge.net
*
*********************************************************/
/**********************************************************
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*********************************************************/
#ifndef MP3SPLT_MP3SPLT_H
#include <sys/types.h>
#include "version.h"
#define SPLT_TRUE 1
#define SPLT_FALSE 0
typedef enum {
SPLT_OK = 0,
SPLT_OK_SPLIT = 1,
SPLT_SPLITPOINT_BIGGER_THAN_LENGTH = 4,
SPLT_SILENCE_OK = 5,
SPLT_TIME_SPLIT_OK = 6,
SPLT_NO_SILENCE_SPLITPOINTS_FOUND = 7,
SPLT_OK_SPLIT_EOF = 8,
SPLT_LENGTH_SPLIT_OK = 9,
SPLT_TRIM_SILENCE_OK = 10,
SPLT_FREEDB_OK = 100,
SPLT_FREEDB_FILE_OK = 101,
SPLT_CDDB_OK = 102,
SPLT_CUE_OK = 103,
SPLT_FREEDB_MAX_CD_REACHED = 104,
SPLT_AUDACITY_OK = 105,
SPLT_DEWRAP_OK = 200,
SPLT_SYNC_OK = 300,
SPLT_MIGHT_BE_VBR = 301,
SPLT_ERR_SYNC = -300,
SPLT_ERR_NO_SYNC_FOUND = -301,
SPLT_ERR_TOO_MANY_SYNC_ERR = -302,
SPLT_OUTPUT_FORMAT_OK = 400,
SPLT_OUTPUT_FORMAT_AMBIGUOUS = 401,
SPLT_REGEX_OK = 800,
SPLT_ERROR_SPLITPOINTS = -1,
SPLT_ERROR_CANNOT_OPEN_FILE = -2,
SPLT_ERROR_INVALID = -3,
SPLT_ERROR_EQUAL_SPLITPOINTS = -5,
SPLT_ERROR_SPLITPOINTS_NOT_IN_ORDER = -6,
SPLT_ERROR_NEGATIVE_SPLITPOINT = -7,
SPLT_ERROR_INCORRECT_PATH = -8,
SPLT_ERROR_INCOMPATIBLE_OPTIONS = -10,
SPLT_ERROR_INPUT_OUTPUT_SAME_FILE = -12,
SPLT_ERROR_CANNOT_ALLOCATE_MEMORY = -15,
SPLT_ERROR_CANNOT_OPEN_DEST_FILE = -16,
SPLT_ERROR_CANT_WRITE_TO_OUTPUT_FILE = -17,
SPLT_ERROR_WHILE_READING_FILE = -18,
SPLT_ERROR_SEEKING_FILE = -19,
SPLT_ERROR_BEGIN_OUT_OF_FILE = -20,
SPLT_ERROR_INEXISTENT_FILE = -21,
SPLT_SPLIT_CANCELLED = -22,
SPLT_ERROR_LIBRARY_LOCKED = -24,
SPLT_ERROR_STATE_NULL = -25,
SPLT_ERROR_NEGATIVE_TIME_SPLIT = -26,
SPLT_ERROR_CANNOT_CREATE_DIRECTORY = -27,
SPLT_ERROR_CANNOT_CLOSE_FILE = -28,
SPLT_ERROR_NO_PLUGIN_FOUND = -29,
SPLT_ERROR_CANNOT_INIT_LIBLTDL = -30,
SPLT_ERROR_CRC_FAILED = -31,
SPLT_ERROR_NO_PLUGIN_FOUND_FOR_FILE = -32,
SPLT_ERROR_PLUGIN_ERROR = -33,
SPLT_ERROR_TIME_SPLIT_VALUE_INVALID = -34,
SPLT_ERROR_LENGTH_SPLIT_VALUE_INVALID = -35,
SPLT_ERROR_CANNOT_GET_TOTAL_TIME = -36,
SPLT_ERROR_LIBID3 = -37,
SPLT_FREEDB_ERROR_INITIALISE_SOCKET = -101,
SPLT_FREEDB_ERROR_CANNOT_GET_HOST = -102,
SPLT_FREEDB_ERROR_CANNOT_OPEN_SOCKET = -103,
SPLT_FREEDB_ERROR_CANNOT_CONNECT = -104,
SPLT_FREEDB_ERROR_CANNOT_SEND_MESSAGE = -105,
SPLT_FREEDB_ERROR_INVALID_SERVER_ANSWER = -106,
SPLT_FREEDB_ERROR_SITE_201 = -107,
SPLT_FREEDB_ERROR_SITE_200 = -108,
SPLT_FREEDB_ERROR_BAD_COMMUNICATION = -109,
SPLT_FREEDB_ERROR_GETTING_INFOS = -110,
SPLT_FREEDB_NO_CD_FOUND = -111,
SPLT_FREEDB_ERROR_CANNOT_RECV_MESSAGE = -112,
SPLT_INVALID_CUE_FILE = -115,
SPLT_INVALID_CDDB_FILE = -116,
SPLT_FREEDB_NO_SUCH_CD_IN_DATABASE = -118,
SPLT_FREEDB_ERROR_SITE = -119,
SPLT_FREEDB_ERROR_CANNOT_DISCONNECT = -120,
SPLT_FREEDB_ERROR_PROXY_NOT_SUPPORTED = -121,
SPLT_DEWRAP_ERR_FILE_LENGTH = -200,
SPLT_DEWRAP_ERR_VERSION_OLD = -201,
SPLT_DEWRAP_ERR_NO_FILE_OR_BAD_INDEX = -202,
SPLT_DEWRAP_ERR_FILE_DAMAGED_INCOMPLETE = -203,
SPLT_DEWRAP_ERR_FILE_NOT_WRAPED_DAMAGED = -204,
SPLT_OUTPUT_FORMAT_ERROR = -400,
SPLT_ERROR_INEXISTENT_SPLITPOINT = -500,
SPLT_PLUGIN_ERROR_UNSUPPORTED_FEATURE = -600,
SPLT_INVALID_AUDACITY_FILE = -700,
SPLT_INVALID_REGEX = -800,
SPLT_REGEX_NO_MATCH = -801,
SPLT_REGEX_UNAVAILABLE = -802,
} splt_code;
typedef struct _splt_state splt_state;
splt_state *mp3splt_new_state(splt_code *error);
splt_code mp3splt_free_state(splt_state *state);
splt_code mp3splt_append_plugins_scan_dir(splt_state *state, const char *directory);
splt_code mp3splt_find_plugins(splt_state *state);
char *mp3splt_get_strerror(splt_state *state, splt_code error);
typedef enum {
SPLT_OPT_PRETEND_TO_SPLIT = 1,
SPLT_OPT_QUIET_MODE,
SPLT_OPT_DEBUG_MODE,
SPLT_OPT_SPLIT_MODE,
SPLT_OPT_TAGS,
SPLT_OPT_XING,
SPLT_OPT_CREATE_DIRS_FROM_FILENAMES,
SPLT_OPT_OUTPUT_FILENAMES,
SPLT_OPT_FRAME_MODE,
SPLT_OPT_AUTO_ADJUST,
SPLT_OPT_INPUT_NOT_SEEKABLE,
SPLT_OPT_PARAM_NUMBER_TRACKS,
SPLT_OPT_PARAM_SHOTS,
SPLT_OPT_PARAM_REMOVE_SILENCE,
SPLT_OPT_PARAM_GAP,
SPLT_OPT_ENABLE_SILENCE_LOG,
SPLT_OPT_FORCE_TAGS_VERSION,
SPLT_OPT_LENGTH_SPLIT_FILE_NUMBER,
SPLT_OPT_REPLACE_TAGS_IN_TAGS,
SPLT_OPT_OVERLAP_TIME,
SPLT_OPT_SPLIT_TIME,
SPLT_OPT_PARAM_THRESHOLD,
SPLT_OPT_PARAM_OFFSET,
SPLT_OPT_PARAM_MIN_LENGTH,
SPLT_OPT_PARAM_MIN_TRACK_LENGTH,
SPLT_OPT_PARAM_MIN_TRACK_JOIN,
SPLT_OPT_ARTIST_TAG_FORMAT,
SPLT_OPT_ALBUM_TAG_FORMAT,
SPLT_OPT_TITLE_TAG_FORMAT,
SPLT_OPT_COMMENT_TAG_FORMAT,
SPLT_OPT_REPLACE_UNDERSCORES_TAG_FORMAT,
SPLT_OPT_SET_FILE_FROM_CUE_IF_FILE_TAG_FOUND,
SPLT_OPT_KEEP_SILENCE_LEFT,
SPLT_OPT_KEEP_SILENCE_RIGHT,
SPLT_OPT_CUE_SET_SPLITPOINT_NAMES_FROM_REM_NAME,
SPLT_OPT_CUE_DISABLE_CUE_FILE_CREATED_MESSAGE,
SPLT_OPT_CUE_CDDB_ADD_TAGS_WITH_KEEP_ORIGINAL_TAGS,
SPLT_OPT_ID3V2_ENCODING,
SPLT_OPT_INPUT_TAGS_ENCODING,
} splt_options;
typedef enum {
SPLT_OPTION_NORMAL_MODE,
SPLT_OPTION_WRAP_MODE,
SPLT_OPTION_SILENCE_MODE,
SPLT_OPTION_TRIM_SILENCE_MODE,
SPLT_OPTION_ERROR_MODE,
SPLT_OPTION_TIME_MODE,
SPLT_OPTION_LENGTH_MODE,
} splt_split_mode_options;
typedef enum {
SPLT_ID3V2_LATIN1,
SPLT_ID3V2_UTF8,
SPLT_ID3V2_UTF16,
} splt_id3v2_encoding;
typedef enum {
SPLT_OUTPUT_FORMAT,
SPLT_OUTPUT_DEFAULT,
SPLT_OUTPUT_CUSTOM
} splt_output_filenames_options;
#define SPLT_DEFAULT_PARAM_THRESHOLD -48.0
#define SPLT_DEFAULT_PARAM_OFFSET 0.8
#define SPLT_DEFAULT_PARAM_MINIMUM_LENGTH 0.0
#define SPLT_DEFAULT_PARAM_MINIMUM_TRACK_LENGTH 0.0
#define SPLT_DEFAULT_PARAM_MIN_TRACK_JOIN 0.0
#define SPLT_DEFAULT_PARAM_GAP 30
#define SPLT_DEFAULT_PARAM_TRACKS 0
#define SPLT_DEFAULT_PARAM_SHOTS 25
#define SPLT_DEFAULT_KEEP_SILENCE_LEFT 0
#define SPLT_DEFAULT_KEEP_SILENCE_RIGHT 0
typedef enum {
SPLT_TAGS_ORIGINAL_FILE,
SPLT_CURRENT_TAGS,
SPLT_NO_TAGS,
SPLT_TAGS_FROM_FILENAME_REGEX,
} splt_tags_options;
#define SPLT_DEFAULT_OUTPUT "@f_@mm_@ss_@h0h__@Mm_@Ss_@H0h"
#define SPLT_DEFAULT_CDDB_CUE_OUTPUT "@A - @n - @t"
#define SPLT_DEFAULT_SYNCERROR_OUTPUT "@f_error_@n"
#define SPLT_DEFAULT_SILENCE_OUTPUT "@f_silence_@n"
#define SPLT_DEFAULT_TRIM_SILENCE_OUTPUT "@f_trimmed"
typedef enum {
SPLT_NO_CONVERSION,
SPLT_TO_LOWERCASE,
SPLT_TO_UPPERCASE,
SPLT_TO_FIRST_UPPERCASE,
SPLT_TO_WORD_FIRST_UPPERCASE
} splt_str_format;
splt_code mp3splt_set_int_option(splt_state *state, splt_options option, int value);
splt_code mp3splt_set_long_option(splt_state *state, splt_options option, long value);
splt_code mp3splt_set_float_option(splt_state *state, splt_options option, float value);
int mp3splt_get_int_option(splt_state *state, splt_options option, splt_code *error);
long mp3splt_get_long_option(splt_state *state, splt_options option, splt_code *error);
float mp3splt_get_float_option(splt_state *state, splt_options option, splt_code *error);
splt_code mp3splt_set_oformat(splt_state *state, const char *format);
splt_code mp3splt_set_filename_to_split(splt_state *state, const char *filename);
splt_code mp3splt_set_path_of_split(splt_state *state, const char *path_of_split);
const char *mp3splt_get_filename_to_split(splt_state *state);
splt_code mp3splt_set_m3u_filename(splt_state *state, const char *m3u_filename);
splt_code mp3splt_set_silence_log_filename(splt_state *state, const char *filename);
splt_code mp3splt_set_silence_full_log_filename(splt_state *state, const char *filename);
typedef enum {
SPLT_MESSAGE_INFO,
SPLT_MESSAGE_DEBUG
} splt_message_type;
splt_code mp3splt_set_message_function(splt_state *state,
void (*message_cb)(const char *message, splt_message_type type, void *cb_data), void *cb_data);
splt_code mp3splt_set_split_filename_function(splt_state *state,
void (*file_cb)(const char *filename, void *cb_data),
void *cb_data);
splt_code mp3splt_set_pretend_to_split_write_function(splt_state *state,
void (*write_cb)(const void *ptr, size_t size, size_t nmemb, void *cb_data),
void *cb_data);
typedef enum {
SPLT_PROGRESS_PREPARE,
SPLT_PROGRESS_CREATE,
SPLT_PROGRESS_SEARCH_SYNC,
SPLT_PROGRESS_SCAN_SILENCE
} splt_progress_messages;
typedef struct splt_progres splt_progress;
splt_code mp3splt_set_progress_function(splt_state *state,
void (*progress_cb)(splt_progress *p_bar, void *cb_data), void *cb_data);
int mp3splt_progress_get_type(const splt_progress *p_bar);
char *mp3splt_progress_get_filename_shorted(const splt_progress *p_bar);
int mp3splt_progress_get_current_split(const splt_progress *p_bar);
int mp3splt_progress_get_max_splits(const splt_progress *p_bar);
int mp3splt_progress_get_silence_found_tracks(const splt_progress *p_bar);
float mp3splt_progress_get_silence_db_level(const splt_progress *p_bar);
float mp3splt_progress_get_percent_progress(const splt_progress *p_bar);
splt_code mp3splt_set_silence_level_function(splt_state *state,
void (*get_silence_cb)(long time, float level, void *user_data),
void *user_data);
typedef enum {
SPLT_SPLITPOINT,
SPLT_SKIPPOINT,
} splt_type_of_splitpoint;
typedef struct _splt_point splt_point;
splt_point *mp3splt_point_new(long splitpoint_value, splt_code *error);
splt_code mp3splt_point_set_name(splt_point *splitpoint, const char *name);
splt_code mp3splt_point_set_type(splt_point *splitpoint, splt_type_of_splitpoint type);
splt_code mp3splt_append_splitpoint(splt_state *state, splt_point *splitpoint);
typedef struct _splt_points splt_points;
splt_points *mp3splt_get_splitpoints(splt_state *state, splt_code *error);
void mp3splt_points_init_iterator(splt_points *splitpoints);
const splt_point *mp3splt_points_next(splt_points *splitpoints);
long mp3splt_point_get_value(const splt_point *point);
splt_type_of_splitpoint mp3splt_point_get_type(const splt_point *point);
char *mp3splt_point_get_name(const splt_point *point);
splt_code mp3splt_erase_all_splitpoints(splt_state *state);
#define SPLT_UNDEFINED_GENRE "Other"
#define SPLT_ID3V1_NUMBER_OF_GENRES 127
extern const char splt_id3v1_genres[SPLT_ID3V1_NUMBER_OF_GENRES][25];
typedef enum {
SPLT_TAGS_TITLE = 1,
SPLT_TAGS_ARTIST = 2,
SPLT_TAGS_ALBUM = 3,
SPLT_TAGS_YEAR = 4,
SPLT_TAGS_COMMENT = 5,
SPLT_TAGS_TRACK = 6,
SPLT_TAGS_GENRE = 7,
SPLT_TAGS_PERFORMER = 8,
SPLT_TAGS_ORIGINAL = 900
} splt_tag_key;
typedef struct _splt_tags splt_tags;
splt_tags *mp3splt_tags_new(splt_code *error);
splt_code mp3splt_tags_set(splt_tags *tags, ...);
splt_code mp3splt_append_tags(splt_state *state, splt_tags *tags);
typedef struct _splt_tags_group splt_tags_group;
splt_tags_group *mp3splt_get_tags_group(splt_state *state, splt_code *error);
splt_code mp3splt_remove_tags_of_skippoints(splt_state *state);
void mp3splt_tags_group_init_iterator(splt_tags_group *tags_group);
splt_tags *mp3splt_tags_group_next(splt_tags_group *tags_group);
char *mp3splt_tags_get(splt_tags *tags, splt_tag_key key);
int mp3splt_put_tags_from_string(splt_state *state, const char *tags, splt_code *error);
splt_code mp3splt_read_original_tags(splt_state *state);
splt_code mp3splt_erase_all_tags(splt_state *state);
splt_code mp3splt_set_input_filename_regex(splt_state *state, const char *regex);
splt_code mp3splt_set_default_comment_tag(splt_state *state, const char *default_comment_tag);
splt_code mp3splt_set_default_genre_tag(splt_state *state, const char *default_genre_tag);
splt_tags *mp3splt_parse_filename_regex(splt_state *state, splt_code *error);
void mp3splt_free_one_tag(splt_tags *tags);
splt_code mp3splt_split(splt_state *state);
splt_code mp3splt_stop_split(splt_state *state);
char **mp3splt_find_filenames(splt_state *state, const char *filename,
int *num_of_files_found, splt_code *error);
typedef enum {
CUE_IMPORT,
CDDB_IMPORT,
AUDACITY_LABELS_IMPORT
} splt_import_type;
splt_code mp3splt_import(splt_state *state, splt_import_type type, const char *file);
#define SPLT_FREEDB_SEARCH_TYPE_CDDB_CGI 1
#define SPLT_FREEDB_GET_FILE_TYPE_CDDB_CGI 3
#define SPLT_FREEDB_GET_FILE_TYPE_CDDB 4
#define SPLT_FREEDB_CDDB_CGI_PORT 80
#define SPLT_FREEDB2_CGI_SITE "tracktype.org/~cddb/cddb.cgi"
typedef struct _splt_freedb_results splt_freedb_results;
typedef struct _splt_freedb_one_result splt_freedb_one_result;
splt_code mp3splt_use_proxy(splt_state *state, const char *proxy_address, int proxy_port);
splt_code mp3splt_use_base64_authentification(splt_state *state,
const char *base64_authentification);
char *mp3splt_encode_in_base64(splt_state *state, const char *input, int *error);
void mp3splt_clear_proxy(splt_state *state);
splt_freedb_results *mp3splt_get_freedb_search(splt_state *state,
const char *searched_string, splt_code *error,
int search_type, const char *search_server, int port);
void mp3splt_freedb_init_iterator(splt_freedb_results *freedb_results);
const splt_freedb_one_result *mp3splt_freedb_next(splt_freedb_results *freedb_results);
int mp3splt_freedb_get_id(const splt_freedb_one_result *result);
const char *mp3splt_freedb_get_name(const splt_freedb_one_result *result);
int mp3splt_freedb_get_number_of_revisions(const splt_freedb_one_result *result);
splt_code mp3splt_write_freedb_file_result(splt_state *state,
int disc_id, const char *output_file,
int cddb_get_type, const char *cddb_get_server, int port);
typedef enum {
CUE_EXPORT
} splt_export_type;
splt_code mp3splt_export(splt_state *state, splt_export_type type,
const char *file, int stop_at_total_time);
typedef struct _splt_wrap splt_wrap;
typedef struct _splt_one_wrap splt_one_wrap;
splt_wrap *mp3splt_get_wrap_files(splt_state *state, splt_code *error);
void mp3splt_wrap_init_iterator(splt_wrap *wrap);
const splt_one_wrap *mp3splt_wrap_next(splt_wrap *wrap);
char *mp3splt_wrap_get_wrapped_file(const splt_one_wrap *one_wrap);
int mp3splt_set_silence_points(splt_state *state, splt_code *error);
splt_code mp3splt_set_trim_silence_points(splt_state *state);
char *mp3splt_get_version();
#ifdef __WIN32__
char *mp3splt_win32_utf16_to_utf8(const wchar_t *source);
#endif
int mp3splt_check_if_directory(const char *filename);
#ifndef SPLT_DIRCHAR
#ifdef __WIN32__
#define SPLT_DIRCHAR '\\'
#define SPLT_DIRSTR "\\"
#else
#define SPLT_DIRCHAR '/'
#define SPLT_DIRSTR "/"
#endif
#endif
typedef struct {
float version;
char *name;
char *extension;
char *upper_extension;
} splt_plugin_info;
typedef struct _splt_original_tags splt_original_tags;
typedef struct {
void (*splt_pl_init)(splt_state *state, splt_code *error);
void (*splt_pl_end)(splt_state *state, splt_code *error);
int (*splt_pl_check_plugin_is_for_file)(splt_state *state, splt_code *error);
void (*splt_pl_set_plugin_info)(splt_plugin_info *information, splt_code *error);
double (*splt_pl_split)(splt_state *state, const char *final_fname, double begin_point,
double end_point, splt_code *error, int save_end_point);
void (*splt_pl_set_original_tags)(splt_state *state, splt_code *error);
void (*splt_pl_clear_original_tags)(splt_original_tags *original_tags);
int (*splt_pl_scan_silence)(splt_state *state, splt_code *error);
int (*splt_pl_scan_trim_silence)(splt_state *state, splt_code *error);
void (*splt_pl_search_syncerrors)(splt_state *state, splt_code *error);
int (*splt_pl_offset_split)(splt_state *state, const char *output_fname, off_t begin, off_t end);
void (*splt_pl_dewrap)(splt_state *state, int listonly, const char *dir, splt_code *error);
} splt_plugin_func;
#define MP3SPLT_MP3SPLT_H
#endif