Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TE2 test cases #31529

Merged
merged 6 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/tv-app/android/java/OnOffManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void OnOffManager::PostOnOffChanged(chip::EndpointId endpoint, bool value)

jboolean OnOffManager::SetOnOff(jint endpoint, bool value)
{
chip::DeviceLayer::StackLock stack;
EmberAfStatus status = app::Clusters::OnOff::Attributes::OnOff::Set(static_cast<chip::EndpointId>(endpoint), value);
return status == EMBER_ZCL_STATUS_SUCCESS;
}
Expand Down
77 changes: 60 additions & 17 deletions examples/tv-app/tv-common/clusters/channel/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,39 @@ ChannelManager::ChannelManager()
program1.title = chip::CharSpan::fromCharString("ABC Title1");
program1.subtitle = MakeOptional(chip::CharSpan::fromCharString("My Program Subtitle1"));
program1.startTime = 0;
program1.endTime = 30 * 60 * 60;
program1.endTime = 30 * 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;
ProgramType program_pbs1;
program_pbs1.identifier = chip::CharSpan::fromCharString("progid-pbs1");
program_pbs1.channel = pbs;
program_pbs1.title = chip::CharSpan::fromCharString("PBS Title1");
program_pbs1.subtitle = MakeOptional(chip::CharSpan::fromCharString("My Program Subtitle1"));
program_pbs1.startTime = 0;
program_pbs1.endTime = 30 * 60;

mPrograms.push_back(program_abc1);
mPrograms.push_back(program_pbs1);

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;
program2.startTime = 30 * 60;
program2.endTime = 60 * 60;

mPrograms.push_back(program2);

ProgramType program3;
program3.identifier = chip::CharSpan::fromCharString("progid-abc3");
program3.channel = abc;
program3.title = chip::CharSpan::fromCharString("My Program Title3");
program3.subtitle = MakeOptional(chip::CharSpan::fromCharString("My Program Subtitle3"));
program3.startTime = 0;
program3.endTime = 60 * 60;

mPrograms.push_back(program3);
}

CHIP_ERROR ChannelManager::HandleGetChannelList(AttributeValueEncoder & aEncoder)
Expand Down Expand Up @@ -182,7 +192,6 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp

bool ChannelManager::HandleChangeChannelByNumber(const uint16_t & majorNumber, const uint16_t & minorNumber)
{
// TODO: Insert code here
bool channelChanged = false;
uint16_t index = 0;
for (auto const & channel : mChannels)
Expand Down Expand Up @@ -242,10 +251,44 @@ void ChannelManager::HandleGetProgramGuide(
// ChannelPagingStructType channelPaging;
// channelPaging.nextToken = MakeOptional<DataModel::Nullable<Structs::PageTokenStruct::Type>>(paging);

ProgramGuideResponseType response;
// response.channelPagingStruct = channelPaging;
response.programList = DataModel::List<const ProgramType>(mPrograms.data(), mPrograms.size());
std::vector<ProgramType> matches;
for (auto const & program : mPrograms)
{
if (startTime.ValueOr(0) > program.startTime)
{
continue;
}
if (endTime.HasValue() && endTime.ValueOr(0) < program.endTime)
{
continue;
}
if (channelList.HasValue())
{
auto iter = channelList.Value().begin();
bool match = false;
int listCount = 0;
while (iter.Next() && !match)
{
listCount++;
auto & channel = iter.GetValue();
if (channel.minorNumber != program.channel.minorNumber || channel.majorNumber != program.channel.majorNumber)
{
continue;
}
// this sample code does not currently check OTT
match = true;
}
if (!match && listCount > 0)
{
continue;
}
}
// this sample code does not currently filter on external id list
matches.push_back(program);
}

ProgramGuideResponseType response;
response.programList = DataModel::List<const ProgramType>(matches.data(), matches.size());
helper.Success(response);
}

Expand All @@ -258,7 +301,7 @@ bool ChannelManager::HandleRecordProgram(const chip::CharSpan & programIdentifie
for (auto & program : mPrograms)
{
std::string nextIdString(program.identifier.data(), program.identifier.size());
if (strcmp(idString.c_str(), nextIdString.c_str()) == 0)
if (nextIdString == idString)
{
program.recordingFlag = MakeOptional(static_cast<uint32_t>(shouldRecordSeries ? 2 : 1));
}
Expand All @@ -276,7 +319,7 @@ bool ChannelManager::HandleCancelRecordProgram(const chip::CharSpan & programIde
for (auto & program : mPrograms)
{
std::string nextIdString(program.identifier.data(), program.identifier.size());
if (strcmp(idString.c_str(), nextIdString.c_str()) == 0)
if (nextIdString == idString)
{
program.recordingFlag = MakeOptional(static_cast<uint32_t>(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,42 +277,32 @@ void MediaPlaybackManager::HandleStartOver(CommandResponseHelper<Commands::Playb

bool MediaPlaybackManager::HandleActivateAudioTrack(const chip::CharSpan & trackId, const uint8_t & audioOutputIndex)
{
bool foundMatch = false;
std::string idString(trackId.data(), trackId.size());
for (auto const & availableAudioTrack : mAvailableAudioTracks)
{
if (strcmp(availableAudioTrack.id.data(), trackId.data()) == 0)
std::string nextIdString(availableAudioTrack.id.data(), availableAudioTrack.id.size());
if (nextIdString == idString)
{
mActiveAudioTrack = availableAudioTrack;
foundMatch = true;
return true;
}
}

if (!foundMatch)
{
// return an error
}

return true;
return false;
}

bool MediaPlaybackManager::HandleActivateTextTrack(const chip::CharSpan & trackId)
{
bool foundMatch = false;
std::string idString(trackId.data(), trackId.size());
for (auto const & availableTextTrack : mAvailableTextTracks)
{
if (strcmp(availableTextTrack.id.data(), trackId.data()) == 0)
std::string nextIdString(availableTextTrack.id.data(), availableTextTrack.id.size());
if (nextIdString == idString)
{
mActiveAudioTrack = availableTextTrack;
foundMatch = true;
mActiveTextTrack = availableTextTrack;
return true;
}
}

if (!foundMatch)
{
// return an error
}

return true;
return false;
}

bool MediaPlaybackManager::HandleDeactivateTextTrack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ class MediaPlaybackManager : public MediaPlaybackDelegate
chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName2", 12)) }) }) }
};
TrackType mActiveTextTrack = { chip::CharSpan("activeTextTrackId_0", 19),
chip::app::DataModel::Nullable<TrackAttributesType>(
{ chip::CharSpan("languageCode1", 13),
chip::Optional<chip::app::DataModel::Nullable<chip::CharSpan>>(
{ chip::app::DataModel::MakeNullable(chip::CharSpan("displayName1", 12)) }) }) };
TrackType mActiveTextTrack = {};
std::vector<TrackType> mAvailableTextTracks = {
{ chip::CharSpan("activeTextTrackId_0", 19),
chip::app::DataModel::Nullable<TrackAttributesType>(
Expand Down
10 changes: 8 additions & 2 deletions src/app/clusters/media-playback-server/media-playback-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,10 @@ bool emberAfMediaPlaybackClusterActivateAudioTrackCallback(
Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);
{
delegate->HandleActivateAudioTrack(trackId, audioOutputIndex);
if (!delegate->HandleActivateAudioTrack(trackId, audioOutputIndex))
{
status = Status::InvalidInState;
}
}

exit:
Expand Down Expand Up @@ -605,7 +608,10 @@ bool emberAfMediaPlaybackClusterActivateTextTrackCallback(
Delegate * delegate = GetDelegate(endpoint);
VerifyOrExit(isDelegateNull(delegate, endpoint) != true, err = CHIP_ERROR_INCORRECT_STATE);
{
delegate->HandleActivateTextTrack(trackId);
if (!delegate->HandleActivateTextTrack(trackId))
{
status = Status::InvalidInState;
}
}

exit:
Expand Down
Loading