GenericTypes.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2022, Lucas Chollet <lucas.chollet@free.fr>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/String.h>
  8. #include <AK/Vector.h>
  9. namespace Audio {
  10. // 11.20. PICTURE_TYPE (in Flac specification)
  11. enum class ID3PictureType : u32 {
  12. Other = 0,
  13. FileIcon = 1,
  14. OtherFileIcon = 2,
  15. FrontCover = 3,
  16. BackCover = 4,
  17. LeafletPage = 5,
  18. Media = 6,
  19. LeadArtist = 7,
  20. Artist = 8,
  21. Conductor = 9,
  22. Band = 10,
  23. Composer = 11,
  24. Lyricist = 12,
  25. RecordingLocation = 13,
  26. DuringRecording = 14,
  27. DuringPerformance = 15,
  28. MovieScreenCapture = 16,
  29. BrightColouredFish = 17,
  30. Illustration = 18,
  31. BandLogoType = 19,
  32. PublisherLogoType = 20,
  33. // others are reserved
  34. };
  35. // Note: This was first implemented for Flac but is compatible with ID3v2
  36. struct PictureData {
  37. ID3PictureType type {};
  38. String mime_string {};
  39. String description_string {};
  40. u32 width {};
  41. u32 height {};
  42. u32 color_depth {};
  43. u32 colors {};
  44. Vector<u8> data;
  45. };
  46. // A generic sample seek point within a file.
  47. struct SeekPoint {
  48. u64 sample_index;
  49. u64 byte_offset;
  50. };
  51. class SeekTable {
  52. public:
  53. Optional<SeekPoint const&> seek_point_before(u64 sample_index) const;
  54. // Returns the distance between the closest two seek points around the sample index.
  55. // The lower seek point may be exactly at the sample index, but the upper seek point must be after the sample index.
  56. Optional<u64> seek_point_sample_distance_around(u64 sample_index) const;
  57. size_t size() const;
  58. ReadonlySpan<SeekPoint> seek_points() const;
  59. Vector<SeekPoint>& seek_points();
  60. ErrorOr<void> insert_seek_point(SeekPoint);
  61. private:
  62. // Invariant: The list of seek points is always sorted.
  63. // This makes all operations, such as inserting and searching, faster.
  64. Vector<SeekPoint> m_seek_points;
  65. };
  66. }