1 /*
2 * Copyright (c) 2023-2023 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 "buffer_info.h"
17
18 #include <unistd.h>
19
20 #include "dp_log.h"
21
22 namespace OHOS {
23 namespace CameraStandard {
24 namespace DeferredProcessing {
BufferInfo(const std::shared_ptr<SharedBuffer> & sharedBuffer,int32_t dataSize,bool isHighQuality,bool isCloudImageEnhanceSupported)25 BufferInfo::BufferInfo(const std::shared_ptr<SharedBuffer>& sharedBuffer, int32_t dataSize, bool isHighQuality,
26 bool isCloudImageEnhanceSupported)
27 : sharedBuffer_(sharedBuffer),
28 dataSize_(dataSize),
29 isHighQuality_(isHighQuality),
30 isCloudImageEnhanceSupported_(isCloudImageEnhanceSupported)
31 {
32 DP_DEBUG_LOG("entered.");
33 }
34
~BufferInfo()35 BufferInfo::~BufferInfo()
36 {
37 DP_DEBUG_LOG("entered.");
38 sharedBuffer_ = nullptr;
39 }
40
GetIPCFileDescriptor()41 sptr<IPCFileDescriptor> BufferInfo::GetIPCFileDescriptor()
42 {
43 int fd = dup(sharedBuffer_->GetFd());
44 DP_DEBUG_LOG("GetIPCFileDescriptor fd: %{public}d", fd);
45 return sptr<IPCFileDescriptor>::MakeSptr(fd);
46 }
47
BufferInfoExt(std::shared_ptr<Media::Picture> picture,long dataSize,bool isHighQuality,bool isCloudImageEnhanceSupported)48 BufferInfoExt::BufferInfoExt(std::shared_ptr<Media::Picture> picture, long dataSize, bool isHighQuality,
49 bool isCloudImageEnhanceSupported)
50 : picture_(picture),
51 dataSize_(dataSize),
52 isHighQuality_(isHighQuality),
53 isCloudImageEnhanceSupported_(isCloudImageEnhanceSupported)
54
55 {
56 }
57
~BufferInfoExt()58 BufferInfoExt::~BufferInfoExt()
59 {
60 picture_ = nullptr;
61 }
62
GetPicture()63 std::shared_ptr<Media::Picture> BufferInfoExt::GetPicture()
64 {
65 return picture_;
66 }
67
GetDataSize()68 long BufferInfoExt::GetDataSize()
69 {
70 return dataSize_;
71 }
72
IsHighQuality()73 bool BufferInfoExt::IsHighQuality()
74 {
75 return isHighQuality_;
76 }
77
IsCloudImageEnhanceSupported()78 bool BufferInfoExt::IsCloudImageEnhanceSupported()
79 {
80 return isCloudImageEnhanceSupported_;
81 }
82 } // namespace DeferredProcessing
83 } // namespace CameraStandard
84 } // namespace OHOS
85