1 /* 2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "command_server.h" 17 18 #include "dp_log.h" 19 20 namespace OHOS { 21 namespace CameraStandard { 22 namespace DeferredProcessing { CommandServer()23CommandServer::CommandServer() : server_(nullptr) 24 { 25 DP_DEBUG_LOG("entered."); 26 } 27 ~CommandServer()28CommandServer::~CommandServer() 29 { 30 DP_DEBUG_LOG("entered."); 31 server_ = nullptr; 32 } 33 Initialize(const std::string & cmdServerName)34int32_t CommandServer::Initialize(const std::string& cmdServerName) 35 { 36 if (server_ == nullptr) { 37 server_ = std::make_shared<CommandServerImpl>(cmdServerName); 38 } 39 return DP_OK; 40 } 41 SendCommand(const CmdSharedPtr & cmd)42int32_t CommandServer::SendCommand(const CmdSharedPtr& cmd) 43 { 44 DP_CHECK_RETURN_RET(server_ != nullptr, server_->AddCommand(cmd)); 45 return DP_INIT_FAIL; 46 } 47 SendUrgentCommand(const CmdSharedPtr & cmd)48int32_t CommandServer::SendUrgentCommand(const CmdSharedPtr& cmd) 49 { 50 DP_CHECK_RETURN_RET(server_ != nullptr, server_->AddUrgentCommand(cmd)); 51 return DP_INIT_FAIL; 52 } 53 SetThreadPriority(int priority)54void CommandServer::SetThreadPriority(int priority) 55 { 56 DP_CHECK_EXECUTE(server_ != nullptr, server_->SetThreadPriority(priority)); 57 } 58 GetThreadPriority() const59int32_t CommandServer::GetThreadPriority() const 60 { 61 DP_CHECK_RETURN_RET(server_ != nullptr, server_->GetThreadPriority()); 62 return DP_INIT_FAIL; 63 } 64 } // namespace DeferredProcessing 65 } // namespace CameraStandard 66 } // namespace OHOS