Microchip® Advanced Software Framework

reader_id3.c File Reference
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include "navigation.h"
#include "file.h"
#include "reader_txt.h"
#include "ctrl_access.h"
#include <string.h>
#include "reader_id3.h"

Functions

bool reader_id3_album (FS_STRING sz_album, uint8_t u8_size_max)
 Return album from ID3 of current file selected. More...
 
bool reader_id3_artist (FS_STRING sz_artist, uint8_t u8_size_max)
 Return artist from ID3 of current file selected. More...
 
uint32_t reader_id3_duration (void)
 Return the length of the audiofile in milliseconds. More...
 
bool reader_id3_genre (FS_STRING sz_genre, uint8_t u8_size_max)
 Return genre from ID3 of current file selected. More...
 
static St_id3ver reader_id3_getver (void)
 Private routines for all ID3 versions. More...
 
bool reader_id3_picture (FS_STRING mime_type, uint8_t u8_size_max, uint8_t *picture_type, uint32_t *offset)
 Return embedded image mime type, image type and offset into the file. More...
 
static uint16_t reader_id3_read_string (FS_STRING string, uint16_t size_string, uint8_t format)
 Read an ASCII string in an ID3 field. More...
 
St_id3size reader_id3_size (void)
 Return ID3 size from ID3 of current file selected. More...
 
static uint32_t reader_id3_strtoul (FS_STRING string)
 Converts a string to an unsigned long. More...
 
bool reader_id3_title (FS_STRING sz_title, uint8_t u8_size_max)
 Return title from ID3 of current file selected. More...
 
uint32_t reader_id3_track (void)
 Return track from ID3 of current file selected. More...
 
static bool reader_id3_v1_album (FS_STRING sz_album, uint8_t u8_size_max)
 Return album from ID3 V1. More...
 
static bool reader_id3_v1_artist (FS_STRING sz_artist, uint8_t u8_size_max)
 Return artist from ID3 V1. More...
 
static bool reader_id3_v1_genre (FS_STRING sz_genre, uint8_t u8_size_max)
 Return genre from ID3 V1. More...
 
static bool reader_id3_v1_string (uint8_t pos_seek, uint8_t size, FS_STRING sz_string, uint8_t u8_size_max)
 Return a string from ID3 V1. More...
 
static bool reader_id3_v1_title (FS_STRING sz_title, uint8_t u8_size_max)
 functions version 1 More...
 
static bool reader_id3_v1_track (FS_STRING sz_track, uint8_t u8_size_max)
 Return a track from ID3 V1. More...
 
static bool reader_id3_v1_year (FS_STRING sz_year, uint8_t u8_size_max)
 Return year from ID3 V1. More...
 
static bool reader_id3_v2_album (St_id3ver ver, FS_STRING sz_album, uint8_t u8_size_max)
 Return album from ID3 V2. More...
 
static bool reader_id3_v2_artist (St_id3ver ver, FS_STRING sz_artist, uint8_t u8_size_max)
 Return artist from ID3 V2. More...
 
static bool reader_id3_v2_duration (St_id3ver ver, FS_STRING sz_duration, uint8_t u8_size_max)
 Return duration from ID3 V2. More...
 
static uint32_t reader_id3_v2_findtag (St_id3ver version, char *tag)
 Get informations of ID3 version 2. More...
 
static bool reader_id3_v2_genre (St_id3ver ver, FS_STRING sz_genre, uint8_t u8_size_max)
 Return genre from ID3 V2. More...
 
static bool reader_id3_v2_picture (St_id3ver ver, FS_STRING mime_type, uint8_t u8_size_max, uint8_t *picture_type, uint32_t *offset)
 Get attached picture from ID3 V2. More...
 
static bool reader_id3_v2_string (St_id3ver ver, char *tag, FS_STRING sz_string, uint8_t u8_size_max)
 Return a string corresponding at TAG V2. More...
 
static bool reader_id3_v2_title (St_id3ver ver, FS_STRING sz_title, uint8_t u8_size_max)
 functions version 2 More...
 
static bool reader_id3_v2_track (St_id3ver ver, FS_STRING sz_track, uint8_t u8_size_max)
 Return track from ID3 V2. More...
 
