Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Examples

libnjb.h

Go to the documentation of this file.
00001 
00013 #ifndef __LIBNJB__H
00014 #define __LIBNJB__H
00015 
00017 #define LIBNJB_VERSION 2.2.5
00018 
00019 #define LIBNJB_COMPILED_FOR_LIBUSB 1
00020 
00021 /* This handles MSVC pecularities */
00022 #ifdef _MSC_VER
00023 #include <windows.h>
00024 #define __WIN32__
00025 #define snprintf _snprintf
00026 #define ssize_t SSIZE_T
00027 #endif
00028 
00029 #include <sys/types.h>
00030 #ifdef __WIN32__
00031 /* Windows specific code, types that do not exist in Windows
00032  * sys/types.h
00033  */
00034 typedef char int8_t;
00035 typedef unsigned char u_int8_t;
00036 typedef __int16 int16_t;
00037 typedef unsigned __int16 u_int16_t;
00038 typedef __int32 int32_t;
00039 typedef unsigned __int32 u_int32_t;
00040 typedef unsigned __int64 u_int64_t;
00041 #endif
00042 #ifdef __sun
00043 
00044 /*
00045  * Solaris specific code, types that do not exist in Solaris'
00046  * sys/types.h. u_intN_t is the ISO C way, whereas Solaris'
00047  * way is POSIXly correct.
00048  */
00049 #define u_int8_t uint8_t
00050 #define u_int16_t uint16_t
00051 #define u_int32_t uint32_t
00052 #define u_int64_t uint64_t
00053 #endif
00054 
00055 
00056 #include <stdio.h>
00057 #include <usb.h>
00058 
00060 #define NJB_MAX_DEVICES 0xFF
00061 
00072 #define NJB_DEVICE_NJB1         0x00 
00073 #define NJB_DEVICE_NJB2         0x01 
00074 #define NJB_DEVICE_NJB3         0x02 
00075 #define NJB_DEVICE_NJBZEN       0x03 
00076 #define NJB_DEVICE_NJBZEN2      0x04 
00077 #define NJB_DEVICE_NJBZENNX     0x05 
00078 #define NJB_DEVICE_NJBZENXTRA   0x06 
00079 #define NJB_DEVICE_DELLDJ       0x07 
00080 #define NJB_DEVICE_NJBZENTOUCH  0x08 
00081 #define NJB_DEVICE_NJBZENMICRO  0x09 
00082 #define NJB_DEVICE_DELLDJ2      0x0a 
00083 #define NJB_DEVICE_POCKETDJ     0x0b 
00084 #define NJB_DEVICE_ZENSLEEK     0x0c 
00085 #define NJB_DEVICE_CREATIVEZEN  0x0d 
00092 #define NJB_TYPE_STRING         0x00 
00093 #define NJB_TYPE_UINT16         0x02 
00094 #define NJB_TYPE_UINT32         0x03 
00101 #define NJB_CODEC_MP3   "MP3" 
00102 #define NJB_CODEC_WMA   "WMA" 
00103 #define NJB_CODEC_WAV   "WAV" 
00104 #define NJB_CODEC_AA    "AA"  
00111 #define FR_SIZE         "FILE SIZE" 
00112 #define FR_LENGTH       "LENGTH"    
00113 #define FR_CODEC        "CODEC"     
00114 #define FR_TITLE        "TITLE"     
00115 #define FR_ALBUM        "ALBUM"     
00116 #define FR_GENRE        "GENRE"     
00117 #define FR_ARTIST       "ARTIST"    
00118 #define FR_TRACK        "TRACK NUM" 
00119 #define FR_FNAME        "FNAME"     
00120 #define FR_YEAR         "YEAR"      
00121 #define FR_PROTECTED    "PlayOnly"  
00122 /* These two are used by Notmad on NJB1, not Creative */
00123 #define FR_BITRATE      "BITRATE"   
00124 #define FR_COMMENT      "COMMENT"   
00125 /* This one is used on series 3 devices only */
00126 #define FR_FOLDER       "FOLDER"    
00134 #define DD_USBCTL       1 
00135 #define DD_USBBLKLIM    2 
00136 #define DD_USBBLK       4 
00137 #define DD_SUBTRACE     8 
00145 #define NJB_UC_8859     0 
00146 #define NJB_UC_UTF8     1 
00154 #define NJB_TURBO_OFF   0 
00155 #define NJB_TURBO_ON    1 
00159 #define OWNER_STRING_LENGTH     128
00160 
00161 typedef unsigned char owner_string[OWNER_STRING_LENGTH + 1];
00162 
00167 typedef struct njb_struct njb_t; 
00168 typedef struct njb_songid_frame_struct njb_songid_frame_t; 
00169 typedef struct njb_songid_struct njb_songid_t; 
00170 typedef struct njb_playlist_track_struct njb_playlist_track_t; 
00171 typedef struct njb_playlist_struct njb_playlist_t; 
00172 typedef struct njb_datafile_struct njb_datafile_t; 
00173 typedef struct njb_eax_struct njb_eax_t; 
00174 typedef struct njb_time_struct njb_time_t; 
00175 typedef struct njb_keyval_struct njb_keyval_t; 
00181 struct njb_struct {
00182         struct usb_device *device; 
00183         usb_dev_handle *dev; 
00184         u_int8_t usb_config; 
00185         u_int8_t usb_interface; 
00186         u_int8_t usb_bulk_in_ep; 
00187         u_int8_t usb_bulk_out_ep; 
00188         int device_type; 
00189         int updated; 
00190         u_int32_t xfersize; 
00191         void *protocol_state; 
00192         void *error_stack; 
00193 };
00194 
00195 /* Song/track tag definitions */
00196 
00201 struct njb_songid_frame_struct {
00202         char *label; 
00203         u_int8_t type; 
00207         union {
00208                 char *strval; 
00209                 u_int8_t u_int8_val; 
00210                 u_int16_t u_int16_val; 
00211                 u_int32_t u_int32_val; 
00212                 u_int64_t u_int64_val; 
00213         } data;
00214         njb_songid_frame_t *next; 
00215 };
00216 
00221 struct njb_songid_struct {
00222         u_int32_t trid; 
00223         u_int16_t nframes; 
00224         njb_songid_frame_t *first; 
00225         njb_songid_frame_t *last; 
00226         njb_songid_frame_t *cur; 
00227         njb_songid_t *next; 
00228 };
00229 
00230 /* Playlist definitions */
00231 
00236 struct njb_playlist_track_struct {
00237         u_int32_t trackid; 
00238         struct njb_playlist_track_struct *prev; 
00239         struct njb_playlist_track_struct *next; 
00240 };
00241 
00246 struct njb_playlist_struct {
00247         char *name; 
00248         int _state; 
00249 #define NJB_PL_NEW              0 
00250 #define NJB_PL_UNCHANGED        1 
00251 #define NJB_PL_CHNAME           2 
00252 #define NJB_PL_CHTRACKS         3 
00253         u_int32_t ntracks; 
00254         u_int32_t plid; 
00255         njb_playlist_track_t *first; 
00256         njb_playlist_track_t *last; 
00257         njb_playlist_track_t *cur; 
00258         njb_playlist_t *nextpl; 
00260 };
00261 
00268 #define NJB_FILEFLAGS_REGULAR_FILE   0x80000000U
00269 
00274 struct njb_datafile_struct {
00275         char *filename;
00280         char *folder;
00287         u_int32_t timestamp;
00289         u_int32_t flags;
00322         u_int32_t dfid;
00324         u_int64_t filesize;
00330         njb_datafile_t *nextdf;
00332 };
00333 
00334 
00338 typedef enum {
00339        NJB_EAX_NO_CONTROL,
00340        NJB_EAX_SLIDER_CONTROL,
00341        NJB_EAX_FIXED_OPTION_CONTROL
00342 } njb_eax_control_t;
00343 
00344 
00348 struct njb_eax_struct {
00349         u_int16_t number; 
00350         char *name; 
00351         u_int8_t exclusive;
00359         u_int8_t group;
00365         njb_eax_control_t type;
00373         int16_t   current_value;
00378         int16_t   min_value;
00383         int16_t   max_value;
00387         char **option_names;
00393         njb_eax_t *next;
00397 };
00398 
00402 struct njb_time_struct {
00403         int16_t year; 
00404         int16_t month; 
00405         int16_t day; 
00406         int16_t weekday; 
00407         int16_t hours; 
00408         int16_t minutes; 
00409         int16_t seconds; 
00410 };
00411 
00416 struct njb_keyval_struct {
00417         char key[5]; 
00418         u_int32_t value1; 
00419         u_int32_t value2; 
00420         unsigned char deviceid[16]; 
00421         njb_keyval_t *next; 
00422 };
00423 
00424 #ifdef __cplusplus
00425 extern "C" {
00426 #endif
00427 
00428 /* NJB commands */
00429 
00431 typedef int NJB_Xfer_Callback(u_int64_t sent, u_int64_t total,
00432                 const char* buf, unsigned len, void *data);
00433 
00438 void NJB_Set_Debug (int debug_flags);
00439 void NJB_Set_Unicode (int unicode_flag);
00440 int NJB_Error_Pending(njb_t *njb);
00441 void NJB_Error_Reset_Geterror(njb_t *njb);
00442 const char *NJB_Error_Geterror(njb_t *njb);
00443 void NJB_Error_Dump(njb_t *njb, FILE *fp);
00449 int NJB_Discover(njb_t *njbs, int limit, int *n);
00450 int NJB_Open(njb_t *njb);
00451 void NJB_Close(njb_t *njb);
00452 int NJB_Capture (njb_t *njb);
00453 int NJB_Release (njb_t *njb);
00454 void NJB_Ping(njb_t *njb);
00455 int NJB_Get_Disk_Usage (njb_t *njb, u_int64_t *btotal, u_int64_t *bfree);
00456 char *NJB_Get_Owner_String (njb_t *njb);
00457 int NJB_Set_Owner_String (njb_t *njb, const char *name);
00458 int NJB_Get_Bitmap_Dimensions(njb_t *njb, int *x, int *y, int *bytes);
00459 int NJB_Set_Bitmap(njb_t *njb, const unsigned char *bitmap);
00460 njb_keyval_t *NJB_Get_Keys(njb_t *njb);
00461 u_int64_t NJB_Get_NJB1_Libcounter(njb_t *njb);
00462 int NJB_Send_Firmware (njb_t *njb, const char *path, NJB_Xfer_Callback *callback, void *data);
00463 int NJB_Get_Battery_Level (njb_t *njb);
00464 int NJB_Get_Battery_Charging (njb_t *njb);
00465 int NJB_Get_Auxpower (njb_t *njb);
00466 int NJB_Get_SDMI_ID(njb_t *njb, u_int8_t *sdmiid);
00467 const char *NJB_Get_Device_Name(njb_t *njb, int type);
00468 int NJB_Get_Firmware_Revision(njb_t *njb, u_int8_t *major, u_int8_t *minor, u_int8_t *release);
00469 int NJB_Get_Hardware_Revision(njb_t *njb, u_int8_t *major, u_int8_t *minor, u_int8_t *release);
00470 int NJB_Set_Turbo_Mode(njb_t *njb, u_int8_t mode);
00476 njb_songid_t *NJB_Songid_New(void);
00477 void NJB_Songid_Destroy(njb_songid_t *song);
00478 void NJB_Songid_Addframe(njb_songid_t *song, njb_songid_frame_t *frame);
00479 void NJB_Songid_Reset_Getframe(njb_songid_t *song);
00480 njb_songid_frame_t *NJB_Songid_Getframe(njb_songid_t *song);
00481 njb_songid_frame_t *NJB_Songid_Findframe(njb_songid_t *song, const char *label);
00482 njb_songid_frame_t *NJB_Songid_Frame_New_String(const char *label, const char *value);
00483 njb_songid_frame_t *NJB_Songid_Frame_New_Uint16(const char *label, u_int16_t value);
00484 njb_songid_frame_t *NJB_Songid_Frame_New_Uint32(const char *label, u_int32_t value);
00485 /* Good helper functions for creating frames - USE THESE IF YOU CAN */
00486 njb_songid_frame_t *NJB_Songid_Frame_New_Codec(const char *value);
00487 /* #define NJB_Songid_Frame_New_Codec(a) NJB_Songid_Frame_New_String(FR_CODEC, a) */
00488 #define NJB_Songid_Frame_New_Title(a) NJB_Songid_Frame_New_String(FR_TITLE, a)
00489 #define NJB_Songid_Frame_New_Album(a) NJB_Songid_Frame_New_String(FR_ALBUM, a)
00490 #define NJB_Songid_Frame_New_Genre(a) NJB_Songid_Frame_New_String(FR_GENRE, a)
00491 #define NJB_Songid_Frame_New_Artist(a) NJB_Songid_Frame_New_String(FR_ARTIST, a)
00492 #define NJB_Songid_Frame_New_Length(a) NJB_Songid_Frame_New_Uint16(FR_LENGTH, a)
00493 #define NJB_Songid_Frame_New_Filesize(a) NJB_Songid_Frame_New_Uint32(FR_SIZE, a)
00494 #define NJB_Songid_Frame_New_Tracknum(a) NJB_Songid_Frame_New_Uint16(FR_TRACK, a)
00495 #define NJB_Songid_Frame_New_Year(a) NJB_Songid_Frame_New_Uint16(FR_YEAR, a)
00496 #define NJB_Songid_Frame_New_Filename(a) NJB_Songid_Frame_New_String(FR_FNAME, a)
00497 #define NJB_Songid_Frame_New_Protected(a) NJB_Songid_Frame_New_Uint16(FR_PROTECTED, a)
00498 /* These two only apply to NJB1 */
00499 #define NJB_Songid_Frame_New_Bitrate(a) NJB_Songid_Frame_New_Uint32(FR_BITRATE, a)
00500 #define NJB_Songid_Frame_New_Comment(a) NJB_Songid_Frame_New_String(FR_COMMENT, a)
00501 /* This one only apply to series 3 devices */
00502 #define NJB_Songid_Frame_New_Folder(a) NJB_Songid_Frame_New_String(FR_FOLDER, a)
00503 void NJB_Songid_Frame_Destroy (njb_songid_frame_t *frame);
00504 void NJB_Get_Extended_Tags (njb_t *njb, int extended);
00505 void NJB_Reset_Get_Track_Tag (njb_t *njb);
00506 njb_songid_t *NJB_Get_Track_Tag (njb_t *njb);
00507 int NJB_Replace_Track_Tag(njb_t *njb, u_int32_t trackid, njb_songid_t *songid);
00508 int NJB_Get_Track (njb_t *njb, u_int32_t trackid, u_int32_t size,
00509         const char *path, NJB_Xfer_Callback *callback, void *data);
00510 int NJB_Get_Track_fd (njb_t *njb, u_int32_t trackid, u_int32_t size,
00511         int fd, NJB_Xfer_Callback *callback, void *data);
00512 int NJB_Send_Track (njb_t *njb, const char *path, njb_songid_t *songid,
00513         NJB_Xfer_Callback *callback, void *data, u_int32_t *trackid);
00514 int NJB_Delete_Track (njb_t *njb, u_int32_t trackid);
00520 void NJB_Reset_Get_Playlist (njb_t *njb);
00521 njb_playlist_t *NJB_Get_Playlist (njb_t *njb);
00522 int NJB_Delete_Playlist (njb_t *njb, u_int32_t plid);
00523 int NJB_Update_Playlist (njb_t *njb, njb_playlist_t *pl);
00524 njb_playlist_t *NJB_Playlist_New(void);
00525 void NJB_Playlist_Destroy(njb_playlist_t *pl);
00526 void NJB_Playlist_Addtrack(njb_playlist_t *pl, njb_playlist_track_t *track, 
00527         unsigned int pos);
00528 #define NJB_PL_END      0
00529 #define NJB_PL_START    1
00530 void NJB_Playlist_Reset_Gettrack(njb_playlist_t *pl);
00531 njb_playlist_track_t *NJB_Playlist_Gettrack(njb_playlist_t *pl);
00532 int NJB_Playlist_Set_Name(njb_playlist_t *pl, const char *name);
00533 void NJB_Playlist_Deltrack(njb_playlist_t *pl, unsigned int pos);
00534 void NJB_Playlist_Deltrack_TrackID(njb_playlist_t *pl, u_int32_t trackid);
00535 njb_playlist_track_t *NJB_Playlist_Track_New(u_int32_t trackid);
00536 void NJB_Playlist_Track_Destroy(njb_playlist_track_t *track);
00542 void NJB_Reset_Get_Datafile_Tag (njb_t *njb);
00543 njb_datafile_t *NJB_Get_Datafile_Tag (njb_t *njb);
00544 void NJB_Datafile_Destroy(njb_datafile_t *df);
00545 #define NJB_Get_File NJB_Get_Track
00546 #define NJB_Get_File_fd NJB_Get_Track_fd
00547 int NJB_Send_File (njb_t *njb, const char *path, const char *name, const char *folder,
00548         NJB_Xfer_Callback *callback, void *data, u_int32_t *fileid);
00549 int NJB_Delete_Datafile (njb_t *njb, u_int32_t fileid);
00550 int NJB_Create_Folder (njb_t *njb, const char *name, u_int32_t *folderid);
00556 void NJB_Reset_Get_EAX_Type (njb_t *njb);
00557 njb_eax_t *NJB_Get_EAX_Type (njb_t *njb);
00558 void NJB_Destroy_EAX_Type (njb_eax_t *eax);
00559 void NJB_Adjust_EAX (njb_t *njb,
00560         u_int16_t eaxid,
00561         u_int16_t patchindex,
00562         int16_t scalevalue);
00568 njb_time_t *NJB_Get_Time(njb_t *njb);
00569 int NJB_Set_Time(njb_t *njb, njb_time_t *time);
00570 void NJB_Destroy_Time(njb_time_t *time);
00576 int NJB_Play_Track (njb_t *njb, u_int32_t trackid);
00577 int NJB_Queue_Track (njb_t *njb, u_int32_t trackid);
00578 int NJB_Stop_Play (njb_t *njb);
00579 int NJB_Pause_Play (njb_t *njb);
00580 int NJB_Resume_Play (njb_t *njb);
00581 int NJB_Seek_Track (njb_t *njb, u_int32_t position);
00582 int NJB_Elapsed_Time (njb_t *njb, u_int16_t *elapsed, int *change);
00585 #ifdef __cplusplus
00586 }
00587 #endif
00588 
00589 #endif

Generated on Thu Oct 20 20:35:58 2005 for libnjb by  doxygen 1.4.4