1
0

Metadata.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef NULLSOFT_IN_MP3_METADATA
  2. #define NULLSOFT_IN_MP3_METADATA
  3. #include "giofile.h"
  4. #include "ID3v1.h"
  5. #include "ID3v2.h"
  6. #include "Lyrics3.h"
  7. #include "apev2.h"
  8. enum
  9. {
  10. METADATA_SUCCESS = 0,
  11. SAVE_SUCCESS = 0,
  12. SAVE_ERROR_OPENING_FILE = 1,
  13. SAVE_ID3V1_WRITE_ERROR = 2,
  14. SAVE_ID3V2_WRITE_ERROR = 3,
  15. SAVE_ERROR_READONLY = 4,
  16. SAVE_ERROR_CANT_OPEN_TEMPFILE = 5,
  17. SAVE_ERROR_ERROR_OVERWRITING = 6,
  18. SAVE_LYRICS3_WRITE_ERROR = 7,
  19. SAVE_APEV2_WRITE_ERROR = 8,
  20. };
  21. class Metadata
  22. {
  23. public:
  24. Metadata() {}
  25. Metadata(CGioFile *_file, const wchar_t *_filename);
  26. ~Metadata();
  27. int Open(const wchar_t *filename);
  28. int GetExtendedData(const char *tag, wchar_t *data, int dataLen);
  29. int SetExtendedData(const char *tag, const wchar_t *data);
  30. int Save();
  31. bool IsMe(const wchar_t *fn) { return filename && !_wcsicmp(filename, fn); }
  32. void AddRef() { InterlockedIncrement(&refs); }
  33. void Release() { if(!InterlockedDecrement(&refs)) delete this; }
  34. private:
  35. bool IsDirty();
  36. void ReadTags(CGioFile *_file);
  37. int GetString(const char *tag, wchar_t *data, int dataLen);
  38. int sampleRate = 0;
  39. int bitrate = 0;
  40. int vbr = 0;
  41. int channels = 0;
  42. int length_ms = 0;
  43. CGioFile file;
  44. public:
  45. ID3v1 id3v1;
  46. ID3v2 id3v2;
  47. Lyrics3 lyrics3;
  48. APE apev2;
  49. wchar_t *filename = 0;
  50. protected:
  51. volatile LONG refs = 1;
  52. };
  53. #endif