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#ifndef OHOS_CAMERA_CONFIG_IMPL_H 160a5c7a17Sopenharmony_ci#define OHOS_CAMERA_CONFIG_IMPL_H 170a5c7a17Sopenharmony_ci 180a5c7a17Sopenharmony_ci#include "camera_config.h" 190a5c7a17Sopenharmony_ci 200a5c7a17Sopenharmony_ci#include "media_log.h" 210a5c7a17Sopenharmony_ci 220a5c7a17Sopenharmony_cinamespace OHOS { 230a5c7a17Sopenharmony_cinamespace Media { 240a5c7a17Sopenharmony_ciclass CameraConfigImpl : public CameraConfig { 250a5c7a17Sopenharmony_cipublic: 260a5c7a17Sopenharmony_ci CameraConfigImpl() = default; 270a5c7a17Sopenharmony_ci ~CameraConfigImpl() = default; 280a5c7a17Sopenharmony_ci void SetFrameStateCallback(FrameStateCallback *callback, EventHandler *handler) override 290a5c7a17Sopenharmony_ci { 300a5c7a17Sopenharmony_ci if (inUse_) { 310a5c7a17Sopenharmony_ci MEDIA_ERR_LOG("This config is in use, do not support config modify."); 320a5c7a17Sopenharmony_ci } 330a5c7a17Sopenharmony_ci if (callback == nullptr || handler == nullptr) { 340a5c7a17Sopenharmony_ci MEDIA_ERR_LOG("Invalid parameter."); 350a5c7a17Sopenharmony_ci } 360a5c7a17Sopenharmony_ci 370a5c7a17Sopenharmony_ci callback_ = callback; 380a5c7a17Sopenharmony_ci handler_ = handler; 390a5c7a17Sopenharmony_ci inUse_ = true; 400a5c7a17Sopenharmony_ci } 410a5c7a17Sopenharmony_ci 420a5c7a17Sopenharmony_ci EventHandler *GetEventHandler() const override 430a5c7a17Sopenharmony_ci { 440a5c7a17Sopenharmony_ci return handler_; 450a5c7a17Sopenharmony_ci } 460a5c7a17Sopenharmony_ci 470a5c7a17Sopenharmony_ci FrameStateCallback *GetFrameStateCb() const override 480a5c7a17Sopenharmony_ci { 490a5c7a17Sopenharmony_ci return callback_; 500a5c7a17Sopenharmony_ci } 510a5c7a17Sopenharmony_ci 520a5c7a17Sopenharmony_ciprivate: 530a5c7a17Sopenharmony_ci FrameStateCallback *callback_ = nullptr; 540a5c7a17Sopenharmony_ci EventHandler *handler_ = nullptr; 550a5c7a17Sopenharmony_ci bool inUse_ = false; 560a5c7a17Sopenharmony_ci}; 570a5c7a17Sopenharmony_ci 580a5c7a17Sopenharmony_ciCameraConfig *CameraConfig::CreateCameraConfig() 590a5c7a17Sopenharmony_ci{ 600a5c7a17Sopenharmony_ci return new (std::nothrow) CameraConfigImpl(); 610a5c7a17Sopenharmony_ci} 620a5c7a17Sopenharmony_ci} // namespace Media 630a5c7a17Sopenharmony_ci} // namespace OHOS 640a5c7a17Sopenharmony_ci#endif // OHOS_CAMERA_CONFIG_IMPL_H