Skip to content

Commit

Permalink
Align naming in Content Launcher cluster XML with the spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Jan 18, 2023
1 parent 8303395 commit 50b3c74
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ using chip::app::AttributeValueEncoder;
using chip::app::CommandResponseHelper;
using ContentLauncherDelegate = chip::app::Clusters::ContentLauncher::Delegate;
using LaunchResponseType = chip::app::Clusters::ContentLauncher::Commands::LaunchResponse::Type;
using ParameterType = chip::app::Clusters::ContentLauncher::Structs::Parameter::DecodableType;
using BrandingInformationType = chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type;
using ParameterType = chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::DecodableType;
using BrandingInformationType = chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type;
using ContentAppAttributeDelegate = chip::AppPlatform::ContentAppAttributeDelegate;

class AppContentLauncherManager : public ContentLauncherDelegate
Expand Down
4 changes: 2 additions & 2 deletions examples/tv-app/android/java/ContentLauncherManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ using chip::app::AttributeValueEncoder;
using chip::app::CommandResponseHelper;
using ContentLauncherDelegate = chip::app::Clusters::ContentLauncher::Delegate;
using LaunchResponseType = chip::app::Clusters::ContentLauncher::Commands::LaunchResponse::Type;
using ParameterType = chip::app::Clusters::ContentLauncher::Structs::Parameter::DecodableType;
using BrandingInformationType = chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type;
using ParameterType = chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::DecodableType;
using BrandingInformationType = chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type;

class ContentLauncherManager : public ContentLauncherDelegate
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ using chip::app::AttributeValueEncoder;
using chip::app::CommandResponseHelper;
using ContentLauncherDelegate = chip::app::Clusters::ContentLauncher::Delegate;
using LaunchResponseType = chip::app::Clusters::ContentLauncher::Commands::LaunchResponse::Type;
using ParameterType = chip::app::Clusters::ContentLauncher::Structs::Parameter::DecodableType;
using BrandingInformationType = chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type;
using ParameterType = chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::DecodableType;
using BrandingInformationType = chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type;

class ContentEntry
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ JNI_METHOD(jboolean, contentLauncherLaunchURL)
}

