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
00018 
00019 #define LIBNJB_COMPILED_FOR_LIBUSB 1
00020 
00021 #include <sys/types.h>
00022 #ifdef __WIN32__
00023 /* Windows specific code, types that do not exist in Windows
00024  * sys/types.h
00025  */
00026 typedef char int8_t;
00027 typedef unsigned char u_int8_t;
00028 typedef __int16 int16_t;
00029 typedef unsigned __int16 u_int16_t;
00030 typedef __int32 int32_t;
00031 typedef unsigned __int32 u_int32_t;
00032 typedef unsigned __int64 u_int64_t;
00033 #endif
00034 #ifdef __sun
00035 /* Solaris specific code, types that do not exist in Solaris'
00036  * sys/types.h
00037  */
00038 #define u_int8_t uint8_t
00039 #define u_int16_t uint16_t
00040 #define u_int32_t uint32_t
00041 #define u_int64_t uint64_t
00042 #endif
00043 
00044 
00045 #include <stdio.h>
00046 #include <usb.h>
00047 
00049 #define NJB_MAX_DEVICES 0xFF
00050 
00061 #define NJB_DEVICE_NJB1         0x00 
00062 #define NJB_DEVICE_NJB2         0x01 
00063 #define NJB_DEVICE_NJB3         0x02 
00064 #define NJB_DEVICE_NJBZEN       0x03 
00065 #define NJB_DEVICE_NJBZEN2      0x04 
00066 #define NJB_DEVICE_NJBZENNX     0x05 
00067 #define NJB_DEVICE_NJBZENXTRA   0x06 
00068 #define NJB_DEVICE_DELLDJ       0x07 
00069 #define NJB_DEVICE_NJBZENTOUCH  0x08 
00070 #define NJB_DEVICE_NJBZENMICRO  0x09 
00071 #define NJB_DEVICE_DELLDJ2      0x0a 
00072 #define NJB_DEVICE_POCKETDJ     0x0b 
00079 #define NJB_TYPE_STRING         0x00 
00080 #define NJB_TYPE_UINT16         0x02 
00081 #define NJB_TYPE_UINT32         0x03 
00088 #define NJB_CODEC_MP3   "MP3" 
00089 #define NJB_CODEC_WMA   "WMA" 
00090 #define NJB_CODEC_WAV   "WAV" 
00091 #define NJB_CODEC_AA    "AA"  
00098 #define FR_SIZE         "FILE SIZE" 
00099 #define FR_LENGTH       "LENGTH"    
00100 #define FR_CODEC        "CODEC"     
00101 #define FR_TITLE        "TITLE"     
00102 #define FR_ALBUM        "ALBUM"     
00103 #define FR_GENRE        "GENRE"     
00104 #define FR_ARTIST       "ARTIST"    
00105 #define FR_TRACK        "TRACK NUM" 
00106 #define FR_FNAME        "FNAME"     
00107 #define FR_YEAR         "YEAR"      
00108 #define FR_PROTECTED    "PlayOnly"  
00109 /* These two are used by Notmad on NJB1, not Creative */
00110 #define FR_BITRATE      "BITRATE"   
00111 #define FR_COMMENT      "COMMENT"   
00112 /* This one is used on series 3 devices only */
00113 #define FR_FOLDER       "FOLDER"    
00121 #define DD_USBCTL       1 
00122 #define DD_USBBLKLIM    2 
00123 #define DD_USBBLK       4 
00124 #define DD_SUBTRACE     8 
00132 #define NJB_UC_8859     0 
00133 #define NJB_UC_UTF8     1 
00136 #define OWNER_STRING_LENGTH     128 
00138 typedef unsigned char owner_string[OWNER_STRING_LENGTH + 1];
00139 
00144 typedef struct njb_struct njb_t; 
00145 typedef struct njb_songid_frame_struct njb_songid_frame_t; 
00146 typedef struct njb_songid_struct njb_songid_t; 
00147 typedef struct njb_playlist_track_struct njb_playlist_track_t; 
00148 typedef struct njb_playlist_struct njb_playlist_t; 
00149 typedef struct njb_datafile_struct njb_datafile_t; 
00150 typedef struct njb_eax_struct njb_eax_t; 
00151 typedef struct njb_time_struct njb_time_t; 
00152 typedef struct njb_keyval_struct njb_keyval_t; 
00158 struct njb_struct {
00159         struct usb_device *device; 
00160         usb_dev_handle *dev; 
00161         u_int8_t usb_config; 
00162         u_int8_t usb_interface; 
00163         u_int8_t usb_bulk_in_ep; 
00164         u_int8_t usb_bulk_out_ep; 
00165         int device_type; 
00166         int updated; 
00167         u_int32_t xfersize; 
00168         void *protocol_state; 
00169         void *error_stack; 
00170 };
00171 
00172 /* Song/track tag definitions */
00173 
00178 struct njb_songid_frame_struct {
00179         char *label; 
00180         u_int8_t type; 
00184         union {
00185                 char *strval; 
00186                 u_int8_t u_int8_val; 
00187                 u_int16_t u_int16_val; 
00188                 u_int32_t u_int32_val; 
00189                 u_int64_t u_int64_val; 
00190         } data;
00191         njb_songid_frame_t *next; 
00192 };
00193 
00198 struct njb_songid_struct {
00199         u_int32_t trid; 
00200         u_int16_t nframes; 
00201         njb_songid_frame_t *first; 
00202         njb_songid_frame_t *last; 
00203         njb_songid_frame_t *cur; 
00204         njb_songid_t *next; 
00205 };
00206 
00207 /* Playlist definitions */
00208 
00213 struct njb_playlist_track_struct {
00214         u_int32_t trackid; 
00215         struct njb_playlist_track_struct *prev; 
00216         struct njb_playlist_track_struct *next; 
00217 };
00218 
00223 struct njb_playlist_struct {
00224         char *name; 
00225         int _state; 
00226 #define NJB_PL_NEW              0 
00227 #define NJB_PL_UNCHANGED        1 
00228 #define NJB_PL_CHNAME           2 
00229 #define NJB_PL_CHTRACKS         3 
00230         u_int32_t ntracks; 
00231         u_int32_t plid; 
00232         njb_playlist_track_t *first; 
00233         njb_playlist_track_t *last; 
00234         njb_playlist_track_t *cur; 
00235         njb_playlist_t *nextpl; 
00237 };
00238 
00245 #define NJB_FILEFLAGS_REGULAR_FILE   0x80000000U
00246 
00251 struct njb_datafile_struct {
00252         char *filename;
00257         char *folder;
00264         u_int32_t timestamp;
00266         u_int32_t flags;
00299         u_int32_t dfid;
00301         u_int64_t filesize;
00307         njb_datafile_t *nextdf;
00309 };
00310 
00311 
00315 typedef enum {
00316        NJB_EAX_NO_CONTROL,
00317        NJB_EAX_SLIDER_CONTROL,
00318        NJB_EAX_FIXED_OPTION_CONTROL
00319 } njb_eax_control_t;
00320 
00321 
00325 struct njb_eax_struct {
00326         u_int16_t number; 
00327         char *name; 
00328         u_int8_t exclusive;
00336         u_int8_t group;
00342         njb_eax_control_t type;
00350         int16_t   current_value;
00355         int16_t   min_value;
00360         int16_t   max_value;
00364         char **option_names;
00370         njb_eax_t *next;
00374 };
00375 
00379 struct njb_time_struct {
00380         int16_t year; 
00381         int16_t month; 
00382         int16_t day; 
00383         int16_t weekday; 
00384         int16_t hours; 
00385         int16_t minutes; 
00386         int16_t seconds; 
00387 };
00388 
00393 struct njb_keyval_struct {
00394         char key[5]; 
00395         u_int32_t value1; 
00396         u_int32_t value2; 
00397         unsigned char deviceid[16]; 
00398         njb_keyval_t *next; 
00399 };
00400 
00401 #ifdef __cplusplus
00402 extern "C" {
00403 #endif
00404 
00405 /* NJB commands */
00406 
00408 typedef int NJB_Xfer_Callback(u_int64_t sent, u_int64_t total,
00409                 const char* buf, unsigned len, void *data);
00410 
00415 void NJB_Set_Debug (int debug_flags);
00416 void NJB_Set_Unicode (int unicode_flag);
00417 int NJB_Error_Pending(njb_t *njb);
00418 void NJB_Error_Reset_Geterror(njb_t *njb);
00419 const char *NJB_Error_Geterror(njb_t *njb);
00420 void NJB_Error_Dump(njb_t *njb, FILE *fp);
00426 int NJB_Discover(njb_t *njbs, int limit, int *n);
00427 int NJB_Open(njb_t *njb);
00428 void NJB_Close(njb_t *njb);
00429 int NJB_Capture (njb_t *njb);
00430 int NJB_Release (njb_t *njb);
00431 void NJB_Ping(njb_t *njb);
00432 int NJB_Get_Disk_Usage (njb_t *njb, u_int64_t *btotal, u_int64_t *bfree);
00433 char *NJB_Get_Owner_String (njb_t *njb);
00434 int NJB_Set_Owner_String (njb_t *njb, const char *name);
00435 int NJB_Get_Bitmap_Dimensions(njb_t *njb, int *x, int *y, int *bytes);
00436 int NJB_Set_Bitmap(njb_t *njb, const unsigned char *bitmap);
00437 njb_keyval_t *NJB_Get_Keys(njb_t *njb);
00438 u_int64_t NJB_Get_NJB1_Libcounter(njb_t *njb);
00439 int NJB_Send_Firmware (njb_t *njb, const char *path, NJB_Xfer_Callback *callback, void *data);
00440 int NJB_Get_Battery_Level (njb_t *njb);
00441 int NJB_Get_Battery_Charging (njb_t *njb);
00442 int NJB_Get_Auxpower (njb_t *njb);
00443 int NJB_Get_SDMI_ID(njb_t *njb, u_int8_t *sdmiid);
00444 const char *NJB_Get_Device_Name(njb_t *njb, int type);
00445 int NJB_Get_Firmware_Revision(njb_t *njb, u_int8_t *major, u_int8_t *minor, u_int8_t *release);
00446 int NJB_Get_Hardware_Revision(njb_t *njb, u_int8_t *major, u_int8_t *minor, u_int8_t *release);
00452 njb_songid_t *NJB_Songid_New(void);
00453 void NJB_Songid_Destroy(njb_songid_t *song);
00454 void NJB_Songid_Addframe(njb_songid_t *song, njb_songid_frame_t *frame);
00455 void NJB_Songid_Reset_Getframe(njb_songid_t *song);
00456 njb_songid_frame_t *NJB_Songid_Getframe(njb_songid_t *song);
00457 njb_songid_frame_t *NJB_Songid_Findframe(njb_songid_t *song, const char *label);
00458 njb_songid_frame_t *NJB_Songid_Frame_New_String(const char *label, const char *value);
00459 njb_songid_frame_t *NJB_Songid_Frame_New_Uint16(const char *label, u_int16_t value);
00460 njb_songid_frame_t *NJB_Songid_Frame_New_Uint32(const char *label, u_int32_t value);
00461 /* Good helper functions for creating frames - USE THESE IF YOU CAN */
00462 njb_songid_frame_t *NJB_Songid_Frame_New_Codec(const char *value);
00463 /* #define NJB_Songid_Frame_New_Codec(a) NJB_Songid_Frame_New_String(FR_CODEC, a) */
00464 #define NJB_Songid_Frame_New_Title(a) NJB_Songid_Frame_New_String(FR_TITLE, a)
00465 #define NJB_Songid_Frame_New_Album(a) NJB_Songid_Frame_New_String(FR_ALBUM, a)
00466 #define NJB_Songid_Frame_New_Genre(a) NJB_Songid_Frame_New_String(FR_GENRE, a)
00467 #define NJB_Songid_Frame_New_Artist(a) NJB_Songid_Frame_New_String(FR_ARTIST, a)
00468 #define NJB_Songid_Frame_New_Length(a) NJB_Songid_Frame_New_Uint16(FR_LENGTH, a)
00469 #define NJB_Songid_Frame_New_Filesize(a) NJB_Songid_Frame_New_Uint32(FR_SIZE, a)
00470 #define NJB_Songid_Frame_New_Tracknum(a) NJB_Songid_Frame_New_Uint16(FR_TRACK, a)
00471 #define NJB_Songid_Frame_New_Year(a) NJB_Songid_Frame_New_Uint16(FR_YEAR, a)
00472 #define NJB_Songid_Frame_New_Filename(a) NJB_Songid_Frame_New_String(FR_FNAME, a)
00473 #define NJB_Songid_Frame_New_Protected(a) NJB_Songid_Frame_New_Uint16(FR_PROTECTED, a)
00474 /* These two only apply to NJB1 */
00475 #define NJB_Songid_Frame_New_Bitrate(a) NJB_Songid_Frame_New_Uint32(FR_BITRATE, a)
00476 #define NJB_Songid_Frame_New_Comment(a) NJB_Songid_Frame_New_String(FR_COMMENT, a)
00477 /* This one only apply to series 3 devices */
00478 #define NJB_Songid_Frame_New_Folder(a) NJB_Songid_Frame_New_String(FR_FOLDER, a)
00479 void NJB_Songid_Frame_Destroy (njb_songid_frame_t *frame);
00480 void NJB_Get_Extended_Tags (njb_t *njb, int extended);
00481 void NJB_Reset_Get_Track_Tag (njb_t *njb);
00482 njb_songid_t *NJB_Get_Track_Tag (njb_t *njb);
00483 int NJB_Replace_Track_Tag(njb_t *njb, u_int32_t trackid, njb_songid_t *songid);
00484 int NJB_Get_Track (njb_t *njb, u_int32_t trackid, u_int32_t size,
00485         const char *path, NJB_Xfer_Callback *callback, void *data);
00486 int NJB_Get_Track_fd (njb_t *njb, u_int32_t trackid, u_int32_t size,
00487         int fd, NJB_Xfer_Callback *callback, void *data);
00488 int NJB_Send_Track (njb_t *njb, const char *path, njb_songid_t *songid,
00489         NJB_Xfer_Callback *callback, void *data, u_int32_t *trackid);
00490 int NJB_Delete_Track (njb_t *njb, u_int32_t trackid);
00496 void NJB_Reset_Get_Playlist (njb_t *njb);
00497 njb_playlist_t *NJB_Get_Playlist (njb_t *njb);
00498 int NJB_Delete_Playlist (njb_t *njb, u_int32_t plid);
00499 int NJB_Update_Playlist (njb_t *njb, njb_playlist_t *pl);
00500 njb_playlist_t *NJB_Playlist_New(void);
00501 void NJB_Playlist_Destroy(njb_playlist_t *pl);
00502 void NJB_Playlist_Addtrack(njb_playlist_t *pl, njb_playlist_track_t *track, 
00503         unsigned int pos);
00504 #define NJB_PL_END      0
00505 #define NJB_PL_START    1
00506 void NJB_Playlist_Reset_Gettrack(njb_playlist_t *pl);
00507 njb_playlist_track_t *NJB_Playlist_Gettrack(njb_playlist_t *pl);
00508 int NJB_Playlist_Set_Name(njb_playlist_t *pl, const char *name);
00509 void NJB_Playlist_Deltrack(njb_playlist_t *pl, unsigned int pos);
00510 void NJB_Playlist_Deltrack_TrackID(njb_playlist_t *pl, u_int32_t trackid);
00511 njb_playlist_track_t *NJB_Playlist_Track_New(u_int32_t trackid);
00512 void NJB_Playlist_Track_Destroy(njb_playlist_track_t *track);
00518 void NJB_Reset_Get_Datafile_Tag (njb_t *njb);
00519 njb_datafile_t *NJB_Get_Datafile_Tag (njb_t *njb);
00520 void NJB_Datafile_Destroy(njb_datafile_t *df);
00521 #define NJB_Get_File NJB_Get_Track
00522 int NJB_Send_File (njb_t *njb, const char *path, const char *name, const char *folder,
00523         NJB_Xfer_Callback *callback, void *data, u_int32_t *fileid);
00524 int NJB_Delete_Datafile (njb_t *njb, u_int32_t fileid);
00525 int NJB_Create_Folder (njb_t *njb, const char *name, u_int32_t *folderid);
00531 void NJB_Reset_Get_EAX_Type (njb_t *njb);
00532 njb_eax_t *NJB_Get_EAX_Type (njb_t *njb);
00533 void NJB_Destroy_EAX_Type (njb_eax_t *eax);
00534 void NJB_Adjust_EAX (njb_t *njb,
00535         u_int16_t eaxid,
00536         u_int16_t patchindex,
00537         int16_t scalevalue);
00543 njb_time_t *NJB_Get_Time(njb_t *njb);
00544 int NJB_Set_Time(njb_t *njb, njb_time_t *time);
00545 void NJB_Destroy_Time(njb_time_t *time);
00551 int NJB_Play_Track (njb_t *njb, u_int32_t trackid);
00552 int NJB_Queue_Track (njb_t *njb, u_int32_t trackid);
00553 int NJB_Stop_Play (njb_t *njb);
00554 int NJB_Pause_Play (njb_t *njb);
00555 int NJB_Resume_Play (njb_t *njb);
00556 int NJB_Seek_Track (njb_t *njb, u_int32_t position);
00557 int NJB_Elapsed_Time (njb_t *njb, u_int16_t *elapsed, int *change);
00560 #ifdef __cplusplus
00561 }
00562 #endif
00563 
00564 #endif

Generated on Mon Aug 1 17:28:24 2005 for libnjb by  doxygen 1.3.9.1