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

📄 wmatag.c

📁 本程序为ST公司开发的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
        if(p.limit>0)        {        wlen = WideStringToUTF8((uint8 *) pDesc->pTitle, len_ptr + 1, length, &p);        if (wlen > 0)        {          *len_ptr = wlen;//#ifdef APM_PICKUP          song_info->infos[song_info->n_infos].enc_of_src = TEXT_ENCODING_UTF_16LE;          song_info->infos[song_info->n_infos].tag_version = 0xFF;//#endif          song_info->infos[song_info->n_infos].info_type = SONG_TITLE;          song_info->infos[song_info->n_infos].string_offset = song_info->strtop;          len_ptr += (1 + wlen);#if (WMA_TAG_DEBUG != 0)          *(len_ptr) = 0;          DBG_PRINTF("SONG_TITLE: %s\r\n", song_info->strings[song_info->infos[song_info->n_infos].string_offset + 1]);#endif /*WMA_TAG_DEBUG*/          song_info->strtop += wlen + 1;          song_info->n_infos++;        }      }    }    }    else      return W_TAG_INFO_BUF_FULL;    if (song_info->n_infos < (XSONG_INFO_TAGS - 1) && (song_info->strtop < MAX_STRINGS_SIZE - 2))    {      if (pDesc->author_len > 1)      {        /* load artists name */        //length = id3_v1_len(&(buffer[ID3_TAG_V1_ALBUM_POSITION]),ID3_TAG_V1_ITEM_LENGTH);        length = pDesc->author_len / 2 - 1;    //TBD - number of wide chars        //estrcpy(temp_buf, pDesc.pTAuthor, length);        //str_convert_byte2int(temp_buf, length);        //wmaTagType = ARTIST;        p.be = 0;        p.trunc = 0;        //p.limit = wmin(length, (MAX_STRINGS_SIZE) - song_info->strtop);        //p.limit = (MAX_STRINGS_SIZE) - song_info->strtop - 1;        p.limit = wmin((MAX_STRINGS_SIZE) - song_info->strtop - 1 , ID3V2_MAX_TEXT_SIZE);        if(p.limit>0)        {        wlen = WideStringToUTF8((uint8 *) pDesc->pAuthor, len_ptr + 1, length, &p);        if (wlen > 0)        {          *len_ptr = wlen;//#ifdef APM_PICKUP          song_info->infos[song_info->n_infos].enc_of_src = TEXT_ENCODING_UTF_16LE;          song_info->infos[song_info->n_infos].tag_version = 0xFF;//#endif          song_info->infos[song_info->n_infos].info_type = ARTIST;          song_info->infos[song_info->n_infos].string_offset = song_info->strtop;          len_ptr += (1 + wlen);#if (WMA_TAG_DEBUG != 0)          *(len_ptr) = 0;          DBG_PRINTF("ARTIST: %s\r\n", song_info->strings[song_info->infos[song_info->n_infos].string_offset + 1]);#endif /*WMA_TAG_DEBUG*/          song_info->strtop += wlen + 1;          song_info->n_infos++;        }      }    }    }    else      return W_TAG_INFO_BUF_FULL;    if (song_info->n_infos < (XSONG_INFO_TAGS - 1) && (song_info->strtop < MAX_STRINGS_SIZE - 2))    {      if (pDesc->description_len > 1)      {        /* load comment */        //length = id3_v1_len(&(buffer[ID3_TAG_V1_ALBUM_POSITION]),ID3_TAG_V1_ITEM_LENGTH);        length = pDesc->description_len / 2 - 1;   //TBD - number of wide chars        //estrcpy(temp_buf, pDesc.pTAuthor, length);        //str_convert_byte2int(temp_buf, length);        //wmaTagType = COMMENT;        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);        if(p.limit>0)        {        wlen = WideStringToUTF8((uint8 *) pDesc->pDescription, len_ptr + 1, length, &p);        if (wlen > 0)        {          *len_ptr = wlen;//#ifdef APM_PICKUP          song_info->infos[song_info->n_infos].enc_of_src = TEXT_ENCODING_UTF_16LE;          song_info->infos[song_info->n_infos].tag_version = 0xFF;//#endif          song_info->infos[song_info->n_infos].info_type = COMMENT;          song_info->infos[song_info->n_infos].string_offset = song_info->strtop;          len_ptr += (1 + wlen);#if (WMA_TAG_DEBUG != 0)          *(len_ptr) = 0;          DBG_PRINTF("COMMENT: %s\r\n", song_info->strings[song_info->infos[song_info->n_infos].string_offset + 1]);#endif /*WMA_TAG_DEBUG*/          song_info->strtop += wlen + 1;          song_info->n_infos++;        }      }    }    }    else      return W_TAG_INFO_BUF_FULL;  }  /* parse Extended File Description */  if (pECDesc != NULL)  {    if (pECDesc->cDescriptors > 0)    {      for (i = 0; i < (unsigned int) pECDesc->cDescriptors; i++)      {        pECDescriptor = (ECD_DESCRIPTOR *)&pECDesc->pDescriptors[i];        /* parse item name */        length = pECDescriptor->cbName / 2 - 1;    //TBD - number of wide chars        //estrcpy(temp_buf, pDesc.pTitle, length);        //str_convert_byte2int(temp_buf, length);        p.be = 0;        p.trunc = 0;        //p.limit = (MAX_STRINGS_SIZE) - song_info->strtop-1 ; //ID3V2_MAX_TEXT_SIZE*2;        p.limit = wmin((MAX_STRINGS_SIZE) - song_info->strtop - 1 , ID3V2_MAX_TEXT_SIZE);        wlen=WideStringToUTF8((uint8 *) pECDescriptor->pwszName, temp_buf, length, &p);		if(wlen<0)			continue;        do        {          if (strncmp((char *) temp_buf, WMA_ALBUM_TITLE_DESC_NAME, length) == 0)          {            /* load item content */            wmaTagType = ALBUM_TITLE;          }          else if (strncmp((char *) temp_buf, WMA_GENRE_DESC_NAME, length) == 0)          {            /* load item content */            wmaTagType = GENRE;          }          else if (strncmp((char *) temp_buf, WMA_YEAR_DESC_NAME, length) == 0)          {            /* load item content */            wmaTagType = YEAR;          }          else            break;#if (WMA_TAG_DEBUG != 0)          *(temp_buf + length) = 0;          DBG_PRINTF("%s: ", (uint8 *)&temp_buf);#endif /*WMA_TAG_DEBUG*/          itemDataType = (DescValDataType) pECDescriptor->data_type;          if (song_info->n_infos < (XSONG_INFO_TAGS - 1)           && (song_info->strtop < MAX_STRINGS_SIZE - 2))          {            switch (itemDataType)            {            case DVDT_UNICODE:              length = pECDescriptor->cbValue / 2 - 1;              p.be = 0;              p.trunc = 0;              p.limit = wmin((MAX_STRINGS_SIZE) - song_info->strtop-1,ID3V2_MAX_TEXT_SIZE);              if(p.limit>0)              {              wlen = WideStringToUTF8((uint8 *) pECDescriptor->uValue.pbBinary, len_ptr + 1, length, &p);              song_info->infos[song_info->n_infos].enc_of_src = TEXT_ENCODING_UTF_16LE;              }              break;                          default:              return W_WMA_TAG_EXTEND_DESC; /* Extended descriptor isn't mandatory */            }			if (wlen > 0)			{                *len_ptr = wlen;                song_info->infos[song_info->n_infos].tag_version = 0xFF;                song_info->infos[song_info->n_infos].info_type = wmaTagType;                song_info->infos[song_info->n_infos].string_offset = song_info->strtop;                song_info->strtop += (wlen + 1);                len_ptr += (wlen + 1);#if (WMA_TAG_DEBUG != 0)			*len_ptr = 0;	            DBG_PRINTF("%s (%d)\r\n", song_info->strings[song_info->infos[song_info->n_infos].string_offset + 1], i + 1);#endif /*WMA_TAG_DEBUG*/                song_info->n_infos++;            }          }          else            return W_TAG_INFO_BUF_FULL;        }        while (0);      }    }  }  return res;}/*** Free all allocated structures ***/GRESULT WMA_CloseTag(tWMAFileHdrStateInternal *pInt){  tWMAFileStatus wma_error = cWMA_BadArgument;  wma_error = WMAFileTagDecodeClose(pInt);  if (wma_error != cWMA_NoErr)    return S_ZERO_ARGUMENT;  INIT_FAST_MALLOC();     /* to ensure 1000% NONE items allocated */  return S_OK;}/*** Extract the WMA TAG from the actual file ***/GRESULT WMA_TagDecode(t_SongInfos *song_info, uint32 count_down){  GRESULT error = S_OK;  tWMAFileHdrStateInternal *pInt = (tWMAFileHdrStateInternal *)&WMA_HdrState;#if (1 == HAVE_WMDRM)  DRM_RESULT dr;  /* When Device is WMDRM ND-Transmitter. */       if ( song_info->fs_type == FS_WMDRM_TYPE && IS_USBDeviceSuppport_WMDRM_ND )  {    /* Open Media Session */    dr = WmdrmNet_TASK_transition( WMDRM_OPEN_MEDIA_SESSION );    if ( DRM_FAILED(dr) )    {      return E_FAIL;    }          /* If WMA object has DRM delivery option supported. */    if ( IS_USBDeviceSessionObject_WMDRM_NDR )    {      dr = WmdrmNet_TASK_transition( WMDRM_GET_LICENSE );      if ( DRM_FAILED(dr) )      {        return E_FAIL;      }    }    else /* No WMDRM song, No need to keep Media Session */    {      /* Close Media Session */      dr = WmdrmNet_TASK_transition( WMDRM_CLOSE_MEDIA_SESSION );      if ( DRM_FAILED(dr) )      {        return E_FAIL;      }    }#if 0    /* If WMA object has Time base seeking is supported. */    if ( IS_USBDeviceSupport_CtrlCapability )    {                                                                       ProximityContext.TimeOffset = 0;      dr = WmdrmNet_TASK_transition( WMDRM_SET_CURRENT_TIME_POSITION );      if ( DRM_FAILED(dr) )      {        return E_FAIL;      }    }#endif  }                    #endif      /* initialise internall buffer for WMA tag recognition */  buffer = tag_buf;#if (WMA_TAG_DEBUG != 0)  WMATagDecodeDBG.flag2 = 0;  WMATagDecodeDBG.flag3 = 0;  WMATagDecodeDBG.flag4 = 0;  WMATagDecodeDBG.flag5 = 0;#endif /*WMA_TAG_DEBUG*/  error = WMAParseASFheader(pInt, song_info);  if (error != S_OK)  {#if (WMA_TAG_DEBUG != 0)    WMATagDecodeDBG.flag2 = 1;#endif /*WMA_TAG_DEBUG*/    WMA_CloseTag(pInt);    return error;  }  error = WMA_CheckWma(pInt);  if (error != S_OK)  { /* is error in our case; don't len go on*/    WMA_CloseTag(pInt);    return error;  }#if (WMA_TAG_DEBUG != 0)  WMATagDecodeDBG.flag3 = 1;#endif /*WMA_TAG_DEBUG*/  error = WMA_ExtractTag(pInt);  if (error != S_OK)  { /* is error in our case; don't len go on*/    WMA_CloseTag(pInt);    return error;  }#if (WMA_TAG_DEBUG != 0)  WMATagDecodeDBG.flag4 = 1;#endif /*WMA_TAG_DEBUG*/  error = WMA_CloseTag(pInt);  if (error != S_OK)    return error;#if (WMA_TAG_DEBUG != 0)  WMATagDecodeDBG.flag5 = 1;#endif /*WMA_TAG_DEBUG*/  song_info->start_offset = pInt->cbHeader;   /* jump to end of the tag */  /* update info about track */  song_info->bitrate = pInt->nAvgBytesPerSec;  song_info->packet_size = pInt->cbPacketSize;  song_info->sampling_fr = pInt->nSamplesPerSec;  song_info->ch_num = pInt->nChannels;  return error;}#else /*HAVE_WMA*/tWMA_U32 WMAFileCBGetData(tHWMAFileState *state, tWMA_U64 offset, tWMA_U32 NB, unsigned char **ppData){}GRESULT WMA_TagDecode(t_SongInfos *song_info, uint32 count_down){  return E_FAIL;}tWMAFileStatus GetASFHeader(tWMAFileHdrStateInternal *pInt){  return cWMA_NoErr;}#endif /*HAVE_WMA*/

⌨️ 快捷键说明

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