summaryrefslogtreecommitdiff
path: root/include/camera_internal.h
blob: a9ac503ea4a519de3881e5b29604d336a983fe77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __TIZEN_MULTIMEDIA_CAMERA_INTERNAL_H__
#define __TIZEN_MULTIMEDIA_CAMERA_INTERNAL_H__

#include <camera.h>
#include <mm_types.h>
#include <tbm_surface_internal.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @file camera_internal.h
 * @brief This file contains the internal Camera API, related structures and enumerations.
 * @since_tizen 3.0
 */

/**
 * @addtogroup CAPI_MEDIA_CAMERA_INTERNAL_MODULE
 * @{
 */

#ifdef BUFFER_MAX_PLANE_NUM
#undef BUFFER_MAX_PLANE_NUM
#endif /* BUFFER_MAX_PLANE_NUM */

#define BUFFER_MAX_PLANE_NUM     4

typedef struct _camera_stream_data_s {
	union {
		struct {
			unsigned char *yuv;
			unsigned int length_yuv;
		} yuv420, yuv422;
		struct {
			unsigned char *y;
			unsigned int length_y;
			unsigned char *uv;
			unsigned int length_uv;
		} yuv420sp;
		struct {
			unsigned char *y;
			unsigned int length_y;
			unsigned char *u;
			unsigned int length_u;
			unsigned char *v;
			unsigned int length_v;
		} yuv420p, yuv422p;
		struct {
			unsigned char *data;
			unsigned int length_data;
			int is_delta_frame;
		} encoded, depth, rgb;
	} data;                         /**< pointer of captured stream */
	int data_type;                  /**< data type */
	unsigned int length_total;      /**< total length of stream buffer (in byte)*/
	unsigned int num_planes;        /**< number of planes */
	MMPixelFormatType format;       /**< image format */
	int width;                      /**< width of video buffer */
	int height;                     /**< height of video buffer */
	unsigned int timestamp;         /**< timestamp of stream buffer (msec)*/
	void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */
	void *internal_buffer;          /**< Internal buffer pointer */
	int stride[BUFFER_MAX_PLANE_NUM];    /**< Stride of each plane */
	int elevation[BUFFER_MAX_PLANE_NUM]; /**< Elevation of each plane */
} camera_stream_data_s;

/**
 * @brief Start the evas rendering.
 *
 * @since_tizen 3.0
 * @param[in] camera The handle to the camera
 * @return @c 0 on success, otherwise a negative error value
 * @retval #CAMERA_ERROR_NONE Successful
 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
 */
int camera_start_evas_rendering(camera_h camera);

/**
 * @brief Stop the evas rendering.
 *
 * @since_tizen 3.0
 * @param[in] camera The handle to the camera
 * @param[in] keep_screen If @c true keep last frame on display, otherwise @c false
 * @return @c 0 on success, otherwise a negative error value
 * @retval #CAMERA_ERROR_NONE Successful
 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
 */
int camera_stop_evas_rendering(camera_h camera, bool keep_screen);

/**
 * @brief Sets the ecore wayland video display.
 * @since_tizen 6.0
 * @remarks This function must be called in main thread of the application.
 *          Otherwise, it will return #CAMERA_ERROR_INVALID_OPERATION by internal restriction.
 *          To avoid #CAMERA_ERROR_INVALID_OPERATION in sub thread, ecore_thread_main_loop_begin() and
 *          ecore_thread_main_loop_end() can be used, but deadlock can occur if the main thread is busy.
 *          So, it's not recommended to use them.
 * @param[in] camera The handle to the camera
 * @param[in] ecore_wl_window The ecore wayland window handle
 * @return @c 0 on success,
 *         otherwise a negative error value
 * @retval #CAMERA_ERROR_NONE Successful
 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
 * @pre The camera state must be set to #CAMERA_STATE_CREATED.
 * @see camera_start_preview()
 * @see ecore_thread_main_loop_begin()
 * @see ecore_thread_main_loop_end()
 */
int camera_set_ecore_wl_display(camera_h camera, void *ecore_wl_window);

/**
 * @brief Creates preview frame from stream data.
 * @since_tizen 6.0
 * @param[in] stream The stream from internal pipeline
 * @param[in] num_buffer_fd The number of buffer fd
 * @param[in] buffer_bo_handle The bo handle of buffer
 * @param[in] data_bo_handle The bo handle of data
 * @param[out] frame The frame which will be filled
 */
void camera_create_preview_frame(camera_stream_data_s *stream, int num_buffer_fd,
	tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);

/**
 * @}
 */
#ifdef __cplusplus
}
#endif

#endif /* __TIZEN_MULTIMEDIA_CAMERA_INTERNAL_H__ */