Skip to content

Commit 1550508

Browse files
authored
Merge f31ce97 into 3a617aa
2 parents 3a617aa + f31ce97 commit 1550508

File tree

10 files changed

+67
-108
lines changed

10 files changed

+67
-108
lines changed

examples/tv-app/linux/AppImpl.cpp

-21
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,6 @@ DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs),
147147
// Declare Content App endpoint
148148
DECLARE_DYNAMIC_ENDPOINT(contentAppEndpoint, contentAppClusters);
149149

150-
ContentAppImpl::ContentAppImpl(const char * szVendorName, uint16_t vendorId, const char * szApplicationName, uint16_t productId,
151-
const char * szApplicationVersion)
152-
{
153-
mApplicationBasic.SetApplicationName(szApplicationName);
154-
mApplicationBasic.SetVendorName(szApplicationName);
155-
mApplicationBasic.SetVendorId(vendorId);
156-
mApplicationBasic.SetProductId(productId);
157-
mApplicationBasic.SetApplicationVersion(szApplicationVersion);
158-
}
159-
160150
void ApplicationBasicImpl::SetApplicationName(const char * szApplicationName)
161151
{
162152
ChipLogProgress(DeviceLayer, "ApplicationBasic[%s]: Application Name=\"%s\"", szApplicationName, szApplicationName);
@@ -206,17 +196,6 @@ ApplicationLauncherResponse ApplicationLauncherImpl::LaunchApp(Application appli
206196
return response;
207197
}
208198

209-
LaunchResponse ContentLauncherImpl::LaunchContent(std::list<Parameter> parameterList, bool autoplay, std::string data)
210-
{
211-
ChipLogProgress(DeviceLayer, "ContentLauncherImpl: LaunchContent autoplay=%d data=\"%s\"", autoplay ? 1 : 0, data.c_str());
212-
213-
LaunchResponse response;
214-
response.err = CHIP_NO_ERROR;
215-
response.data = "Example app data";
216-
response.status = chip::app::Clusters::ContentLauncher::StatusEnum::kSuccess;
217-
return response;
218-
}
219-
220199
ContentAppFactoryImpl::ContentAppFactoryImpl()
221200
{
222201
mContentApps[1].GetAccountLogin()->SetSetupPIN(34567890);

examples/tv-app/linux/AppImpl.h

+20-13
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <stdbool.h>
3131
#include <stdint.h>
3232

33+
#include "include/content-launcher/ContentLauncherManager.h"
34+
3335
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
3436

3537
namespace chip {
@@ -103,16 +105,6 @@ class DLL_EXPORT ApplicationLauncherImpl : public ApplicationLauncher
103105
protected:
104106
};
105107

106-
class DLL_EXPORT ContentLauncherImpl : public ContentLauncher
107-
{
108-
public:
109-
virtual ~ContentLauncherImpl() {}
110-
111-
LaunchResponse LaunchContent(std::list<Parameter> parameterList, bool autoplay, std::string data) override;
112-
113-
protected:
114-
};
115-
116108
class DLL_EXPORT MediaPlaybackImpl : public MediaPlayback
117109
{
118110
public:
@@ -142,27 +134,42 @@ class DLL_EXPORT ContentAppImpl : public ContentApp
142134
{
143135
public:
144136
ContentAppImpl(const char * szVendorName, uint16_t vendorId, const char * szApplicationName, uint16_t productId,
145-
const char * szApplicationVersion);
137+
const char * szApplicationVersion) :
138+
mContentLauncherDelegate({ "image/*", "video/*" },
139+
static_cast<uint32_t>(chip::app::Clusters::ContentLauncher::SupportedStreamingProtocol::kDash) |
140+
static_cast<uint32_t>(chip::app::Clusters::ContentLauncher::SupportedStreamingProtocol::kHls))
141+
{
142+
mApplicationBasic.SetApplicationName(szApplicationName);
143+
mApplicationBasic.SetVendorName(szApplicationName);
144+
mApplicationBasic.SetVendorId(vendorId);
145+
mApplicationBasic.SetProductId(productId);
146+
mApplicationBasic.SetApplicationVersion(szApplicationVersion);
147+
};
146148
virtual ~ContentAppImpl() {}
147149

148150
inline ApplicationBasic * GetApplicationBasic() override { return &mApplicationBasic; };
149151
inline AccountLogin * GetAccountLogin() override { return &mAccountLogin; };
150152
inline KeypadInput * GetKeypadInput() override { return &mKeypadInput; };
151153
inline ApplicationLauncher * GetApplicationLauncher() override { return &mApplicationLauncher; };
152-
inline ContentLauncher * GetContentLauncher() override { return &mContentLauncher; };
153154
inline MediaPlayback * GetMediaPlayback() override { return &mMediaPlayback; };
154155
inline TargetNavigator * GetTargetNavigator() override { return &mTargetNavigator; };
155156
inline Channel * GetChannel() override { return &mChannel; };
156157

158+
inline chip::app::Clusters::ContentLauncher::Delegate * GetContentLauncherDelegate() override
159+
{
160+
return &mContentLauncherDelegate;
161+
};
162+
157163
protected:
158164
ApplicationBasicImpl mApplicationBasic;
159165
AccountLoginImpl mAccountLogin;
160166
KeypadInputImpl mKeypadInput;
161167
ApplicationLauncherImpl mApplicationLauncher;
162-
ContentLauncherImpl mContentLauncher;
163168
MediaPlaybackImpl mMediaPlayback;
164169
TargetNavigatorImpl mTargetNavigator;
165170
ChannelImpl mChannel;
171+
172+
ContentLauncherManager mContentLauncherDelegate;
166173
};
167174

168175
class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory

examples/tv-app/linux/include/content-launcher/ContentLauncherManager.cpp

+8-11
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,18 @@
3838
using namespace std;
3939
using namespace chip::AppPlatform;
4040

41+
ContentLauncherManager::ContentLauncherManager(std::list<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols)
42+
{
43+
mAcceptHeaderList = acceptHeaderList;
44+
mSupportedStreamingProtocols = supportedStreamingProtocols;
45+
}
46+
4147
LaunchResponse ContentLauncherManager::HandleLaunchContent(chip::EndpointId endpointId, const std::list<Parameter> & parameterList,
4248
bool autoplay, const chip::CharSpan & data)
4349
{
4450
ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchContent ");
4551
string dataString(data.data(), data.size());
4652

47-
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
48-
ContentApp * app = chip::AppPlatform::AppPlatform::GetInstance().GetContentAppByEndpointId(endpointId);
49-
if (app != NULL)
50-
{
51-
return app->GetContentLauncher()->LaunchContent(parameterList, autoplay, dataString);
52-
}
53-
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
54-
5553
// TODO: Insert code here
5654
LaunchResponse response;
5755
response.err = CHIP_NO_ERROR;
@@ -79,12 +77,11 @@ LaunchResponse ContentLauncherManager::HandleLaunchUrl(const chip::CharSpan & co
7977
std::list<std::string> ContentLauncherManager::HandleGetAcceptHeaderList()
8078
{
8179
ChipLogProgress(Zcl, "ContentLauncherManager::HandleGetAcceptHeaderList");
82-
return { "example", "example" };
80+
return mAcceptHeaderList;
8381
}
8482

8583
uint32_t ContentLauncherManager::HandleGetSupportedStreamingProtocols()
8684
{
8785
ChipLogProgress(Zcl, "ContentLauncherManager::HandleGetSupportedStreamingProtocols");
88-
uint32_t streamingProtocols = 0;
89-
return streamingProtocols;
86+
return mSupportedStreamingProtocols;
9087
}

examples/tv-app/linux/include/content-launcher/ContentLauncherManager.h

+7
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,17 @@
3030
class ContentLauncherManager : public chip::app::Clusters::ContentLauncher::Delegate
3131
{
3232
public:
33+
ContentLauncherManager() : ContentLauncherManager({ "example", "example" }, 0){};
34+
ContentLauncherManager(std::list<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols);
35+
3336
LaunchResponse HandleLaunchContent(chip::EndpointId endpointId, const std::list<Parameter> & parameterList, bool autoplay,
3437
const chip::CharSpan & data) override;
3538
LaunchResponse HandleLaunchUrl(const chip::CharSpan & contentUrl, const chip::CharSpan & displayString,
3639
const std::list<BrandingInformation> & brandingInformation) override;
3740
std::list<std::string> HandleGetAcceptHeaderList() override;
3841
uint32_t HandleGetSupportedStreamingProtocols() override;
42+
43+
protected:
44+
std::list<std::string> mAcceptHeaderList;
45+
uint32_t mSupportedStreamingProtocols;
3946
};

examples/tv-app/linux/main.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * comm
5454

5555
namespace {
5656
static ContentLauncherManager contentLauncherManager;
57-
constexpr chip::EndpointId kContentLauncherEndpoint = 1;
5857
} // namespace
5958

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

122121
void emberAfContentLauncherClusterInitCallback(EndpointId endpoint)
123122
{
124-
ChipLogProgress(Zcl, "TV Linux App: ContentLauncherManager::SetDelegate");
125-
chip::app::Clusters::ContentLauncher::SetDelegate(kContentLauncherEndpoint, &contentLauncherManager);
123+
ChipLogProgress(Zcl, "TV Linux App: ContentLauncherManager::SetDefaultDelegate");
124+
chip::app::Clusters::ContentLauncher::SetDefaultDelegate(&contentLauncherManager);
126125
}

src/app/clusters/content-launch-server/content-launch-server.cpp

+16-12
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <app/CommandHandler.h>
4949
#include <app/ConcreteCommandPath.h>
5050
#include <app/data-model/Encode.h>
51+
#include <app/util/ContentAppPlatform.h>
5152
#include <app/util/af.h>
5253
#include <app/util/attribute-storage.h>
5354
#include <list>
@@ -59,15 +60,25 @@ using namespace chip::app;
5960
// Delegate Implementation
6061

6162
using chip::app::Clusters::ContentLauncher::Delegate;
63+
using namespace chip::AppPlatform;
6264

6365
namespace {
6466

65-
Delegate * gDelegateTable[EMBER_AF_CONTENT_LAUNCH_CLUSTER_SERVER_ENDPOINT_COUNT] = { nullptr };
67+
Delegate * gDelegate = NULL;
6668

6769
Delegate * GetDelegate(EndpointId endpoint)
6870
{
69-
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, chip::app::Clusters::ContentLauncher::Id);
70-
return (ep == 0xFFFF ? NULL : gDelegateTable[ep]);
71+
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
72+
ContentApp * app = chip::AppPlatform::AppPlatform::GetInstance().GetContentAppByEndpointId(endpoint);
73+
if (app != NULL && app->GetContentLauncherDelegate() != NULL)
74+
{
75+
ChipLogError(Zcl, "Content Launcher returning ContentApp delegate for endpoint:%" PRIu16, endpoint);
76+
return app->GetContentLauncherDelegate();
77+
}
78+
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
79+
ChipLogError(Zcl, "Content Launcher NOT returning ContentApp delegate for endpoint:%" PRIu16, endpoint);
80+
81+
return gDelegate;
7182
}
7283

7384
bool isDelegateNull(Delegate * delegate, EndpointId endpoint)
@@ -86,16 +97,9 @@ namespace app {
8697
namespace Clusters {
8798
namespace ContentLauncher {
8899

89-
void SetDelegate(EndpointId endpoint, Delegate * delegate)
100+
void SetDefaultDelegate(Delegate * delegate)
90101
{
91-
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, chip::app::Clusters::ContentLauncher::Id);
92-
if (ep != 0xFFFF)
93-
{
94-
gDelegateTable[ep] = delegate;
95-
}
96-
else
97-
{
98-
}
102+
gDelegate = delegate;
99103
}
100104

101105
} // namespace ContentLauncher

src/app/clusters/content-launch-server/content-launch-server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace app {
2626
namespace Clusters {
2727
namespace ContentLauncher {
2828

29-
void SetDelegate(EndpointId endpoint, Delegate * delegate);
29+
void SetDefaultDelegate(Delegate * delegate);
3030

3131
} // namespace ContentLauncher
3232
} // namespace Clusters

src/app/util/ContentApp.cpp

+9-26
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

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

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

53-
EmberAfStatus ret = EMBER_ZCL_STATUS_FAILURE;
5452
if (clusterId == ZCL_APPLICATION_BASIC_CLUSTER_ID)
5553
{
56-
ret = GetApplicationBasic()->HandleReadAttribute(attributeId, buffer, maxReadLength);
54+
return GetApplicationBasic()->HandleReadAttribute(attributeId, buffer, maxReadLength);
5755
}
5856
if (clusterId == ZCL_ACCOUNT_LOGIN_CLUSTER_ID)
5957
{
60-
ret = GetAccountLogin()->HandleReadAttribute(attributeId, buffer, maxReadLength);
58+
return GetAccountLogin()->HandleReadAttribute(attributeId, buffer, maxReadLength);
6159
}
62-
return ret;
60+
return EMBER_ZCL_STATUS_FAILURE;
6361
}
6462

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

71-
EmberAfStatus ret = EMBER_ZCL_STATUS_FAILURE;
72-
7369
if (clusterId == ZCL_APPLICATION_BASIC_CLUSTER_ID)
7470
{
75-
ret = GetApplicationBasic()->HandleWriteAttribute(attributeId, buffer);
71+
return GetApplicationBasic()->HandleWriteAttribute(attributeId, buffer);
7672
}
7773
if (clusterId == ZCL_ACCOUNT_LOGIN_CLUSTER_ID)
7874
{
79-
ret = GetAccountLogin()->HandleWriteAttribute(attributeId, buffer);
75+
return GetAccountLogin()->HandleWriteAttribute(attributeId, buffer);
8076
}
81-
return ret;
77+
return EMBER_ZCL_STATUS_FAILURE;
8278
}
8379

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

189-
EmberAfStatus ContentLauncher::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
190-
{
191-
ChipLogProgress(DeviceLayer, "ContentLauncher::HandleReadAttribute: attrId=%d, maxReadLength=%d",
192-
static_cast<uint16_t>(attributeId), maxReadLength);
193-
return EMBER_ZCL_STATUS_FAILURE;
194-
}
195-
196-
EmberAfStatus ContentLauncher::HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer)
197-
{
198-
ChipLogProgress(DeviceLayer, "ContentLauncher::HandleWriteAttribute: attrId=%d", static_cast<uint16_t>(attributeId));
199-
return EMBER_ZCL_STATUS_FAILURE;
200-
}
201-
202185
EmberAfStatus MediaPlayback::HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength)
203186
{
204187
ChipLogProgress(DeviceLayer, "MediaPlayback::HandleReadAttribute: attrId=%d, maxReadLength=%d",

src/app/util/ContentApp.h

+3-12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <app-common/zap-generated/cluster-objects.h>
2727
#include <app-common/zap-generated/enums.h>
2828
#include <app/clusters/application-launcher-server/application-launcher-server.h>
29+
#include <app/clusters/content-launch-server/content-launch-delegate.h>
2930
#include <app/clusters/content-launch-server/content-launch-server.h>
3031
#include <app/clusters/target-navigator-server/target-navigator-server.h>
3132
#include <app/util/attribute-storage.h>
@@ -97,17 +98,6 @@ class DLL_EXPORT ApplicationLauncher : public ContentAppCluster
9798
EmberAfStatus HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer) override;
9899
};
99100

100-
class DLL_EXPORT ContentLauncher : public ContentAppCluster
101-
{
102-
public:
103-
virtual ~ContentLauncher() = default;
104-
105-
virtual LaunchResponse LaunchContent(std::list<Parameter> parameterList, bool autoplay, std::string data) = 0;
106-
107-
EmberAfStatus HandleReadAttribute(chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength) override;
108-
EmberAfStatus HandleWriteAttribute(chip::AttributeId attributeId, uint8_t * buffer) override;
109-
};
110-
111101
class DLL_EXPORT MediaPlayback : public ContentAppCluster
112102
{
113103
public:
@@ -155,11 +145,12 @@ class DLL_EXPORT ContentApp
155145
virtual AccountLogin * GetAccountLogin() = 0;
156146
virtual KeypadInput * GetKeypadInput() = 0;
157147
virtual ApplicationLauncher * GetApplicationLauncher() = 0;
158-
virtual ContentLauncher * GetContentLauncher() = 0;
159148
virtual MediaPlayback * GetMediaPlayback() = 0;
160149
virtual TargetNavigator * GetTargetNavigator() = 0;
161150
virtual Channel * GetChannel() = 0;
162151

152+
virtual chip::app::Clusters::ContentLauncher::Delegate * GetContentLauncherDelegate() = 0;
153+
163154
EmberAfStatus HandleReadAttribute(ClusterId clusterId, chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength);
164155
EmberAfStatus HandleWriteAttribute(ClusterId clusterId, chip::AttributeId attributeId, uint8_t * buffer);
165156

src/app/util/ContentAppPlatform.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

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

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

175-
{
176-
for (int i = 0; i < emberAfFixedEndpointCount(); i++)
177-
{
178-
ChipLogProgress(DeviceLayer, "endpoint index=%d, id=%d", i,
179-
static_cast<chip::EndpointId>(static_cast<int>(emberAfEndpointFromIndex(static_cast<uint16_t>(i)))));
180-
}
181-
}
182-
183175
if (mCurrentEndpointId < emberAfFixedEndpointCount())
184176
{
185177
mCurrentEndpointId = emberAfFixedEndpointCount();

0 commit comments

Comments
 (0)