• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef HW_EMULATOR_CAMERA_BASE_H
18 #define HW_EMULATOR_CAMERA_BASE_H
19 
20 #include <log/log.h>
21 
22 #include <memory>
23 
24 #include "android/hardware/graphics/common/1.1/types.h"
25 #include "hwl_types.h"
26 
27 namespace android {
28 
29 using android::hardware::graphics::common::V1_1::PixelFormat;
30 using google_camera_hal::HwlPipelineCallback;
31 using google_camera_hal::StreamBuffer;
32 
33 struct YCbCrPlanes {
34   uint8_t* img_y = nullptr;
35   uint8_t* img_cb = nullptr;
36   uint8_t* img_cr = nullptr;
37   uint32_t y_stride = 0;
38   uint32_t cbcr_stride = 0;
39   uint32_t cbcr_step = 0;
40   size_t bytesPerPixel = 1;
41 };
42 
43 struct SinglePlane {
44   uint8_t* img = nullptr;
45   uint32_t stride_in_bytes = 0;
46   uint32_t buffer_size = 0;
47 };
48 
49 struct SensorBuffer {
50   uint32_t width, height;
51   uint32_t frame_number;
52   uint32_t pipeline_id;
53   uint32_t camera_id;
54   PixelFormat format;
55   android_dataspace_t dataSpace;
56   StreamBuffer stream_buffer;
57   HwlPipelineCallback callback;
58   int acquire_fence_fd;
59   bool is_input;
60   bool is_failed_request;
61 
62   union Plane {
63     SinglePlane img;
64     YCbCrPlanes img_y_crcb;
65   } plane;
66 
SensorBufferSensorBuffer67   SensorBuffer()
68       : width(0),
69         height(0),
70         frame_number(0),
71         pipeline_id(0),
72         camera_id(0),
73         format(PixelFormat::RGBA_8888),
74         dataSpace(HAL_DATASPACE_UNKNOWN),
75         acquire_fence_fd(-1),
76         is_input(false),
77         is_failed_request(false),
78         plane{} {
79   }
80 
81   SensorBuffer(const SensorBuffer&) = delete;
82   SensorBuffer& operator=(const SensorBuffer&) = delete;
83 
~SensorBufferSensorBuffer84   virtual ~SensorBuffer() {
85   }
86 };
87 
88 typedef std::vector<std::unique_ptr<SensorBuffer>> Buffers;
89 
90 }  // namespace android
91 
92 #endif
93