static bool reader_id3_v2_year (St_id3ver ver, FS_STRING sz_year, uint8_t u8_size_max)
 Return year from ID3 V2. More...
 
St_id3ver reader_id3_version (void)
 Return ID3 version from ID3 of current file selected. More...
 
uint16_t reader_id3_year (void)
 Return year from ID3 of current file selected. More...
 

Variables

static _CONST_TYPE_ uint8_t tab_genre_id3_v1 [126][18]
 

bool reader_id3_album ( FS_STRING  sz_album,
uint8_t  u8_size_max 
)

Return album from ID3 of current file selected.

References file_close(), reader_id3_getver(), reader_id3_v1_album(), reader_id3_v2_album(), St_id3ver::ver1, and St_id3ver::ver10.

bool reader_id3_artist ( FS_STRING  sz_artist,
uint8_t  u8_size_max 
)

Return artist from ID3 of current file selected.

References file_close(), reader_id3_getver(), reader_id3_v1_artist(), reader_id3_v2_artist(), St_id3ver::ver1, and St_id3ver::ver10.

uint32_t reader_id3_duration ( void  )
bool reader_id3_genre ( FS_STRING  sz_genre,
uint8_t  u8_size_max 
)

Return genre from ID3 of current file selected.

References file_close(), reader_id3_getver(), reader_id3_v1_genre(), reader_id3_v2_genre(), St_id3ver::ver1, and St_id3ver::ver10.

static St_id3ver reader_id3_getver ( void  )
static

Private routines for all ID3 versions.

Open the file and return major version of ID3.

Returns
version, 0 in case of error (the file is close in this case)

References file_close(), file_getc(), file_open(), file_seek(), FOPEN_MODE_R, FS_SEEK_END, St_id3ver::ver1, St_id3ver::ver10, St_id3ver::ver100, and version.

Referenced by reader_id3_album(), reader_id3_artist(), reader_id3_duration(), reader_id3_genre(), reader_id3_picture(), reader_id3_title(), reader_id3_track(), reader_id3_version(), and reader_id3_year().

bool reader_id3_picture ( FS_STRING  mime_type,
uint8_t  u8_size_max,
uint8_t *  picture_type,
uint32_t *  offset 
)

Return embedded image mime type, image type and offset into the file.

References file_close(), reader_id3_getver(), reader_id3_v2_picture(), and St_id3ver::ver1.

Referenced by ai_usb_ms_support_info_image().

static uint16_t reader_id3_read_string ( FS_STRING  string,
uint16_t  size_string,
uint8_t  format 
)
static

Read an ASCII string in an ID3 field.

Returns
number of char contained in tag

References Is_unicode, reader_txt_get_line(), and reader_txt_select_format().

Referenced by reader_id3_v1_string(), reader_id3_v2_picture(), and reader_id3_v2_string().

St_id3size reader_id3_size ( void  )

Return ID3 size from ID3 of current file selected.

References St_id3size::appended_tag, file_close(), file_getc(), file_open(), file_seek(), FOPEN_MODE_R, FS_SEEK_CUR_FW, FS_SEEK_END, and St_id3size::prepended_tag.

Referenced by play_mp3().

static uint32_t reader_id3_strtoul ( FS_STRING  string)
static

Converts a string to an unsigned long.

Returns
number resulting from string conversion

References Is_unicode.

Referenced by reader_id3_duration(), reader_id3_track(), and reader_id3_year().

bool reader_id3_title ( FS_STRING  sz_title,
uint8_t  u8_size_max 
)

Return title from ID3 of current file selected.

References file_close(), reader_id3_getver(), reader_id3_v1_title(), reader_id3_v2_title(), St_id3ver::ver1, and St_id3ver::ver10.

uint32_t reader_id3_track ( void  )
static bool reader_id3_v1_album ( FS_STRING  sz_album,
uint8_t  u8_size_max 
)
static

Return album from ID3 V1.

References reader_id3_v1_string().

Referenced by reader_id3_album().

static bool reader_id3_v1_artist ( FS_STRING  sz_artist,
uint8_t  u8_size_max 
)
static

Return artist from ID3 V1.

References reader_id3_v1_string().

Referenced by reader_id3_artist().

static bool reader_id3_v1_genre ( FS_STRING  sz_genre,
uint8_t  u8_size_max 
)
static

