• 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 #ifndef DISTRIBUTED_CAMERA_IMAGE_BUFFER_H
17 #define DISTRIBUTED_CAMERA_IMAGE_BUFFER_H
18 
19 #include <mutex>
20 
21 #include "constants.h"
22 #include "v1_0/dcamera_types.h"
23 
24 namespace OHOS {
25 namespace DistributedHardware {
26 class DImageBuffer {
27 public:
28     DImageBuffer() = default;
29     virtual ~DImageBuffer();
30 
31     int32_t GetIndex() const;
32     uint32_t GetWidth() const;
33     uint32_t GetHeight() const;
34     uint32_t GetStride() const;
35     int32_t GetFormat() const;
36     uint32_t GetSize() const;
37     uint64_t GetUsage() const;
38     uint64_t GetPhyAddress() const;
39     int32_t GetFileDescriptor() const;
40     uint64_t GetTimestamp() const;
41     uint64_t GetFrameNumber() const;
42     int32_t GetCaptureId() const;
43     bool GetValidFlag() const;
44     int32_t GetFenceId() const;
45     int32_t GetEncodeType() const;
46     BufferHandle* GetBufferHandle() const;
47 
48     void SetIndex(const int32_t index);
49     void SetWidth(const uint32_t width);
50     void SetHeight(const uint32_t height);
51     void SetStride(const uint32_t stride);
52     void SetFormat(const int32_t format);
53     void SetSize(const uint32_t size);
54     void SetUsage(const uint64_t usage);
55     void SetPhyAddress(const uint64_t addr);
56     void SetFileDescriptor(const int32_t fd);
57     void SetTimestamp(const uint64_t timestamp);
58     void SetFrameNumber(const uint64_t frameNumber);
59     void SetCaptureId(const int32_t id);
60     void SetValidFlag(const bool flag);
61     void SetFenceId(const int32_t fence);
62     void SetEncodeType(const int32_t type);
63     void SetBufferHandle(const BufferHandle* bufHandle);
64 
65     void Free();
66     bool operator==(const DImageBuffer& u);
67 
68 private:
69     int32_t index_ = -1;
70     uint32_t width_ = 0;
71     uint32_t height_ = 0;
72     uint32_t stride_ = 0;
73     uint32_t format_ = OHOS_CAMERA_FORMAT_INVALID;
74     uint32_t size_ = 0;
75     uint64_t usage_ = 0;
76     uint64_t phyAddr_ = 0;
77     int32_t fd_ = -1;
78     uint64_t frameNumber_ = 0;
79     uint64_t timeStamp_ = 0;
80     int32_t captureId_ = -1;
81     bool valid_ = true;
82     int32_t fenceId_ = -1;
83     int32_t encodeType_ = 0;
84     BufferHandle* bufHandle_ = nullptr;
85 
86     std::mutex l_;
87 };
88 } // namespace DistributedHardware
89 } // namespace OHOS
90 #endif // DISTRIBUTED_CAMERA_IMAGE_BUFFER_H
91