ifc_metadata.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "foundation/dispatch.h"
  3. #include "nx/nxstring.h"
  4. #include "nx/nxdata.h"
  5. #include "foundation/error.h"
  6. #include "metadata/MetadataKeys.h"
  7. #include "metadata/types.h"
  8. class NOVTABLE ifc_metadata : public Wasabi2::Dispatchable
  9. {
  10. protected:
  11. ifc_metadata() : Dispatchable(DISPATCHABLE_VERSION) {}
  12. public:
  13. virtual ~ifc_metadata() {}
  14. enum
  15. {
  16. INDEX_DEFAULT = -1,
  17. };
  18. /* Fields */
  19. ns_error_t GetField(int field, unsigned int index, nx_string_t *value) { return Metadata_GetField(field, index, value); }
  20. ns_error_t GetInteger(int field, unsigned int index, int64_t *value) { return Metadata_GetInteger(field, index, value); }
  21. ns_error_t GetReal(int field, unsigned int index, double *value) { return Metadata_GetReal(field, index, value); }
  22. ns_error_t SetField(int field, unsigned int index, nx_string_t value) { return Metadata_SetField(field, index, value); }
  23. ns_error_t SetInteger(int field, unsigned int index, int64_t value) { return Metadata_SetInteger(field, index, value); }
  24. ns_error_t SetReal(int field, unsigned int index, double value) { return Metadata_SetReal(field, index, value); }
  25. /* Art */
  26. ns_error_t GetArtwork(int field, unsigned int index, artwork_t *artwork, data_flags_t flags=DATA_FLAG_ALL) { return Metadata_GetArtwork(field, index, artwork, flags); }
  27. /* Binary Data */
  28. ns_error_t GetBinary(int field, unsigned int index, nx_data_t *data) { return Metadata_GetBinary(field, index, data); }
  29. /* sub-tracks */
  30. ns_error_t GetMetadata(int field, unsigned int index, ifc_metadata **metadata) { return Metadata_GetMetadata(field, index, metadata); }
  31. ns_error_t Serialize(nx_data_t *data) { return Metadata_Serialize(data); }
  32. enum
  33. {
  34. DISPATCHABLE_VERSION,
  35. };
  36. protected:
  37. virtual ns_error_t WASABICALL Metadata_GetField(int field, unsigned int index, nx_string_t *value)=0;
  38. virtual ns_error_t WASABICALL Metadata_GetInteger(int field, unsigned int index, int64_t *value)=0;
  39. virtual ns_error_t WASABICALL Metadata_GetReal(int field, unsigned int index, double *value)=0;
  40. virtual ns_error_t WASABICALL Metadata_SetField(int field, unsigned int index, nx_string_t value){ return NErr_NotImplemented; };
  41. virtual ns_error_t WASABICALL Metadata_SetInteger(int field, unsigned int index, int64_t value){ return NErr_NotImplemented; };
  42. virtual ns_error_t WASABICALL Metadata_SetReal(int field, unsigned int index, double value){ return NErr_NotImplemented; };
  43. /* notes:
  44. passing NULL for any of the pointers (most notably, data) indicates that it's not needed
  45. width and height aren't guaranteed to be actually accurate. they will be set only if it was marked in the file, otherwise they will be set to 0
  46. mime_type might also come back as 0 if it wasn't stored in the metadata. and again, mime_type isn't guaranteed to be accurate
  47. for type, MetadataKeys::ALBUM is for album art. use Metadata::UNKNOWN for unknown types, such as id3v2 tags with Picture types marked as "other" ($00)
  48. index should be as stored in the file, do not re-arrange. */
  49. virtual ns_error_t WASABICALL Metadata_GetArtwork(int field, unsigned int index, artwork_t *artwork, data_flags_t flags)=0;
  50. virtual ns_error_t WASABICALL Metadata_GetBinary(int field, unsigned int index, nx_data_t *data)=0;
  51. virtual ns_error_t WASABICALL Metadata_GetMetadata(int field, unsigned int index, ifc_metadata **metadata) { return NErr_NotImplemented; }
  52. virtual ns_error_t WASABICALL Metadata_Serialize(nx_data_t *data) { return NErr_NotImplemented; }
  53. };