id3_tag.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // The authors have released ID3Lib as Public Domain (PD) and claim no copyright,
  2. // patent or other intellectual property protection in this work. This means that
  3. // it may be modified, redistributed and used in commercial and non-commercial
  4. // software and hardware without restrictions. ID3Lib is distributed on an "AS IS"
  5. // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
  6. //
  7. // The ID3Lib authors encourage improvements and optimisations to be sent to the
  8. // ID3Lib coordinator, currently Dirk Mahoney ([email protected]). Approved
  9. // submissions may be altered, and will be included and released under these terms.
  10. //
  11. // Mon Nov 23 18:34:01 1998
  12. #ifndef ID3LIB_TAG_H
  13. #define ID3LIB_TAG_H
  14. #include <windows.h>
  15. #include <wchar.h>
  16. #include <stdio.h>
  17. #include "id3_types.h"
  18. #include "id3_frame.h"
  19. #include "id3_header_frame.h"
  20. #include "id3_header_tag.h"
  21. #include "id3_version.h"
  22. // for file buffers etc
  23. #define BUFF_SIZE (65536)
  24. struct ID3_Elem
  25. {
  26. ID3_Elem *next;
  27. ID3_Frame *frame;
  28. uchar *binary;
  29. size_t binarySize;
  30. bool tagOwns;
  31. };
  32. class ID3_Tag
  33. {
  34. public:
  35. ID3_Tag();
  36. ~ID3_Tag(void);
  37. void Clear(void);
  38. bool HasChanged(void);
  39. void SetUnsync(bool newSync);
  40. void SetExtendedHeader(bool ext);
  41. void SetCompression(bool comp);
  42. void SetPadding(bool pad);
  43. void ForcePading(luint _padding);
  44. void AddFrame(ID3_Frame *newFrame, bool freeWhenDone = false);
  45. void RemoveFrame(ID3_Frame *oldFrame);
  46. luint Render(uchar *buffer);
  47. luint Size(void);
  48. void Parse(const uchar header[ID3_TAGHEADERSIZE], const uchar *buffer);
  49. ID3_Frame *Find(ID3_FrameID id);
  50. ID3_Frame *Find(ID3_FrameID id, ID3_FieldID fld, luint data);
  51. ID3_Frame *Find(ID3_FrameID id, ID3_FieldID fld, const wchar_t *data);
  52. ID3_Frame *Find(ID3_FrameID id, ID3_FieldID fld, const char *data);
  53. luint NumFrames(void);
  54. ID3_Frame *GetFrameNum(luint num);
  55. ID3_Frame *operator[] (luint num);
  56. // *** PRIVATE INTERNAL DATA - DO NOT USE *** PRIVATE INTERNAL DATA - DO NOT USE ***
  57. void SetupTag();
  58. void SetVersion(uchar ver, uchar rev);
  59. void ClearList(ID3_Elem *list);
  60. void DeleteElem(ID3_Elem *cur);
  61. void AddBinary(const uchar *buffer, luint size);
  62. void ExpandBinaries(const uchar *buffer, luint size);
  63. void ProcessBinaries(ID3_FrameID whichFrame = ID3FID_NOFRAME, bool attach = true); // this default means all frames
  64. void RemoveFromList(ID3_Elem *which, ID3_Elem **list);
  65. ID3_Elem *GetLastElem(ID3_Elem *list);
  66. ID3_Elem *Find(ID3_Frame *frame);
  67. luint PaddingSize(luint curSize);
  68. void RenderExtHeader(uchar *buffer);
  69. luint GetUnSyncSize (uchar *buffer, luint size);
  70. void UnSync (uchar *destData, luint destSize, uchar *sourceData, luint sourceSize);
  71. luint ReSync (uchar *binarySourceData, luint sourceSize);
  72. uchar version; // what version tag?
  73. uchar revision; // what revision tag?
  74. ID3_Elem *frameList; // the list of known frames currently attached to this tag
  75. ID3_Elem *binaryList; // the list of yet-to-be-parsed frames currently attached to this tag
  76. ID3_Elem *findCursor; // on which element in the frameList are we currently positioned?
  77. bool syncOn; // should we unsync this tag when rendering?
  78. bool compression; // should we compress frames when rendering?
  79. bool padding; // add padding to tags?
  80. bool extendedHeader; // create an extended header when rendering?
  81. bool hasChanged; // has the tag changed since the last parse or render?
  82. //FILE *fileHandle; // a handle to the file we are linked to
  83. luint forcedPadding;
  84. bool globalUnsync; // did the header indicate that all frames are unsync'd?
  85. static luint instances; // how many ID3_Tag objects are floating around in this app?
  86. ID3_Quirks quirks;
  87. uchar *syncBuffer; // so we don't destroy someone else's data when we unsynchronize
  88. };
  89. ID3_Tag& operator<< (ID3_Tag& tag, ID3_Frame& frame);
  90. ID3_Tag& operator<< (ID3_Tag& tag, ID3_Frame *frame);
  91. #endif