GenericTypes.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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/DeprecatedString.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. DeprecatedString mime_string {};
  39. Vector<u32> 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. ErrorOr<void> insert_seek_point(SeekPoint);
  60. private:
  61. // Invariant: The list of seek points is always sorted.
  62. // This makes all operations, such as inserting and searching, faster.
  63. Vector<SeekPoint> m_seek_points;
  64. };
  65. }