1 /* 2 * Copyright 2008-2013 Various Authors 3 * Copyright 2004 Timo Hirvonen 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License as 7 * published by the Free Software Foundation; either version 2 of the 8 * License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef CMUS_API_H 20 #define CMUS_API_H 21 22 #include "track_info.h" 23 24 enum file_type { 25 /* not found, device file... */ 26 FILE_TYPE_INVALID, 27 28 FILE_TYPE_URL, 29 FILE_TYPE_PL, 30 FILE_TYPE_DIR, 31 FILE_TYPE_FILE, 32 FILE_TYPE_CDDA 33 }; 34 35 typedef int (*track_info_cb)(void *data, struct track_info *ti); 36 37 /* lib_for_each, lib_for_each_filtered, pl_for_each, play_queue_for_each */ 38 typedef int (*for_each_ti_cb)(track_info_cb cb, void *data, void *opaque); 39 40 /* lib_for_each_sel, pl_for_each_sel, play_queue_for_each_sel */ 41 typedef int (*for_each_sel_ti_cb)(track_info_cb cb, void *data, int reverse, int advance); 42 43 /* lib_add_track, pl_add_track, play_queue_append, play_queue_prepend */ 44 typedef void (*add_ti_cb)(struct track_info *, void *opaque); 45 46 /* cmus_save, cmus_save_ext */ 47 typedef int (*save_ti_cb)(for_each_ti_cb for_each_ti, const char *filename, 48 void *opaque); 49 50 int cmus_init(void); 51 void cmus_exit(void); 52 void cmus_play_file(const char *filename); 53 54 /* detect file type, returns absolute path or url in @ret */ 55 enum file_type cmus_detect_ft(const char *name, char **ret); 56 57 /* add to library, playlist or queue view 58 * 59 * @add callback that does the actual adding 60 * @name playlist, directory, file, URL 61 * @ft detected FILE_TYPE_* 62 * @jt JOB_TYPE_{LIB,PL,QUEUE} 63 * 64 * returns immediately, actual work is done in the worker thread. 65 */ 66 void cmus_add(add_ti_cb, const char *name, enum file_type ft, int jt, 67 int force, void *opaque); 68 69 int cmus_save(for_each_ti_cb for_each_ti, const char *filename, void *opaque); 70 int cmus_save_ext(for_each_ti_cb for_each_ti, const char *filename, 71 void *opaque); 72 73 void cmus_update_cache(int force); 74 void cmus_update_lib(void); 75 void cmus_update_tis(struct track_info **tis, int nr, int force); 76 77 int cmus_is_playlist(const char *filename); 78 int cmus_is_playable(const char *filename); 79 int cmus_is_supported(const char *filename); 80 81 int cmus_playlist_for_each(const char *buf, int size, int reverse, 82 int (*cb)(void *data, const char *line), 83 void *data); 84 85 void cmus_next(void); 86 void cmus_prev(void); 87 88 extern int cmus_next_track_request_fd; 89 struct track_info *cmus_get_next_track(void); 90 void cmus_provide_next_track(void); 91 void cmus_track_request_init(void); 92 93 int cmus_can_raise_vte(void); 94 void cmus_raise_vte(void); 95 96 #endif 97