1 #include <VP_Api/vp_api.h>
2 #include <VP_Api/vp_api_error.h>
3 #include <VP_Stages/vp_stages_configs.h>
4 #include <VP_Stages/vp_stages_i_v4l.h>
5 #include <VP_Stages/vp_stages_io_com.h>
6 #include <VP_Stages/vp_stages_buffer_to_picture.h>
7 #include <VP_Os/vp_os_print.h>
8 #include <VP_Os/vp_os_malloc.h>
9 #include <VP_Os/vp_os_delay.h>
10 #include <VP_Api/vp_api_thread_helper.h>
11 #include <VLIB/Stages/vlib_stage_encode.h>
14 #define VIDEO_DEVICE_PATH "/dev/video0"
21 #define ACQ_HEIGHT 240
23 #define COM_VIDEO() wired_com()
24 #define COM_CONFIG_VIDEO() wired_config()
25 #define COM_CONNECTION_VIDEO() wired_connection()
28 PROTO_THREAD_ROUTINE(app,nomParams);
31 THREAD_TABLE_ENTRY(app,20)
35 #define NB_STAGES_MAX 10
38 static vp_stages_input_v4l_config_t ivc;
39 static vp_stages_buffer_to_picture_config_t bpc;
40 static vlib_stage_encoding_config_t vec;
41 static vp_stages_output_com_config_t occ;
43 static PIPELINE_HANDLE pipeline_handle;
45 static vp_api_picture_t picture;
48 vp_com_t* wired_com(void)
50 static vp_com_t com = {
74 vp_com_config_t* wired_config(void)
76 static vp_com_wired_config_t config = {
83 return (vp_com_config_t*) &config;
86 vp_com_connection_t* wired_connection(void)
88 static vp_com_wired_connection_t connection = {
92 return (vp_com_connection_t*) (void*) &connection;
96 int main(int argc, char **argv)
100 PRINT("You need to specify video device path\n");
101 PRINT("Ex : %s /dev/video0\n", argv[0]);
105 START_THREAD(app, argv);
112 PROTO_THREAD_ROUTINE(app,argv)
114 vp_api_io_pipeline_t pipeline;
115 vp_api_io_data_t out;
116 vp_api_io_stage_t stages[NB_STAGES_MAX];
118 uint16_t time1,time2;
123 vp_os_memset(&ivc,0,sizeof(ivc));
124 vp_os_memset(&bpc,0,sizeof(bpc));
125 vp_os_memset(&vec,0,sizeof(vec));
126 vp_os_memset(&occ,0,sizeof(occ));
128 ivc.device = ((char**)argv)[1];
129 ivc.width = ACQ_WIDTH;
130 ivc.height = ACQ_HEIGHT;
131 ivc.vp_api_picture = &picture;
133 vec.width = ACQ_WIDTH;
134 vec.height = ACQ_HEIGHT;
135 vec.block_mode_enable = FALSE;
136 vec.picture = &picture;
138 occ.com = COM_VIDEO();
139 occ.config = COM_CONFIG_VIDEO();
140 occ.connection = COM_CONNECTION_VIDEO();
141 occ.socket.type = VP_COM_SERVER;
142 occ.socket.protocol = VP_COM_TCP;
143 occ.socket.port = 5555;
144 occ.buffer_size = 1500;
146 pipeline.nb_stages = 0;
148 stages[pipeline.nb_stages].type = VP_API_INPUT_FILE;
149 stages[pipeline.nb_stages].cfg = (void *)&ivc;
150 stages[pipeline.nb_stages++].funcs = vp_stages_input_v4l_funcs;
152 stages[pipeline.nb_stages].type = VP_API_FILTER_ENCODER;
153 stages[pipeline.nb_stages].cfg = (void*)&vec;
154 stages[pipeline.nb_stages++].funcs = vlib_encoding_funcs;
156 stages[pipeline.nb_stages].type = VP_API_OUTPUT_SOCKET;
157 stages[pipeline.nb_stages].cfg = (void *)&occ;
158 stages[pipeline.nb_stages++].funcs = vp_stages_output_com_funcs;
160 pipeline.stages = &stages[0];
162 vp_api_open(&pipeline, &pipeline_handle);
164 out.status = VP_API_STATUS_PROCESSING;
166 /////////////////////////////////////////////////////////////////////////////////////////
168 while(SUCCEED(vp_api_run(&pipeline, &out)) && (out.status == VP_API_STATUS_PROCESSING))
171 PRINT("image %d \n",i);
174 /////////////////////////////////////////////////////////////////////////////////////////
177 printf("temps ecoule : %d \n",time2-time1);
179 vp_api_close(&pipeline, &pipeline_handle);