libmpd
0.20.0
Main Page
Modules
Data Structures
Files
Examples
File List
Globals
libmpd.h
Go to the documentation of this file.
1
/* libmpd (high level libmpdclient library)
2
* Copyright (C) 2004-2009 Qball Cow <qball@sarine.nl>
3
* Project homepage: http://gmpcwiki.sarine.nl/
4
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
*/
19
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
33
#ifndef __MPD_LIB__
34
#define __MPD_LIB__
35
#ifdef WIN32
36
#define __REGEX_IMPORT__ 1
37
#define __W32API_USE_DLLIMPORT__ 1
38
#endif
39
40
#include "
libmpdclient.h
"
41
42
#ifndef TRUE
43
44
#define TRUE 1
45
#endif
46
47
#ifndef FALSE
48
49
#define FALSE 0
50
#endif
51
#include "
libmpd-version.h
"
52
extern
char
*
libmpd_version
;
53
58
typedef
enum
{
60
MPD_OK
= 0,
62
MPD_ARGS_ERROR
= -5,
64
MPD_NOT_CONNECTED
= -10,
66
MPD_STATUS_FAILED
= -20,
68
MPD_LOCK_FAILED
= -30,
70
MPD_STATS_FAILED
= -40,
72
MPD_SERVER_ERROR
= -50,
74
MPD_SERVER_NOT_SUPPORTED
= -51,
75
77
MPD_DATABASE_PLAYLIST_EXIST
= -60,
79
MPD_PLAYLIST_EMPTY
= -70,
81
MPD_PLAYLIST_QUEUE_EMPTY
= -75,
83
MPD_PLAYER_NOT_PLAYING
= -80,
84
86
MPD_TAG_NOT_FOUND
= -90,
87
88
/* MPD_PLALIST_LOAD_FAILED */
89
MPD_PLAYLIST_LOAD_FAILED
= -100,
90
92
MPD_FATAL_ERROR
= -1000
93
}
MpdError
;
94
95
96
100
typedef
struct
_MpdObj
MpdObj
;
101
106
typedef
enum
{
107
MPD_SERVER_COMMAND_ALLOWED
=
TRUE
,
108
MPD_SERVER_COMMAND_NOT_ALLOWED
=
FALSE
,
109
MPD_SERVER_COMMAND_NOT_SUPPORTED
= -1,
110
MPD_SERVER_COMMAND_ERROR
= -2
111
}
MpdServerCommand
;
112
113
121
typedef
enum
{
123
MPD_DATA_TYPE_NONE
,
125
MPD_DATA_TYPE_TAG
,
127
MPD_DATA_TYPE_DIRECTORY
,
129
MPD_DATA_TYPE_SONG
,
131
MPD_DATA_TYPE_PLAYLIST
,
133
MPD_DATA_TYPE_OUTPUT_DEV
134
}
MpdDataType
;
135
140
typedef
struct
_MpdData
{
142
MpdDataType
type
;
143
union
{
144
struct
{
146
int
tag_type
;
148
char
*
tag
;
149
};
151
char
*
directory
;
153
mpd_PlaylistFile
*
playlist
;
155
mpd_Song
*
song
;
157
mpd_OutputEntity
*
output_dev
;
158
};
159
160
void
*
userdata
;
161
void (*
freefunc
)(
void
*
userdata
);
162
}
MpdData
;
163
164
165
#include "
libmpd-player.h
"
166
#include "
libmpd-status.h
"
167
#include "
libmpd-database.h
"
168
#include "
libmpd-playlist.h
"
169
#include "
libmpd-strfsong.h
"
170
#include "
libmpd-sticker.h
"
171
172
173
188
MpdObj
*
mpd_new_default
();
189
190
191
202
MpdObj
*
mpd_new
(
char
*hostname,
int
port,
char
*password);
203
204
205
214
int
mpd_set_hostname
(
MpdObj
* mi,
char
*hostname);
215
223
const
char
*
mpd_get_hostname
(
MpdObj
*mi);
224
233
int
mpd_set_password
(
MpdObj
* mi,
const
char
*password);
234
235
245
int
mpd_set_port
(
MpdObj
* mi,
int
port);
246
247
248
249
259
int
mpd_set_connection_timeout
(
MpdObj
* mi,
float
timeout);
260
261
262
int
mpd_connect_real
(
MpdObj
*mi,
mpd_Connection
*connection);
271
int
mpd_connect
(
MpdObj
* mi);
272
273
280
int
mpd_disconnect
(
MpdObj
* mi);
281
282
283
290
int
mpd_check_connected
(
MpdObj
* mi);
291
292
293
300
int
mpd_check_error
(
MpdObj
* mi);
301
302
303
309
void
mpd_free
(
MpdObj
* mi);
310
311
312
322
int
mpd_send_password
(
MpdObj
* mi);
323
324
325
326
/*
327
* signals
328
*/
329
349
typedef
enum
{
351
MPD_CST_PLAYLIST
= 0x0001,
353
MPD_CST_SONGPOS
= 0x0002,
355
MPD_CST_SONGID
= 0x0004,
357
MPD_CST_DATABASE
= 0x0008,
359
MPD_CST_UPDATING
= 0x0010,
361
MPD_CST_VOLUME
= 0x0020,
363
MPD_CST_TOTAL_TIME
= 0x0040,
365
MPD_CST_ELAPSED_TIME
= 0x0080,
367
MPD_CST_CROSSFADE
= 0x0100,
369
MPD_CST_RANDOM
= 0x0200,
371
MPD_CST_REPEAT
= 0x0400,
373
MPD_CST_AUDIO
= 0x0800,
375
MPD_CST_STATE
= 0x1000,
377
MPD_CST_PERMISSION
= 0x2000,
379
MPD_CST_BITRATE
= 0x4000,
381
MPD_CST_AUDIOFORMAT
= 0x8000,
383
MPD_CST_STORED_PLAYLIST
= 0x20000,
385
MPD_CST_SERVER_ERROR
= 0x40000,
387
MPD_CST_OUTPUT
= 0x80000,
389
MPD_CST_STICKER
= 0x100000,
391
MPD_CST_NEXTSONG
= 0x200000,
393
MPD_CST_SINGLE_MODE
= 0x400000,
395
MPD_CST_CONSUME_MODE
= 0x800000,
397
MPD_CST_REPLAYGAIN
= 0x1000000
398
}
ChangedStatusType
;
399
400
401
/* callback typedef's */
409
typedef
void (*
StatusChangedCallback
) (
MpdObj
* mi,
ChangedStatusType
what,
void
*userdata);
410
411
412
413
423
typedef
int (*
ErrorCallback
) (
MpdObj
* mi,
int
id,
char
*msg,
void
*userdata);
424
425
426
434
typedef
void (*
ConnectionChangedCallback
) (
MpdObj
* mi,
int
connect,
void
*userdata);
435
436
437
438
/* new style signal connectors */
444
void
mpd_signal_connect_status_changed
(
MpdObj
* mi,
StatusChangedCallback
status_changed,
445
void
*userdata);
446
447
448
454
void
mpd_signal_connect_error
(
MpdObj
* mi,
ErrorCallback
error,
void
*userdata);
455
456
457
463
void
mpd_signal_connect_connection_changed
(
MpdObj
* mi,
464
ConnectionChangedCallback
connection_changed,
465
void
*userdata);
466
476
483
int
mpd_data_is_last
(
MpdData
const
*data);
484
485
491
void
mpd_data_free
(
MpdData
* data);
492
493
494
510
MpdData
*
mpd_data_get_next
(
MpdData
* data);
511
512
513
514
522
MpdData
*
mpd_data_get_first
(
MpdData
const
*data);
523
524
525
533
MpdData
*
mpd_data_delete_item
(
MpdData
* data);
534
535
536
544
545
553
MpdData
*
mpd_server_get_output_devices
(
MpdObj
* mi);
554
555
556
566
int
mpd_server_set_output_device
(
MpdObj
* mi,
int
device_id,
int
state);
567
568
569
577
long
unsigned
mpd_server_get_database_update_time
(
MpdObj
* mi);
578
579
580
591
int
mpd_server_check_version
(
MpdObj
* mi,
int
major,
int
minor,
int
micro);
592
599
char
*
mpd_server_get_version
(
MpdObj
*mi);
608
int
mpd_server_check_command_allowed
(
MpdObj
* mi,
const
char
*command);
609
610
611
617
char
**
mpd_server_get_url_handlers
(
MpdObj
*mi);
618
625
char
**
mpd_server_get_tag_types
(
MpdObj
*mi);
632
640
int
mpd_misc_get_tag_by_name
(
char
*name);
641
651
int
mpd_server_has_idle
(
MpdObj
*mi);
652
661
int
mpd_server_tag_supported
(
MpdObj
*mi,
int
tag);
662
663
664
typedef
enum
{
665
MPD_SERVER_REPLAYGAIN_MODE_OFF
= 0,
666
MPD_SERVER_REPLAYGAIN_MODE_TRACK
= 1,
667
MPD_SERVER_REPLAYGAIN_MODE_ALBUM
= 2
668
}
MpdServerReplaygainMode
;
669
670
MpdServerReplaygainMode
mpd_server_get_replaygain_mode
(
MpdObj
*mi);
671
672
int
mpd_server_set_replaygain_mode
(
MpdObj
*mi,
MpdServerReplaygainMode
mode);
673
674
#endif
675
676
#ifdef __cplusplus
677
}
678
#endif
Copyright 2006
Qball Cow