99c36cd6e0516192a73d34e1eebf9606aa4e6786
[platform/core/multimedia/vision-source.git] / include / vision_source_interface.h
1 /**
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
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 __VISION_SOURCE_INTERFACE__
18 #define __VISION_SOURCE_INTERFACE__
19
20 #include <stdint.h>
21
22 #define BUFFER_PLANE_MAX 4
23 #define DEVICE_COUNT_MAX 16
24 #define RESOLUTION_COUNT_MAX 32
25 #define FPS_COUNT_MAX 16
26 #define DEVICE_NAME_LENGTH_MAX 16
27 #define DEVICE_NODE_PATH_LENGTH_MAX 16
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33
34 typedef struct vision_source_resolution
35 {
36         uint32_t width;
37         uint32_t height;
38 } vision_source_resolution_s;
39
40 typedef enum vision_source_pixel_format
41 {
42         VISION_SOURCE_PIXEL_FORMAT_RGB24 = 0x0000,
43         VISION_SOURCE_PIXEL_FORMAT_GREY,
44         VISION_SOURCE_PIXEL_FORMAT_Y10,
45         VISION_SOURCE_PIXEL_FORMAT_NV12,
46         VISION_SOURCE_PIXEL_FORMAT_NV21,
47         VISION_SOURCE_PIXEL_FORMAT_YVU420, //YV12
48         VISION_SOURCE_PIXEL_FORMAT_YUV420, //I420
49         VISION_SOURCE_PIXEL_FORMAT_MAX
50 } vision_source_pixel_format_e;
51
52 typedef struct vision_source_pixel_format_list
53 {
54         uint32_t count;
55         vision_source_pixel_format_e
56                         pixel_formats[VISION_SOURCE_PIXEL_FORMAT_MAX];
57 } vision_source_pixel_format_list_s;
58
59 typedef struct vision_source_resolution_list
60 {
61         uint32_t count;
62         vision_source_resolution_s resolutions[RESOLUTION_COUNT_MAX];
63 } vision_source_resolution_list_s;
64
65 typedef struct vision_source_fps_list
66 {
67         uint32_t count;
68         int fps[FPS_COUNT_MAX];
69 } vision_source_fps_list_s;
70
71 typedef struct vision_source_resolution_match_fps
72 {
73         vision_source_resolution_s resolution;
74         vision_source_fps_list_s fps_list;
75 } vision_source_resolution_match_fps_s;
76
77 typedef struct vision_source_resolution_match_fps_list
78 {
79         uint32_t count;
80         vision_source_resolution_match_fps_s resolutions[RESOLUTION_COUNT_MAX];
81 } vision_source_resolution_match_fps_list_s;
82
83 typedef struct vision_source_pixel_match_resolution
84 {
85         vision_source_pixel_format_e pixel_format;
86         vision_source_resolution_match_fps_list_s resolution_list;
87 } vision_source_pixel_match_resolution_s;
88
89 typedef struct vision_source_pixel_match_resolution_list
90 {
91         uint32_t count;
92         vision_source_pixel_match_resolution_s
93                         pixels[VISION_SOURCE_PIXEL_FORMAT_MAX];
94 } vision_source_pixel_match_resolution_list_s;
95
96 typedef struct vision_source_device_info
97 {
98         uint32_t index;
99         char name[DEVICE_NAME_LENGTH_MAX];
100         char node_path[DEVICE_NODE_PATH_LENGTH_MAX];
101         vision_source_pixel_match_resolution_list_s pixel_list;
102 } vision_source_device_info_s;
103
104 typedef struct vision_source_device_info_list
105 {
106         uint32_t count;
107         vision_source_device_info_s device_info[DEVICE_COUNT_MAX];
108 } vision_source_device_info_list_s;
109
110 typedef struct vision_source_plane
111 {
112         unsigned char *data;
113         uint32_t align_width;
114         uint32_t align_height;
115         uint32_t size;
116         uint32_t used_size;
117 } vision_source_plane_s;
118
119 typedef struct vision_source_format
120 {
121         vision_source_pixel_format_e pixel_format;
122         vision_source_resolution_s resolution;
123         uint32_t fps;
124         uint32_t quality;
125         uint32_t bitrate;
126 } vision_source_format_s;
127
128 typedef struct vision_source_buffer
129 {
130         int index;
131         vision_source_pixel_format_e pixel_format;
132         vision_source_resolution_s resolution;
133         uint32_t total_size;
134         uint32_t num_planes;
135         vision_source_plane_s planes[BUFFER_PLANE_MAX];
136         uint64_t timestamp;
137 } vision_source_buffer_s;
138
139 typedef enum vision_source_error
140 {
141         VISION_SOURCE_ERROR_NONE = 0,
142         VISION_SOURCE_ERROR_INVALID_PARAMETER,
143         VISION_SOURCE_ERROR_INTERNAL,
144         VISION_SOURCE_ERROR_NOT_IMPLEMENTED,
145         VISION_SOURCE_ERROR_UNKNOWN
146 } vision_source_error_e;
147
148 typedef void *vision_source_h;
149
150 typedef int (*stream_cb)(vision_source_buffer_s *buffer, void *user_data);
151
152 typedef struct vision_source_func
153 {
154         int (*init)(vision_source_h *handle);
155         int (*exit)(vision_source_h handle);
156         int (*open_device)(vision_source_h handle, int device_index);
157         int (*close_device)(vision_source_h handle);
158
159         int (*enumerate_devices)(vision_source_h handle,
160                                                                 vision_source_device_info_list_s *info_list);
161         int (*set_stream_format)(vision_source_h handle,
162                                                                 vision_source_format_s *format);
163
164         int (*start_stream)(vision_source_h handle, stream_cb callback,
165                                                 void *user_data);
166         int (*stop_stream)(vision_source_h handle);
167
168         int (*get_capture_frame)(vision_source_h handle,
169                                                                 vision_source_buffer_s *buffer);
170         int (*release_capture_frame)(vision_source_h handle, int buffer_index);
171 } vision_source_func_s;
172
173 void attach_backend(vision_source_func_s *funcp);
174
175 #ifdef __cplusplus
176 }
177 #endif
178
179 #endif /* __VISION_SOURCE_INTERFACE__ */