forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Chef] Fix basicvideoplayer device type
This was actually a squashed and rebased commit for PR project-chip#31987 since it mixed with unwanted commit from other people due to conflicts during rebasing
- Loading branch information
Showing
25 changed files
with
3,090 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
examples/chef/common/clusters/audio-output/AudioOutputManager.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <app/util/config.h> | ||
#ifdef MATTER_DM_PLUGIN_AUDIO_OUTPUT_SERVER | ||
#include "AudioOutputManager.h" | ||
|
||
using namespace std; | ||
using namespace chip::app; | ||
using namespace chip::app::Clusters::AudioOutput; | ||
using chip::app::AttributeValueEncoder; | ||
|
||
AudioOutputManager::AudioOutputManager() | ||
{ | ||
const int totalOutput = 4; | ||
|
||
for (uint8_t i = 1; i < totalOutput; ++i) | ||
{ | ||
OutputInfoType outputInfo; | ||
outputInfo.outputType = chip::app::Clusters::AudioOutput::OutputTypeEnum::kHdmi; | ||
// note: safe only because of use of string literal | ||
outputInfo.name = chip::CharSpan::fromCharString("HDMI"); | ||
outputInfo.index = static_cast<uint8_t>(i); | ||
mOutputs.push_back(outputInfo); | ||
} | ||
} | ||
|
||
uint8_t AudioOutputManager::HandleGetCurrentOutput() | ||
{ | ||
return mCurrentOutput; | ||
} | ||
|
||
CHIP_ERROR AudioOutputManager::HandleGetOutputList(AttributeValueEncoder & aEncoder) | ||
{ | ||
return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR { | ||
for (auto const & outputInfo : this->mOutputs) | ||
{ | ||
ReturnErrorOnFailure(encoder.Encode(outputInfo)); | ||
} | ||
return CHIP_NO_ERROR; | ||
}); | ||
} | ||
|
||
bool AudioOutputManager::HandleRenameOutput(const uint8_t & index, const chip::CharSpan & name) | ||
{ | ||
bool audioOutputRenamed = false; | ||
|
||
for (OutputInfoType & output : mOutputs) | ||
{ | ||
if (output.index == index) | ||
{ | ||
audioOutputRenamed = true; | ||
const size_t len = std::min(mBufMax, name.size()); | ||
memcpy(this->Data(index), name.data(), len); | ||
output.name = chip::CharSpan(this->Data(index), len); | ||
return audioOutputRenamed; | ||
} | ||
} | ||
|
||
return audioOutputRenamed; | ||
} | ||
|
||
bool AudioOutputManager::HandleSelectOutput(const uint8_t & index) | ||
{ | ||
bool audioOutputSelected = false; | ||
for (OutputInfoType & output : mOutputs) | ||
{ | ||
if (output.index == index) | ||
{ | ||
audioOutputSelected = true; | ||
mCurrentOutput = index; | ||
return audioOutputSelected; | ||
} | ||
} | ||
|
||
return audioOutputSelected; | ||
} | ||
#endif // MATTER_DM_PLUGIN_AUDIO_OUTPUT_SERVER |
Oops, something went wrong.