mp3_tag.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * SPDX-License-Identifier: Apache-2.0
  3. *
  4. * Date Author Notes
  5. * 2021-06-02 MrzhangF1ghter first implementation
  6. */
  7. #ifndef __MP3_TAG_H__
  8. #define __MP3_TAG_H__
  9. #include <stdint.h>
  10. #include <stdio.h>
  11. #include "mp3_player.h"
  12. #define TITLE_LEN_MAX 30
  13. #define ARTIST_LEN_MAX 30
  14. #define ALBUM_LEN_MAX 30
  15. /*
  16. * ID3V1 TAG
  17. */
  18. typedef struct
  19. {
  20. uint8_t id[3];
  21. uint8_t title[30];
  22. uint8_t artist[30];
  23. uint8_t year[4];
  24. uint8_t comment[30];
  25. uint8_t genre;
  26. } ID3V1_Tag_t;
  27. /*
  28. * ID3V2 TAG header
  29. */
  30. typedef struct
  31. {
  32. uint8_t id[3];
  33. uint8_t mversion;
  34. uint8_t sversion;
  35. uint8_t flags;
  36. uint8_t size[4];
  37. } ID3V2_TagHead_t;
  38. /*
  39. * ID3V2.3 TAG header
  40. */
  41. typedef struct
  42. {
  43. uint8_t id[4];
  44. uint8_t size[4];
  45. uint16_t flags;
  46. } ID3V23_FrameHead_t;
  47. /*
  48. * MP3 Xing Frame
  49. */
  50. typedef struct
  51. {
  52. uint8_t id[4];
  53. uint8_t flags[4];
  54. uint8_t frames[4];
  55. uint8_t fsize[4];
  56. } MP3_FrameXing_t;
  57. /*
  58. * MP3 VBRI Frame
  59. */
  60. typedef struct
  61. {
  62. uint8_t id[4]; /* frame id:Xing/Info */
  63. uint8_t version[2]; /* VBRI Version */
  64. uint8_t delay[2]; /* delay */
  65. uint8_t quality[2]; /* audio quality,0~100 */
  66. uint8_t fsize[4]; /* file size */
  67. uint8_t frames[4]; /* total frame */
  68. } MP3_FrameVBRI_t;
  69. /**
  70. * @description: Get genre string by genre id
  71. * @param {uint16_t} genre_id [0,147]
  72. * @return {char *} genre string
  73. */
  74. char *mp3_get_genre_string_by_id(uint16_t genre_id);
  75. /**
  76. * @description: get mp3 tag info
  77. * @param {struct mp3_player} *player
  78. * @return the error code,0 on success
  79. */
  80. rt_err_t mp3_get_info(struct mp3_player *player);
  81. /**
  82. * @description: print mp3 info
  83. * @param {mp3_info_t} mp3_info
  84. * @return the error code,0 on success
  85. */
  86. rt_err_t mp3_info_print(mp3_info_t mp3_info);
  87. #endif