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 4 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
69 changes: 62 additions & 7 deletions examples/tv-app/tv-common/clusters/channel/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ ChannelManager::ChannelManager()
worldChannel.minorNumber = static_cast<uint16_t>(3);
mChannels.push_back(worldChannel);

ChannelInfoType ottChannel;
ottChannel.affiliateCallSign = MakeOptional(chip::CharSpan::fromCharString("OTT"));
ottChannel.callSign = MakeOptional(chip::CharSpan::fromCharString("OTT-TV"));
ottChannel.name = MakeOptional(chip::CharSpan::fromCharString("OTT Channel"));
ottChannel.majorNumber = static_cast<uint8_t>(0);
ottChannel.minorNumber = static_cast<uint16_t>(0);
ottChannel.identifier = MakeOptional(chip::CharSpan::fromCharString("ott-1"));
// ottChannel.type = MakeOptional(chip::app::Clusters::Channel::ChannelTypeEnum::kUnknownEnumValue); // TODO: OTT
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved

mChannels.push_back(worldChannel);

mCurrentChannelIndex = 0;
mCurrentChannel = mChannels[mCurrentChannelIndex];

Expand All @@ -69,7 +80,7 @@ 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);

Expand All @@ -79,7 +90,7 @@ ChannelManager::ChannelManager()
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;
program_abc1.endTime = 30 * 60;

mPrograms.push_back(program_abc1);

Expand All @@ -88,10 +99,20 @@ ChannelManager::ChannelManager()
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-ott3");
program3.channel = ottChannel;
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 @@ -242,10 +263,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;
}
// TODO: check OTT
match = true;
}
if (!match && listCount > 0)
{
continue;
}
}
// TODO: check external id list
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
matches.push_back(program);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,22 @@ 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 (strcmp(nextidString.c_str(), idString.c_str()) == 0)
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
{
mActiveAudioTrack = availableAudioTrack;
foundMatch = true;
break;
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
}
}

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

return true;
Expand All @@ -298,18 +302,25 @@ bool MediaPlaybackManager::HandleActivateAudioTrack(const chip::CharSpan & track
bool MediaPlaybackManager::HandleActivateTextTrack(const chip::CharSpan & trackId)
{
bool foundMatch = false;
std::string idString(trackId.data(), trackId.size());
ChipLogError(Controller, "HandleActivateTextTrack - Looking for %s", idString.c_str());
for (auto const & availableTextTrack : mAvailableTextTracks)
{
if (strcmp(availableTextTrack.id.data(), trackId.data()) == 0)
std::string nextidString(availableTextTrack.id.data(), availableTextTrack.id.size());
ChipLogError(Controller, "HandleActivateTextTrack - next track %s", nextidString.c_str());
if (strcmp(nextidString.c_str(), idString.c_str()) == 0)
{
mActiveAudioTrack = availableTextTrack;
foundMatch = true;
ChipLogError(Controller, "HandleActivateTextTrack - match");
mActiveTextTrack = availableTextTrack;
foundMatch = true;
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
break;
}
}

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

return true;
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