libnjb 2.2.7

Macros | Functions | Variables
songid.c File Reference
`#include <stdlib.h>`
`#include <string.h>`
`#include "libnjb.h"`
`#include "base.h"`
`#include "njb_error.h"`
`#include "defs.h"`
`#include "protocol3.h"`
`#include "byteorder.h"`
`#include "unicode.h"`
`#include "songid.h"`

## Macros
#define | UNICODE_ON_NJB1
#define | FR_UNI_TITLE "UNI_TITLE"
#define | FR_UNI_ALBUM "UNI_ALBUM"
#define | FR_UNI_GENRE "UNI_GENRE"
#define | FR_UNI_ARTIST "UNI_ARTIST"
#define | FR_UNI_FNAME "UNI_FNAME"

## Functions
njb_songid_t * | NJB_Songid_New (void)
njb_songid_t * | songid_unpack (void *data, size_t nbytes)
unsigned char * | songid_pack (njb_songid_t *song, u_int32_t *tagsize)
unsigned char * | songid_pack3 (njb_songid_t *song, u_int32_t *tagsize)
void | NJB_Songid_Addframe (njb_songid_t *song, njb_songid_frame_t *frame)
void | NJB_Songid_Destroy (njb_songid_t *songid)
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)
int | songid_sanity_check (njb_t *njb, njb_songid_t *songid)
njb_songid_frame_t * | NJB_Songid_Frame_New_String (const char *label, const char *value)
njb_songid_frame_t * | NJB_Songid_Frame_New_Codec (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)
void | NJB_Songid_Frame_Destroy (njb_songid_frame_t *frame)

## Variables
int | __sub_depth
int | njb_unicode_flag

## Detailed Description

This file contains the functions that are used for manipulating all song/track metadata, such as artist, title etc.

## Macro Definition Documentation

## ◆ FR_UNI_ALBUM

#define FR_UNI_ALBUM "UNI_ALBUM"

Unicode Album metadata for NJB1

Referenced by songid_pack().

## ◆ FR_UNI_ARTIST

#define FR_UNI_ARTIST "UNI_ARTIST"

Unicode Artist metadata for NJB1

Referenced by songid_pack().

## ◆ FR_UNI_FNAME

#define FR_UNI_FNAME "UNI_FNAME"

Unicode Filename metadata for NJB1 (not used)

## ◆ FR_UNI_GENRE

#define FR_UNI_GENRE "UNI_GENRE"

Unicode Genre metadata for NJB1

Referenced by songid_pack().

## ◆ FR_UNI_TITLE

#define FR_UNI_TITLE "UNI_TITLE"

Unicode Title metadata for NJB1

Referenced by songid_pack().

## ◆ UNICODE_ON_NJB1

#define UNICODE_ON_NJB1

We want to use Unicode also on NJB1

## Function Documentation

## ◆ songid_pack()

unsigned char* songid_pack | ( | njb_songid_t * | song,
|  | u_int32_t * | tagsize
| ) |  |

This packs (serialize, marshal) a libnjb song ID into the raw byte structure used by the NJB1.

Parameters

  song | the libnjb song ID to pack
  tagsize | a pointer to an integer that will hold the size of the resulting NJB1 songid structure

Returns
  a newly allocated byte array holding the NJB1 representation of the song ID, the memory should be freed by the caller after use

References njb_songid_frame_struct::data, FR_ALBUM, FR_ARTIST, FR_GENRE, FR_TITLE, FR_UNI_ALBUM, FR_UNI_ARTIST, FR_UNI_GENRE, FR_UNI_TITLE, from_16bit_to_njb1_bytes(), from_32bit_to_njb1_bytes(), njb_songid_frame_struct::label, njb_songid_struct::nframes, NJB_Songid_Getframe(), NJB_Songid_Reset_Getframe(), NJB_TYPE_STRING, NJB_TYPE_UINT16, NJB_TYPE_UINT32, NJB_UC_UTF8, njb_unicode_flag, strtoucs2(), njb_songid_frame_struct::strval, njb_songid_frame_struct::type, njb_songid_frame_struct::u_int16_val, njb_songid_frame_struct::u_int32_val, ucs2strlen(), and utf8tostr().

Referenced by NJB_Replace_Track_Tag().

## ◆ songid_pack3()

unsigned char* songid_pack3 | ( | njb_songid_t * | song,
|  | u_int32_t * | tagsize
| ) |  |

This packs (serialize, marshal) a libnjb song ID into the raw byte structure used by the series 3 devices.

Parameters

  song | the libnjb song ID to pack
  tagsize | a pointer to an integer that will hold the size of the resulting series 3 songid structure

Returns
  a newly allocated byte array holding the series 3 representation of the song ID, the memory should be freed by the caller after use

Referenced by NJB_Replace_Track_Tag().

## ◆ songid_sanity_check()

int songid_sanity_check | ( | njb_t * | njb,
|  | njb_songid_t * | songid
| ) |  |

This function checks that a tag has all compulsory elements, i.e.: size, codec and track number

Parameters

  songid | the song ID to be checked for sanity

Returns
  0 if the tag is sane, -1 if it is insane

References njb_songid_frame_struct::data, FR_CODEC, FR_LENGTH, FR_PROTECTED, FR_SIZE, FR_TITLE, FR_TRACK, FR_YEAR, njb_songid_frame_struct::label, NJB_CODEC_MP3, NJB_CODEC_WAV, NJB_CODEC_WMA, NJB_Songid_Getframe(), NJB_Songid_Reset_Getframe(), NJB_TYPE_STRING, NJB_TYPE_UINT16, NJB_TYPE_UINT32, njb_songid_frame_struct::strval, njb_songid_frame_struct::type, njb_songid_frame_struct::u_int16_val, and njb_songid_frame_struct::u_int32_val.

Referenced by NJB_Replace_Track_Tag().

## ◆ songid_unpack()

njb_songid_t* songid_unpack | ( | void * | data,
|  | size_t | nbytes
| ) |  |

This takes a raw chunk of memory representing a song ID as used by the NJB1 and convert it into a song ID structure as used by libnjb.

Parameters

  data | the raw bytes from the NJB1
  nbytes | the size of the NJB1 byte array

Returns
  a newly allocated song ID that shall be freed by the caller after use

References FR_ALBUM, FR_ARTIST, FR_FNAME, FR_GENRE, FR_TITLE, FR_YEAR, njb1_bytes_to_16bit(), NJB_Songid_Destroy(), NJB_Songid_Frame_New_String(), NJB_Songid_New(), NJB_UC_UTF8, njb_unicode_flag, and strtoutf8().

## Variable Documentation

## ◆ __sub_depth

int __sub_depth

The current subroutine depth for all of libnjb (global)

## ◆ njb_unicode_flag

int njb_unicode_flag

A flag for if unicode is used or not (global)

Referenced by njb_set_unicode(), songid_pack(), songid_unpack(), strtoucs2(), and ucs2tostr().