1 /*
2  * Copyright (c) 2021-2022 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 "dcamera_photo_callback.h"
17 
18 #include "distributed_camera_constants.h"
19 #include "distributed_hardware_log.h"
20 
21 namespace OHOS {
22 namespace DistributedHardware {
DCameraPhotoCallback(const std::shared_ptr<StateCallback> & callback)23 DCameraPhotoCallback::DCameraPhotoCallback(const std::shared_ptr<StateCallback>& callback) : callback_(callback)
24 {
25 }
26 
OnCaptureStarted(const int32_t captureID) const27 void DCameraPhotoCallback::OnCaptureStarted(const int32_t captureID) const
28 {
29     DHLOGI("enter, captureID: %{public}d", captureID);
30 }
31 
OnCaptureStarted(const int32_t captureID,uint32_t exposureTime) const32 void DCameraPhotoCallback::OnCaptureStarted(const int32_t captureID, uint32_t exposureTime) const
33 {
34     DHLOGI("enter, captureID: %{public}d, exposureTime: %{public}u", captureID, exposureTime);
35 }
36 
OnCaptureEnded(const int32_t captureID,const int32_t frameCount) const37 void DCameraPhotoCallback::OnCaptureEnded(const int32_t captureID, const int32_t frameCount) const
38 {
39     DHLOGI("enter, captureID: %{public}d, frameCount: %{public}d", captureID, frameCount);
40 }
41 
OnFrameShutter(const int32_t captureId,const uint64_t timestamp) const42 void DCameraPhotoCallback::OnFrameShutter(const int32_t captureId, const uint64_t timestamp) const
43 {
44     DHLOGI("enter, captureId: %{public}d, timestamp: %{public}" PRIu64, captureId, timestamp);
45 }
46 
OnFrameShutterEnd(const int32_t captureId,const uint64_t timestamp) const47 void DCameraPhotoCallback::OnFrameShutterEnd(const int32_t captureId, const uint64_t timestamp) const
48 {
49     DHLOGI("enter, captureId: %{public}d, timestamp: %{public}" PRIu64, captureId, timestamp);
50 }
51 
OnCaptureReady(const int32_t captureId,const uint64_t timestamp) const52 void DCameraPhotoCallback::OnCaptureReady(const int32_t captureId, const uint64_t timestamp) const
53 {
54     DHLOGI("enter, captureId: %{public}d, timestamp: %{public}" PRIu64, captureId, timestamp);
55 }
56 
OnEstimatedCaptureDuration(const int32_t duration) const57 void DCameraPhotoCallback::OnEstimatedCaptureDuration(const int32_t duration) const
58 {
59     DHLOGI("enter, duration: %{public}d", duration);
60 }
61 
OnCaptureError(const int32_t captureId,const int32_t errorCode) const62 void DCameraPhotoCallback::OnCaptureError(const int32_t captureId, const int32_t errorCode) const
63 {
64     DHLOGE("enter, captureId: %{public}d, errorCode: %{public}d", captureId, errorCode);
65     if (callback_ == nullptr) {
66         DHLOGE("StateCallback is null");
67         return;
68     }
69 
70     std::shared_ptr<DCameraEvent> event = std::make_shared<DCameraEvent>();
71     event->eventType_ = DCAMERA_MESSAGE;
72     event->eventResult_ = DCAMERA_EVENT_DEVICE_ERROR;
73     callback_->OnStateChanged(event);
74 }
75 } // namespace DistributedHardware
76 } // namespace OHOS