⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmatag.c

📁 本程序为ST公司开发的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/************************************************** * * wmatag.c * * CVS ID:   $Id: wmatag.c,v 1.37 2007/09/21 05:27:36 hara Exp $ * Author:   Jiri Sedmik [JS] - STM * Date:     $Date: 2007/09/21 05:27:36 $ * Revision: $Revision: 1.37 $ * * Description: * * ASF header parsing and WMA Tag decoding. * ************************************************** * * COPYRIGHT (C) ST Microelectronics  2005 *            All Rights Reserved * ******************************************************************************* * *  \par            Change History: * * - BB060920c      Removed tag string pointer from t_SongInfos *                  (copying structure easier and safer) * **************************************************** * * STM CVS Log: * * $Log: wmatag.c,v $ * Revision 1.37  2007/09/21 05:27:36  hara * Initial implementation for WMDRM feature into A+. * * Revision 1.36  2007/09/10 18:00:22  trubac * different macro name used MAX_TEXT_SIZE, improved string limits (<100 bytes) * * Revision 1.35  2007/07/25 15:15:37  belardi * Added initialization of sampling_fr and ch_num for song_info * * Revision 1.34  2007/06/28 13:46:41  trubac * WMA tag string cuting fixed * * Revision 1.33  2006/10/20 15:18:41  trubac * wrong Genre, Year fixed in WMA tag decoding * * Revision 1.32  2006/10/17 09:55:29  trubac * new id3 tag strings handling + new tag infos in song_info * * Revision 1.29  2006/09/18 09:55:22  belardi * Corrected CVS keyword usage * * Revision 1.28  2006/09/18 09:23:25  belardi * Added Log CVS keyword into file header * * **************************************************///[RB] WMA Library is compiled without interworking, so this file must be compiled//[RB] in ARM mode#pragma ARM#include "configuration.h"//#include <stdio.h>//#include <stdlib.h>#include <string.h>#include "debug.h"/* pure WMA stuff */#include "wmaudio.h"#include "wmaerr.h"#include "wmaudio_type.h"#include "wmaudio_add.h"#include "gendef.h"#include "allocation.h"#include "wmatag.h"#include "tag.h"#include "utf8.h"#include "ioread.h"#if (HAVE_WMA!=0)#include "filesys.h"extern uint8 tag_buf[WMA_BUFFER_LENGTH];  /* tag.c */extern tWMAFileHdrState WMA_HdrState;   /* wmawrap.c; share ASF Header info */uint8 *buffer;                /* pointer to temporary tag buffer */#if (1 == HAVE_WMDRM)#include "WMDRM_Receiver.h"#endif#if (WMA_TAG_DEBUG != 0)#include "debug.h"typedef struct{  uint8 tmp_buf[50];} general_tmp_buf;general_tmp_buf wma_tmp_buf1;typedef struct _WMATagDecodeDBG_{  uint8 flag1;  uint8 flag2;  uint8 flag3;  uint8 flag4;  uint8 flag5;  uint8 flag6;  uint8 flag7;  uint8 flag8;  uint8 flag9;  uint8 flag10;}  _WMATagDecodeDBG;_WMATagDecodeDBG WMATagDecodeDBG;#endif /*WMA_TAG_DEBUG*/static char WMA_ALBUM_TITLE_DESC_NAME[] ={  //  'W', 0, 'M', 0, '/', 0, 'A', 0, 'l', 0, 'b', 0, 'u', 0, 'm', 0, 'T', 0, 'i', 0, 't', 0, 'l', 0, 'e', 0, 0  'W', 'M', '/', 'A', 'l', 'b', 'u', 'm', 'T', 'i', 't', 'l', 'e', 0};static char WMA_GENRE_DESC_NAME[] ={  //  'W', 0, 'M', 0, '/', 0, 'G', 0, 'e', 0, 'n', 0, 'r', 0, 'e', 0, 0, 0  'W', 'M', '/', 'G', 'e', 'n', 'r', 'e', 0};static char WMA_YEAR_DESC_NAME[] ={  //  'W', 0, 'M', 0, '/', 0, 'Y', 0, 'e', 0, 'a', 0, 'r', 0, 0, 0  'W', 'M', '/', 'Y', 'e', 'a', 'r', 0};/***************** FUNCTIONS **********************//************************************* WMAFileCBGetData()** Description:** Wma ASF decoder directly asks data* in FileSystem Task.*************************************/tWMA_U32 WMAFileCBGetData(tHWMAFileState *state,                          tWMA_U64 offset,                          tWMA_U32 NB,                          unsigned char **ppData){  tWMAFileStateInternal *pInt = (tWMAFileStateInternal *) state;  GRESULT ret_down = S_OK;  /* Initialize return values */  tWMA_U32 ret_up = 0;  *ppData = NULL;#if (WMA_TAG_DEBUG != 0)  WMATagDecodeDBG.flag6 = 0;  WMATagDecodeDBG.flag7 = 0;  WMATagDecodeDBG.flag8 = 0;  WMATagDecodeDBG.flag9 = 0;  WMATagDecodeDBG.flag10 = 0;#endif /*WMA_TAG_DEBUG*/  ret_down = XAR_SeekFile(pInt->hdr_parse.song_info, offset, 1);#if (WMA_TAG_DEBUG != 0)  WMATagDecodeDBG.flag6 = 1;#endif /*WMA_TAG_DEBUG*/  if (ret_down != S_OK)    return ret_up;        /* requested NB; returned 0 */#if (WMA_TAG_DEBUG != 0)  WMATagDecodeDBG.flag7 = 1;#endif /*WMA_TAG_DEBUG*/  ret_down = XAR_ReadFile(pInt->hdr_parse.song_info, buffer, NB, IO_READ_CACHE);#if (WMA_TAG_DEBUG != 0)  WMATagDecodeDBG.flag8 = 1;#endif /*WMA_TAG_DEBUG*/  if (ret_down == 0)    return ret_up;#if (WMA_TAG_DEBUG != 0)  WMATagDecodeDBG.flag9 = 1;#endif /*WMA_TAG_DEBUG*/  ret_up = (tWMA_U32) ret_down;  if (ret_up == NB)    *ppData = buffer;#if (WMA_TAG_DEBUG != 0)  WMATagDecodeDBG.flag10 = 1;#endif /*WMA_TAG_DEBUG*/  return ret_up;}/************************************* GetASFHeader()** Description:** Wma decoder will ask during* initialization for song control* information.*************************************/tWMAFileStatus GetASFHeader(tWMAFileHdrStateInternal *pInt){  pInt->wTargetAudioStreamNumber = 1; /* wTargetAudioStream; */  // should be implemented some kind of protection  // i.e return NULL if FileDesc not ready  //*pInt = FileDesc;  /* WMA_HdrState always exists; must be valit here */  *pInt = *(tWMAFileHdrStateInternal *)&WMA_HdrState;  return cWMA_NoErr;}/************************************* WMAParseASFheader()** Description:** Starts ASF header parsing.*************************************/GRESULT WMAParseASFheader(tWMAFileHdrStateInternal *pInt, t_SongInfos *song_info){  uint16 nMBRTargetStream = 1;  tWMAFileStatus wma_error;  /* init struct */  memset((void *) pInt, 0, sizeof(WMA_HdrState));  pInt->song_info = song_info;  /* test the checking API */  wma_error = WMAFileSetTargetMBRAudioStream(&WMA_HdrState, nMBRTargetStream);  if (wma_error != cWMA_NoErr)  {#if (WMA_TAG_DEBUG != 0)    DBG_PRINTF("WMATAG: ** Error while setting target stream number.\r\n");#endif /*WMA_TAG_DEBUG*/    return E_FAIL;    /* WMAERR_INVALIDARG; */  }  wma_error = WMAFileIsWMA(&WMA_HdrState);  if (wma_error != cWMA_NoErr)  {    if (wma_error == cWMA_BadArgument)    {#if (WMA_TAG_DEBUG != 0)      DBG_PRINTF("WMATAG: ** Invalid WMA arguments - is wma file?\r\n");#endif /*WMA_TAG_DEBUG*/      return E_FAIL;  /* WMAERR_INVALIDARG; */    }    else    {#if (WMA_TAG_DEBUG != 0)      DBG_PRINTF("WMATAG: ** Invalid WMA header.\r\n");#endif /*WMA_TAG_DEBUG*/      return E_FAIL;  /* WMAERR_INVALIDHEADER; */    }  }  return WMAERR_OK;}/*** Check if WMA is supported  ***/GRESULT WMA_CheckWma(tWMAFileHdrStateInternal *pInt){  tWMAFileStatus wma_error;  if ((pInt->wFormatTag < 0x160) || (pInt->wFormatTag > 0x161))  { /* Proffesional and Loss-less are not supported */    DBG_PRINTF("WMATAG: ** W:Proffesional and Loss-less are not supported\r\n");    return E_FAIL;  }#if (0 != HAVE_WMDRM) // DRM Implementation. [FHA]   if ((pInt->cbSecretData > 0) &&       ((((t_SongInfos *)(pInt->song_info))->fs_type != FS_WMDRM_TYPE) || !IS_USBDeviceLicense_Available))#else  if (pInt->cbSecretData > 0)#endif  { /* DRM is not supported */    DBG_PRINTF("WMATAG: ** W:DRM is not supported\r\n");    return E_FAIL;  }  wma_error = WMACheckInitParams(pInt);  if (wma_error != cWMA_NoErr)  {    DBG_PRINTF("WMATAG: ** E:Not supportedformat\r\n");    return E_FAIL;    /* WMA_E_NOTSUPPORTED */  }  return S_OK;}/*** Copy out WMA fileinfo from parsed ASF header  ***/GRESULT WMA_ExtractTag(tWMAFileHdrStateInternal *pInt){  GRESULT res = S_OK;  int i;  uint16 length;  uint8 *len_ptr;  uint8 temp_buf[ID3V2_MAX_TEXT_SIZE*2];  /* for charset conversions */  int wlen;  t_conv_param p;  t_SongTagType wmaTagType;  t_SongInfos *song_info = pInt->song_info;  tWMAFileContDesc *pDesc = pInt->m_pDesc;  tWMAExtendedContentDesc *pECDesc = pInt->m_pECDesc;  ECD_DESCRIPTOR *pECDescriptor;  DescValDataType itemDataType;  if (pDesc == NULL)  {    res = S_OK;   //TBD - return no tag descriptor  }  else  {    /* allocate and assign memory for tag infos */    len_ptr = song_info->strings + song_info->strtop;    if (song_info->n_infos < (XSONG_INFO_TAGS - 1) && (song_info->strtop < MAX_STRINGS_SIZE - 2))    {      if (pDesc->title_len > 1)      {        /* load song title */        //length = id3_v1_len(&(buffer[ID3_TAG_V1_ALBUM_POSITION]),ID3_TAG_V1_ITEM_LENGTH);        length = pDesc->title_len / 2 - 1;   //TBD - number of wide chars        //estrcpy(temp_buf, pDesc.pTitle, length);        //str_convert_byte2int(temp_buf, length);        //wmaTagType = SONG_TITLE;        p.be = 0;        p.trunc = 0;        //p.limit = (MAX_STRINGS_SIZE) - song_info->strtop - 1;        p.limit = wmin((MAX_STRINGS_SIZE) - song_info->strtop - 1 , ID3V2_MAX_TEXT_SIZE);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -