1 /*
2 * Copyright (c) 2023-2025 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 "image_info.h"
17
18 #include "dp_log.h"
19 #include "picture_interface.h"
20
21 namespace OHOS {
22 namespace CameraStandard {
23 namespace DeferredProcessing {
ImageInfo()24 ImageInfo::ImageInfo()
25 {
26 DP_DEBUG_LOG("entered.");
27 }
28
ImageInfo(int32_t dataSize,bool isHighQuality,uint32_t cloudFlag)29 ImageInfo::ImageInfo(int32_t dataSize, bool isHighQuality, uint32_t cloudFlag)
30 : dataSize_(dataSize), isHighQuality_(isHighQuality), cloudFlag_(cloudFlag)
31 {
32 DP_DEBUG_LOG("entered.");
33 }
34
~ImageInfo()35 ImageInfo::~ImageInfo()
36 {
37 DP_INFO_LOG("entered.");
38 }
39
SetBuffer(std::unique_ptr<SharedBuffer> sharedBuffer)40 void ImageInfo::SetBuffer(std::unique_ptr<SharedBuffer> sharedBuffer)
41 {
42 sharedBuffer_ = std::move(sharedBuffer);
43 SetType(CallbackType::IMAGE_PROCESS_DONE);
44 }
45
SetPicture(const std::shared_ptr<PictureIntf> & picture)46 void ImageInfo::SetPicture(const std::shared_ptr<PictureIntf>& picture)
47 {
48 picture_ = picture;
49 SetType(CallbackType::IMAGE_PROCESS_YUV_DONE);
50 }
51
SetError(DpsError error)52 void ImageInfo::SetError(DpsError error)
53 {
54 error_ = error;
55 SetType(CallbackType::IMAGE_ERROR);
56 }
57
SetType(CallbackType type)58 void ImageInfo::SetType(CallbackType type)
59 {
60 type_ = type;
61 }
62
GetIPCFileDescriptor()63 sptr<IPCFileDescriptor> ImageInfo::GetIPCFileDescriptor()
64 {
65 DP_CHECK_RETURN_RET(sharedBuffer_ == nullptr, nullptr);
66
67 int fd = dup(sharedBuffer_->GetFd());
68 DP_DEBUG_LOG("GetIPCFileDescriptor fd: %{public}d", fd);
69 return sptr<IPCFileDescriptor>::MakeSptr(fd);
70 }
71
GetPicture()72 std::shared_ptr<PictureIntf> ImageInfo::GetPicture()
73 {
74 return picture_;
75 }
76 } // namespace DeferredProcessing
77 } // namespace CameraStandard
78 } // namespace OHOS
79