summaryrefslogtreecommitdiff
path: root/src/bt.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-10-20 21:29:01 +0200
committerJoel Klinghed <the_jk@spawned.biz>2025-10-20 21:29:01 +0200
commite8dc8edad7cdf194091f0479b70b154e872f57ef (patch)
tree5431680ce100812b9b3bea32a7847e7dcfdcf29d /src/bt.hh
parent0687ec31d1d75500beaee0e983ebf73d7c4517f7 (diff)
bt & main: Add optional player for device
Diffstat (limited to 'src/bt.hh')
-rw-r--r--src/bt.hh47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/bt.hh b/src/bt.hh
index 588a328..bc7cd84 100644
--- a/src/bt.hh
+++ b/src/bt.hh
@@ -23,6 +23,7 @@ class Config;
namespace bt {
class Device;
+class Player;
class Adapter {
public:
@@ -84,12 +85,51 @@ class Device {
[[nodiscard]]
virtual bool connected() const = 0;
+ // Returns null if there are no players.
+ // Otherwise, returns the "primary" player.
+ [[nodiscard]]
+ virtual Player* player() const = 0;
+
protected:
Device() = default;
Device(Device const&) = delete;
Device& operator=(Device const&) = delete;
};
+class Player {
+ public:
+ virtual ~Player() = default;
+
+ enum class Status : uint8_t {
+ kPlaying,
+ kStopped,
+ kPaused,
+ kForwardSeek,
+ kReverseSeek,
+ kError,
+ };
+
+ [[nodiscard]]
+ virtual Status status() const = 0;
+
+ [[nodiscard]]
+ virtual std::string const& track_title() const = 0;
+
+ [[nodiscard]]
+ virtual std::string const& track_artist() const = 0;
+
+ [[nodiscard]]
+ virtual std::string const& track_album() const = 0;
+
+ virtual void play() = 0;
+ virtual void pause() = 0;
+
+ protected:
+ Player() = default;
+ Player(Player const&) = delete;
+ Player& operator=(Player const&) = delete;
+};
+
class Manager {
public:
virtual ~Manager() = default;
@@ -110,6 +150,13 @@ class Manager {
// Called when device changes a property.
virtual void updated_device(Device& /* device */) {}
+ // Called when a new player is added to a device.
+ virtual void added_player(Device& /* device */, Player& /* player */) {}
+ // Called when a player was removed from a device.
+ virtual void removed_player(Device& /* device */) {}
+ // Called when a device player changes a property.
+ virtual void updated_player(Device& /* device */, Player& /* player */) {}
+
virtual void agent_request_pincode(
Device& device,
std::function<void(std::optional<std::string>)> callback) = 0;