libnjb: /root/tmp/build-libnjb/libnjb-2.2.7/src/protocol.h Source File

libnjb 2.2.7

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
time_pack
void * time_pack(njb_time_t *time)
Definition: njbtime.c:100
libnjb.h
njb_init_state
int njb_init_state(njb_t *njb)
Definition: protocol.c:43
njb_state_t
Definition: protocol.h:28
njb_state_t::fwMinor
u_int8_t fwMinor
Definition: protocol.h:43
njb_datafile_struct
Definition: libnjb.h:275
njb_eax_struct::next
njb_eax_t * next
Definition: libnjb.h:394
from_64bit_to_njb1_bytes
void from_64bit_to_njb1_bytes(u_int64_t val, unsigned char *dp)
Definition: byteorder.c:52
EO_TOOBIG
#define EO_TOOBIG
Definition: njb_error.h:22
njb_struct::protocol_state
void * protocol_state
Definition: libnjb.h:192
njb_struct
Definition: libnjb.h:182
from_16bit_to_njb1_bytes
void from_16bit_to_njb1_bytes(u_int16_t val, unsigned char *dp)
Definition: byteorder.c:183
__sub_depth
int __sub_depth
Definition: base.c:62
usb_pipe_write
ssize_t usb_pipe_write(njb_t *njb, void *buf, size_t nbytes)
Definition: usb_io.c:67
EO_BADSTATUS
#define EO_BADSTATUS
Definition: njb_error.h:17
njbttaghdr_t
Definition: protocol.h:11
njb_songid_struct
Definition: libnjb.h:222
OWNER_STRING_LENGTH
#define OWNER_STRING_LENGTH
Definition: libnjb.h:160
njb_receive_file_block
u_int32_t njb_receive_file_block(njb_t *njb, u_int32_t offset, u_int32_t bsize, void *bp)
Definition: protocol.c:814
njb_eax_struct
Definition: libnjb.h:349
njb_read_eaxtypes
void njb_read_eaxtypes(njb_t *njb, u_int32_t size)
Definition: protocol.c:1199
njb_capture
int njb_capture(njb_t *njb, int which)
Definition: protocol.c:373
EO_USBBLK
#define EO_USBBLK
Definition: njb_error.h:12
EO_NOMEM
#define EO_NOMEM
Definition: njb_error.h:14
njb_datafile_struct::dfid
u_int32_t dfid
Definition: libnjb.h:323
njb_state_t::power
u_int8_t power
Definition: protocol.h:37
owner_string
unsigned char owner_string[OWNER_STRING_LENGTH+1]
Definition: libnjb.h:162
EO_USBCTL
#define EO_USBCTL
Definition: njb_error.h:11
njb_get_library_counter
int njb_get_library_counter(njb_t *njb, njblibctr_t *lcount)
Definition: protocol.c:241
time_unpack
njb_time_t * time_unpack(void *data)
Definition: njbtime.c:25
njb_state_t::fwMajor
u_int8_t fwMajor
Definition: protocol.h:42
njb_ping
int njb_ping(njb_t *njb)
Definition: protocol.c:285
get_lsw
u_int16_t get_lsw(u_int32_t word)
Definition: byteorder.c:225
njb_get_track_tag_header
int njb_get_track_tag_header(njb_t *njb, njbttaghdr_t *tagh, int cmd)
Definition: protocol.c:407
usb_setup
int usb_setup(njb_t *njb, int type, int request, int value, int index, int length, void *data)
Definition: usb_io.c:190
njb1_bytes_to_32bit
u_int32_t njb1_bytes_to_32bit(unsigned char *dp)
Definition: byteorder.c:72
njb1_bytes_to_64bit
u_int64_t njb1_bytes_to_64bit(unsigned char *dp)
Definition: byteorder.c:27
data_dump
void data_dump(FILE *f, void *buf, size_t n)
Definition: ioutil.c:35
njblibctr_t
Definition: protocol.h:6
EO_RDSHORT
#define EO_RDSHORT
Definition: njb_error.h:13
njb_time_struct
Definition: libnjb.h:403
njb_songid_struct::trid
u_int32_t trid
Definition: libnjb.h:223
from_32bit_to_njb1_bytes
void from_32bit_to_njb1_bytes(u_int32_t val, unsigned char *dp)
Definition: byteorder.c:112
njb_state_t::productName
char productName[33]
Definition: protocol.h:41
njb_playlist_struct
Definition: libnjb.h:247
njb_get_disk_usage
int njb_get_disk_usage(njb_t *njb, u_int64_t *total, u_int64_t *free_bytes)
Definition: protocol.c:599
datafile_unpack
njb_datafile_t * datafile_unpack(unsigned char *data, size_t nbytes)
Definition: datafile.c:164
songid_unpack
njb_songid_t * songid_unpack(void *data, size_t nbytes)
Definition: songid.c:68
njb_get_playlist_header
int njb_get_playlist_header(njb_t *njb, njbplhdr_t *plh, int cmd)
Definition: protocol.c:500
njbplhdr_t
Definition: protocol.h:16
njb_get_nexteax
njb_eax_t * njb_get_nexteax(njb_t *njb)
Definition: protocol.c:1267
njb_state_t::sdmiid
u_int8_t sdmiid[16]
Definition: protocol.h:39
EO_WRSHORT
#define EO_WRSHORT
Definition: njb_error.h:20
njbdfhdr_t
Definition: protocol.h:21
usb_pipe_read
ssize_t usb_pipe_read(njb_t *njb, void *buf, size_t nbytes)
Definition: usb_io.c:118
njb_verify_last_command
int njb_verify_last_command(njb_t *njb)
Definition: protocol.c:342
njb1_bytes_to_16bit
u_int16_t njb1_bytes_to_16bit(unsigned char *dp)
Definition: byteorder.c:146
get_msw
u_int16_t get_msw(u_int32_t word)
Definition: byteorder.c:212
NJB_STATUS
#define NJB_STATUS(a, b)
Definition: protocol.c:84
eax_unpack
int eax_unpack(void *data, size_t nbytes, njb_state_t *state)
Definition: eax.c:66
njb_get_datafile_header
int njb_get_datafile_header(njb_t *njb, njbdfhdr_t *dfh, int cmd)
Definition: protocol.c:709
njb_set_library_counter
int njb_set_library_counter(njb_t *njb, u_int64_t count)
Definition: protocol.c:207
playlist_unpack
njb_playlist_t * playlist_unpack(void *data, size_t nbytes)
Definition: playlist.c:56