Defines | |
#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_ARTIST, a) |
#define | NJB_Songid_Frame_New_Length(a) NJB_Songid_Frame_New_Uint16(FR_LENGTH, a) |
#define | NJB_Songid_Frame_New_Filesize(a) NJB_Songid_Frame_New_Uint32(FR_SIZE, a) |
#define | NJB_Songid_Frame_New_Tracknum(a) NJB_Songid_Frame_New_Uint16(FR_TRACK, 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_FNAME, a) |
#define | NJB_Songid_Frame_New_Protected(a) NJB_Songid_Frame_New_Uint16(FR_PROTECTED, a) |
#define | NJB_Songid_Frame_New_Bitrate(a) NJB_Songid_Frame_New_Uint32(FR_BITRATE, a) |
#define | NJB_Songid_Frame_New_Comment(a) NJB_Songid_Frame_New_String(FR_COMMENT, a) |
#define | NJB_Songid_Frame_New_Folder(a) NJB_Songid_Frame_New_String(FR_FOLDER, a) |
Functions | |
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 *label) |
njb_songid_frame_t * | NJB_Songid_Frame_New_String (const char *label, const char *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) |
njb_songid_frame_t * | NJB_Songid_Frame_New_Codec (const char *value) |
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 *songid) |
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) |
|
This deletes a track from the device.
|
|
This configures libnjb to retrieve extended tags from the device. For the NJB1 this is the default behaviour anyway so it need not be set, but for the series 3 devices, retrieving the extended tag information is a costly operation that will slow down the initial track scanning by orders of magnitude and irritate the user. Make sure end-users can configure whether they want to use this or not. The extended tags will include things like the filename and folder that the file used on the host before it was transfered to the device.
|
|
This retrieves ("uploads") a track from the device to the host computer.
|
|
This retrieves ("uploads") a track from the device to the host computer by way of a file descriptor, which is good for e.g. streaming stuff. The daring type can start playing back audio from the file descriptor before it is finished. This is also good for fetching to temporary files, which are often only given as file descriptors.
|
|
This gets a track tag (song ID) from the device. The device should first be rewound using the Notice that there is no function for getting the tag for a single track, there is just this function that dumps out the entire database in one big go. The recommended approach is to keep an internal track cache of all tracks and use this for getting metadata for single tracks. There is as far as we know no function in the Creative firmwares for getting the metadata of a single track, so access through this function is the only option.
|
|
This routine will replace the track tag or parts of a track tag for a track that already exist on the device. On the NJB1 the whole metadata set must be specified for this routine to work properly, but on the series 3 devices you can specify incremental updates (only parts of the metadata set). Be sure to either specify the full set all the time, or check if we are handling an NJB1 before submitting an incremental update (see example below).
njb_t *njb; njb_songid_t *songid; njb_songid_frame_t *frame;
songid = NJB_Songid_New(); // On NJB1 incremental update is not possible, so a full // metadata set must always be specified. if (njb->device_type == NJB_DEVICE_NJB1) { frame = NJB_Songid_Frame_New_Codec(meta->codec); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Filesize(meta->size); NJB_Songid_Addframe(songid, frame); } frame = NJB_Songid_Frame_New_Codec(NJB_CODEC_MP3); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Title("MyTitle"); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Album("MyAlbum"); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Artist("MyArtist"); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Genre("MyGenre"); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Year(2004); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Tracknum(1); NJB_Songid_Addframe(songid, frame); // The length of the track should typically be given, or such things // as progress indicators will stop working. If you absolutely want to // upload a file of unknown length and break progress indicators, set // length to 1 second. frame = NJB_Songid_Frame_New_Length(123); NJB_Songid_Addframe(songid, frame); // This one is optional, the track will survive without it. frame = NJB_Songid_Frame_New_Filename("Foo.mp3"); NJB_Songid_Addframe(songid, frame); if (NJB_Replace_Track_Tag(njb, 123456, songid) == -1) { NJB_Error_Dump(stderr); } NJB_Songid_Destroy(songid);
|
|
This resets the track tag (song ID) retrieveal function. The track tags can then be retrieved one by one using the Typical usage:
njb_t *njb; njb_songid_t *song;
NJB_Songid_Reset_Get_Track_Tag(njb); while ( (song = NJB_Get_Track_Tag(njb)) != NULL ) { // Do something with all the songs... }
|
|
This sends ("downloads") a track (playable music file) to the device. Typical usage:
njb_t *njb; njb_songid_t *songid; njb_songid_frame_t *frame; u_int32_t id;
songid = NJB_Songid_New(); frame = NJB_Songid_Frame_New_Codec(NJB_CODEC_MP3); NJB_Songid_Addframe(songid, frame); // This one is optional - libnjb will fill it in if not specified frame = NJB_Songid_Frame_New_Filesize(12345678); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Title("MyTitle"); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Album("MyAlbum"); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Artist("MyArtist"); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Genre("MyGenre"); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Year(2004); NJB_Songid_Addframe(songid, frame); frame = NJB_Songid_Frame_New_Tracknum(1); NJB_Songid_Addframe(songid, frame); // The length of the track should typically be given, or such things // as progress indicators will stop working. If you absolutely want to // upload a file of unknown length and break progress indicators, set // length to 1 second. frame = NJB_Songid_Frame_New_Length(123); NJB_Songid_Addframe(songid, frame); // This one is optional - libnjb will fill it in if not specified frame = NJB_Songid_Frame_New_Filename("Foo.mp3"); NJB_Songid_Addframe(songid, frame); if (NJB_Send_Track (njb, "foo.mp3", songid, NULL, NULL, &id) == -1) { NJB_Error_Dump(stderr); } NJB_Songid_Destroy(songid);
|
|
This adds a song ID frame to a song ID.
|
|
This destroys an entire song ID structure and free the memory used by it.
|
|
This locates a particular song ID frame inside a song ID, by using the textual label given.
|
|
This destroys a song ID frame and free any memory used by it.
|
|
This is a wrapper function to fix a common mistake made when creating codec frames: lowercase codec names and other strange mistakes. |
|
Creates a new string frame.
|
|
Creates a new unsigned 16-bit integer frame.
|
|
Creates a new unsigned 32-bit integer frame.
|
|
This gets the next song ID frame from a song ID structure.
|
|
This creates a new song ID holder structure. (A songid in turn contains several frames represening different metadata.)
|
|
This resets the internal pointer in the song ID so that it points to the first frame of the song ID. It should typically be called before subsequent calls to Typical usage:
njb_songid_t *song; njb_songid_frame_t *frame;
// Get a song ID into "song"... NJB_Songid_Reset_Getframe(song); while ( (frame = NJB_Songid_Getframe(song)) != NULL ) { // Do something with all the frames... }
|