libmpd 0.20.0
|
00001 /* libmpd (high level libmpdclient library) 00002 * Copyright (C) 2004-2009 Qball Cow <qball@sarine.nl> 00003 * Project homepage: http://gmpcwiki.sarine.nl/ 00004 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 #ifndef __MPD_LIB__ 00034 #define __MPD_LIB__ 00035 #ifdef WIN32 00036 #define __REGEX_IMPORT__ 1 00037 #define __W32API_USE_DLLIMPORT__ 1 00038 #endif 00039 00040 #include "libmpdclient.h" 00041 00042 #ifndef TRUE 00043 00044 #define TRUE 1 00045 #endif 00046 00047 #ifndef FALSE 00048 00049 #define FALSE 0 00050 #endif 00051 #include "libmpd-version.h" 00052 extern char *libmpd_version; 00053 00058 typedef enum { 00060 MPD_OK = 0, 00062 MPD_ARGS_ERROR = -5, 00064 MPD_NOT_CONNECTED = -10, 00066 MPD_STATUS_FAILED = -20, 00068 MPD_LOCK_FAILED = -30, 00070 MPD_STATS_FAILED = -40, 00072 MPD_SERVER_ERROR = -50, 00074 MPD_SERVER_NOT_SUPPORTED = -51, 00075 00077 MPD_DATABASE_PLAYLIST_EXIST = -60, 00079 MPD_PLAYLIST_EMPTY = -70, 00081 MPD_PLAYLIST_QUEUE_EMPTY = -75, 00083 MPD_PLAYER_NOT_PLAYING = -80, 00084 00086 MPD_TAG_NOT_FOUND = -90, 00087 00088 /* MPD_PLALIST_LOAD_FAILED */ 00089 MPD_PLAYLIST_LOAD_FAILED = -100, 00090 00092 MPD_FATAL_ERROR = -1000 00093 }MpdError; 00094 00095 00096 00100 typedef struct _MpdObj MpdObj; 00101 00106 typedef enum { 00107 MPD_SERVER_COMMAND_ALLOWED = TRUE, 00108 MPD_SERVER_COMMAND_NOT_ALLOWED = FALSE, 00109 MPD_SERVER_COMMAND_NOT_SUPPORTED = -1, 00110 MPD_SERVER_COMMAND_ERROR = -2 00111 } MpdServerCommand; 00112 00113 00121 typedef enum { 00123 MPD_DATA_TYPE_NONE, 00125 MPD_DATA_TYPE_TAG, 00127 MPD_DATA_TYPE_DIRECTORY, 00129 MPD_DATA_TYPE_SONG, 00131 MPD_DATA_TYPE_PLAYLIST, 00133 MPD_DATA_TYPE_OUTPUT_DEV 00134 } MpdDataType; 00135 00140 typedef struct _MpdData { 00142 MpdDataType type; 00143 union { 00144 struct { 00146 int tag_type; 00148 char *tag; 00149 }; 00151 char *directory; 00153 mpd_PlaylistFile *playlist; 00155 mpd_Song *song; 00157 mpd_OutputEntity *output_dev; 00158 }; 00159 00160 void *userdata; 00161 void (*freefunc)(void *userdata); 00162 } MpdData; 00163 00164 00165 #include "libmpd-player.h" 00166 #include "libmpd-status.h" 00167 #include "libmpd-database.h" 00168 #include "libmpd-playlist.h" 00169 #include "libmpd-strfsong.h" 00170 #include "libmpd-sticker.h" 00171 00172 00173 00188 MpdObj *mpd_new_default(); 00189 00190 00191 00202 MpdObj *mpd_new(char *hostname, int port, char *password); 00203 00204 00205 00214 int mpd_set_hostname(MpdObj * mi, char *hostname); 00215 00223 const char * mpd_get_hostname(MpdObj *mi); 00224 00233 int mpd_set_password(MpdObj * mi,const char *password); 00234 00235 00245 int mpd_set_port(MpdObj * mi, int port); 00246 00247 00248 00249 00259 int mpd_set_connection_timeout(MpdObj * mi, float timeout); 00260 00261 00262 int mpd_connect_real(MpdObj *mi,mpd_Connection *connection); 00271 int mpd_connect(MpdObj * mi); 00272 00273 00280 int mpd_disconnect(MpdObj * mi); 00281 00282 00283 00290 int mpd_check_connected(MpdObj * mi); 00291 00292 00293 00300 int mpd_check_error(MpdObj * mi); 00301 00302 00303 00309 void mpd_free(MpdObj * mi); 00310 00311 00312 00322 int mpd_send_password(MpdObj * mi); 00323 00324 00325 00326 /* 00327 * signals 00328 */ 00329 00349 typedef enum { 00351 MPD_CST_PLAYLIST = 0x0001, 00353 MPD_CST_SONGPOS = 0x0002, 00355 MPD_CST_SONGID = 0x0004, 00357 MPD_CST_DATABASE = 0x0008, 00359 MPD_CST_UPDATING = 0x0010, 00361 MPD_CST_VOLUME = 0x0020, 00363 MPD_CST_TOTAL_TIME = 0x0040, 00365 MPD_CST_ELAPSED_TIME = 0x0080, 00367 MPD_CST_CROSSFADE = 0x0100, 00369 MPD_CST_RANDOM = 0x0200, 00371 MPD_CST_REPEAT = 0x0400, 00373 MPD_CST_AUDIO = 0x0800, 00375 MPD_CST_STATE = 0x1000, 00377 MPD_CST_PERMISSION = 0x2000, 00379 MPD_CST_BITRATE = 0x4000, 00381 MPD_CST_AUDIOFORMAT = 0x8000, 00383 MPD_CST_STORED_PLAYLIST = 0x20000, 00385 MPD_CST_SERVER_ERROR = 0x40000, 00387 MPD_CST_OUTPUT = 0x80000, 00389 MPD_CST_STICKER = 0x100000, 00391 MPD_CST_NEXTSONG = 0x200000, 00393 MPD_CST_SINGLE_MODE = 0x400000, 00395 MPD_CST_CONSUME_MODE = 0x800000, 00397 MPD_CST_REPLAYGAIN = 0x1000000 00398 } ChangedStatusType; 00399 00400 00401 /* callback typedef's */ 00409 typedef void (*StatusChangedCallback) (MpdObj * mi, ChangedStatusType what, void *userdata); 00410 00411 00412 00413 00423 typedef int (*ErrorCallback) (MpdObj * mi, int id, char *msg, void *userdata); 00424 00425 00426 00434 typedef void (*ConnectionChangedCallback) (MpdObj * mi, int connect, void *userdata); 00435 00436 00437 00438 /* new style signal connectors */ 00444 void mpd_signal_connect_status_changed(MpdObj * mi, StatusChangedCallback status_changed, 00445 void *userdata); 00446 00447 00448 00454 void mpd_signal_connect_error(MpdObj * mi, ErrorCallback error, void *userdata); 00455 00456 00457 00463 void mpd_signal_connect_connection_changed(MpdObj * mi, 00464 ConnectionChangedCallback connection_changed, 00465 void *userdata); 00466 00476 00483 int mpd_data_is_last(MpdData const *data); 00484 00485 00491 void mpd_data_free(MpdData * data); 00492 00493 00494 00510 MpdData *mpd_data_get_next(MpdData * data); 00511 00512 00513 00514 00522 MpdData *mpd_data_get_first(MpdData const *data); 00523 00524 00525 00533 MpdData *mpd_data_delete_item(MpdData * data); 00534 00535 00536 00544 00545 00553 MpdData *mpd_server_get_output_devices(MpdObj * mi); 00554 00555 00556 00566 int mpd_server_set_output_device(MpdObj * mi, int device_id, int state); 00567 00568 00569 00577 long unsigned mpd_server_get_database_update_time(MpdObj * mi); 00578 00579 00580 00591 int mpd_server_check_version(MpdObj * mi, int major, int minor, int micro); 00592 00599 char *mpd_server_get_version(MpdObj *mi); 00608 int mpd_server_check_command_allowed(MpdObj * mi, const char *command); 00609 00610 00611 00617 char ** mpd_server_get_url_handlers(MpdObj *mi); 00618 00625 char ** mpd_server_get_tag_types(MpdObj *mi); 00632 00640 int mpd_misc_get_tag_by_name(char *name); 00641 00651 int mpd_server_has_idle(MpdObj *mi); 00652 00661 int mpd_server_tag_supported(MpdObj *mi, int tag); 00662 00663 00664 typedef enum { 00665 MPD_SERVER_REPLAYGAIN_MODE_OFF = 0, 00666 MPD_SERVER_REPLAYGAIN_MODE_TRACK = 1, 00667 MPD_SERVER_REPLAYGAIN_MODE_ALBUM = 2 00668 }MpdServerReplaygainMode; 00669 00670 MpdServerReplaygainMode mpd_server_get_replaygain_mode(MpdObj *mi); 00671 00672 int mpd_server_set_replaygain_mode(MpdObj *mi, MpdServerReplaygainMode mode); 00673 00674 #endif 00675 00676 #ifdef __cplusplus 00677 } 00678 #endif