CSpotContext.h 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <memory>
  3. #include "MercurySession.h"
  4. #include "TimeProvider.h"
  5. #include "protobuf/metadata.pb.h"
  6. namespace cspot {
  7. struct Context {
  8. struct ConfigState {
  9. // Setup default bitrate to 160
  10. AudioFormat audioFormat = AudioFormat::AudioFormat_OGG_VORBIS_160;
  11. std::string deviceId;
  12. std::string deviceName;
  13. int volume;
  14. std::string username;
  15. std::string countryCode;
  16. };
  17. ConfigState config;
  18. std::shared_ptr<TimeProvider> timeProvider;
  19. std::shared_ptr<cspot::MercurySession> session;
  20. static std::shared_ptr<Context> createFromBlob(std::shared_ptr<LoginBlob> blob) {
  21. auto ctx = std::make_shared<Context>();
  22. ctx->timeProvider = std::make_shared<TimeProvider>();
  23. ctx->session = std::make_shared<MercurySession>(ctx->timeProvider);
  24. ctx->config.deviceId = blob->getDeviceId();
  25. ctx->config.deviceName = blob->getDeviceName();
  26. ctx->config.volume = 0;
  27. ctx->config.username = blob->getUserName();
  28. return ctx;
  29. }
  30. };
  31. } // namespace cspot