diff --git a/examples/tv-app/tv-common/clusters/channel/ChannelManager.cpp b/examples/tv-app/tv-common/clusters/channel/ChannelManager.cpp index 59b00e828aff26..a278de45489112 100644 --- a/examples/tv-app/tv-common/clusters/channel/ChannelManager.cpp +++ b/examples/tv-app/tv-common/clusters/channel/ChannelManager.cpp @@ -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) @@ -203,9 +233,19 @@ void ChannelManager::HandleGetProgramGuide( // 1. Decode received parameters // 2. Perform search // 3. Return results + + // PageTokenType paging; + // paging.limit = MakeOptional(static_cast(10)); + // paging.after = MakeOptional(chip::CharSpan::fromCharString("after-token")); + // paging.before = MakeOptional(chip::CharSpan::fromCharString("before-token")); + + // ChannelPagingStructType channelPaging; + // channelPaging.nextToken = MakeOptional>(paging); + ProgramGuideResponseType response; - // response.channelPagingStruct; - // response.programList; + // response.channelPagingStruct = channelPaging; + response.programList = DataModel::List(mPrograms.data(), mPrograms.size()); + helper.Success(response); } @@ -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(shouldRecordSeries ? 2 : 1)); + } + } + return true; } @@ -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(0)); + } + } return true; } diff --git a/examples/tv-app/tv-common/clusters/channel/ChannelManager.h b/examples/tv-app/tv-common/clusters/channel/ChannelManager.h index 68c473e74dc70d..c0c28bb9d00c08 100644 --- a/examples/tv-app/tv-common/clusters/channel/ChannelManager.h +++ b/examples/tv-app/tv-common/clusters/channel/ChannelManager.h @@ -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 { @@ -66,6 +68,7 @@ class ChannelManager : public ChannelDelegate uint16_t mCurrentChannelIndex; ChannelInfoType mCurrentChannel; std::vector mChannels; + std::vector mPrograms; private: // TODO: set this based upon meta data from app diff --git a/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.cpp b/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.cpp index 7145ba24305f21..0b5c949216ed55 100644 --- a/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.cpp +++ b/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.cpp @@ -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 & helper, - const chip::Optional & data, const chip::CharSpan & encodingHint) +void ContentAppObserverManager::HandleContentAppMessage(chip::app::CommandResponseHelper & helper, + const chip::Optional & 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); } diff --git a/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.h b/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.h index 07ba89b2de3a1a..0c0f6fb6efbaec 100644 --- a/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.h +++ b/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.h @@ -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 & helper, const chip::Optional & data, const chip::CharSpan & encodingHint) override; diff --git a/examples/tv-app/tv-common/clusters/content-control/ContentController.cpp b/examples/tv-app/tv-common/clusters/content-control/ContentController.cpp index c4eee0355f4552..7ebb2ee4a45954 100644 --- a/examples/tv-app/tv-common/clusters/content-control/ContentController.cpp +++ b/examples/tv-app/tv-common/clusters/content-control/ContentController.cpp @@ -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 oldPIN, chip::CharSpan newPIN) {} +void ContentControlManager::HandleUpdatePIN(chip::Optional oldPIN, chip::CharSpan newPIN) {} -void ContentController::HandleResetPIN(chip::app::CommandResponseHelper & helper) {} +void ContentControlManager::HandleResetPIN(chip::app::CommandResponseHelper & helper) {} -void ContentController::HandleEnable() {} +void ContentControlManager::HandleEnable() {} -void ContentController::HandleDisable() {} +void ContentControlManager::HandleDisable() {} -void ContentController::HandleAddBonusTime(chip::Optional PINCode, chip::Optional bonusTime) {} +void ContentControlManager::HandleAddBonusTime(chip::Optional PINCode, chip::Optional 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) { diff --git a/examples/tv-app/tv-common/clusters/content-control/ContentController.h b/examples/tv-app/tv-common/clusters/content-control/ContentController.h index 01636f37fcb772..719d42bcbf79b4 100644 --- a/examples/tv-app/tv-common/clusters/content-control/ContentController.h +++ b/examples/tv-app/tv-common/clusters/content-control/ContentController.h @@ -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; diff --git a/examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.h b/examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.h index 54fc9de5b67e87..18ed5ca1a12bd9 100644 --- a/examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.h +++ b/examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.h @@ -73,37 +73,37 @@ class MediaPlaybackManager : public MediaPlaybackDelegate PlaybackPositionType mPlaybackPosition = { 0, chip::app::DataModel::Nullable(0) }; TrackType mActiveAudioTrack = { chip::CharSpan("activeAudioTrackId_0", 20), chip::app::DataModel::Nullable( - { chip::CharSpan("languageCode", 12), + { chip::CharSpan("languageCode1", 13), chip::Optional>( - { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName", 11)) }) }) }; + { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName1", 12)) }) }) }; std::vector mAvailableAudioTracks = { { chip::CharSpan("activeAudioTrackId_0", 20), chip::app::DataModel::Nullable( - { chip::CharSpan("languageCode", 12), + { chip::CharSpan("languageCode1", 13), chip::Optional>( - { 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( - { chip::CharSpan("languageCode", 12), + { chip::CharSpan("languageCode2", 13), chip::Optional>( - { 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( - { chip::CharSpan("languageCode", 12), + { chip::CharSpan("languageCode1", 13), chip::Optional>( - { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName", 11)) }) }) }; + { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName1", 12)) }) }) }; std::vector mAvailableTextTracks = { - { chip::CharSpan("activeTextTrackId_0", 20), + { chip::CharSpan("activeTextTrackId_0", 19), chip::app::DataModel::Nullable( - { chip::CharSpan("languageCode", 12), + { chip::CharSpan("languageCode1", 13), chip::Optional>( - { 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( - { chip::CharSpan("languageCode", 12), + { chip::CharSpan("languageCode2", 13), chip::Optional>( - { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName", 11)) }) }) } + { chip::app::DataModel::MakeNullable(chip::CharSpan("displayName2", 12)) }) }) } }; float mPlaybackSpeed = 0; uint64_t mStartTime = 0; diff --git a/examples/tv-app/tv-common/include/AppTv.h b/examples/tv-app/tv-common/include/AppTv.h index 8bfdf558dd1465..0a56ebe1da8624 100644 --- a/examples/tv-app/tv-common/include/AppTv.h +++ b/examples/tv-app/tv-common/include/AppTv.h @@ -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; diff --git a/examples/tv-app/tv-common/src/ZCLCallbacks.cpp b/examples/tv-app/tv-common/src/ZCLCallbacks.cpp index 8a5416ff3569b4..1358ab0bba9bb1 100644 --- a/examples/tv-app/tv-common/src/ZCLCallbacks.cpp +++ b/examples/tv-app/tv-common/src/ZCLCallbacks.cpp @@ -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; @@ -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"); @@ -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");