1 /*
2  * Copyright (c) 2020-2021 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 #ifndef OHOS_CAMERA_CONFIG_IMPL_H
16 #define OHOS_CAMERA_CONFIG_IMPL_H
17 
18 #include "camera_config.h"
19 
20 #include "media_log.h"
21 
22 namespace OHOS {
23 namespace Media {
24 class CameraConfigImpl : public CameraConfig {
25 public:
26     CameraConfigImpl() = default;
27     ~CameraConfigImpl() = default;
SetFrameStateCallback(FrameStateCallback * callback,EventHandler * handler)28     void SetFrameStateCallback(FrameStateCallback *callback, EventHandler *handler) override
29     {
30         if (inUse_) {
31             MEDIA_ERR_LOG("This config is in use, do not support config modify.");
32         }
33         if (callback == nullptr || handler == nullptr) {
34             MEDIA_ERR_LOG("Invalid parameter.");
35         }
36 
37         callback_ = callback;
38         handler_ = handler;
39         inUse_ = true;
40     }
41 
GetEventHandler() const42     EventHandler *GetEventHandler() const override
43     {
44         return handler_;
45     }
46 
GetFrameStateCb() const47     FrameStateCallback *GetFrameStateCb() const override
48     {
49         return callback_;
50     }
51 
52 private:
53     FrameStateCallback *callback_ = nullptr;
54     EventHandler *handler_ = nullptr;
55     bool inUse_ = false;
56 };
57 
CreateCameraConfig()58 CameraConfig *CameraConfig::CreateCameraConfig()
59 {
60     return new (std::nothrow) CameraConfigImpl();
61 }
62 } // namespace Media
63 } // namespace OHOS
64 #endif // OHOS_CAMERA_CONFIG_IMPL_H