Return genre from ID3 V1.

References file_getc(), file_seek(), FS_SEEK_END, g_b_string_length, and tab_genre_id3_v1.

Referenced by reader_id3_genre().

static bool reader_id3_v1_string ( uint8_t  pos_seek,
uint8_t  size,
FS_STRING  sz_string,
uint8_t  u8_size_max 
)
static
static bool reader_id3_v1_title ( FS_STRING  sz_title,
uint8_t  u8_size_max 
)
static

functions version 1

Return title from ID3 V1.

References reader_id3_v1_string().

Referenced by reader_id3_title().

static bool reader_id3_v1_track ( FS_STRING  sz_track,
uint8_t  u8_size_max 
)
static

Return a track from ID3 V1.

References file_getc(), file_seek(), FS_SEEK_END, and g_b_string_length.

Referenced by reader_id3_track().

static bool reader_id3_v1_year ( FS_STRING  sz_year,
uint8_t  u8_size_max 
)
static

Return year from ID3 V1.

References reader_id3_v1_string().

Referenced by reader_id3_year().

static bool reader_id3_v2_album ( St_id3ver  ver,
FS_STRING  sz_album,
uint8_t  u8_size_max 
)
static

Return album from ID3 V2.

References reader_id3_v2_string(), and St_id3ver::ver10.

Referenced by reader_id3_album().

static bool reader_id3_v2_artist ( St_id3ver  ver,
FS_STRING  sz_artist,
uint8_t  u8_size_max 
)
static

Return artist from ID3 V2.

References reader_id3_v2_string(), and St_id3ver::ver10.

Referenced by reader_id3_artist().

static bool reader_id3_v2_duration ( St_id3ver  ver,
FS_STRING  sz_duration,
uint8_t  u8_size_max 
)
static

Return duration from ID3 V2.

References reader_id3_v2_string(), and St_id3ver::ver10.

Referenced by reader_id3_duration().

static uint32_t reader_id3_v2_findtag ( St_id3ver  version,
char *  tag 
)
static

Get informations of ID3 version 2.

References file_getc(), file_seek(), FS_SEEK_CUR_FW, FS_SEEK_SET, MSB0, MSB1, MSB2, MSB3, and St_id3ver::ver10.

Referenced by reader_id3_v2_picture(), and reader_id3_v2_string().

static bool reader_id3_v2_genre ( St_id3ver  ver,
FS_STRING  sz_genre,
uint8_t  u8_size_max 
)
static

Return genre from ID3 V2.

References reader_id3_v2_string(), and St_id3ver::ver10.

Referenced by reader_id3_genre().

static bool reader_id3_v2_picture ( St_id3ver  ver,
FS_STRING  mime_type,
uint8_t  u8_size_max,
uint8_t *  picture_type,
uint32_t *  offset 
)
static
static bool reader_id3_v2_string ( St_id3ver  ver,
char *  tag,
FS_STRING  sz_title,
uint8_t  u8_size_max 
)
static
static bool reader_id3_v2_title ( St_id3ver  ver,
FS_STRING  sz_title,
uint8_t  u8_size_max 
)
static

functions version 2

Return title from ID3 V2.

References reader_id3_v2_string(), and St_id3ver::ver10.

Referenced by reader_id3_title().

static bool reader_id3_v2_track ( St_id3ver  ver,
FS_STRING  sz_track,
uint8_t  u8_size_max 
)
static

Return track from ID3 V2.

References reader_id3_v2_string(), and St_id3ver::ver10.

Referenced by reader_id3_track().

static bool reader_id3_v2_year ( St_id3ver  ver,
FS_STRING  sz_year,
uint8_t  u8_size_max 
)
static

Return year from ID3 V2.

References reader_id3_v2_string(), and St_id3ver::ver10.

Referenced by reader_id3_year().

St_id3ver reader_id3_version ( void  )

Return ID3 version from ID3 of current file selected.

References file_close(), reader_id3_getver(), St_id3ver::ver1, and St_id3ver::ver10.

Referenced by ai_usb_ms_mp3_support_get_metadata_version().

uint16_t reader_id3_year ( void  )

_CONST_TYPE_ uint8_t tab_genre_id3_v1[126][18]
static

Referenced by reader_id3_v1_genre().