• 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   int32_t color_space;
57   int32_t use_case;
58   StreamBuffer stream_buffer;
59   HwlPipelineCallback callback;
60   int acquire_fence_fd;
61   bool is_input;
62   bool is_failed_request;
63 
64   union Plane {
65     SinglePlane img;
66     YCbCrPlanes img_y_crcb;
67   } plane;
68 
SensorBufferSensorBuffer69   SensorBuffer()
70       : width(0),
71         height(0),
72         frame_number(0),
73         pipeline_id(0),
74         camera_id(0),
75         format(PixelFormat::RGBA_8888),
76         dataSpace(HAL_DATASPACE_UNKNOWN),
77         color_space(
78             ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED),
79         use_case(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT),
80         acquire_fence_fd(-1),
81         is_input(false),
82         is_failed_request(false),
83         plane{} {
84   }
85 
86   SensorBuffer(const SensorBuffer&) = delete;
87   SensorBuffer& operator=(const SensorBuffer&) = delete;
88 
~SensorBufferSensorBuffer89   virtual ~SensorBuffer() {
90   }
91 };
92 
93 typedef std::vector<std::unique_ptr<SensorBuffer>> Buffers;
94 
95 }  // namespace android
96 
97 #endif
98