Skip to content

Commit

Permalink
Merge f31ce97 into 3a617aa
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdecenzo authored Dec 24, 2021
2 parents 3a617aa + f31ce97 commit 1550508
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 108 deletions.
21 changes: 0 additions & 21 deletions examples/tv-app/linux/AppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,6 @@ DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs),
// Declare Content App endpoint
DECLARE_DYNAMIC_ENDPOINT(contentAppEndpoint, contentAppClusters);

ContentAppImpl::ContentAppImpl(const char * szVendorName, uint16_t vendorId, const char * szApplicationName, uint16_t productId,
const char * szApplicationVersion)
{
mApplicationBasic.SetApplicationName(szApplicationName);
mApplicationBasic.SetVendorName(szApplicationName);
mApplicationBasic.SetVendorId(vendorId);
mApplicationBasic.SetProductId(productId);
mApplicationBasic.SetApplicationVersion(szApplicationVersion);
}

void ApplicationBasicImpl::SetApplicationName(const char * szApplicationName)
{
ChipLogProgress(DeviceLayer, "ApplicationBasic[%s]: Application Name=\"%s\"", szApplicationName, szApplicationName);
Expand Down Expand Up @@ -206,17 +196,6 @@ ApplicationLauncherResponse ApplicationLauncherImpl::LaunchApp(Application appli
return response;
}

LaunchResponse ContentLauncherImpl::LaunchContent(std::list<Parameter> parameterList, bool autoplay, std::string data)
{
ChipLogProgress(DeviceLayer, "ContentLauncherImpl: LaunchContent autoplay=%d data=\"%s\"", autoplay ? 1 : 0, data.c_str());

LaunchResponse response;
response.err = CHIP_NO_ERROR;
response.data = "Example app data";
response.status = chip::app::Clusters::ContentLauncher::StatusEnum::kSuccess;
return response;
}

ContentAppFactoryImpl::ContentAppFactoryImpl()
{
mContentApps[1].GetAccountLogin()->SetSetupPIN(34567890);
Expand Down
33 changes: 20 additions & 13 deletions examples/tv-app/linux/AppImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <stdbool.h>
#include <stdint.h>

#include "include/content-launcher/ContentLauncherManager.h"

#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED

namespace chip {
Expand Down Expand Up @@ -103,16 +105,6 @@ class DLL_EXPORT ApplicationLauncherImpl : public ApplicationLauncher
protected:
};

class DLL_EXPORT ContentLauncherImpl : public ContentLauncher
{
public:
virtual ~ContentLauncherImpl() {}

LaunchResponse LaunchContent(std::list<Parameter> parameterList, bool autoplay, std::string data) override;

protected:
};

class DLL_EXPORT MediaPlaybackImpl : public MediaPlayback
{
public:
Expand Down Expand Up @@ -142,27 +134,42 @@ class DLL_EXPORT ContentAppImpl : public ContentApp
{
public:
ContentAppImpl(const char * szVendorName, uint16_t vendorId, const char * szApplicationName, uint16_t productId,
const char * szApplicationVersion);
const char * szApplicationVersion) :
mContentLauncherDelegate({ "image/*", "video/*" },
static_cast<uint32_t>(chip::app::Clusters::ContentLauncher::SupportedStreamingProtocol::kDash) |
static_cast<uint32_t>(chip::app::Clusters::ContentLauncher::SupportedStreamingProtocol::kHls))
{
mApplicationBasic.SetApplicationName(szApplicationName);
mApplicationBasic.SetVendorName(szApplicationName);
mApplicationBasic.SetVendorId(vendorId);
mApplicationBasic.SetProductId(productId);
mApplicationBasic.SetApplicationVersion(szApplicationVersion);
};
virtual ~ContentAppImpl() {}

inline ApplicationBasic * GetApplicationBasic() override { return &mApplicationBasic; };
inline AccountLogin * GetAccountLogin() override { return &mAccountLogin; };
inline KeypadInput * GetKeypadInput() override { return &mKeypadInput; };
inline ApplicationLauncher * GetApplicationLauncher() override { return &mApplicationLauncher; };
inline ContentLauncher * GetContentLauncher() override { return &mContentLauncher; };
inline MediaPlayback * GetMediaPlayback() override { return &mMediaPlayback; };
inline TargetNavigator * GetTargetNavigator() override { return &mTargetNavigator; };
inline Channel * GetChannel() override { return &mChannel; };

inline chip::app::Clusters::ContentLauncher::Delegate * GetContentLauncherDelegate() override
{
return &mContentLauncherDelegate;
};

protected:
ApplicationBasicImpl mApplicationBasic;
AccountLoginImpl mAccountLogin;
KeypadInputImpl mKeypadInput;
ApplicationLauncherImpl mApplicationLauncher;
ContentLauncherImpl mContentLauncher;
MediaPlaybackImpl mMediaPlayback;
TargetNavigatorImpl mTargetNavigator;
ChannelImpl mChannel;

ContentLauncherManager mContentLauncherDelegate;
};

class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,18 @@
using namespace std;
using namespace chip::AppPlatform;

ContentLauncherManager::ContentLauncherManager(std::list<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols)
{
mAcceptHeaderList = acceptHeaderList;
mSupportedStreamingProtocols = supportedStreamingProtocols;
}

LaunchResponse ContentLauncherManager::HandleLaunchContent(chip::EndpointId endpointId, const std::list<Parameter> & parameterList,
bool autoplay, const chip::CharSpan & data)
{
ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchContent ");
string dataString(data.data(), data.size());

#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ContentApp * app = chip::AppPlatform::AppPlatform::GetInstance().GetContentAppByEndpointId(endpointId);
if (app != NULL)
{
return app->GetContentLauncher()->LaunchContent(parameterList, autoplay, dataString);
}
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED

// TODO: Insert code here
LaunchResponse response;
response.err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -79,12 +77,11 @@ LaunchResponse ContentLauncherManager::HandleLaunchUrl(const chip::CharSpan & co
std::list<std::string> ContentLauncherManager::HandleGetAcceptHeaderList()
{
ChipLogProgress(Zcl, "ContentLauncherManager::HandleGetAcceptHeaderList");
return { "example", "example" };
return mAcceptHeaderList;
}

uint32_t ContentLauncherManager::HandleGetSupportedStreamingProtocols()
{
ChipLogProgress(Zcl, "ContentLauncherManager::HandleGetSupportedStreamingProtocols");
uint32_t streamingProtocols = 0;
return streamingProtocols;
return mSupportedStreamingProtocols;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@
class ContentLauncherManager : public chip::app::Clusters::ContentLauncher::Delegate
{
public:
ContentLauncherManager() : ContentLauncherManager({ "example", "example" }, 0){};
ContentLauncherManager(std::list<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols);

LaunchResponse HandleLaunchContent(chip::EndpointId endpointId, const std::list<Parameter> & parameterList, bool autoplay,
const chip::CharSpan & data) override;
LaunchResponse HandleLaunchUrl(const chip::CharSpan & contentUrl, const chip::CharSpan & displayString,
const std::list<BrandingInformation> & brandingInformation) override;
std::list<std::string> HandleGetAcceptHeaderList() override;
uint32_t HandleGetSupportedStreamingProtocols() override;

protected:
std::list<std::string> mAcceptHeaderList;
uint32_t mSupportedStreamingProtocols;
};
5 changes: 2 additions & 3 deletions examples/tv-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * comm

namespace {
static ContentLauncherManager contentLauncherManager;
constexpr chip::EndpointId kContentLauncherEndpoint = 1;
} // namespace

void ApplicationInit() {}
Expand Down Expand Up @@ -121,6 +120,6 @@ int main(int argc, char * argv[])

void emberAfContentLauncherClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: ContentLauncherManager::SetDelegate");
chip::app::Clusters::ContentLauncher::SetDelegate(kContentLauncherEndpoint, &contentLauncherManager);
ChipLogProgress(Zcl, "TV Linux App: ContentLauncherManager::SetDefaultDelegate");
chip::app::Clusters::ContentLauncher::SetDefaultDelegate(&contentLauncherManager);
}
28 changes: 16 additions & 12 deletions src/app/clusters/content-launch-server/content-launch-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/data-model/Encode.h>
#include <app/util/ContentAppPlatform.h>
#include <app/util/af.h>
#include <app/util/attribute-storage.h>
#include <list>
Expand All @@ -59,15 +60,25 @@ using namespace chip::app;
// Delegate Implementation

using chip::app::Clusters::ContentLauncher::Delegate;
using namespace chip::AppPlatform;

namespace {

Delegate * gDelegateTable[EMBER_AF_CONTENT_LAUNCH_CLUSTER_SERVER_ENDPOINT_COUNT] = { nullptr };
Delegate * gDelegate = NULL;

Delegate * GetDelegate(EndpointId endpoint)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, chip::app::Clusters::ContentLauncher::Id);
return (ep == 0xFFFF ? NULL : gDelegateTable[ep]);
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ContentApp * app = chip::AppPlatform::AppPlatform::GetInstance().GetContentAppByEndpointId(endpoint);
if (app != NULL && app->GetContentLauncherDelegate() != NULL)
{
ChipLogError(Zcl, "Content Launcher returning ContentApp delegate for endpoint:%" PRIu16, endpoint);
return app->GetContentLauncherDelegate();
}
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
ChipLogError(Zcl, "Content Launcher NOT returning ContentApp delegate for endpoint:%" PRIu16, endpoint);

return gDelegate;
}

bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
Expand All @@ -86,16 +97,9 @@ namespace app {
namespace Clusters {
namespace ContentLauncher {

void SetDelegate(EndpointId endpoint, Delegate * delegate)
void SetDefaultDelegate(Delegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, chip::app::Clusters::ContentLauncher::Id);
if (ep != 0xFFFF)
{
gDelegateTable[ep] = delegate;
}
else
{
}
gDelegate = delegate;
}

} // namespace ContentLauncher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace app {
namespace Clusters {
namespace ContentLauncher {

void SetDelegate(EndpointId endpoint, Delegate * delegate);
void SetDefaultDelegate(Delegate * delegate);

} // namespace ContentLauncher
} // namespace Clusters
Expand Down
35 changes: 9 additions & 26 deletions src/app/util/ContentApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

/**
* @file Contains shell commands for a commissionee (eg. end device) related to commissioning.
* @file Contains shell commands for a ContentApp relating to Content App platform of the Video Player.
*/

#include <app-common/zap-generated/attribute-id.h>
Expand Down Expand Up @@ -46,20 +46,18 @@ namespace AppPlatform {
EmberAfStatus ContentApp::HandleReadAttribute(ClusterId clusterId, chip::AttributeId attributeId, uint8_t * buffer,
uint16_t maxReadLength)
{
ChipLogProgress(DeviceLayer, "Read Attribute for device %s cluster %d attribute=%d)",
GetApplicationBasic()->GetApplicationName(), static_cast<uint16_t>(clusterId),
static_cast<uint16_t>(attributeId));
ChipLogProgress(DeviceLayer, "Read Attribute for device %s cluster " ChipLogFormatMEI " attribute=" ChipLogFormatMEI,
GetApplicationBasic()->GetApplicationName(), ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId));

EmberAfStatus ret = EMBER_ZCL_STATUS_FAILURE;
if (clusterId == ZCL_APPLICATION_BASIC_CLUSTER_ID)
{
ret = GetApplicationBasic()->HandleReadAttribute(attributeId, buffer, maxReadLength);
return GetApplicationBasic()->HandleReadAttribute(attributeId, buffer, maxReadLength);
}
if (clusterId == ZCL_ACCOUNT_LOGIN_CLUSTER_ID)
{
ret = GetAccountLogin()->HandleReadAttribute(attributeId, buffer, maxReadLength);
return GetAccountLogin()->HandleReadAttribute(attributeId, buffer, maxReadLength);
}
return ret;
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus ContentApp::HandleWriteAttribute(ClusterId clusterId, chip::AttributeId attributeId, uint8_t * buffer)
Expand All @@ -68,17 +66,15 @@ EmberAfStatus ContentApp::HandleWriteAttribute(ClusterId clusterId, chip::Attrib
GetApplicationBasic()->GetApplicationName(), static_cast<uint16_t>(clusterId),
static_cast<uint16_t>(attributeId));

EmberAfStatus ret = EMBER_ZCL_STATUS_FAILURE;

if (clusterId == ZCL_APPLICATION_BASIC_CLUSTER_ID)
{
ret = GetApplicationBasic()->HandleWriteAttribute(attributeId, buffer);
return GetApplicationBasic()->HandleWriteAttribute(attributeId, buffer);
}
if (clusterId == ZCL_ACCOUNT_LOGIN_CLUSTER_ID)
{
ret = GetAccountLogin()->HandleWriteAttribute(attributeId, buffer);
return GetAccountLogin()->HandleWriteAttribute(attributeId, buffer);
}
return ret;
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus ApplicationBasic::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
Expand Down Expand Up @@ -186,19 +182,6 @@ EmberAfStatus ApplicationLauncher::HandleWriteAttribute(chip::AttributeId attrib
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus ContentLauncher::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
{
ChipLogProgress(DeviceLayer, "ContentLauncher::HandleReadAttribute: attrId=%d, maxReadLength=%d",
static_cast<uint16_t>(attributeId), maxReadLength);
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus ContentLauncher::HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer)
{
ChipLogProgress(DeviceLayer, "ContentLauncher::HandleWriteAttribute: attrId=%d", static_cast<uint16_t>(attributeId));
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus MediaPlayback::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
{
ChipLogProgress(DeviceLayer, "MediaPlayback::HandleReadAttribute: attrId=%d, maxReadLength=%d",
Expand Down
15 changes: 3 additions & 12 deletions src/app/util/ContentApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/enums.h>
#include <app/clusters/application-launcher-server/application-launcher-server.h>
#include <app/clusters/content-launch-server/content-launch-delegate.h>
#include <app/clusters/content-launch-server/content-launch-server.h>
#include <app/clusters/target-navigator-server/target-navigator-server.h>
#include <app/util/attribute-storage.h>
Expand Down Expand Up @@ -97,17 +98,6 @@ class DLL_EXPORT ApplicationLauncher : public ContentAppCluster
EmberAfStatus HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer) override;
};

class DLL_EXPORT ContentLauncher : public ContentAppCluster
{
public:
virtual ~ContentLauncher() = default;

virtual LaunchResponse LaunchContent(std::list<Parameter> parameterList, bool autoplay, std::string data) = 0;

EmberAfStatus HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength) override;
EmberAfStatus HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer) override;
};

class DLL_EXPORT MediaPlayback : public ContentAppCluster
{
public:
Expand Down Expand Up @@ -155,11 +145,12 @@ class DLL_EXPORT ContentApp
virtual AccountLogin * GetAccountLogin() = 0;
virtual KeypadInput * GetKeypadInput() = 0;
virtual ApplicationLauncher * GetApplicationLauncher() = 0;
virtual ContentLauncher * GetContentLauncher() = 0;
virtual MediaPlayback * GetMediaPlayback() = 0;
virtual TargetNavigator * GetTargetNavigator() = 0;
virtual Channel * GetChannel() = 0;

virtual chip::app::Clusters::ContentLauncher::Delegate * GetContentLauncherDelegate() = 0;

EmberAfStatus HandleReadAttribute(ClusterId clusterId, chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength);
EmberAfStatus HandleWriteAttribute(ClusterId clusterId, chip::AttributeId attributeId, uint8_t * buffer);

Expand Down
10 changes: 1 addition & 9 deletions src/app/util/ContentAppPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

/**
* @file Contains shell commands for a commissionee (eg. end device) related to commissioning.
* @file Contains shell commands for a ContentApp relating to Content App platform of the Video Player.
*/

#include <app-common/zap-generated/attribute-id.h>
Expand Down Expand Up @@ -172,14 +172,6 @@ void AppPlatform::SetupAppPlatform()
static_cast<int>(emberAfEndpointFromIndex(static_cast<uint16_t>(emberAfFixedEndpointCount() - 1))) + 1);
mCurrentEndpointId = mFirstDynamicEndpointId;

{
for (int i = 0; i < emberAfFixedEndpointCount(); i++)
{
ChipLogProgress(DeviceLayer, "endpoint index=%d, id=%d", i,
static_cast<chip::EndpointId>(static_cast<int>(emberAfEndpointFromIndex(static_cast<uint16_t>(i)))));
}
}

if (mCurrentEndpointId < emberAfFixedEndpointCount())
{
mCurrentEndpointId = emberAfFixedEndpointCount();
Expand Down

0 comments on commit 1550508

Please sign in to comment.