data_audio_msg_id.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. class DocumentData;
  9. class AudioMsgId final {
  10. public:
  11. enum class Type {
  12. Unknown,
  13. Voice,
  14. Song,
  15. Video,
  16. };
  17. AudioMsgId();
  18. AudioMsgId(
  19. not_null<DocumentData*> audio,
  20. FullMsgId msgId,
  21. uint32 externalPlayId = 0);
  22. [[nodiscard]] static uint32 CreateExternalPlayId();
  23. [[nodiscard]] static AudioMsgId ForVideo();
  24. [[nodiscard]] Type type() const;
  25. [[nodiscard]] DocumentData *audio() const;
  26. [[nodiscard]] FullMsgId contextId() const;
  27. [[nodiscard]] uint32 externalPlayId() const;
  28. [[nodiscard]] bool changeablePlaybackSpeed() const;
  29. [[nodiscard]] explicit operator bool() const;
  30. bool operator<(const AudioMsgId &other) const;
  31. bool operator==(const AudioMsgId &other) const;
  32. bool operator!=(const AudioMsgId &other) const;
  33. private:
  34. void setTypeFromAudio();
  35. DocumentData *_audio = nullptr;
  36. Type _type = Type::Unknown;
  37. FullMsgId _contextId;
  38. uint32 _externalPlayId = 0;
  39. bool _changeablePlaybackSpeed = false;
  40. };