• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("DCameraPhotoCallback::OnCaptureStarted, captureID: %d", captureID);
30 }
31 
OnCaptureEnded(const int32_t captureID,const int32_t frameCount) const32 void DCameraPhotoCallback::OnCaptureEnded(const int32_t captureID, const int32_t frameCount) const
33 {
34     DHLOGI("DCameraPhotoCallback::OnCaptureEnded, captureID: %d, frameCount: %d", captureID, frameCount);
35 }
36 
OnFrameShutter(const int32_t captureId,const uint64_t timestamp) const37 void DCameraPhotoCallback::OnFrameShutter(const int32_t captureId, const uint64_t timestamp) const
38 {
39     DHLOGI("DCameraPhotoCallback::OnFrameShutter, captureId: %d, timestamp: %llu", captureId, timestamp);
40 }
41 
OnCaptureError(const int32_t captureId,const int32_t errorCode) const42 void DCameraPhotoCallback::OnCaptureError(const int32_t captureId, const int32_t errorCode) const
43 {
44     DHLOGE("DCameraPhotoCallback::OnCaptureError, captureId: %d, errorCode: %d", captureId, errorCode);
45     if (callback_ == nullptr) {
46         DHLOGE("DCameraPhotoCallback::OnCaptureError StateCallback is null");
47         return;
48     }
49 
50     std::shared_ptr<DCameraEvent> event = std::make_shared<DCameraEvent>();
51     event->eventType_ = DCAMERA_MESSAGE;
52     event->eventResult_ = DCAMERA_EVENT_DEVICE_ERROR;
53     callback_->OnStateChanged(event);
54 }
55 } // namespace DistributedHardware
56 } // namespace OHOS