Skip to content

Commit

Permalink
Media Clusters: Fix for cert test failures (#31047)
Browse files Browse the repository at this point in the history
* Fix for cert test failures

* Fix for channel test cases
  • Loading branch information
chrisdecenzo authored and pull[bot] committed Apr 16, 2024
1 parent 14ba888 commit 303ce51
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 53 deletions.
63 changes: 61 additions & 2 deletions examples/tv-app/tv-common/clusters/channel/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,36 @@ ChannelManager::ChannelManager()

mCurrentChannelIndex = 0;
mCurrentChannel = mChannels[mCurrentChannelIndex];

ProgramType program1;
program1.identifier = chip::CharSpan::fromCharString("progid-abc1");
program1.channel = abc;
program1.title = chip::CharSpan::fromCharString("ABC Title1");
program1.subtitle = MakeOptional(chip::CharSpan::fromCharString("My Program Subtitle1"));
program1.startTime = 0;
program1.endTime = 30 * 60 * 60;

mPrograms.push_back(program1);

ProgramType program_abc1;
program_abc1.identifier = chip::CharSpan::fromCharString("progid-pbs1");
program_abc1.channel = pbs;
program_abc1.title = chip::CharSpan::fromCharString("PBS Title1");
program_abc1.subtitle = MakeOptional(chip::CharSpan::fromCharString("My Program Subtitle1"));
program_abc1.startTime = 0;
program_abc1.endTime = 30 * 60 * 60;

mPrograms.push_back(program_abc1);

ProgramType program2;
program2.identifier = chip::CharSpan::fromCharString("progid-abc2");
program2.channel = abc;
program2.title = chip::CharSpan::fromCharString("My Program Title2");
program2.subtitle = MakeOptional(chip::CharSpan::fromCharString("My Program Subtitle2"));
program2.startTime = 30 * 60 * 60;
program2.endTime = 30 * 60 * 60;

mPrograms.push_back(program2);
}

CHIP_ERROR ChannelManager::HandleGetChannelList(AttributeValueEncoder & aEncoder)
Expand Down Expand Up @@ -203,9 +233,19 @@ void ChannelManager::HandleGetProgramGuide(
// 1. Decode received parameters
// 2. Perform search
// 3. Return results

// PageTokenType paging;
// paging.limit = MakeOptional(static_cast<uint16_t>(10));
// paging.after = MakeOptional(chip::CharSpan::fromCharString("after-token"));
// paging.before = MakeOptional(chip::CharSpan::fromCharString("before-token"));

// ChannelPagingStructType channelPaging;
// channelPaging.nextToken = MakeOptional<DataModel::Nullable<Structs::PageTokenStruct::Type>>(paging);

ProgramGuideResponseType response;
// response.channelPagingStruct;
// response.programList;
// response.channelPagingStruct = channelPaging;
response.programList = DataModel::List<const ProgramType>(mPrograms.data(), mPrograms.size());

helper.Success(response);
}

Expand All @@ -214,6 +254,16 @@ bool ChannelManager::HandleRecordProgram(const chip::CharSpan & programIdentifie
const chip::ByteSpan & data)
{
// Start recording
std::string idString(programIdentifier.data(), programIdentifier.size());
for (auto & program : mPrograms)
{
std::string nextIdString(program.identifier.data(), program.identifier.size());
if (strcmp(idString.c_str(), nextIdString.c_str()) == 0)
{
program.recordingFlag = MakeOptional(static_cast<uint32_t>(shouldRecordSeries ? 2 : 1));
}
}

return true;
}

Expand All @@ -222,6 +272,15 @@ bool ChannelManager::HandleCancelRecordProgram(const chip::CharSpan & programIde
const chip::ByteSpan & data)
{
// Cancel recording
std::string idString(programIdentifier.data(), programIdentifier.size());
for (auto & program : mPrograms)
{
std::string nextIdString(program.identifier.data(), program.identifier.size());
if (strcmp(idString.c_str(), nextIdString.c_str()) == 0)
{
program.recordingFlag = MakeOptional(static_cast<uint32_t>(0));
}
}
return true;
}

