libnjb.h   libnjb.h 
/**
* \file libnjb.h
*
* Interface to the Nomad Jukebox library libnjb, handles most models.
* Also handles the Dell Digital Jukebox.
* This file should be included by programs that want to use libnjb, e.g.:
*
* <code>
* #include <libnjb.h>
* </code>
*/
#ifndef __LIBNJB__H #ifndef __LIBNJB__H
#define __LIBNJB__H #define __LIBNJB__H
#define LIBNJB_VERSION 1.2 /** The version of this installation of libnjb */
#define LIBNJB_VERSION 2.0
/** A legacy definition - nowadays we always compile for libusb */
#define LIBNJB_COMPILED_FOR_LIBUSB 1 #define LIBNJB_COMPILED_FOR_LIBUSB 1
#include <sys/types.h> #include <sys/types.h>
#ifdef __WIN32__ #ifdef __WIN32__
/* Windows specific code, types that do not exist in Windows /* Windows specific code, types that do not exist in Windows
* sys/types.h * sys/types.h
*/ */
typedef char int8_t; typedef char int8_t;
typedef unsigned char u_int8_t; typedef unsigned char u_int8_t;
typedef short int16_t; typedef short int16_t;
typedef unsigned short u_int16_t; typedef unsigned short u_int16_t;
typedef int int32_t; typedef int int32_t;
typedef unsigned int u_int32_t; typedef unsigned int u_int32_t;
typedef unsigned __int64 u_int64_t; typedef unsigned __int64 u_int64_t;
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <usb.h> #include <usb.h>
/** The maximum number of devices that can be found by libnjb */
#define NJB_MAX_DEVICES 0xFF #define NJB_MAX_DEVICES 0xFF
/* Enumerators to identify different jukeboxes */ /**
#define NJB_DEVICE_NJB1 0x00 * @defgroup njbboxes Enumerators to identify different jukeboxes
#define NJB_DEVICE_NJB2 0x01 *
#define NJB_DEVICE_NJB3 0x02 * These are found in the <code>device_type</code> field of the
#define NJB_DEVICE_NJBZEN 0x03 * <code>njb_t</code> struct. It is used a lot inside libnjb for
#define NJB_DEVICE_NJBZEN2 0x04 * deciding how to handle a certain device.
#define NJB_DEVICE_NJBZENNX 0x05 *
#define NJB_DEVICE_NJBZENXTRA 0x06 * @see njb_t
#define NJB_DEVICE_DELLDJ 0x07 * @{
#define NJB_DEVICE_NJBZENTOUCH 0x08 */
#define NJB_DEVICE_NJB1 0x00 /**< Nomad Jukebox 1 */
#define NJB_DEVICE_NJB2 0x01 /**< Nomad Jukebox 2 */
#define NJB_DEVICE_NJB3 0x02 /**< Nomad Jukebox 3 */
#define NJB_DEVICE_NJBZEN 0x03 /**< Nomad Jukebox Zen (with FireWire)
*/
#define NJB_DEVICE_NJBZEN2 0x04 /**< Nomad Jukebox Zen USB 2.0 */
#define NJB_DEVICE_NJBZENNX 0x05 /**< Nomad Jukebox Zen NX */
#define NJB_DEVICE_NJBZENXTRA 0x06 /**< Nomad Jukebox Zen Xtra */
#define NJB_DEVICE_DELLDJ 0x07 /**< Dell Digital DJ "Dell DJ" */
#define NJB_DEVICE_NJBZENTOUCH 0x08 /**< Nomad Jukebox Zen Touch */
#define NJB_DEVICE_NJBZENMICRO 0x09 /**< Nomad Jukebox Zen Micro */
#define NJB_DEVICE_DELLDJ2 0x0a /**< Second Generation Dell DJ */
#define NJB_DEVICE_POCKETDJ 0x0b /**< Dell Pocket DJ */
/** @} */
#define NJB_POWER_BATTERY 0x00 /**
#define NJB_POWER_AC_CHARGED 0x01 * @defgroup power Power connection and status
#define NJB_POWER_AC_CHARGING 0x03 * @{
*/
#define NJB_POWER_BATTERY 0x00 /**< If the device is running on batte
ry (NJB1 only) */
#define NJB_POWER_AC_CHARGED 0x01 /**< If the device is running on DC
and the battery is fully charged *
/
#define NJB_POWER_AC_CHARGING 0x03 /**< If the device is running on DC
and the battery is being charged *
/
/** @} */
#define ID_DATA_ASCII 0 /**
#define ID_DATA_BIN 1 * @defgroup frametypes Frame types for different song ID frames
#define ID_DATA_UNI 2 * @{
*/
#define NJB_TYPE_STRING 0x00 /**< A string type song ID fram
e */
#define NJB_TYPE_UINT16 0x02 /**< An unsigned 16 bit integer
type song ID frame */
#define NJB_TYPE_UINT32 0x03 /**< An unsigned 32 bit integer
type song ID frame */
/** @} */
#define NJB_CODEC_MP3 "MP3" /**
#define NJB_CODEC_WMA "WMA" * @defgroup codecs Codec types
#define NJB_CODEC_WAV "WAV" * @{
*/
#define NJB_CODEC_MP3 "MP3" /**< The MPEG audio level 3 codec */
#define NJB_CODEC_WMA "WMA" /**< The Windows Media Audio codec */
#define NJB_CODEC_WAV "WAV" /**< The RIFF waveform codec */
/** @} */
#define FR_SIZE "FILE SIZE" /**
#define FR_LENGTH "LENGTH" * @defgroup frames Song ID frame types
#define FR_CODEC "CODEC" * @{
#define FR_TITLE "TITLE" */
#define FR_ALBUM "ALBUM" #define FR_SIZE "FILE SIZE" /**< Filesize metadata frame */
#define FR_GENRE "GENRE" #define FR_LENGTH "LENGTH" /**< Length metadata frame (in seconds)
#define FR_ARTIST "ARTIST" */
#define FR_TRACK "TRACK NUM" #define FR_CODEC "CODEC" /**< Codec metadata frame */
#define FR_FNAME "FNAME" #define FR_TITLE "TITLE" /**< Title metadata frame */
#define FR_YEAR "YEAR" #define FR_ALBUM "ALBUM" /**< Album metadata frame */
#define FR_PROTECTED "PlayOnly" #define FR_GENRE "GENRE" /**< Genre metadata frame */
#define FR_ARTIST "ARTIST" /**< Artist metadata frame */
#define FR_TRACK "TRACK NUM" /**< Track number metadata frame */
#define FR_FNAME "FNAME" /**< File name metadata frame */
#define FR_YEAR "YEAR" /**< Year metadata frame */
#define FR_PROTECTED "PlayOnly" /**< Copy protected track metadata frame
*/
/* These two are used by Notmad on NJB1, not Creative */ /* These two are used by Notmad on NJB1, not Creative */
#define FR_BITRATE "BITRATE" #define FR_BITRATE "BITRATE" /**< Bitrate metadata frame */
#define FR_COMMENT "COMMENT" #define FR_COMMENT "COMMENT" /**< Comment metadata frame */
/* This one is used on series 3 devices only */
/* Sound adjustment parameters - deprecated: use new EAX API */ #define FR_FOLDER "FOLDER" /**< Folder name metadata frame */
/* These are to be moved into protocol.h and only used internally */ /** @} */
#define NJB_SOUND_SET_VOLUME 0x01
#define NJB_SOUND_SET_BASS 0x02
#define NJB_SOUND_SET_TREBLE 0x03
#define NJB_SOUND_SET_MUTING 0x04
#define NJB_SOUND_SET_MIDRANGE 0x05
#define NJB_SOUND_SET_MIDFREQ 0x06
#define NJB_SOUND_SET_EAX 0x07
#define NJB_SOUND_SET_EAXAMT 0x08
#define NJB_SOUND_SET_HEADPHONE 0x09
#define NJB_SOUND_SET_REAR 0x0A
#define NJB_SOUND_SET_EQSTATUS 0x0D
/* Error codes */
#define EO_USBCTL 1 /* I/O failure on USB control pipe */
#define EO_USBBLK 2 /* I/O failure on USB data pipe */
#define EO_RDSHORT 3 /* short read on USB data pipe */
#define EO_NOMEM 4 /* out of memory */
#define EO_BADDATA 5 /* invalid data */
#define EO_EOM 6 /* end of data */
#define EO_BADSTATUS 7 /* bad status from Jukebox */
#define EO_BADNJBID 8 /* Jukebox ID has changed */
#define EO_BADCOUNT 9 /* library count mismatch */
#define EO_WRSHORT 10 /* short write on USB data pipe */
#define EO_NULLTMP 11 /* temporary transfer dir not defined */
#define EO_TOOBIG 12 /* block size too big */
#define EO_CANTMOVE 13 /* can't move file to destination */
#define EO_TIMEOUT 14 /* operation timed out */
#define EO_ABORTED 15 /* operation aborted */
#define EO_EOF 16 /* received EOF */
#define EO_DEVICE 17 /* can't open device for read/write */
#define EO_INIT 18 /* can't initialize device */
#define EO_TMPFILE 19 /* can't create temporary file */
#define EO_XFERDENIED 20 /* transfer request denied */
#define EO_WRFILE 21 /* error writing output file */
#define EO_XFERERROR 22 /* bad transfer completion status */
#define EO_SRCFILE 23 /* can't read source file */
#define EO_INVALID 24 /* invalid arguments */
#define EO_AGAIN 25 /* resource temporarily unavailable */
/* Debug flags */
#define DD_USBCTL 1
#define DD_USBBLKLIM 2
#define DD_USBBLK 4
#define DD_SUBTRACE 8
/* Unicode flags */
#define NJB_UC_8859 0
#define NJB_UC_UTF8 1
/* NJB structure definitions */
typedef struct { /**
unsigned char id[16]; /* Move all of this into njb_t eventually */ * @defgroup debugflags Debug flags
u_int8_t fwMajor; * @{
u_int8_t fwMinor; */
u_int8_t fwRel; #define DD_USBCTL 1 /**< Print USB control transfer debug messages */
u_int8_t hwMajor; #define DD_USBBLKLIM 2 /**< Print USB bulk transfer debug messages (limit
u_int8_t hwMinor; ed) */
u_int8_t hwRel; #define DD_USBBLK 4 /**< Print USB bulk transfer debug messages (compl
char productName[33]; ete) */
u_int8_t power; #define DD_SUBTRACE 8 /**< Print subroutine call tree names debug messag
} njbid_t; es */
/** @} */
typedef struct { /**
unsigned char id[16]; * @defgroup unicodeflags Unicode flags
u_int64_t count; * @see NJB_Set_Unicode()
} njblibctr_t; * @{
*/
#define NJB_UC_8859 0 /**< libnjb to use ISO 8859-1 / codepage 1252 */
#define NJB_UC_UTF8 1 /**< libnjb to use Unicode UTF-8 */
/** @} */
#define OWNER_STRING_LENGTH 128 #define OWNER_STRING_LENGTH 128 /**< The fixed length of the owner strin
g */
/** A type defined for owner strings */
typedef unsigned char owner_string[OWNER_STRING_LENGTH + 1]; typedef unsigned char owner_string[OWNER_STRING_LENGTH + 1];
typedef struct njb_t njb_t; /**
typedef struct songid_frame_t songid_frame_t; * @defgroup types libnjb global type definitions
typedef struct songid_t songid_t; * @{
typedef struct playlist_track_struct playlist_track_t; */
typedef struct playlist_struct playlist_t; typedef struct njb_struct njb_t; /**< @see njb_struct */
typedef struct datafile_struct datafile_t; typedef struct njbid_struct njbid_t; /**< See struct definition */
typedef struct eax_struct njb_eax_t; typedef struct njb_songid_frame_struct njb_songid_frame_t; /**< See struct
definition */
typedef struct njb_songid_struct njb_songid_t; /**< See struct definition *
/
typedef struct njb_playlist_track_struct njb_playlist_track_t; /**< See str
uct definition */
typedef struct njb_playlist_struct njb_playlist_t; /**< See struct definiti
on */
typedef struct njb_datafile_struct njb_datafile_t; /**< See struct definiti
on */
typedef struct njb_eax_struct njb_eax_t; /**< See struct definition */
typedef struct njb_time_struct njb_time_t; /**< See struct definition */
typedef struct njb_keyval_struct njb_keyval_t; /**< See struct definition *
/
/** @} */
struct njb_t { /**
struct usb_device *device; * Main NJB object struct
usb_dev_handle *dev; */
int bulkep; struct njb_struct {
int intrep; njbid_t *njbid; /**< The ID for this jukebox */
int device_type; /* what kind of jukebox it is */ struct usb_device *device; /**< The libusb device for this jukebox *
unsigned char id[16]; /
char idstring[33]; usb_dev_handle *dev; /**< The libusb device handle for this jukebox
int updated; */
u_int32_t xfersize; u_int8_t usb_config; /**< The libusb config for this jukebox */
void *protocol_state; /* dereferenced and maintained individually by u_int8_t usb_interface; /**< The libusb interface for this jukebox *
protocol implementations */ /
u_int8_t fwMajor; /* should eventually be moved here from njbid_t */ u_int8_t usb_bulk_in_ep; /**< The BULK IN endpoint for this jukebox
u_int8_t fwMinor; */
u_int8_t fwRel; u_int8_t usb_bulk_out_ep; /**< The BULK OUT endpoint for this jukebo
x */
int device_type; /**< what kind of jukebox this is */
int updated; /**< If the device has been updated with some metadata
*/
u_int32_t xfersize; /**< The transfer size for endpoints */
void *protocol_state; /**< dereferenced and maintained individually
by protocol implementations */
void *error_stack; /**< Error stack, used inside libnjb */
};
/**
* Jukebox identification struct
*/
struct njbid_struct {
unsigned char id[16]; /**< The SDMI device ID for this device, 16 by
tes */
u_int8_t fwMajor; /**< Firmware major revision */
u_int8_t fwMinor; /**< Firmware minor revision */
u_int8_t fwRel; /**< Firmware release */
u_int8_t hwMajor; /**< Hardware major revision */
u_int8_t hwMinor; /**< Hardware minor revision */
u_int8_t hwRel; /**< Hardware release */
char productName[33]; /**< A string with the product name */
u_int8_t power; /**< If the power cord is plugged in or not */
}; };
/* Song/track tag definitions */ /* Song/track tag definitions */
struct songid_frame_t { /**
u_int16_t type; * The song ID frame struct, one song ID has many
u_int16_t labelsz; * such frames, stored as a linked list.
u_int16_t datasz; */
void *label; struct njb_songid_frame_struct {
void *data; char *label; /**< terminated string with frame type */
songid_frame_t *next; u_int8_t type; /**< this tells us which subtype it is */
/**
* This is a union of possible frame types
*/
union {
char *strval; /**< A string value */
u_int8_t u_int8_val; /**< An 8 bit unsigned integer value */
u_int16_t u_int16_val; /**< A 16 bit unsigned integer value
*/
u_int32_t u_int32_val; /**< A 32 bit unsigned integer value
*/
u_int64_t u_int64_val; /**< A 64 bit unsigned integer value
*/
} data;
njb_songid_frame_t *next; /**< A pointer to the next frame following
this one in the song ID */
}; };
struct songid_t { /**
u_int32_t trid; * The song ID struct is used for holding metadata about a particular
u_int16_t nframes; * track.
songid_frame_t *first; */
songid_frame_t *last; struct njb_songid_struct {
songid_frame_t *cur; u_int32_t trid; /**< The track ID as used on the device */
songid_t *next; /* Used on NJB3 only */ u_int16_t nframes; /**< The number of frames in this song ID */
njb_songid_frame_t *first; /**< A pointer to the first frame */
njb_songid_frame_t *last; /**< A pointer to the last frame */
njb_songid_frame_t *cur; /**< A pointer to the current frame */
njb_songid_t *next; /**< Used internally on series 3 devices for spa
nning lists of song IDs only */
}; };
/* Playlist definitions */ /* Playlist definitions */
struct playlist_track_struct { /**
u_int32_t trackid; * This struct is used for representing a track that
struct playlist_track_struct *prev; * is part of a <code>njb_playlist_t</code> playlist
struct playlist_track_struct *next; */
struct njb_playlist_track_struct {
u_int32_t trackid; /**< The track ID as used on the device */
struct njb_playlist_track_struct *prev; /**< The previous track in t
he playlist */
struct njb_playlist_track_struct *next; /**< The next track in the p
laylist */
}; };
struct playlist_struct { /**
char *name; * This struct holds the actual playlist. A playlist usually
int _state; * contain a number of <code>njb_playlist_track_t</code> tracks.
#define NJB_PL_NEW 0 */
#define NJB_PL_UNCHANGED 1 struct njb_playlist_struct {
#define NJB_PL_CHNAME 2 char *name; /**< The name of this playlist */
#define NJB_PL_CHTRACKS 3 int _state; /**< The state of this playlist */
u_int32_t ntracks; #define NJB_PL_NEW 0 /**< This playlist is new */
u_int32_t plid; #define NJB_PL_UNCHANGED 1 /**< This playlist has not changed */
playlist_track_t *first; #define NJB_PL_CHNAME 2 /**< This playlist has changed name */
playlist_track_t *last; #define NJB_PL_CHTRACKS 3 /**< This playlist has a new track
playlist_track_t *cur; listing */
playlist_t *nextpl; /* Used on NJB3 only */ u_int32_t ntracks; /**< The number of tracks in this playlist */
u_int32_t plid; /**< The playlist ID for this playlist, as used on t
he device */
njb_playlist_track_t *first; /**< A pointer to the first track in th
is playlist */
njb_playlist_track_t *last; /**< A pointer to the last track in this
playlist */
njb_playlist_track_t *cur; /**< A pointer to the current track in th
is playlist */
njb_playlist_t *nextpl; /**< Used internally for spanning lists of
playlists on series 3 devices only */
}; };
/* Data file tag definitions */ /**
* This definition corresponds to the standard file permissions
* set for most files transferred from Windows machines to the
* device "file system" (file database). Can be used as a template
* to simplify things.
*/
#define NJB_FILEFLAGS_REGULAR_FILE 0x80000000U
struct datafile_struct { /**
* This is the struct storing the metadata of a regular file
* or folder.
*/
struct njb_datafile_struct {
char *filename; char *filename;
/**<
* The name of this file. The name "." means that this is
* an empty folder name marker.
*/
char *folder;
/**<
* This is the name of the folder the file belongs in.
* All folder names are given with full hierarchy and leading
* and trailing backslash as in: "\foo\bar\fnord\".
* If filename is "." this is the name of the empty folder.
*/
u_int32_t timestamp; u_int32_t timestamp;
/**< This is an ordinary UNIX styled timestamp for the file. */
u_int32_t flags;
/**<
* These are ordinary windows file flags:
* <pre>
* bit (from MSB) meaning
* -----------------------------
* 31 Normal file (0x80000000U)
* 29 This file should be archived (0x20000000U)
* 28 Directory (0x10000000U)
* 26 System file (0x04000000U)
* 25 Hidden file (0x02000000U)
* 24 Read only file (0x01000000U)
* 22 Encrypted file (0x00400000U)
* 21 Normal file? (0x00200000U)
* 19 Compressed file (0x00080000U)
* 17 Sparse file (0x00020000U)
* 16 Temporary file (0x00010000U)
* </pre>
*
* SAMBA maps the bits to Unix permissions thus:
*
* <pre>
* owner group world
* r w x r w x r w x
* ^ ^ ^ ^ ^
* | | | | |
* | | Archive System Hidden
* | |
* Read only
* </pre>
*
* The meaning of bits 30, 27, 23, 20 and 15-0 is unknown.
*/
u_int32_t dfid; u_int32_t dfid;
u_int32_t msdw; /**< The 32-bit unsigned file ID. */
u_int32_t lsdw; u_int64_t filesize;
datafile_t *nextdf; /**<
* The file size as a 64-bit unsigned integer. The files on
* series 3 devices only have 32-bit signed length (and can only be
* 2GB in size) but the NJB1 supports 64-bit length.
*/
njb_datafile_t *nextdf;
/**< This is only to be used internally by libnjb. */
}; };
/* EAX block definition - deprecated: use new EAX API */ /**
* This is the EAX Control Type
typedef struct { */
u_int8_t volume; typedef enum {
u_int8_t volumemin; NJB_EAX_NO_CONTROL,
u_int8_t volumemax; NJB_EAX_SLIDER_CONTROL,
int16_t muted; NJB_EAX_FIXED_OPTION_CONTROL
int16_t eq_status; } njb_eax_control_t;
int8_t bass;
int8_t bassmin;
int8_t bassmax;
int8_t midrange;
int8_t midrangemin;
int8_t midrangemax;
int8_t treble;
int8_t treblemin;
int8_t treblemax;
u_int8_t nfreq;
u_int8_t freqset;
int16_t *frequencies;
u_int8_t neffects;
u_int8_t acteffect;
char **effects;
u_int8_t *effamts;
u_int8_t nphone;
u_int8_t actphone;
char **phonemodes;
u_int8_t nrear;
u_int8_t actrear;
char **rears;
} eax_t;
/* EAX API type */ /**
struct eax_struct { * This is the EAX API type.
u_int16_t number; */
char *name; struct njb_eax_struct {
/* u_int16_t number; /**< The number of this effect */
char *name; /**< The name of this effect */
u_int8_t exclusive;
/**<
* 0x00 = not exclusive, 0x01 = exclusive
* The "exclusive" attribute signifies if this effect can be used * The "exclusive" attribute signifies if this effect can be used
* in parallell with other EAX effects, * in parallell with other EAX effects,
* GUI:s shall make sure all other effects are reset to default * GUI:s shall make sure all other effects are reset to default
* values when one effect is chosen. * values when one effect is chosen.
*/ */
u_int8_t exclusive; /* 0x00 = not exclusive, 0x01 = exclusive */ u_int8_t group;
/* /**<
* The visual group for this effect - * The visual group for this effect -
* effects appearing after each other are grouped if their * effects appearing after each other are grouped if their
* group numbers are identical * group numbers are identical
*/ */
u_int8_t group; njb_eax_control_t type;
/* If this effect has several different settings */ /**<
u_int8_t selectable; /* 0x00 = not selectable, 0x01 = selectable */ * NJB_EAX_NO_CONTROL,
u_int16_t current_selectionvalue; * NJB_EAX_SLIDER_CONTROL,
u_int16_t min_selectionvalue; * NJB_EAX_FIXED_OPTION_CONTROL
u_int16_t max_selectionvalue; *
char **selection_names; /* Array with names for these selections */ * this replaces selectable, scalable with a single variable
/* If this effect can be slided on a scale */ */
u_int8_t scaleable; /* 0x00 = not scalable, 0x01 = scalable */ int16_t current_value;
int16_t current_scalevalue; /**<
int16_t min_scalevalue; * The current value of this effect.
int16_t max_scalevalue; * Notice that this value may be negative!
njb_eax_t *next; /* Only to be used inside of libnjb */ */
int16_t min_value;
/**<
* The minumum value for this effect.
* Notice that this value may be negative!
*/
int16_t max_value;
/**<
* The maximum value for this effect.
*/
char **option_names;
/**<
* Array with names for the selections, if this is a fixed
* option control. It may not be dereferenced for slider
* controls.
*/
njb_eax_t *next;
/**<
* Only to be used inside of libnjb
*/
}; };
/* Time set/read struct */ /**
typedef struct { * Time set/read struct
int16_t year; */
int16_t month; struct njb_time_struct {
int16_t day; int16_t year; /**< Year (4 digits) */
int16_t weekday; int16_t month; /**< Month (0-11) */
int16_t hours; int16_t day; /**< Day (0-31) */
int16_t minutes; int16_t weekday; /**< Day of the week 0=sunday, 6=saturday */
int16_t seconds; int16_t hours; /**< Hours (24-hour notation) */
} njb_time_t; int16_t minutes; /**< Minutes */
int16_t seconds; /**< Seconds */
};
/* Struct to hold key/value pairs */ /**
typedef struct njb_keyval_t njb_keyval_t; * Struct to hold key/value pairs which are used
struct njb_keyval_t { * for some kind of DRM encryption scheme. Usage unknown.
char key[5]; */
u_int32_t value1; struct njb_keyval_struct {
u_int32_t value2; char key[5]; /**< The name of this key (AR00, PL00 etc.) */
unsigned char deviceid[16]; u_int32_t value1; /**< The first 32 bit unsigned integer of this key
njb_keyval_t *next; */
u_int32_t value2; /**< The second 32 bit unsigned integer of this ke
y */
unsigned char deviceid[16]; /**< The SDMI compliant device ID associ
ated with this key */
njb_keyval_t *next; /**< A pointer to the next key/value pair */
}; };
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* NJB commands */ /* NJB commands */
typedef int XferCallback(u_int64_t sent, u_int64_t total, /** The callback type */
typedef int NJB_Xfer_Callback(u_int64_t sent, u_int64_t total,
const char* buf, unsigned len, void *data); const char* buf, unsigned len, void *data);
/**
* @defgroup internals The libnjb configuration API
* @{
*/
void NJB_Set_Debug (int debug_flags);
void NJB_Set_Unicode (int unicode_flag);
int NJB_Error_Pending(njb_t *njb);
void NJB_Error_Reset_Geterror(njb_t *njb);
const char *NJB_Error_Geterror(njb_t *njb);
void NJB_Error_Dump(njb_t *njb, FILE *fp);
/**
* @}
* @defgroup basic The basic device management and information API
* @{
*/
int NJB_Discover(njb_t *njbs, int limit, int *n); int NJB_Discover(njb_t *njbs, int limit, int *n);
int NJB_Open(njb_t *njb); int NJB_Open(njb_t *njb);
void NJB_Close(njb_t *njb); void NJB_Close(njb_t *njb);
int NJB_Capture (njb_t *njb); int NJB_Capture (njb_t *njb);
int NJB_Release (njb_t *njb); int NJB_Release (njb_t *njb);
njbid_t *NJB_Ping(njb_t *njb); void NJB_Ping(njb_t *njb);
void NJB_Get_Extended_Tags (njb_t *njb, int extended);
void NJB_Reset_Get_Track_Tag (njb_t *njb);
songid_t *NJB_Get_Track_Tag (njb_t *njb);
void NJB_Reset_Get_Playlist (njb_t *njb);
playlist_t *NJB_Get_Playlist (njb_t *njb);
int NJB_Get_Disk_Usage (njb_t *njb, u_int64_t *btotal, u_int64_t *bfree); int NJB_Get_Disk_Usage (njb_t *njb, u_int64_t *btotal, u_int64_t *bfree);
char *NJB_Get_Owner_String (njb_t *njb); char *NJB_Get_Owner_String (njb_t *njb);
int NJB_Set_Owner_String (njb_t *njb, const char *name); int NJB_Set_Owner_String (njb_t *njb, const char *name);
int NJB_Get_Bitmap_Dimensions(njb_t *njb, int *x, int *y, int *bytes);
int NJB_Set_Bitmap(njb_t *njb, const unsigned char *bitmap);
njb_keyval_t *NJB_Get_Keys(njb_t *njb);
u_int64_t NJB_Get_NJB1_Libcounter(njb_t *njb);
int NJB_Send_Firmware (njb_t *njb, const char *path, NJB_Xfer_Callback *cal
lback, void *data);
/**
* @}
* @defgroup tagapi The track and tag (song ID metadata) manipulation API
* @{
*/
njb_songid_t *NJB_Songid_New(void);
void NJB_Songid_Destroy(njb_songid_t *song);
void NJB_Songid_Addframe(njb_songid_t *song, njb_songid_frame_t *frame);
void NJB_Songid_Reset_Getframe(njb_songid_t *song);
njb_songid_frame_t *NJB_Songid_Getframe(njb_songid_t *song);
njb_songid_frame_t *NJB_Songid_Findframe(njb_songid_t *song, const char *la
bel);
njb_songid_frame_t *NJB_Songid_Frame_New_String(const char *label, const ch
ar *value);
njb_songid_frame_t *NJB_Songid_Frame_New_Uint16(const char *label, u_int16_
t value);
njb_songid_frame_t *NJB_Songid_Frame_New_Uint32(const char *label, u_int32_
t value);
/* Good helper functions for creating frames - USE THESE IF YOU CAN */
njb_songid_frame_t *NJB_Songid_Frame_New_Codec(const char *value);
/* #define NJB_Songid_Frame_New_Codec(a) NJB_Songid_Frame_New_String(FR_COD
EC, a) */
#define NJB_Songid_Frame_New_Title(a) NJB_Songid_Frame_New_String(FR_TITLE,
a)
#define NJB_Songid_Frame_New_Album(a) NJB_Songid_Frame_New_String(FR_ALBUM,
a)
#define NJB_Songid_Frame_New_Genre(a) NJB_Songid_Frame_New_String(FR_GENRE,
a)
#define NJB_Songid_Frame_New_Artist(a) NJB_Songid_Frame_New_String(FR_ARTIS
T, a)
#define NJB_Songid_Frame_New_Length(a) NJB_Songid_Frame_New_Uint16(FR_LENGT
H, a)
#define NJB_Songid_Frame_New_Filesize(a) NJB_Songid_Frame_New_Uint32(FR_SIZ
E, a)
#define NJB_Songid_Frame_New_Tracknum(a) NJB_Songid_Frame_New_Uint16(FR_TRA
CK, a)
#define NJB_Songid_Frame_New_Year(a) NJB_Songid_Frame_New_Uint16(FR_YEAR, a
)
#define NJB_Songid_Frame_New_Filename(a) NJB_Songid_Frame_New_String(FR_FNA
ME, a)
#define NJB_Songid_Frame_New_Protected(a) NJB_Songid_Frame_New_Uint16(FR_PR
OTECTED, a)
/* These two only apply to NJB1 */
#define NJB_Songid_Frame_New_Bitrate(a) NJB_Songid_Frame_New_Uint32(FR_BITR
ATE, a)
#define NJB_Songid_Frame_New_Comment(a) NJB_Songid_Frame_New_String(FR_COMM
ENT, a)
/* This one only apply to series 3 devices */
#define NJB_Songid_Frame_New_Folder(a) NJB_Songid_Frame_New_String(FR_FOLDE
R, a)
void NJB_Songid_Frame_Destroy (njb_songid_frame_t *frame);
void NJB_Get_Extended_Tags (njb_t *njb, int extended);
void NJB_Reset_Get_Track_Tag (njb_t *njb);
njb_songid_t *NJB_Get_Track_Tag (njb_t *njb);
int NJB_Replace_Track_Tag(njb_t *njb, u_int32_t trackid, njb_songid_t *song
id);
int NJB_Get_Track (njb_t *njb, u_int32_t trackid, u_int32_t size,
const char *path, NJB_Xfer_Callback *callback, void *data);
int NJB_Get_Track_fd (njb_t *njb, u_int32_t trackid, u_int32_t size,
int fd, NJB_Xfer_Callback *callback, void *data);
int NJB_Send_Track (njb_t *njb, const char *path, njb_songid_t *songid,
NJB_Xfer_Callback *callback, void *data, u_int32_t *trackid);
int NJB_Delete_Track (njb_t *njb, u_int32_t trackid);
/**
* @}
* @defgroup playlistapi The playlist manipulation API
* @{
*/
void NJB_Reset_Get_Playlist (njb_t *njb);
njb_playlist_t *NJB_Get_Playlist (njb_t *njb);
int NJB_Delete_Playlist (njb_t *njb, u_int32_t plid);
int NJB_Update_Playlist (njb_t *njb, njb_playlist_t *pl);
njb_playlist_t *NJB_Playlist_New(void);
void NJB_Playlist_Destroy(njb_playlist_t *pl);
void NJB_Playlist_Addtrack(njb_playlist_t *pl, njb_playlist_track_t *track,
unsigned int pos);
#define NJB_PL_END 0
#define NJB_PL_START 1
void NJB_Playlist_Reset_Gettrack(njb_playlist_t *pl);
njb_playlist_track_t *NJB_Playlist_Gettrack(njb_playlist_t *pl);
int NJB_Playlist_Set_Name(njb_playlist_t *pl, const char *name);
void NJB_Playlist_Deltrack(njb_playlist_t *pl, unsigned int pos);
void NJB_Playlist_Deltrack_TrackID(njb_playlist_t *pl, u_int32_t trackid);
njb_playlist_track_t *NJB_Playlist_Track_New(u_int32_t trackid);
void NJB_Playlist_Track_Destroy(njb_playlist_track_t *track);
/**
* @}
* @defgroup datatagapi The datafile tag (metadata) retrieveal API
* @{
*/
void NJB_Reset_Get_Datafile_Tag (njb_t *njb); void NJB_Reset_Get_Datafile_Tag (njb_t *njb);
datafile_t *NJB_Get_Datafile_Tag (njb_t *njb); njb_datafile_t *NJB_Get_Datafile_Tag (njb_t *njb);
eax_t *NJB_Get_EAX (njb_t *njb); /* Deprecated, use new EAX API */ void NJB_Datafile_Destroy(njb_datafile_t *df);
int NJB_Refresh_EAX (njb_t *njb, eax_t *eax); /* Deprecated, use new EAX AP #define NJB_Get_File NJB_Get_Track
I */ int NJB_Send_File (njb_t *njb, const char *path, const char *name, const ch
ar *folder,
NJB_Xfer_Callback *callback, void *data, u_int32_t *fileid);
int NJB_Delete_Datafile (njb_t *njb, u_int32_t fileid);
int NJB_Create_Folder (njb_t *njb, const char *name, u_int32_t *folderid);
/**
* @}
* @defgroup eaxapi The EAX (and volume) manipulation API
* @{
*/
void NJB_Reset_Get_EAX_Type (njb_t *njb); void NJB_Reset_Get_EAX_Type (njb_t *njb);
njb_eax_t *NJB_Get_EAX_Type (njb_t *njb); njb_eax_t *NJB_Get_EAX_Type (njb_t *njb);
void NJB_Destroy_EAX_Type (njb_eax_t *eax); void NJB_Destroy_EAX_Type (njb_eax_t *eax);
void NJB_Adjust_EAX (njb_t *njb, void NJB_Adjust_EAX (njb_t *njb,
u_int16_t eaxid, u_int16_t eaxid,
u_int16_t patchindex, u_int16_t patchindex,
int16_t scalevalue); int16_t scalevalue);
/**
* @}
* @defgroup timeapi The time manipulation API
* @{
*/
njb_time_t *NJB_Get_Time(njb_t *njb); njb_time_t *NJB_Get_Time(njb_t *njb);
int NJB_Set_Time(njb_t *njb, njb_time_t *time); int NJB_Set_Time(njb_t *njb, njb_time_t *time);
void NJB_Destroy_Time(njb_time_t *time); void NJB_Destroy_Time(njb_time_t *time);
int NJB_Set_Bitmap(njb_t *njb, const char * pbm_file); /**
int NJB_Delete_Playlist (njb_t *njb, u_int32_t plid); * @}
int NJB_Update_Playlist (njb_t *njb, playlist_t *pl); * @defgroup playapi The track playback (listening) API
int NJB_Delete_Track (njb_t *njb, u_int32_t trackid); * @{
int NJB_Delete_Datafile (njb_t *njb, u_int32_t fileid); */
#define NJB_Get_File NJB_Get_Track
int NJB_Get_Track (njb_t *njb, u_int32_t trackid, u_int32_t size,
const char *path, XferCallback *callback, void *data);
int NJB_Send_Track (njb_t *njb, const char *path, const char *codec,
const char *title, const char *album, const char *genre,
const char *artist, u_int32_t length, u_int32_t tracknum,
const char *year, int protect,
XferCallback *callback, void *data, u_int32_t *trackid);
int NJB_Send_File (njb_t *njb, const char *path, const char *name,
XferCallback *callback, void *data, u_int32_t *fileid);
int NJB_Replace_Track_Tag(njb_t *njb, u_int32_t trackid, const char *codec,
const char *title, const char *album, const char *genre,
const char *artist, u_int32_t length, u_int32_t tracknum,
u_int32_t filesize, const char *fname, const char *year, int protect
);
int NJB_Play_Track (njb_t *njb, u_int32_t trackid); int NJB_Play_Track (njb_t *njb, u_int32_t trackid);
int NJB_Queue_Track (njb_t *njb, u_int32_t trackid); int NJB_Queue_Track (njb_t *njb, u_int32_t trackid);
int NJB_Stop_Play (njb_t *njb); int NJB_Stop_Play (njb_t *njb);
int NJB_Pause_Play (njb_t *njb); int NJB_Pause_Play (njb_t *njb);
int NJB_Resume_Play (njb_t *njb); int NJB_Resume_Play (njb_t *njb);
int NJB_Seek_Track (njb_t *njb, u_int32_t position); int NJB_Seek_Track (njb_t *njb, u_int32_t position);
int NJB_Elapsed_Time (njb_t *njb, u_int16_t *elapsed, int *change); int NJB_Elapsed_Time (njb_t *njb, u_int16_t *elapsed, int *change);
int NJB_Adjust_Sound(njb_t *njb, u_int8_t effect, u_int16_t value); /** @} */
void NJB_Set_Debug (int debug_flags);
void NJB_Set_Unicode (int unicode_flag);
njb_keyval_t *NJB_Get_Keys(njb_t *njb);
/* Error functions */
void njb_error_reset_geterror (void);
const char *njb_error_geterror (void);
const char *njb_error_string (int err);
void njb_error_dump (FILE *fp);
/* Song/track tag functions */
songid_t *songid_new (void);
songid_t *songid_unpack (void *data, size_t nbytes);
unsigned char *songid_pack (songid_t *song, u_int32_t *size);
unsigned char *songid_pack3 (songid_t *song, u_int32_t *size);
void songid_destroy (songid_t *song);
void songid_addframe (songid_t *song, songid_frame_t *frame);
void songid_dump (songid_t *song, FILE *fp);
void songid_reset_getframe (songid_t *song);
songid_frame_t *songid_getframe (songid_t *song);
songid_frame_t *songid_findframe (songid_t *song, const char *label);
songid_frame_t *songid_frame_new (u_int16_t labelsz, const void *label,
u_int16_t type, u_int16_t datasz, const void *data);
void songid_frame_destroy (songid_frame_t *frame);
void songid_frame_dump (songid_frame_t *frame, FILE *fp);
u_int32_t songid_frame_data32 (songid_frame_t *frame);
#define songid_frame_new_codec(a) songid_frame_new(6,FR_CODEC,ID_DATA_ASCII
,strlen(a)+1,a)
#define songid_frame_new_title(a) songid_frame_new(6,FR_TITLE,ID_DATA_ASCII
,strlen(a)+1,a)
#define songid_frame_new_album(a) songid_frame_new(6,FR_ALBUM,ID_DATA_ASCII
,strlen(a)+1,a)
#define songid_frame_new_genre(a) songid_frame_new(6,FR_GENRE,ID_DATA_ASCII
,strlen(a)+1,a)
#define songid_frame_new_artist(a) songid_frame_new(7,FR_ARTIST,ID_DATA_ASC
II,strlen(a)+1,a)
#define songid_frame_new_length(a) songid_frame_new(7,FR_LENGTH,ID_DATA_BIN
,sizeof(u_int32_t),a)
#define songid_frame_new_filesize(a) songid_frame_new(10,FR_SIZE,ID_DATA_BI
N,sizeof(u_int32_t),a)
#define songid_frame_new_tracknum(a) songid_frame_new(10,FR_TRACK,ID_DATA_B
IN,sizeof(u_int32_t),a)
#define songid_frame_new_fname(a) songid_frame_new(10,FR_FNAME,ID_DATA_ASCI
I,strlen(a)+1,a)
#define songid_frame_new_year(a) songid_frame_new(10,FR_YEAR,ID_DATA_ASCII,
strlen(a)+1,a)
#define songid_frame_new_protected(a) songid_frame_new(10,FR_PROTECTED,ID_D
ATA_ASCII,strlen(a)+1,a)
u_int32_t songid_size (songid_t *song);
u_int32_t songid_length (songid_t *song);
u_int32_t songid_track (songid_t *song);
const char *songid_label (songid_t *song, const char *label);
#define songid_title(a) songid_label(a,FR_TITLE);
#define songid_album(a) songid_label(a,FR_ALBUM);
#define songid_genre(a) songid_label(a,FR_GENRE);
#define songid_codec(a) songid_label(a,FR_CODEC);
#define songid_fname(a) songid_label(a,FR_FNAME);
#define songid_artist(a) songid_label(a,FR_ARTIST);
#define songid_year(a) songid_label(a,FR_YEAR);
#define songid_protected(a) songid_label(a,FR_PROTECTED);
/* Playlist fuctions */
playlist_t *playlist_new (void);
void playlist_destroy (playlist_t *pl);
void playlist_addtrack (playlist_t *pl, playlist_track_t *track,
unsigned int pos);
#define NJB_PL_END 0
#define NJB_PL_START 1
void playlist_reset_gettrack (playlist_t *pl);
playlist_track_t *playlist_gettrack (playlist_t *pl);
int playlist_set_name (playlist_t *pl, const char *name);
void playlist_deltrack (playlist_t *pl, unsigned int pos);
void playlist_dump(playlist_t *pl, FILE *fp);
playlist_t *playlist_unpack (void *data, size_t nbytes);
u_int32_t playlist_pack (playlist_t *pl, char *data);
playlist_track_t *playlist_track_new (u_int32_t trackid);
void playlist_track_destroy (playlist_track_t *track);
/* Data file tag functions */
datafile_t *datafile_new (void);
void datafile_destroy (datafile_t *df);
void datafile_dump(datafile_t *df, FILE *fp);
datafile_t *datafile_unpack (unsigned char *data, size_t nbytes);
unsigned char *datafile_pack (datafile_t *df, u_int32_t *size);
u_int64_t datafile_size (datafile_t *df);
void datafile_set_size (datafile_t *df, u_int64_t size);
void datafile_set_time (datafile_t *df, time_t ts);
int datafile_set_name (datafile_t *df, const char *filename);
unsigned char *datafile_pack3 (njb_t *njb, datafile_t *df, u_int32_t *size)
;
/* EAX functions */
void eax_destroy(eax_t *eax);
/* Time functions */
njb_time_t *time_unpack(void *data);
njb_time_t *time_unpack3(void *data);
void *time_pack(njb_time_t *time);
void *time_pack3(njb_time_t *time);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 37 change blocks. 
372 lines changed or deleted 524 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/