libnjb: /usr/obj/ports/libnjb-2.2.7/libnjb-2.2.7/src/protocol.h Source File

libnjb 2.2.7

- Main Page
- Modules
- Data Structures
- Files
- Examples

- File List
- Globals

protocol.h
1 #ifndef __NJB__PROTO__H
2 #define __NJB__PROTO__H
3
4 #include "libnjb.h"
5
6 typedef struct {
7 unsigned char id[16];
8 u_int64_t count;
9 } njblibctr_t;
10
11 typedef struct {
12 u_int32_t trackid;
13 u_int32_t size;
14 } njbttaghdr_t;
15
16 typedef struct {
17 u_int32_t plid;
18 u_int32_t size;
19 } njbplhdr_t;
20
21 typedef struct {
22 u_int32_t dfid;
23 u_int32_t size;
24 } njbdfhdr_t;
25
26
27 /* Structure to hold protocol states */
28 typedef struct {
29 int session_updated;
30 u_int64_t libcount;
31 njb_eax_t *first_eax;
32 njb_eax_t *next_eax;
33 int reset_get_track_tag;
34 int reset_get_playlist;
35 int reset_get_datafile_tag;
37 u_int8_t power;
39 u_int8_t sdmiid[16];
41 char productName[33];
42 u_int8_t fwMajor;
43 u_int8_t fwMinor;
44 } njb_state_t;
45
46 /*
47 * These defines are only applicable to the NJB1.
48 */
49 #define NJB_POWER_BATTERY 0x00
50 #define NJB_POWER_AC_CHARGED 0x01
52 #define NJB_POWER_AC_CHARGING 0x03
55 #define NJB_XFER_BLOCK_SIZE 0x0000FE00
56 #define NJB_XFER_BLOCK_HEADER_SIZE 68
57
58 #define NJB_RELEASE 0x00
59 #define NJB_CAPTURE 0x01
60
61 #define NJB_CMD_PING 0x01
62 #define NJB_CMD_GET_DISK_USAGE 0x04
63 #define NJB_CMD_GET_FIRST_TRACK_TAG_HEADER 0x06
64 #define NJB_CMD_GET_NEXT_TRACK_TAG_HEADER 0x07
65 #define NJB_CMD_GET_TRACK_TAG 0x09
66 #define NJB_CMD_SEND_TRACK_TAG 0x0a
67 #define NJB_CMD_DELETE_TRACK 0x0b
68 #define NJB_CMD_REPLACE_TRACK_TAG 0x0c
69 #define NJB_CMD_REQUEST_TRACK 0x0d
70 #define NJB_CMD_TRANSFER_COMPLETE 0x0e
71 #define NJB_CMD_SEND_FILE_BLOCK 0x0f
72 #define NJB_CMD_RECEIVE_FILE_BLOCK 0x10
73 #define NJB_CMD_GET_FIRST_PLAYLIST_HEADER 0x11
74 #define NJB_CMD_GET_NEXT_PLAYLIST_HEADER 0x12
75 #define NJB_CMD_GET_PLAYLIST 0x14
76 #define NJB_CMD_CREATE_PLAYLIST 0x15
77 #define NJB_CMD_DELETE_PLAYLIST 0x16
78 #define NJB_CMD_ADD_TRACK_TO_PLAYLIST 0x17
79 #define NJB_CMD_QUEUE_TRACK 0x1b
80 #define NJB_CMD_PLAY_TRACK 0x1d
81 #define NJB_CMD_STOP_PLAY 0x1e
82 #define NJB_CMD_ELAPSED_TIME 0x22
83 #define NJB_CMD_ADJUST_SOUND 0x23
84 #define NJB_CMD_GET_TIME 0x29
85 #define NJB_CMD_SET_TIME 0x2a
86 #define NJB_CMD_CAPTURE_NJB 0x2b
87 #define NJB_CMD_RELEASE_NJB 0x2c
88 #define NJB_CMD_GET_EAX_SIZE 0x3a
89 #define NJB_CMD_GET_EAX 0x24
90 #define NJB_CMD_RENAME_PLAYLIST 0x40
91 #define NJB_CMD_SET_OWNER_STRING 0x41
92 #define NJB_CMD_GET_OWNER_STRING 0x42
93 #define NJB_CMD_GET_LIBRARY_COUNTER 0x43
94 #define NJB_CMD_SET_LIBRARY_COUNTER 0x44
95 #define NJB_CMD_ADD_MULTIPLE_TRACKS_TO_PLAYLIST 0x46
96 #define NJB_CMD_SEND_DATAFILE_TAG 0x48
97 #define NJB_CMD_DELETE_DATAFILE 0x49
98 #define NJB_CMD_GET_FIRST_DATAFILE_HEADER 0x4a
99 #define NJB_CMD_GET_NEXT_DATAFILE_HEADER 0x4b
100 #define NJB_CMD_GET_DATAFILE_TAG 0x4d
101 #define NJB_CMD_VERIFY_LAST_CMD 0xf0
102 #define NJB_CMD_CAPTURE_NJB3 0xfd
103 #define NJB_CMD_RELEASE_NJB3 0xfe
104 #define NJB_CMD_UNKNOWN_NJB3 0xff
105
106 #define NJB_VAL_GET_EAX 0x00
107 #define NJB_VAL_GET_EAX_UNKNOWN 0x01
108
109 #define NJB_SOUND_SET_VOLUME 0x01
110 #define NJB_SOUND_SET_BASS 0x02
111 #define NJB_SOUND_SET_TREBLE 0x03
112 #define NJB_SOUND_SET_MUTING 0x04
113 #define NJB_SOUND_SET_MIDRANGE 0x05
114 #define NJB_SOUND_SET_MIDFREQ 0x06
115 #define NJB_SOUND_SET_EAX 0x07
116 #define NJB_SOUND_SET_EAXAMT 0x08
117 #define NJB_SOUND_SET_HEADPHONE 0x09
118 #define NJB_SOUND_SET_REAR 0x0A
119 #define NJB_SOUND_SET_EQSTATUS 0x0D
120
121 #define NJB_MSG_OKAY 0x00
122 #define NJB_ERR_FAILED 0x01
123 #define NJB_ERR_DEVICE_BUSY 0x02
124 #define NJB_ERR_STORAGE_FULL 0x03
125 #define NJB_ERR_HD_GENERAL_ERROR 0x04
126 #define NJB_ERR_SETTIME_REJECTED 0x05
127
128 #define NJB_ERR_TRACK_NOT_FOUND 0x10
129 #define NJB_ERR_TRACK_EXISTS 0x11
130 #define NJB_ERR_TITLE_MISSING 0x12
131 #define NJB_ERR_CODEC_MISSING 0x13
132 #define NJB_ERR_SIZE_MISSING 0x14
133 #define NJB_ERR_IO_OPERATION_ABORTED 0x15
134 #define NJB_ERR_READ_WRITE_ERROR 0x16
135 #define NJB_ERR_NOT_OPENED 0x17
136 #define NJB_ERR_UPLOAD_DENIED 0x18
137
138 #define NJB_ERR_PLAYLIST_NOT_FOUND 0x20
139 #define NJB_ERR_PLAYLIST_EXISTS 0x21
140 #define NJB_ERR_PLAYLIST_ITEM_NOT_FOUND 0x22
141 #define NJB_ERR_PLAYLIST_ITEM_EXISTS 0x23
142
143 #define NJB_MSG_QUEUED_AUDIO_STARTED 0x30
144 #define NJB_MSG_PLAYER_FINISHED 0x31
145
146 #define NJB_ERR_QUEUE_ALREADY_EMPTY 0x40
147 #define NJB_ERR_VOLUME_CONTROL_UNAVAILABLE 0x42
148
149 #define NJB_ERR_DATA_NOT_FOUND 0x60
150 #define NJB_ERR_DATA_NOT_OPENED 0x67
151
152 #define NJB_ERR_PLAYER_NOT_CONNECTED 0x80
153 #define NJB_ERR_CANCELLED 0x81
154 #define NJB_ERR_PORT_NOT_AVAILABLE 0x82
155 #define NJB_ERR_OUT_OF_MEMORY 0x83
156 #define NJB_ERR_FILEOPEN_ERR 0x84
157 #define NJB_ERR_ITEM_NOT_FOUND 0x85
158 #define NJB_ERR_LOAD_COMPONENTS_FAILED 0x86
159 #define NJB_ERR_ID_INVALID 0x87
160 #define NJB_ERR_FILETYPE_ILLEGAL 0x88
161 #define NJB_ERR_LOADRES_FAIL 0x89
162 #define NJB_ERR_FORMAT_NOT_FOUND 0x8a
163 #define NJB_ERR_FILE_ALREADY_EXISTS 0x8b
164 #define NJB_ERR_LIB_CORRUPTED 0x8c
165 #define NJB_ERR_LIB_BUSY 0x8d
166 #define NJB_ERR_FILE_READ_WRITE_FAILED 0x8e
167 #define NJB_ERR_INVALID_FILEPATH 0x8f
168 #define NJB_ERR_DISKFULL_FOR_DOWNLOAD 0x90
169 #define NJB_ERR_FILE_PLAYONLY 0x91
170
171 #define NJB_ERR_UNDEFINED_ERR 0xff
172 #define NJB_ERR_NOT_IMPLEMENTED 0x100
173
174 /* NJB1 functions */
175
176 int njb_init_state (njb_t *njb);
177
178 int njb_get_library_counter (njb_t *njb, njblibctr_t *njbctr);
179 int njb_set_library_counter (njb_t *njb, u_int64_t count);
180 int njb_ping (njb_t *njb);
181 int njb_verify_last_command (njb_t *njb);
182 int njb_capture (njb_t *njb, int which);
183 int njb_reset_get_songlist (njb_t *njb);
184 int njb_get_disk_usage (njb_t *njb, u_int64_t *total, u_int64_t *free);
185 int njb_get_owner_string (njb_t *njb, owner_string name);
186 int njb_set_owner_string (njb_t *njb, owner_string name);
187 int njb_request_file (njb_t *njb, u_int32_t fileid);
188 int njb_transfer_complete (njb_t *njb);
189 int njb_send_track_tag (njb_t *njb, njbttaghdr_t *tagh, void *tag);
190 int njb_send_datafile_tag (njb_t *njb, njbdfhdr_t *dfh, void *tag);
191 int njb_replace_track_tag (njb_t *njb, njbttaghdr_t *tagh, void *tag);
192 int njb_add_track_to_playlist (njb_t *njb, u_int32_t plid, u_int32_t trid);
193 int njb_add_multiple_tracks_to_playlist (njb_t *njb, u_int32_t plid,
194 u_int32_t *trids, u_int16_t ntracks);
195 int njb_delete_track (njb_t *njb, u_int32_t trackid);
196 int njb_delete_datafile (njb_t *njb, u_int32_t fileid);
197
198 int njb_create_playlist (njb_t *njb, char *name, u_int32_t *plid);
199 int njb_delete_playlist (njb_t *njb, u_int32_t plid);
200 int njb_rename_playlist (njb_t *njb, u_int32_t plid, char *name);
201
202 int njb_get_eax_size (njb_t *njb, u_int32_t *size);
203 void njb_read_eaxtypes (njb_t *njb, u_int32_t size);
204 njb_eax_t *njb_get_nexteax(njb_t *njb);
205
206 njb_time_t *njb_get_time(njb_t *njb);
207 int njb_set_time(njb_t *njb, njb_time_t *time);
208
209 u_int32_t njb_send_file_block (njb_t *njb, void *data, u_int32_t blocksize);
210 u_int32_t njb_receive_file_block (njb_t *njb, u_int32_t offset, u_int32_t blocksize,
211 void *block);
212 int njb_get_track_tag_header (njb_t *njb, njbttaghdr_t *tagh, int cmd);
213 #define njb_get_first_track_tag_header(a,b) njb_get_track_tag_header(a,b,NJB_CMD_GET_FIRST_TRACK_TAG_HEADER)
214 #define njb_get_next_track_tag_header(a,b) njb_get_track_tag_header(a,b,NJB_CMD_GET_NEXT_TRACK_TAG_HEADER)
215 njb_songid_t *njb_get_track_tag (njb_t *njb, njbttaghdr_t *tagh);
216
217 int njb_get_playlist_header(njb_t *njb, njbplhdr_t *plh, int cmd);
218 #define njb_get_first_playlist_header(a,b) njb_get_playlist_header(a,b,NJB_CMD_GET_FIRST_PLAYLIST_HEADER)
219 #define njb_get_next_playlist_header(a,b) njb_get_playlist_header(a,b,NJB_CMD_GET_NEXT_PLAYLIST_HEADER)
220 njb_playlist_t *njb_get_playlist (njb_t *njb, njbplhdr_t *plh);
221
222 int njb_get_datafile_header (njb_t *njb, njbdfhdr_t *dfh, int cmd);
223 #define njb_get_first_datafile_header(a,b) njb_get_datafile_header(a,b,NJB_CMD_GET_FIRST_DATAFILE_HEADER);
224 #define njb_get_next_datafile_header(a,b) njb_get_datafile_header(a,b,NJB_CMD_GET_NEXT_DATAFILE_HEADER);
225 njb_datafile_t *njb_get_datafile_tag (njb_t *njb, njbdfhdr_t *dfh);
226
227 #define njb_play_track(a,b) njb_play_or_queue(a,b,NJB_CMD_PLAY_TRACK)
228 #define njb_queue_track(a,b) njb_play_or_queue(a,b,NJB_CMD_QUEUE_TRACK)
229 int njb_play_or_queue (njb_t *njb, u_int32_t trackid, int cmd);
230 int njb_stop_play (njb_t *njb);
231 int njb_elapsed_time (njb_t *njb, u_int16_t *elapsed, int *change);
232 int njb_adjust_sound(njb_t *njb, u_int8_t effect, int16_t value);
233
234 #endif
235