10a5c7a17Sopenharmony_ci/* 20a5c7a17Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 30a5c7a17Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 40a5c7a17Sopenharmony_ci * you may not use this file except in compliance with the License. 50a5c7a17Sopenharmony_ci * You may obtain a copy of the License at 60a5c7a17Sopenharmony_ci * 70a5c7a17Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 80a5c7a17Sopenharmony_ci * 90a5c7a17Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 100a5c7a17Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 110a5c7a17Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120a5c7a17Sopenharmony_ci * See the License for the specific language governing permissions and 130a5c7a17Sopenharmony_ci * limitations under the License. 140a5c7a17Sopenharmony_ci */ 150a5c7a17Sopenharmony_ci#include "camera_kit.h" 160a5c7a17Sopenharmony_ci#include "camera_manager.h" 170a5c7a17Sopenharmony_ci#include "pms_interface.h" 180a5c7a17Sopenharmony_ci 190a5c7a17Sopenharmony_ciusing namespace std; 200a5c7a17Sopenharmony_cinamespace OHOS { 210a5c7a17Sopenharmony_cinamespace Media { 220a5c7a17Sopenharmony_ciCameraManager *cameraManager_ = nullptr; 230a5c7a17Sopenharmony_ciCameraKit::CameraKit() 240a5c7a17Sopenharmony_ci{ 250a5c7a17Sopenharmony_ci cameraManager_ = CameraManager::GetInstance(); 260a5c7a17Sopenharmony_ci} 270a5c7a17Sopenharmony_ci 280a5c7a17Sopenharmony_ciCameraKit::~CameraKit() {} 290a5c7a17Sopenharmony_ci 300a5c7a17Sopenharmony_ciCameraKit *CameraKit::GetInstance() 310a5c7a17Sopenharmony_ci{ 320a5c7a17Sopenharmony_ci if (CheckSelfPermission("ohos.permission.CAMERA") != GRANTED) { 330a5c7a17Sopenharmony_ci MEDIA_WARNING_LOG("Process can not access camera."); 340a5c7a17Sopenharmony_ci return nullptr; 350a5c7a17Sopenharmony_ci } 360a5c7a17Sopenharmony_ci static CameraKit kit; 370a5c7a17Sopenharmony_ci return &kit; 380a5c7a17Sopenharmony_ci} 390a5c7a17Sopenharmony_ci 400a5c7a17Sopenharmony_cilist<string> CameraKit::GetCameraIds() 410a5c7a17Sopenharmony_ci{ 420a5c7a17Sopenharmony_ci return cameraManager_->GetCameraIds(); 430a5c7a17Sopenharmony_ci} 440a5c7a17Sopenharmony_ci 450a5c7a17Sopenharmony_ciconst CameraAbility *CameraKit::GetCameraAbility(string cameraId) 460a5c7a17Sopenharmony_ci{ 470a5c7a17Sopenharmony_ci return cameraManager_->GetCameraAbility(cameraId); 480a5c7a17Sopenharmony_ci} 490a5c7a17Sopenharmony_ci 500a5c7a17Sopenharmony_ciconst CameraInfo *CameraKit::GetCameraInfo(string cameraId) 510a5c7a17Sopenharmony_ci{ 520a5c7a17Sopenharmony_ci return cameraManager_->GetCameraInfo(cameraId); 530a5c7a17Sopenharmony_ci} 540a5c7a17Sopenharmony_ci 550a5c7a17Sopenharmony_civoid CameraKit::RegisterCameraDeviceCallback(CameraDeviceCallback &callback, EventHandler &handler) 560a5c7a17Sopenharmony_ci{ 570a5c7a17Sopenharmony_ci cameraManager_->RegisterCameraDeviceCallback(callback, handler); 580a5c7a17Sopenharmony_ci} 590a5c7a17Sopenharmony_ci 600a5c7a17Sopenharmony_civoid CameraKit::UnregisterCameraDeviceCallback(CameraDeviceCallback &callback) 610a5c7a17Sopenharmony_ci{ 620a5c7a17Sopenharmony_ci cameraManager_->UnregisterCameraDeviceCallback(callback); 630a5c7a17Sopenharmony_ci} 640a5c7a17Sopenharmony_ci 650a5c7a17Sopenharmony_civoid CameraKit::CreateCamera(const string &cameraId, CameraStateCallback &callback, EventHandler &handler) 660a5c7a17Sopenharmony_ci{ 670a5c7a17Sopenharmony_ci cameraManager_->CreateCamera(cameraId, callback, handler); 680a5c7a17Sopenharmony_ci} 690a5c7a17Sopenharmony_ci 700a5c7a17Sopenharmony_ciuint8_t CameraKit::GetCameraModeNum() 710a5c7a17Sopenharmony_ci{ 720a5c7a17Sopenharmony_ci return cameraManager_->GetCameraModeNum(); 730a5c7a17Sopenharmony_ci} 740a5c7a17Sopenharmony_ci 750a5c7a17Sopenharmony_ciint32_t CameraKit::SetCameraMode(uint8_t modeIndex) 760a5c7a17Sopenharmony_ci{ 770a5c7a17Sopenharmony_ci return cameraManager_->SetCameraMode(modeIndex); 780a5c7a17Sopenharmony_ci} 790a5c7a17Sopenharmony_ci} // namespace Media 800a5c7a17Sopenharmony_ci} // namespace OHOS 81