• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "picture_interface.h"
22 
23 namespace OHOS {
24 namespace CameraStandard {
25 namespace DeferredProcessing {
BufferInfo(const std::shared_ptr<SharedBuffer> & sharedBuffer,int32_t dataSize,bool isHighQuality,uint32_t cloudImageEnhanceFlag)26 BufferInfo::BufferInfo(const std::shared_ptr<SharedBuffer>& sharedBuffer, int32_t dataSize, bool isHighQuality,
27     uint32_t cloudImageEnhanceFlag)
28     : sharedBuffer_(sharedBuffer),
29       dataSize_(dataSize),
30       isHighQuality_(isHighQuality),
31       cloudImageEnhanceFlag_(cloudImageEnhanceFlag)
32 {
33     DP_DEBUG_LOG("entered.");
34 }
35 
~BufferInfo()36 BufferInfo::~BufferInfo()
37 {
38     DP_DEBUG_LOG("entered.");
39     sharedBuffer_ = nullptr;
40 }
41 
GetIPCFileDescriptor()42 sptr<IPCFileDescriptor> BufferInfo::GetIPCFileDescriptor()
43 {
44     int fd = dup(sharedBuffer_->GetFd());
45     DP_DEBUG_LOG("GetIPCFileDescriptor fd: %{public}d", fd);
46     return sptr<IPCFileDescriptor>::MakeSptr(fd);
47 }
48 
BufferInfoExt(std::shared_ptr<PictureIntf> picture,long dataSize,bool isHighQuality,uint32_t cloudImageEnhanceFlag)49 BufferInfoExt::BufferInfoExt(std::shared_ptr<PictureIntf> picture, long dataSize, bool isHighQuality,
50     uint32_t cloudImageEnhanceFlag)
51     : picture_(picture),
52       dataSize_(dataSize),
53       isHighQuality_(isHighQuality),
54       cloudImageEnhanceFlag_(cloudImageEnhanceFlag)
55 {
56 }
57 
~BufferInfoExt()58 BufferInfoExt::~BufferInfoExt()
59 {
60     picture_ = nullptr;
61 }
62 
GetPicture()63 std::shared_ptr<PictureIntf> 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 
GetCloudImageEnhanceFlag()78 uint32_t BufferInfoExt::GetCloudImageEnhanceFlag()
79 {
80     return cloudImageEnhanceFlag_;
81 }
82 } //namespace DeferredProcessing
83 } // namespace CameraStandard
84 } // namespace OHOS
85