Main Page | Modules | Data Structures | 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.4
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 
00158 #define OWNER_STRING_LENGTH     128
00159 
00160 typedef unsigned char owner_string[OWNER_STRING_LENGTH + 1];
00161 
00166 typedef struct njb_struct njb_t; 
00167 typedef struct njb_songid_frame_struct njb_songid_frame_t; 
00168 typedef struct njb_songid_struct njb_songid_t; 
00169 typedef struct njb_playlist_track_struct njb_playlist_track_t; 
00170 typedef struct njb_playlist_struct njb_playlist_t; 
00171 typedef struct njb_datafile_struct njb_datafile_t; 
00172 typedef struct njb_eax_struct njb_eax_t; 
00173 typedef struct njb_time_struct njb_time_t; 
00174 typedef struct njb_keyval_struct njb_keyval_t; 
00180 struct njb_struct {
00181         struct usb_device *device; 
00182         usb_dev_handle *dev; 
00183         u_int8_t usb_config; 
00184         u_int8_t usb_interface; 
00185         u_int8_t usb_bulk_in_ep; 
00186         u_int8_t usb_bulk_out_ep; 
00187         int device_type; 
00188         int updated; 
00189         u_int32_t xfersize; 
00190         void *protocol_state; 
00191         void *error_stack; 
00192 };
00193 
00194 /* Song/track tag definitions */
00195 
00200 struct njb_songid_frame_struct {
00201         char *label; 
00202         u_int8_t type; 
00206         union {
00207                 char *strval; 
00208                 u_int8_t u_int8_val; 
00209                 u_int16_t u_int16_val; 
00210                 u_int32_t u_int32_val; 
00211                 u_int64_t u_int64_val; 
00212         } data;
00213         njb_songid_frame_t *next; 
00214 };
00215 
00220 struct njb_songid_struct {
00221         u_int32_t trid; 
00222         u_int16_t nframes; 
00223         njb_songid_frame_t *first; 
00224         njb_songid_frame_t *last; 
00225         njb_songid_frame_t *cur; 
00226         njb_songid_t *next; 
00227 };
00228 
00229 /* Playlist definitions */
00230 
00235 struct njb_playlist_track_struct {
00236         u_int32_t trackid; 
00237         struct njb_playlist_track_struct *prev; 
00238         struct njb_playlist_track_struct *next; 
00239 };
00240 
00245 struct njb_playlist_struct {
00246         char *name; 
00247         int _state; 
00248 #define NJB_PL_NEW              0 
00249 #define NJB_PL_UNCHANGED        1 
00250 #define NJB_PL_CHNAME           2 
00251 #define NJB_PL_CHTRACKS         3 
00252         u_int32_t ntracks; 
00253         u_int32_t plid; 
00254         njb_playlist_track_t *first; 
00255         njb_playlist_track_t *last; 
00256         njb_playlist_track_t *cur; 
00257         njb_playlist_t *nextpl; 
00259 };
00260 
00267 #define NJB_FILEFLAGS_REGULAR_FILE   0x80000000U
00268 
00273 struct njb_datafile_struct {
00274         char *filename;
00279         char *folder;
00286         u_int32_t timestamp;
00288         u_int32_t flags;
00321         u_int32_t dfid;
00323         u_int64_t filesize;
00329         njb_datafile_t *nextdf;
00331 };
00332 
00333 
00337 typedef enum {
00338        NJB_EAX_NO_CONTROL,
00339        NJB_EAX_SLIDER_CONTROL,
00340        NJB_EAX_FIXED_OPTION_CONTROL
00341 } njb_eax_control_t;
00342 
00343 
00347 struct njb_eax_struct {
00348         u_int16_t number; 
00349         char *name; 
00350         u_int8_t exclusive;
00358         u_int8_t group;
00364         njb_eax_control_t type;
00372         int16_t   current_value;
00377         int16_t   min_value;
00382         int16_t   max_value;
00386         char **option_names;
00392         njb_eax_t *next;
00396 };
00397 
00401 struct njb_time_struct {
00402         int16_t year; 
00403         int16_t month; 
00404         int16_t day; 
00405         int16_t weekday; 
00406         int16_t hours; 
00407         int16_t minutes; 
00408         int16_t seconds; 
00409 };
00410 
00415 struct njb_keyval_struct {
00416         char key[5]; 
00417         u_int32_t value1; 
00418         u_int32_t value2; 
00419         unsigned char deviceid[16]; 
00420         njb_keyval_t *next; 
00421 };
00422 
00423 #ifdef __cplusplus
00424 extern "C" {
00425 #endif
00426 
00427 /* NJB commands */
00428 
00430 typedef int NJB_Xfer_Callback(u_int64_t sent, u_int64_t total,
00431                 const char* buf, unsigned len, void *data);
00432 
00437 void NJB_Set_Debug (int debug_flags);
00438 void NJB_Set_Unicode (int unicode_flag);
00439 int NJB_Error_Pending(njb_t *njb);
00440 void NJB_Error_Reset_Geterror(njb_t *njb);
00441 const char *NJB_Error_Geterror(njb_t *njb);
00442 void NJB_Error_Dump(njb_t *njb, FILE *fp);
00448 int NJB_Discover(njb_t *njbs, int limit, int *n);
00449 int NJB_Open(njb_t *njb);
00450 void NJB_Close(njb_t *njb);
00451 int NJB_Capture (njb_t *njb);
00452 int NJB_Release (njb_t *njb);
00453 void NJB_Ping(njb_t *njb);
00454 int NJB_Get_Disk_Usage (njb_t *njb, u_int64_t *btotal, u_int64_t *bfree);
00455 char *NJB_Get_Owner_String (njb_t *njb);
00456 int NJB_Set_Owner_String (njb_t *njb, const char *name);
00457 int NJB_Get_Bitmap_Dimensions(njb_t *njb, int *x, int *y, int *bytes);
00458 int NJB_Set_Bitmap(njb_t *njb, const unsigned char *bitmap);
00459 njb_keyval_t *NJB_Get_Keys(njb_t *njb);
00460 u_int64_t NJB_Get_NJB1_Libcounter(njb_t *njb);
00461 int NJB_Send_Firmware (njb_t *njb, const char *path, NJB_Xfer_Callback *callback, void *data);
00462 int NJB_Get_Battery_Level (njb_t *njb);
00463 int NJB_Get_Battery_Charging (njb_t *njb);
00464 int NJB_Get_Auxpower (njb_t *njb);
00465 int NJB_Get_SDMI_ID(njb_t *njb, u_int8_t *sdmiid);
00466 const char *NJB_Get_Device_Name(njb_t *njb, int type);
00467 int NJB_Get_Firmware_Revision(njb_t *njb, u_int8_t *major, u_int8_t *minor, u_int8_t *release);
00468 int NJB_Get_Hardware_Revision(njb_t *njb, u_int8_t *major, u_int8_t *minor, u_int8_t *release);
00469 int NJB_Set_Turbo_Mode(njb_t *njb, u_int8_t mode);
00475 njb_songid_t *NJB_Songid_New(void);
00476 void NJB_Songid_Destroy(njb_songid_t *song);
00477 void NJB_Songid_Addframe(njb_songid_t *song, njb_songid_frame_t *frame);
00478 void NJB_Songid_Reset_Getframe(njb_songid_t *song);
00479 njb_songid_frame_t *NJB_Songid_Getframe(njb_songid_t *song);
00480 njb_songid_frame_t *NJB_Songid_Findframe(njb_songid_t *song, const char *label);
00481 njb_songid_frame_t *NJB_Songid_Frame_New_String(const char *label, const char *value);
00482 njb_songid_frame_t *NJB_Songid_Frame_New_Uint16(const char *label, u_int16_t value);
00483 njb_songid_frame_t *NJB_Songid_Frame_New_Uint32(const char *label, u_int32_t value);
00484 /* Good helper functions for creating frames - USE THESE IF YOU CAN */
00485 njb_songid_frame_t *NJB_Songid_Frame_New_Codec(const char *value);
00486 /* #define NJB_Songid_Frame_New_Codec(a) NJB_Songid_Frame_New_String(FR_CODEC, a) */
00487 #define NJB_Songid_Frame_New_Title(a) NJB_Songid_Frame_New_String(FR_TITLE, a)
00488 #define NJB_Songid_Frame_New_Album(a) NJB_Songid_Frame_New_String(FR_ALBUM, a)
00489 #define NJB_Songid_Frame_New_Genre(a) NJB_Songid_Frame_New_String(FR_GENRE, a)
00490 #define NJB_Songid_Frame_New_Artist(a) NJB_Songid_Frame_New_String(FR_ARTIST, a)
00491 #define NJB_Songid_Frame_New_Length(a) NJB_Songid_Frame_New_Uint16(FR_LENGTH, a)
00492 #define NJB_Songid_Frame_New_Filesize(a) NJB_Songid_Frame_New_Uint32(FR_SIZE, a)
00493 #define NJB_Songid_Frame_New_Tracknum(a) NJB_Songid_Frame_New_Uint16(FR_TRACK, a)
00494 #define NJB_Songid_Frame_New_Year(a) NJB_Songid_Frame_New_Uint16(FR_YEAR, a)
00495 #define NJB_Songid_Frame_New_Filename(a) NJB_Songid_Frame_New_String(FR_FNAME, a)
00496 #define NJB_Songid_Frame_New_Protected(a) NJB_Songid_Frame_New_Uint16(FR_PROTECTED, a)
00497 /* These two only apply to NJB1 */
00498 #define NJB_Songid_Frame_New_Bitrate(a) NJB_Songid_Frame_New_Uint32(FR_BITRATE, a)
00499 #define NJB_Songid_Frame_New_Comment(a) NJB_Songid_Frame_New_String(FR_COMMENT, a)
00500 /* This one only apply to series 3 devices */
00501 #define NJB_Songid_Frame_New_Folder(a) NJB_Songid_Frame_New_String(FR_FOLDER, a)
00502 void NJB_Songid_Frame_Destroy (njb_songid_frame_t *frame);
00503 void NJB_Get_Extended_Tags (njb_t *njb, int extended);
00504 void NJB_Reset_Get_Track_Tag (njb_t *njb);
00505 njb_songid_t *NJB_Get_Track_Tag (njb_t *njb);
00506 int NJB_Replace_Track_Tag(njb_t *njb, u_int32_t trackid, njb_songid_t *songid);
00507 int NJB_Get_Track (njb_t *njb, u_int32_t trackid, u_int32_t size,
00508         const char *path, NJB_Xfer_Callback *callback, void *data);
00509 int NJB_Get_Track_fd (njb_t *njb, u_int32_t trackid, u_int32_t size,
00510         int fd, NJB_Xfer_Callback *callback, void *data);
00511 int NJB_Send_Track (njb_t *njb, const char *path, njb_songid_t *songid,
00512         NJB_Xfer_Callback *callback, void *data, u_int32_t *trackid);
00513 int NJB_Delete_Track (njb_t *njb, u_int32_t trackid);
00519 void NJB_Reset_Get_Playlist (njb_t *njb);
00520 njb_playlist_t *NJB_Get_Playlist (njb_t *njb);
00521 int NJB_Delete_Playlist (njb_t *njb, u_int32_t plid);
00522 int NJB_Update_Playlist (njb_t *njb, njb_playlist_t *pl);
00523 njb_playlist_t *NJB_Playlist_New(void);
00524 void NJB_Playlist_Destroy(njb_playlist_t *pl);
00525 void NJB_Playlist_Addtrack(njb_playlist_t *pl, njb_playlist_track_t *track, 
00526         unsigned int pos);
00527 #define NJB_PL_END      0
00528 #define NJB_PL_START    1
00529 void NJB_Playlist_Reset_Gettrack(njb_playlist_t *pl);
00530 njb_playlist_track_t *NJB_Playlist_Gettrack(njb_playlist_t *pl);
00531 int NJB_Playlist_Set_Name(njb_playlist_t *pl, const char *name);
00532 void NJB_Playlist_Deltrack(njb_playlist_t *pl, unsigned int pos);
00533 void NJB_Playlist_Deltrack_TrackID(njb_playlist_t *pl, u_int32_t trackid);
00534 njb_playlist_track_t *NJB_Playlist_Track_New(u_int32_t trackid);
00535 void NJB_Playlist_Track_Destroy(njb_playlist_track_t *track);
00541 void NJB_Reset_Get_Datafile_Tag (njb_t *njb);
00542 njb_datafile_t *NJB_Get_Datafile_Tag (njb_t *njb);
00543 void NJB_Datafile_Destroy(njb_datafile_t *df);
00544 #define NJB_Get_File NJB_Get_Track
00545 #define NJB_Get_File_fd NJB_Get_Track_fd
00546 int NJB_Send_File (njb_t *njb, const char *path, const char *name, const char *folder,
00547         NJB_Xfer_Callback *callback, void *data, u_int32_t *fileid);
00548 int NJB_Delete_Datafile (njb_t *njb, u_int32_t fileid);
00549 int NJB_Create_Folder (njb_t *njb, const char *name, u_int32_t *folderid);
00555 void NJB_Reset_Get_EAX_Type (njb_t *njb);
00556 njb_eax_t *NJB_Get_EAX_Type (njb_t *njb);
00557 void NJB_Destroy_EAX_Type (njb_eax_t *eax);
00558 void NJB_Adjust_EAX (njb_t *njb,
00559         u_int16_t eaxid,
00560         u_int16_t patchindex,
00561         int16_t scalevalue);
00567 njb_time_t *NJB_Get_Time(njb_t *njb);
00568 int NJB_Set_Time(njb_t *njb, njb_time_t *time);
00569 void NJB_Destroy_Time(njb_time_t *time);
00575 int NJB_Play_Track (njb_t *njb, u_int32_t trackid);
00576 int NJB_Queue_Track (njb_t *njb, u_int32_t trackid);
00577 int NJB_Stop_Play (njb_t *njb);
00578 int NJB_Pause_Play (njb_t *njb);
00579 int NJB_Resume_Play (njb_t *njb);
00580 int NJB_Seek_Track (njb_t *njb, u_int32_t position);
00581 int NJB_Elapsed_Time (njb_t *njb, u_int16_t *elapsed, int *change);
00584 #ifdef __cplusplus
00585 }
00586 #endif
00587 
00588 #endif

Generated on Fri Oct 14 08:59:56 2005 for libnjb by  doxygen 1.3.9.1