Expand Down
3 changes: 3 additions & 0 deletions examples/tv-app/tv-common/clusters/channel/ChannelManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ using ChannelInfoType = chip::app::Clusters::Channel::Structs::Channel
using AdditionalInfoType = chip::app::Clusters::Channel::Structs::AdditionalInfoStruct::Type;
using LineupInfoType = chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type;
using PageTokenType = chip::app::Clusters::Channel::Structs::PageTokenStruct::Type;
using ProgramType = chip::app::Clusters::Channel::Structs::ProgramStruct::Type;
using ChannelPagingType = chip::app::Clusters::Channel::Structs::ChannelPagingStruct::Type;

class ChannelManager : public ChannelDelegate
{
Expand Down Expand Up @@ -66,6 +68,7 @@ class ChannelManager : public ChannelDelegate
uint16_t mCurrentChannelIndex;
ChannelInfoType mCurrentChannel;
std::vector<ChannelInfoType> mChannels;
std::vector<ProgramType> mPrograms;

private:
// TODO: set this based upon meta data from app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,28 @@ using namespace std;
using namespace chip;
using namespace chip::app::Clusters::ContentAppObserver;

ContentAppObserver::ContentAppObserver()
ContentAppObserverManager::ContentAppObserverManager()
{
// Create Test Data
}

void ContentAppObserver::HandleContentAppMessage(chip::app::CommandResponseHelper<ContentAppMessageResponse> & helper,
const chip::Optional<chip::CharSpan> & data, const chip::CharSpan & encodingHint)
void ContentAppObserverManager::HandleContentAppMessage(chip::app::CommandResponseHelper<ContentAppMessageResponse> & helper,
const chip::Optional<chip::CharSpan> & data,
const chip::CharSpan & encodingHint)
{
ChipLogProgress(Zcl, "ContentAppObserver::HandleContentAppMessage");
ChipLogProgress(Zcl, "ContentAppObserverManager::HandleContentAppMessage");

string dataString(data.HasValue() ? data.Value().data() : "", data.HasValue() ? data.Value().size() : 0);
string encodingHintString(encodingHint.data(), encodingHint.size());

ChipLogProgress(Zcl, "ContentAppObserverManager::HandleContentAppMessage TEST CASE hint=%s data=%s ",
encodingHintString.c_str(), dataString.c_str());

ContentAppMessageResponse response;
// TODO: Insert code here
// TODO: optional and mandatory are swapped
response.data = CharSpan::fromCharString("exampleData");
response.encodingHint = CharSpan::fromCharString(encodingHintString.c_str());
response.status = chip::MakeOptional(StatusEnum::kSuccess);
helper.Success(response);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
using ContentAppObserverDelegate = chip::app::Clusters::ContentAppObserver::Delegate;
using ContentAppMessageResponse = chip::app::Clusters::ContentAppObserver::Commands::ContentAppMessageResponse::Type;

class ContentAppObserver : public ContentAppObserverDelegate
class ContentAppObserverManager : public ContentAppObserverDelegate
{
public:
ContentAppObserver();
ContentAppObserverManager();

void HandleContentAppMessage(chip::app::CommandResponseHelper<ContentAppMessageResponse> & helper,
const chip::Optional<chip::CharSpan> & data, const chip::CharSpan & encodingHint) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,74 +25,74 @@ using namespace chip::app::Clusters;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters::ContentControl;

ContentController::ContentController()
ContentControlManager::ContentControlManager()
{
// Create Test Data
}

// Attribute Delegates
bool ContentController::HandleGetEnabled()
bool ContentControlManager::HandleGetEnabled()
{
return false;
}

CHIP_ERROR ContentController::HandleGetOnDemandRatings(chip::app::AttributeValueEncoder & aEncoder)
CHIP_ERROR ContentControlManager::HandleGetOnDemandRatings(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.Encode(chip::CharSpan());
}

chip::CharSpan ContentController::HandleGetOnDemandRatingThreshold()
chip::CharSpan ContentControlManager::HandleGetOnDemandRatingThreshold()
{
return chip::CharSpan();
}

CHIP_ERROR ContentController::HandleGetScheduledContentRatings(chip::app::AttributeValueEncoder & aEncoder)
CHIP_ERROR ContentControlManager::HandleGetScheduledContentRatings(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.Encode(chip::CharSpan());
}

chip::CharSpan ContentController::HandleGetScheduledContentRatingThreshold()
chip::CharSpan ContentControlManager::HandleGetScheduledContentRatingThreshold()
{
return chip::CharSpan();
}

uint32_t ContentController::HandleGetScreenDailyTime()
uint32_t ContentControlManager::HandleGetScreenDailyTime()
{
return (uint32_t) 0xFFFFFFFF;
}

uint32_t ContentController::HandleGetRemainingScreenTime()
uint32_t ContentControlManager::HandleGetRemainingScreenTime()
{
return (uint32_t) 0xFFFFFFFF;
}

bool ContentController::HandleGetBlockUnrated()
bool ContentControlManager::HandleGetBlockUnrated()
{
return false;
}

// Command Delegates
void ContentController::HandleUpdatePIN(chip::Optional<chip::CharSpan> oldPIN, chip::CharSpan newPIN) {}
void ContentControlManager::HandleUpdatePIN(chip::Optional<chip::CharSpan> oldPIN, chip::CharSpan newPIN) {}

void ContentController::HandleResetPIN(chip::app::CommandResponseHelper<ResetPINResponseType> & helper) {}
void ContentControlManager::HandleResetPIN(chip::app::CommandResponseHelper<ResetPINResponseType> & helper) {}

void ContentController::HandleEnable() {}
void ContentControlManager::HandleEnable() {}

void ContentController::HandleDisable() {}
void ContentControlManager::HandleDisable() {}

void ContentController::HandleAddBonusTime(chip::Optional<chip::CharSpan> PINCode, chip::Optional<uint32_t> bonusTime) {}
void ContentControlManager::HandleAddBonusTime(chip::Optional<chip::CharSpan> PINCode, chip::Optional<uint32_t> bonusTime) {}

void ContentController::HandleSetScreenDailyTime(uint32_t screenDailyTime) {}
void ContentControlManager::HandleSetScreenDailyTime(uint32_t screenDailyTime) {}

void ContentController::HandleBlockUnratedContent() {}
void ContentControlManager::HandleBlockUnratedContent() {}

void ContentController::HandleUnblockUnratedContent() {}
void ContentControlManager::HandleUnblockUnratedContent() {}

void ContentController::HandleSetOnDemandRatingThreshold(chip::CharSpan rating) {}
void ContentControlManager::HandleSetOnDemandRatingThreshold(chip::CharSpan rating) {}

void ContentController::HandleSetScheduledContentRatingThreshold(chip::CharSpan rating) {}
void ContentControlManager::HandleSetScheduledContentRatingThreshold(chip::CharSpan rating) {}

uint32_t ContentController::GetFeatureMap(chip::EndpointId endpoint)
uint32_t ContentControlManager::GetFeatureMap(chip::EndpointId endpoint)
{
if (endpoint >= EMBER_AF_CONTENT_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
using ContentControlDelegate = chip::app::Clusters::ContentControl::Delegate;
using ResetPINResponseType = chip::app::Clusters::ContentControl::Commands::ResetPINResponse::Type;

class ContentController : public ContentControlDelegate
class ContentControlManager : public ContentControlDelegate
{
public:
ContentController();
ContentControlManager();

// Attribute Delegates
bool HandleGetEnabled() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,37 +73,37 @@ class MediaPlaybackManager : public MediaPlaybackDelegate
PlaybackPositionType mPlaybackPosition = { 0, chip::app::DataModel::Nullable<uint64_t>(0) };
TrackType mActiveAudioTrack = { chip::CharSpan("activeAudioTrackId_0", 20),
chip::app::DataModel::Nullable<TrackAttributesType>(
{ chip::CharSpan("languageCode", 12),
{ chip::CharSpan("languageCode1", 13),
chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName", 11)) }) }) };
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName1", 12)) }) }) };
std::vector<TrackType> mAvailableAudioTracks = {
{ chip::CharSpan("activeAudioTrackId_0", 20),
chip::app::DataModel::Nullable<TrackAttributesType>(
{ chip::CharSpan("languageCode", 12),
{ chip::CharSpan("languageCode1", 13),
chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName", 11)) }) }) },
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName1", 12)) }) }) },
{ chip::CharSpan("activeAudioTrackId_1", 20),
chip::app::DataModel::Nullable<TrackAttributesType>(
{ chip::CharSpan("languageCode", 12),
{ chip::CharSpan("languageCode2", 13),
chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName", 11)) }) }) }
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName2", 12)) }) }) }
};
TrackType mActiveTextTrack = { chip::CharSpan("activeTextTrackId_0", 20),
TrackType mActiveTextTrack = { chip::CharSpan("activeTextTrackId_0", 19),
chip::app::DataModel::Nullable<TrackAttributesType>(
{ chip::CharSpan("languageCode", 12),
{ chip::CharSpan("languageCode1", 13),
chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName", 11)) }) }) };
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName1", 12)) }) }) };
std::vector<TrackType> mAvailableTextTracks = {
{ chip::CharSpan("activeTextTrackId_0", 20),
{ chip::CharSpan("activeTextTrackId_0", 19),
chip::app::DataModel::Nullable<TrackAttributesType>(
{ chip::CharSpan("languageCode", 12),
{ chip::CharSpan("languageCode1", 13),
chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName", 11)) }) }) },
{ chip::CharSpan("activeTextTrackId_1", 20),
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName1", 12)) }) }) },
{ chip::CharSpan("activeTextTrackId_1", 19),
chip::app::DataModel::Nullable<TrackAttributesType>(
{ chip::CharSpan("languageCode", 12),
{ chip::CharSpan("languageCode2", 13),
chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName", 11)) }) }) }
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName2", 12)) }) }) }
};
float mPlaybackSpeed = 0;
uint64_t mStartTime = 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/tv-app/tv-common/include/AppTv.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class DLL_EXPORT ContentAppImpl : public ContentApp
ApplicationLauncherManager mApplicationLauncherDelegate;
ChannelManager mChannelDelegate;
ContentLauncherManager mContentLauncherDelegate;
ContentAppObserver mContentAppObserverDelegate;
ContentController mContentControlDelegate;
ContentAppObserverManager mContentAppObserverDelegate;
ContentControlManager mContentControlDelegate;
KeypadInputManager mKeypadInputDelegate;
MediaPlaybackManager mMediaPlaybackDelegate;
TargetNavigatorManager mTargetNavigatorDelegate;
Expand Down
26 changes: 20 additions & 6 deletions examples/tv-app/tv-common/src/ZCLCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ static ApplicationLauncherManager applicationLauncherManager(false);
#endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
static AudioOutputManager audioOutputManager;
static ChannelManager channelManager;
static ContentAppObserverManager contentAppObserverManager;
static ContentControlManager contentControlManager;
static ContentLauncherManager contentLauncherManager;
static KeypadInputManager keypadInputManager;
static LowPowerManager lowPowerManager;
Expand Down Expand Up @@ -104,12 +106,6 @@ void emberAfOnOffClusterInitCallback(EndpointId endpoint)
// TODO: implement any additional Cluster Server init actions
}

void emberAfContentLauncherClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: ContentLauncher::SetDefaultDelegate");
ContentLauncher::SetDefaultDelegate(endpoint, &contentLauncherManager);
}

void emberAfAccountLoginClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: AccountLogin::SetDefaultDelegate");
Expand All @@ -134,6 +130,24 @@ void emberAfAudioOutputClusterInitCallback(EndpointId endpoint)
AudioOutput::SetDefaultDelegate(endpoint, &audioOutputManager);
}

void emberAfContentAppObserverClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: ContentAppObserverManager::SetDefaultDelegate");
ContentAppObserver::SetDefaultDelegate(endpoint, &contentAppObserverManager);
}

void emberAfContentControlClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: ContentControlManager::SetDefaultDelegate");
ContentControl::SetDefaultDelegate(endpoint, &contentControlManager);
}

void emberAfContentLauncherClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: ContentLauncher::SetDefaultDelegate");
ContentLauncher::SetDefaultDelegate(endpoint, &contentLauncherManager);
}

void emberAfChannelClusterInitCallback(EndpointId endpoint)
{
ChipLogProgress(Zcl, "TV Linux App: Channel::SetDefaultDelegate");
Expand Down

0 comments on commit 303ce51

Please sign in to comment.