Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/openrpc/the-spec/firebolt-app-open-rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,43 @@
}
]
},
{
"name": "Device.onDolbyAtmosExperienceAvailableChanged",
"summary": "Returns whether Dolby Atmos experience is available on the device",
"tags": [
{
"name": "notifier",
"x-notifier-for": "Device.dolbyAtmosExperienceAvailable",
"x-event": "Device.onDolbyAtmosExperienceAvailableChanged"
},
{
"name": "capabilities",
"x-uses": [
"xrn:firebolt:capability:device:info"
]
}
],
"params": [
{
"name": "dolbyAtmosExperienceAvailable",
"summary": "Whether Dolby Atmos experience is available on the device",
"schema": {
"type": "boolean"
}
}
],
"examples": [
{
"name": "Getting Dolby Atmos experience availability",
"params": [
{
"name": "dolbyAtmosExperienceAvailable",
"value": true
}
]
}
]
},
{
"name": "Network.onConnectedChanged",
"summary": "Returns whether the device currently has a usable network connection.",
Expand Down
91 changes: 91 additions & 0 deletions docs/openrpc/the-spec/firebolt-open-rpc--legacy.json
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,97 @@
}
]
},
{
"name": "Device.dolbyAtmosExperienceAvailable",
"summary": "Returns whether Dolby Atmos experience is available on the device",
"params": [],
"tags": [
{
"name": "property:readonly"
},
{
"name": "capabilities",
"x-uses": [
"xrn:firebolt:capability:device:info"
]
}
],
"result": {
"name": "dolbyAtmosExperienceAvailable",
"summary": "Whether Dolby Atmos experience is available on the device",
"schema": {
"type": "boolean"
}
},
"examples": [
{
"name": "Getting Dolby Atmos experience availability",
"params": [],
"result": {
"name": "Default Result",
"value": true
}
}
]
},
{
"name": "Device.onDolbyAtmosExperienceAvailableChanged",
"summary": "Returns whether Dolby Atmos experience is available on the device",
"params": [
{
"name": "listen",
"required": true,
"schema": {
"type": "boolean"
}
}
],
"tags": [
{
"name": "subscriber",
"x-subscriber-for": "Device.dolbyAtmosExperienceAvailable"
},
{
"name": "event",
"x-alternative": "dolbyAtmosExperienceAvailable"
},
{
"name": "capabilities",
"x-uses": [
"xrn:firebolt:capability:device:info"
]
}
],
"result": {
"name": "dolbyAtmosExperienceAvailable",
"summary": "Whether Dolby Atmos experience is available on the device",
"schema": {
"anyOf": [
{
"$ref": "#/x-schemas/Types/ListenResponse"
},
{
"type": "boolean"
}
]
}
},
"examples": [
{
"name": "Getting Dolby Atmos experience availability",
"params": [
{
"name": "listen",
"value": true
}
],
"result": {
"name": "Default Result",
"value": true
}
}
]
},
{
"name": "Discovery.watched",
"summary": "Notify the platform that content was partially or completely watched",
Expand Down
79 changes: 79 additions & 0 deletions docs/openrpc/the-spec/firebolt-open-rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,39 @@
}
]
},
{
"name": "Device.dolbyAtmosExperienceAvailable",
"summary": "Returns whether Dolby Atmos experience is available on the device",
"params": [],
"tags": [
{
"name": "property:readonly"
},
{
"name": "capabilities",
"x-uses": [
"xrn:firebolt:capability:device:info"
]
}
],
"result": {
"name": "dolbyAtmosExperienceAvailable",
"summary": "Whether Dolby Atmos experience is available on the device",
"schema": {
"type": "boolean"
}
},
"examples": [
{
"name": "Getting Dolby Atmos experience availability",
"params": [],
"result": {
"name": "Default Result",
"value": true
}
}
]
},
{
"name": "Discovery.watched",
"summary": "Notify the platform that content was partially or completely watched",
Expand Down Expand Up @@ -3245,6 +3278,52 @@
}
}
},
{
"name": "Device.onDolbyAtmosExperienceAvailableChanged",
"summary": "Returns whether Dolby Atmos experience is available on the device",
"params": [
{
"name": "listen",
"schema": {
"type": "boolean"
}
}
],
"tags": [
{
"name": "event",
"x-notifier": "Device.onDolbyAtmosExperienceAvailableChanged",
"x-subscriber-for": "Device.dolbyAtmosExperienceAvailable"
},
{
"name": "capabilities",
"x-uses": [
"xrn:firebolt:capability:device:info"
]
}
],
"examples": [
{
"name": "Getting Dolby Atmos experience availability",
"params": [
{
"name": "listen",
"value": true
}
],
"result": {
"name": "result",
"value": null
}
}
],
"result": {
"name": "result",
"schema": {
"type": "null"
}
}
},
{
"name": "Localization.onCountryChanged",
"tags": [
Expand Down
15 changes: 15 additions & 0 deletions include/firebolt/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ class IDevice
*/
virtual Result<uint32_t> uptime() const = 0;

/**
* @brief Returns whether Dolby Atmos experience is available on the device
*
* @retval True if Dolby Atmos experience is available, or error
*/
virtual Result<bool> dolbyAtmosExperienceAvailable() const = 0;

/**
* @brief Subscribe to Dolby Atmos experience availability changes
*
* @retval SubscriptionId or error
*/
virtual Result<SubscriptionId>
subscribeOnDolbyAtmosExperienceAvailableChanged(std::function<void(bool)>&& notification) = 0;

/**
* @brief Subscribe to HDR format changes
*
Expand Down
11 changes: 11 additions & 0 deletions src/device_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ Result<uint32_t> DeviceImpl::uptime() const
return helper_.get<Firebolt::JSON::Unsigned, uint32_t>("Device.uptime");
}

Result<bool> DeviceImpl::dolbyAtmosExperienceAvailable() const
{
return helper_.get<Firebolt::JSON::Boolean, bool>("Device.dolbyAtmosExperienceAvailable");
}

Result<SubscriptionId> DeviceImpl::subscribeOnDolbyAtmosExperienceAvailableChanged(std::function<void(bool)>&& notification)
{
return subscriptionManager_.subscribe<Firebolt::JSON::Boolean>("Device.onDolbyAtmosExperienceAvailableChanged",
std::move(notification));
}

Result<SubscriptionId> DeviceImpl::subscribeOnHdrChanged(std::function<void(const HDRFormat&)>&& notification)
{
return subscriptionManager_.subscribe<JsonData::HDRFormat>("Device.onHdrChanged", std::move(notification));
Expand Down
4 changes: 4 additions & 0 deletions src/device_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class DeviceImpl : public IDevice
Result<std::string> uid() const override;
Result<uint32_t> uptime() const override;

Result<bool> dolbyAtmosExperienceAvailable() const override;
Result<SubscriptionId>
subscribeOnDolbyAtmosExperienceAvailableChanged(std::function<void(bool)>&& notification) override;

Result<SubscriptionId> subscribeOnHdrChanged(std::function<void(const HDRFormat&)>&& notification) override;

Result<void> unsubscribe(SubscriptionId id) override;
Expand Down
9 changes: 9 additions & 0 deletions test/api_test_app/apis/deviceDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ DeviceDemo::DeviceDemo()
{
methods_.push_back("Device.chipsetId");
methods_.push_back("Device.deviceClass");
methods_.push_back("Device.dolbyAtmosExperienceAvailable");
methods_.push_back("Device.hdr");
methods_.push_back("Device.timeInActiveState");
methods_.push_back("Device.uid");
Expand Down Expand Up @@ -93,4 +94,12 @@ void DeviceDemo::runOption(const std::string& method)
std::cout << "Device Uptime (seconds): " << *r << std::endl;
}
}
else if (method == "Device.dolbyAtmosExperienceAvailable")
{
auto r = Firebolt::IFireboltAccessor::Instance().DeviceInterface().dolbyAtmosExperienceAvailable();
if (succeed(r))
{
std::cout << std::boolalpha << "Dolby Atmos Experience Available: " << *r << std::endl;
}
}
}
31 changes: 31 additions & 0 deletions test/component/deviceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,34 @@ TEST_F(DeviceCTest, SubscribeOnHdrChanged)
auto result = Firebolt::IFireboltAccessor::Instance().DeviceInterface().unsubscribe(id.value());
verifyUnsubscribeResult(result);
}

TEST_F(DeviceCTest, DolbyAtmosExperienceAvailable)
{
auto expectedValue = jsonEngine.get_value("Device.dolbyAtmosExperienceAvailable");
auto result = Firebolt::IFireboltAccessor::Instance().DeviceInterface().dolbyAtmosExperienceAvailable();
ASSERT_TRUE(result) << "DeviceImpl::dolbyAtmosExperienceAvailable() returned an error";
EXPECT_EQ(*result, expectedValue.get<bool>());
}

TEST_F(DeviceCTest, SubscribeOnDolbyAtmosExperienceAvailableChanged)
{
auto id = Firebolt::IFireboltAccessor::Instance().DeviceInterface().subscribeOnDolbyAtmosExperienceAvailableChanged(
[&](const bool& value)
{
std::cout << "[Subscription] Device Dolby Atmos experience availability changed" << std::endl;
EXPECT_EQ(value, true);
{
std::lock_guard<std::mutex> lock(mtx);
eventReceived = true;
}
cv.notify_one();
});

verifyEventSubscription(id);

triggerEvent("Device.onDolbyAtmosExperienceAvailableChanged", R"({ "value": true })");
verifyEventReceived(mtx, cv, eventReceived);

auto result = Firebolt::IFireboltAccessor::Instance().DeviceInterface().unsubscribe(id.value());
verifyUnsubscribeResult(result);
}
31 changes: 31 additions & 0 deletions test/unit/deviceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,34 @@ TEST_F(DeviceUTest, SubscribeOnHdrChanged)

deviceImpl_.unsubscribe(*result);
}

TEST_F(DeviceUTest, DolbyAtmosExperienceAvailable)
{
mock("Device.dolbyAtmosExperienceAvailable");
auto expectedValue = jsonEngine.get_value("Device.dolbyAtmosExperienceAvailable");

auto result = deviceImpl_.dolbyAtmosExperienceAvailable();
ASSERT_TRUE(result) << "DeviceImpl::dolbyAtmosExperienceAvailable() returned an error";

EXPECT_EQ(*result, expectedValue.get<bool>());
}

TEST_F(DeviceUTest, DolbyAtmosExperienceAvailableBadResponse)
{
mock_with_response("Device.dolbyAtmosExperienceAvailable", "invalid_response");
ASSERT_FALSE(deviceImpl_.dolbyAtmosExperienceAvailable())
<< "DeviceImpl::dolbyAtmosExperienceAvailable() did not return an error";
}

TEST_F(DeviceUTest, SubscribeOnDolbyAtmosExperienceAvailableChanged)
{
nlohmann::json expectedValue = 1;
mockSubscribe("Device.onDolbyAtmosExperienceAvailableChanged");

auto result = deviceImpl_.subscribeOnDolbyAtmosExperienceAvailableChanged([&](const bool& /*value*/) {});

ASSERT_TRUE(result) << "DeviceImpl::subscribeOnDolbyAtmosExperienceAvailableChanged() returned an error";
EXPECT_EQ(*result, expectedValue);

deviceImpl_.unsubscribe(*result);
}
Loading