CHIP_ERROR CreateParameter(JNIEnv * env, jobject jParameter,
chip::app::Clusters::ContentLauncher::Structs::Parameter::Type & parameter)
chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & parameter)
{
jclass jParameterClass = env->GetObjectClass(jParameter);

Expand All @@ -348,7 +348,8 @@ CHIP_ERROR CreateParameter(JNIEnv * env, jobject jParameter,
}

CHIP_ERROR CreateContentSearch(JNIEnv * env, jobject jSearch,
chip::app::Clusters::ContentLauncher::Structs::ContentSearch::Type & search, ListFreer & listFreer)
chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & search,
ListFreer & listFreer)
{
jclass jContentSearchClass;
ReturnErrorOnFailure(
Expand All @@ -367,20 +368,21 @@ CHIP_ERROR CreateContentSearch(JNIEnv * env, jobject jSearch,
jmethodID jNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "next", "()Ljava/lang/Object;");
jmethodID jHasNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "hasNext", "()Z");

auto * parameterListHolder = new ListHolder<chip::app::Clusters::ContentLauncher::Structs::Parameter::Type>(parameterListSize);
auto * parameterListHolder =
new ListHolder<chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type>(parameterListSize);
listFreer.add(parameterListHolder);
int parameterIndex = 0;
while (env->CallBooleanMethod(jIterator, jHasNextMid))
{
jobject jParameter = env->CallObjectMethod(jIterator, jNextMid);
chip::app::Clusters::ContentLauncher::Structs::Parameter::Type parameter;
chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type parameter;
ReturnErrorOnFailure(CreateParameter(env, jParameter, parameter));
parameterListHolder->mList[parameterIndex].type = parameter.type;
parameterListHolder->mList[parameterIndex].value = parameter.value;
parameterListHolder->mList[parameterIndex].externalIDList = parameter.externalIDList;
parameterIndex++;
}
search.parameterList = chip::app::DataModel::List<chip::app::Clusters::ContentLauncher::Structs::Parameter::Type>(
search.parameterList = chip::app::DataModel::List<chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type>(
parameterListHolder->mList, parameterListSize);

return CHIP_NO_ERROR;
Expand All @@ -400,7 +402,7 @@ JNI_METHOD(jboolean, contentLauncher_1launchContent)
chip::Optional<chip::CharSpan> data = MakeOptional(CharSpan::fromCharString(nativeData));

ListFreer listFreer;
chip::app::Clusters::ContentLauncher::Structs::ContentSearch::Type search;
chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type search;
CHIP_ERROR err = CreateContentSearch(env, jSearch, search, listFreer);

TargetEndpointInfo endpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,18 +668,18 @@ - (void)contentLauncher_launchContent:(ContentApp * _Nonnull)contentApp
[ConversionUtils convertToCppTargetEndpointInfoFrom:contentApp outTargetEndpointInfo:endpoint];

ListFreer listFreer;
chip::app::Clusters::ContentLauncher::Structs::ContentSearch::Type cppSearch;
chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type cppSearch;
if (contentSearch.parameterList.count > 0) {
auto * parameterListHolder
= new ListHolder<chip::app::Clusters::ContentLauncher::Structs::Parameter::Type>(contentSearch.parameterList.count);
auto * parameterListHolder = new ListHolder<chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type>(
contentSearch.parameterList.count);
listFreer.add(parameterListHolder);

int parameterIndex = 0;
for (ContentLauncher_Parameter * parameter in contentSearch.parameterList) {
int externalIdListIndex = 0;
if (parameter.externalIDList != nil) {
auto * externalIdListHolder
= new ListHolder<chip::app::Clusters::ContentLauncher::Structs::AdditionalInfo::Type>(
= new ListHolder<chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type>(
parameter.externalIDList.count);
listFreer.add(externalIdListHolder);

Expand All @@ -691,11 +691,11 @@ - (void)contentLauncher_launchContent:(ContentApp * _Nonnull)contentApp
externalIdListIndex++;
}
parameterListHolder->mList[parameterIndex].externalIDList = MakeOptional(
chip::app::DataModel::List<const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfo::Type>(
chip::app::DataModel::List<const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type>(
externalIdListHolder->mList, parameter.externalIDList.count));
} else {
parameterListHolder->mList[parameterIndex].externalIDList = chip::Optional<chip::app::DataModel::List<
const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfo::Type>>::Missing();
const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type>>::Missing();
}

parameterListHolder->mList[parameterIndex].type
Expand All @@ -704,7 +704,7 @@ - (void)contentLauncher_launchContent:(ContentApp * _Nonnull)contentApp
[parameter.value UTF8String], [parameter.value lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
parameterIndex++;
cppSearch.parameterList
= chip::app::DataModel::List<chip::app::Clusters::ContentLauncher::Structs::Parameter::Type>(
= chip::app::DataModel::List<chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type>(
parameterListHolder->mList, contentSearch.parameterList.count);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ constexpr chip::System::Clock::Seconds16 kCommissioningWindowTimeout = chip::Sys
class CastingServer
{
public:
CastingServer(CastingServer & other) = delete;
CastingServer(CastingServer & other) = delete;
void operator=(const CastingServer &) = delete;
static CastingServer * GetInstance();

Expand Down Expand Up @@ -112,10 +112,10 @@ class CastingServer
*/
CHIP_ERROR ContentLauncher_LaunchURL(
TargetEndpointInfo * endpoint, const char * contentUrl, const char * contentDisplayStr,
chip::Optional<chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type> brandingInformation,
chip::Optional<chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type> brandingInformation,
std::function<void(CHIP_ERROR)> responseCallback);
CHIP_ERROR ContentLauncher_LaunchContent(TargetEndpointInfo * endpoint,
chip::app::Clusters::ContentLauncher::Structs::ContentSearch::Type search,
chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type search,
bool autoPlay, chip::Optional<chip::CharSpan> data,
std::function<void(CHIP_ERROR)> responseCallback);
CHIP_ERROR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ class LaunchURLCommand : public MediaCommandBase<chip::app::Clusters::ContentLau
public:
LaunchURLCommand() : MediaCommandBase(chip::app::Clusters::ContentLauncher::Id) {}

CHIP_ERROR Invoke(const char * contentUrl, const char * contentDisplayStr,
chip::Optional<chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type> brandingInformation,
std::function<void(CHIP_ERROR)> responseCallback);
CHIP_ERROR
Invoke(const char * contentUrl, const char * contentDisplayStr,
chip::Optional<chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type> brandingInformation,
std::function<void(CHIP_ERROR)> responseCallback);
};

class LaunchContentCommand : public MediaCommandBase<chip::app::Clusters::ContentLauncher::Commands::LaunchContent::Type,
Expand All @@ -40,7 +41,7 @@ class LaunchContentCommand : public MediaCommandBase<chip::app::Clusters::Conten
public:
LaunchContentCommand() : MediaCommandBase(chip::app::Clusters::ContentLauncher::Id) {}

CHIP_ERROR Invoke(chip::app::Clusters::ContentLauncher::Structs::ContentSearch::Type search, bool autoPlay,
CHIP_ERROR Invoke(chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type search, bool autoPlay,
chip::Optional<chip::CharSpan> data, std::function<void(CHIP_ERROR)> responseCallback);
};

Expand Down
11 changes: 5 additions & 6 deletions examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ CastingServer::ContentLauncherLaunchURL(TargetEndpointInfo * endpoint, const cha
std::function<void(CHIP_ERROR)> launchURLResponseCallback)
{
return ContentLauncher_LaunchURL(endpoint, contentUrl, contentDisplayStr,
MakeOptional(chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type()),
MakeOptional(chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type()),
launchURLResponseCallback);
}

Expand Down Expand Up @@ -520,17 +520,16 @@ void CastingServer::Disconnect()
*/
CHIP_ERROR CastingServer::ContentLauncher_LaunchURL(
TargetEndpointInfo * endpoint, const char * contentUrl, const char * contentDisplayStr,
chip::Optional<chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type> brandingInformation,
chip::Optional<chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type> brandingInformation,
std::function<void(CHIP_ERROR)> responseCallback)
{
ReturnErrorOnFailure(mLaunchURLCommand.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
return mLaunchURLCommand.Invoke(contentUrl, contentDisplayStr, brandingInformation, responseCallback);
}

CHIP_ERROR CastingServer::ContentLauncher_LaunchContent(TargetEndpointInfo * endpoint,
chip::app::Clusters::ContentLauncher::Structs::ContentSearch::Type search,
bool autoPlay, chip::Optional<chip::CharSpan> data,
std::function<void(CHIP_ERROR)> responseCallback)
CHIP_ERROR CastingServer::ContentLauncher_LaunchContent(
TargetEndpointInfo * endpoint, chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type search, bool autoPlay,
chip::Optional<chip::CharSpan> data, std::function<void(CHIP_ERROR)> responseCallback)
{
ReturnErrorOnFailure(mLaunchContentCommand.SetTarget(mActiveTargetVideoPlayerInfo, endpoint->GetEndpointId()));
return mLaunchContentCommand.Invoke(search, autoPlay, data, responseCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace chip;
using namespace chip::app::Clusters;

CHIP_ERROR LaunchURLCommand::Invoke(const char * contentUrl, const char * contentDisplayStr,
Optional<ContentLauncher::Structs::BrandingInformation::Type> brandingInformation,
Optional<ContentLauncher::Structs::BrandingInformationStruct::Type> brandingInformation,
std::function<void(CHIP_ERROR)> responseCallback)
{
ContentLauncher::Commands::LaunchURL::Type request;
Expand All @@ -32,7 +32,7 @@ CHIP_ERROR LaunchURLCommand::Invoke(const char * contentUrl, const char * conten
return MediaCommandBase::Invoke(request, responseCallback);
}

CHIP_ERROR LaunchContentCommand::Invoke(ContentLauncher::Structs::ContentSearch::Type search, bool autoPlay,
CHIP_ERROR LaunchContentCommand::Invoke(ContentLauncher::Structs::ContentSearchStruct::Type search, bool autoPlay,
Optional<chip::CharSpan> data, std::function<void(CHIP_ERROR)> responseCallback)
{
ContentLauncher::Commands::LaunchContent::Type request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace app {
namespace Clusters {
namespace ContentLauncher {

using BrandingInformation = chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type;
using Parameter = chip::app::Clusters::ContentLauncher::Structs::Parameter::DecodableType;
using BrandingInformation = chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type;
using Parameter = chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::DecodableType;

/** @brief
* Defines methods for implementing application-specific logic for the Content Launcher Cluster.
Expand Down
52 changes: 26 additions & 26 deletions src/app/tests/suites/TV_ContentLauncherCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ tests:
- name: "search"
value:
{
parameterList:
ParameterList:
[
{
type: 1,
value: "exampleValue",
externalIDList:
[{ name: "name", value: "value" }],
Type: 1,
Value: "exampleValue",
ExternalIDList:
[{ Name: "name", Value: "value" }],
},
],
}
Expand All @@ -79,36 +79,36 @@ tests:
- name: "brandingInformation"
value:
{
providerName: "exampleName",
background:
ProviderName: "exampleName",
Background:
{
imageUrl: "exampleUrl",
color: "exampleColor",
size: { width: 0, height: 0, metric: 0 },
ImageURL: "exampleUrl",
Color: "exampleColor",
Size: { Width: 0, Height: 0, Metric: 0 },
},
logo:
Logo:
{
imageUrl: "exampleUrl",
color: "exampleColor",
size: { width: 0, height: 0, metric: 0 },
ImageURL: "exampleUrl",
Color: "exampleColor",
Size: { Width: 0, Height: 0, Metric: 0 },
},
progressBar:
ProgressBar:
{
imageUrl: "exampleUrl",
color: "exampleColor",
size: { width: 0, height: 0, metric: 0 },
ImageURL: "exampleUrl",
Color: "exampleColor",
Size: { Width: 0, Height: 0, Metric: 0 },
},
splash:
Splash:
{
imageUrl: "exampleUrl",
color: "exampleColor",
size: { width: 0, height: 0, metric: 0 },
ImageURL: "exampleUrl",
Color: "exampleColor",
Size: { Width: 0, Height: 0, Metric: 0 },
},
waterMark:
WaterMark:
{
imageUrl: "exampleUrl",
color: "exampleColor",
size: { width: 0, height: 0, metric: 0 },
ImageURL: "exampleUrl",
Color: "exampleColor",
Size: { Width: 0, Height: 0, Metric: 0 },
},
}
response:
Expand Down
Loading

0 comments on commit 50b3c74

Please sign in to comment.