diff --git a/examples/tv-app/linux/AppImpl.cpp b/examples/tv-app/linux/AppImpl.cpp index 74a3cf8b0e1c6e..c91ba949e962e8 100644 --- a/examples/tv-app/linux/AppImpl.cpp +++ b/examples/tv-app/linux/AppImpl.cpp @@ -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); @@ -206,17 +196,6 @@ ApplicationLauncherResponse ApplicationLauncherImpl::LaunchApp(Application appli return response; } -LaunchResponse ContentLauncherImpl::LaunchContent(std::list 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); diff --git a/examples/tv-app/linux/AppImpl.h b/examples/tv-app/linux/AppImpl.h index c188b0b37bcccd..9dff6457bc4df3 100644 --- a/examples/tv-app/linux/AppImpl.h +++ b/examples/tv-app/linux/AppImpl.h @@ -30,6 +30,8 @@ #include #include +#include "include/content-launcher/ContentLauncherManager.h" + #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED namespace chip { @@ -103,16 +105,6 @@ class DLL_EXPORT ApplicationLauncherImpl : public ApplicationLauncher protected: }; -class DLL_EXPORT ContentLauncherImpl : public ContentLauncher -{ -public: - virtual ~ContentLauncherImpl() {} - - LaunchResponse LaunchContent(std::list parameterList, bool autoplay, std::string data) override; - -protected: -}; - class DLL_EXPORT MediaPlaybackImpl : public MediaPlayback { public: @@ -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(chip::app::Clusters::ContentLauncher::SupportedStreamingProtocol::kDash) | + static_cast(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 diff --git a/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp b/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp index a45066f5ba5283..3ebecfd031cf8f 100644 --- a/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp +++ b/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp @@ -38,20 +38,18 @@ using namespace std; using namespace chip::AppPlatform; +ContentLauncherManager::ContentLauncherManager(std::list acceptHeaderList, uint32_t supportedStreamingProtocols) +{ + mAcceptHeaderList = acceptHeaderList; + mSupportedStreamingProtocols = supportedStreamingProtocols; +} + LaunchResponse ContentLauncherManager::HandleLaunchContent(chip::EndpointId endpointId, const std::list & 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; @@ -79,12 +77,11 @@ LaunchResponse ContentLauncherManager::HandleLaunchUrl(const chip::CharSpan & co std::list 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; } diff --git a/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.h b/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.h index c9dbe270e5859c..0a17c4e69ea8bd 100644 --- a/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.h +++ b/examples/tv-app/linux/include/content-launcher/ContentLauncherManager.h @@ -30,10 +30,17 @@ class ContentLauncherManager : public chip::app::Clusters::ContentLauncher::Delegate { public: + ContentLauncherManager() : ContentLauncherManager({ "example", "example" }, 0){}; + ContentLauncherManager(std::list acceptHeaderList, uint32_t supportedStreamingProtocols); + LaunchResponse HandleLaunchContent(chip::EndpointId endpointId, const std::list & parameterList, bool autoplay, const chip::CharSpan & data) override; LaunchResponse HandleLaunchUrl(const chip::CharSpan & contentUrl, const chip::CharSpan & displayString, const std::list & brandingInformation) override; std::list HandleGetAcceptHeaderList() override; uint32_t HandleGetSupportedStreamingProtocols() override; + +protected: + std::list mAcceptHeaderList; + uint32_t mSupportedStreamingProtocols; }; diff --git a/examples/tv-app/linux/main.cpp b/examples/tv-app/linux/main.cpp index 41e61a257a3cd3..9131f13edfc8b1 100644 --- a/examples/tv-app/linux/main.cpp +++ b/examples/tv-app/linux/main.cpp @@ -54,7 +54,6 @@ bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * comm namespace { static ContentLauncherManager contentLauncherManager; -constexpr chip::EndpointId kContentLauncherEndpoint = 1; } // namespace void ApplicationInit() {} @@ -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); } diff --git a/src/app/clusters/content-launch-server/content-launch-server.cpp b/src/app/clusters/content-launch-server/content-launch-server.cpp index 52624611c9b211..75c4b9f3cd719e 100644 --- a/src/app/clusters/content-launch-server/content-launch-server.cpp +++ b/src/app/clusters/content-launch-server/content-launch-server.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -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) @@ -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 diff --git a/src/app/clusters/content-launch-server/content-launch-server.h b/src/app/clusters/content-launch-server/content-launch-server.h index 7a0911078ffad5..4effc1342f8f72 100644 --- a/src/app/clusters/content-launch-server/content-launch-server.h +++ b/src/app/clusters/content-launch-server/content-launch-server.h @@ -26,7 +26,7 @@ namespace app { namespace Clusters { namespace ContentLauncher { -void SetDelegate(EndpointId endpoint, Delegate * delegate); +void SetDefaultDelegate(Delegate * delegate); } // namespace ContentLauncher } // namespace Clusters diff --git a/src/app/util/ContentApp.cpp b/src/app/util/ContentApp.cpp index 90afd8bd3d4600..44a6cfec39e703 100644 --- a/src/app/util/ContentApp.cpp +++ b/src/app/util/ContentApp.cpp @@ -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 @@ -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(clusterId), - static_cast(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) @@ -68,17 +66,15 @@ EmberAfStatus ContentApp::HandleWriteAttribute(ClusterId clusterId, chip::Attrib GetApplicationBasic()->GetApplicationName(), static_cast(clusterId), static_cast(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) @@ -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(attributeId), maxReadLength); - return EMBER_ZCL_STATUS_FAILURE; -} - -EmberAfStatus ContentLauncher::HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer) -{ - ChipLogProgress(DeviceLayer, "ContentLauncher::HandleWriteAttribute: attrId=%d", static_cast(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", diff --git a/src/app/util/ContentApp.h b/src/app/util/ContentApp.h index c7e38a33728457..bab8a18a2d7803 100644 --- a/src/app/util/ContentApp.h +++ b/src/app/util/ContentApp.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -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 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: @@ -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); diff --git a/src/app/util/ContentAppPlatform.cpp b/src/app/util/ContentAppPlatform.cpp index d4b18158a6f33a..652d4b7db4973b 100644 --- a/src/app/util/ContentAppPlatform.cpp +++ b/src/app/util/ContentAppPlatform.cpp @@ -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 @@ -172,14 +172,6 @@ void AppPlatform::SetupAppPlatform() static_cast(emberAfEndpointFromIndex(static_cast(emberAfFixedEndpointCount() - 1))) + 1); mCurrentEndpointId = mFirstDynamicEndpointId; - { - for (int i = 0; i < emberAfFixedEndpointCount(); i++) - { - ChipLogProgress(DeviceLayer, "endpoint index=%d, id=%d", i, - static_cast(static_cast(emberAfEndpointFromIndex(static_cast(i))))); - } - } - if (mCurrentEndpointId < emberAfFixedEndpointCount()) { mCurrentEndpointId = emberAfFixedEndpointCount();