/*This file is prepared for Doxygen automatic documentation generation.*/
/*! \file *********************************************************************
 *
 * \brief ID3 metadata parser.
 *
 * This file contains the algorithms to read ID3 information.
 *
 * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32
 * - Supported devices:  All AVR32 devices can be used.
 * - AppNote:
 *
 * \author               Atmel Corporation: http://www.atmel.com \n
 *                       Support and FAQ: http://support.atmel.no/
 *
 ******************************************************************************/

/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. The name of Atmel may not be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * 4. This software may only be redistributed and used in connection with an Atmel
 * AVR product.
 *
 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
 *
 */

#ifndef _READER_ID3_H_
#define _READER_ID3_H_

#include <stddef.h>
#include "compiler.h"


//_____ I N C L U D E S ____________________________________________________


//_____ D E F I N I T I O N ________________________________________________

typedef struct
{
   U8    ver1;
   U8    ver10;
   U8    ver100;
} St_id3ver;

typedef struct
{
  size_t prepended_tag;
  size_t appended_tag;
} St_id3size;


//! @brief Return ID3 size from ID3 of current file selected
//!
extern St_id3size reader_id3_size ( void );

//! @brief Return ID3 version from ID3 of current file selected
//!
extern St_id3ver reader_id3_version ( void );

//! @brief Return title from ID3 of current file selected
//!
extern Bool reader_id3_title   ( FS_STRING sz_title , U8 u8_size_max );

//! @brief Return artist from ID3 of current file selected
//!
extern Bool reader_id3_artist ( FS_STRING sz_artist , U8 u8_size_max );

//! @brief Return album from ID3 of current file selected
//!
extern Bool reader_id3_album   ( FS_STRING sz_album , U8 u8_size_max );

//! @brief Return year from ID3 of current file selected
//!
extern U16 reader_id3_year    ( void );

//! @brief Return track from ID3 of current file selected
//!
extern U32  reader_id3_track   ( void );

//! @brief Return genre from ID3 of current file selected
//!
extern Bool reader_id3_genre   ( FS_STRING sz_genre , U8 u8_size_max );

//! @brief Return the length of the audiofile in milliseconds
//!
extern U32  reader_id3_duration ( void );

//! @brief Return embedded image mime type, image type and offset into the file.
//  
//  This function returns only the first picture that was found in the file!
//  
//  @mime_type is "image/jpeg" for an attached jpeg file
//  
//  @u8_size_max specifies the maximum string to get for mime_type
//  
//  @picture_type specifies what kind of picture it is 
//  (e.g. 0x03 for fron cover) more types are listed in the ID3 specification.
//  
//  @offset is the offset of the raw picture data from the file beginning
//
//  @returns TURE on success
//  @returns FALSE when no attached picture was found or an error occurred.
extern Bool reader_id3_picture ( FS_STRING mime_type, U8 u8_size_max, 
   U8 *picture_type, U32 *offset);



#endif  // _READER_ID3_H_
