cf57a45a408378d4d96c2a8c0052d0d180f9c606
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VP_SDK / VP_Api / vp_api.h
1 /**
2  *  @file     vp_api.h
3  *  @brief    VP Api. Pipeline definition
4  *  @author   Sylvain Gaeremynck <sylvain.gaeremynck@parrot.fr>
5  *  @author   Aurelien Morelle <aurelien.morelle@parrot.fr>
6  *  @author   Thomas Landais <thomas.landais@parrot.fr>
7  *  @author   Julien Floret <julien.floret.ext@parrot.com>
8  *  @version  2.0
9  *  @date     first release 16/03/2007
10  *  @date     modification  24/05/2007
11  */
12
13 #ifndef _VP_API_INCLUDE_H_
14 #define _VP_API_INCLUDE_H_
15
16 #include <VP_Os/vp_os_signal.h>
17 #include <VP_Os/vp_os_types.h>
18 #include <VP_Api/vp_api_config.h>
19 #include <VP_Api/vp_api_stage.h>
20 #include <VP_Api/vp_api_supervisor.h>
21
22
23 /**
24  * @enum  _VP_API_IO_TYPES_
25  * @brief Available io stages type
26  */
27 typedef enum _VP_API_IO_TYPES_
28 {
29   // INPUTS
30   VP_API_INPUT_BUFFER,
31   VP_API_INPUT_CAMIF,
32   VP_API_INPUT_FILE,
33   VP_API_INPUT_SOCKET,
34
35   // FILTERS
36   VP_API_FILTER_ENCODER,
37   VP_API_FILTER_DECODER,
38   VP_API_FFMPEG_ENCODER,
39   VP_API_FFMPEG_DECODER,
40   VP_API_FILTER_VISION,
41   VP_API_VISION_PREPARE,
42   VP_API_FILTER_YUV2RGB,
43   VP_API_JPEG_ENCODER,
44   VP_API_JPEG_DECODER,
45   VP_API_ARWIZ,
46
47   // OUTPUTS
48   VP_API_OUTPUT_CONSOLE,
49   VP_API_OUTPUT_SDL,
50   VP_API_OUTPUT_LCD,
51   VP_API_OUTPUT_FILE,
52   VP_API_OUTPUT_SOCKET,
53
54   // MIXERS
55   VP_API_PIPE
56 }
57 VP_API_IO_TYPE;
58
59 /**
60  * @enum  _VP_API_IO_STATUS_
61  * @brief Stage's state definition
62  */
63 typedef enum _VP_API_IO_STATUS_
64 {
65   VP_API_STATUS_INIT        = 0, // needs being equal to zero to ease initialization
66   VP_API_STATUS_PROCESSING,
67   VP_API_STATUS_STILL_RUNNING,
68   VP_API_STATUS_ENDED,
69   VP_API_STATUS_ERROR
70 }
71 VP_API_IO_STATUS;
72
73
74 /**
75  * @struct _vp_api_io_data_
76  * @brief  This structure is used by stages to share data in a generic way
77  */
78 typedef struct _vp_api_io_data_
79 {
80   uint32_t         numBuffers;
81   int8_t         **buffers;
82   uint32_t         indexBuffer;
83
84   int32_t          size;
85   int32_t         *lineSize;
86
87   VP_API_IO_STATUS status;
88
89   vp_os_mutex_t    lock;
90 }
91 vp_api_io_data_t;
92
93
94 /**
95  * @struct _vp_api_io_stage_
96  * @brief  Public definition of a stage
97  *
98  * This structure is used to configure stages
99  * The cfg field can be used to share data between stages in a specific way
100  */
101 typedef struct _vp_api_io_stage_
102 {
103   VP_API_IO_TYPE        type;
104   void                 *cfg;
105   vp_api_stage_funcs_t  funcs;
106   vp_api_io_data_t      data;
107 }
108 vp_api_io_stage_t;
109
110
111 /**
112  * @struct _vp_api_io_pipeline_
113  * @brief  Public definition of the pipeline
114  *
115  * This structure is used to configure the pipeline
116  */
117 typedef struct _vp_api_io_pipeline_
118 {
119   uint32_t                nb_stages;
120   vp_api_io_stage_t      *stages;
121   vp_api_handle_msg_t     handle_msg;
122   uint32_t                nb_still_running;
123   vp_api_fifo_t           fifo;
124
125 }
126 vp_api_io_pipeline_t;
127
128 #ifdef __cplusplus
129 extern "C"
130 {
131 #endif
132
133 /**
134  * @fn      C_RESULT vp_api_open(vp_api_io_pipeline_t *pipeline, PIPELINE_HANDLE *handle)
135  * @brief  Creates internally all
136  * @param   pipeline  Pipeline definition
137  * @param   handle    Pipeline handle
138  * @return  VP_SUCCESS or VP_FAILURE
139  */
140 C_RESULT
141 vp_api_open(vp_api_io_pipeline_t *pipeline, PIPELINE_HANDLE *handle);
142
143
144 /**
145  * @fn      C_RESULT vp_api_run(vp_api_io_pipeline_t *pipeline, vp_api_io_data_t *out_data)
146  * @brief   Runs pipeline
147  * @param   pipeline  Pipeline definition
148  * @param   out_data  Output data of the last pipeline stage
149  * @return  VP_SUCCESS or VP_FAILURE
150  */
151 C_RESULT
152 vp_api_run(vp_api_io_pipeline_t *pipeline, vp_api_io_data_t *out_data);
153
154
155 /**
156  * @fn      C_RESULT vp_api_flush(vp_api_io_pipeline_t *pipeline)
157  * @brief   Flushes pipeline
158  * @param   pipeline  Pipeline definition
159  * @return  VP_SUCCESS or VP_FAILURE
160  */
161 C_RESULT
162 vp_api_flush(vp_api_io_pipeline_t *pipeline);
163
164 /**
165  * @fn      C_RESULT vp_api_close(vp_api_io_pipeline_t *pipeline)
166  * @brief   Clean up
167  * @param   pipeline  Pipeline definition
168  * @return  VP_SUCCESS or VP_FAILURE
169  */
170 C_RESULT
171 vp_api_close(vp_api_io_pipeline_t *pipeline, PIPELINE_HANDLE *handle);
172
173 #ifdef __cplusplus
174 }
175 #endif
176
177 #endif // ! _VP_API_INCLUDE_H_