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_Os/vp_os_print.h>
7 #include <VP_Os/vp_os_malloc.h>
8 #include <VP_Os/vp_os_delay.h>
9 #include <VP_Api/vp_api_thread_helper.h>
10 #include <VLIB/Stages/vlib_stage_encode.h>
18 #define ACQ_HEIGHT 240
20 #define COM_VIDEO() wired_com()
21 #define COM_CONFIG_VIDEO() wired_config()
22 #define COM_CONNECTION_VIDEO() wired_connection()
25 PROTO_THREAD_ROUTINE(app,nomParams);
28 THREAD_TABLE_ENTRY(app,20)
32 #define NB_STAGES_MAX 10
35 static vp_stages_input_v4l_config_t ivc;
36 static vp_stages_output_com_config_t occ;
38 static PIPELINE_HANDLE pipeline_handle;
40 static vp_api_picture_t picture;
43 vp_com_t* wired_com(void)
45 static vp_com_t com = {
69 vp_com_config_t* wired_config(void)
71 static vp_com_wired_config_t config = {
78 return (vp_com_config_t*) &config;
81 vp_com_connection_t* wired_connection(void)
83 static vp_com_wired_connection_t connection = {
87 return (vp_com_connection_t*) (void*) &connection;
91 int main(int argc, char **argv)
95 PRINT("You need to specify video device path\n");
96 PRINT("Ex : %s /dev/video0\n", argv[0]);
100 START_THREAD(app, argv);
107 PROTO_THREAD_ROUTINE(app,argv)
109 vp_api_io_pipeline_t pipeline;
110 vp_api_io_data_t out;
111 vp_api_io_stage_t stages[NB_STAGES_MAX];
113 uint16_t time1,time2;
118 vp_os_memset(&ivc,0,sizeof(ivc));
119 vp_os_memset(&occ,0,sizeof(occ));
121 ivc.device = ((char**)argv)[1];
122 ivc.width = ACQ_WIDTH;
123 ivc.height = ACQ_HEIGHT;
124 ivc.vp_api_picture = &picture;
126 occ.com = COM_VIDEO();
127 occ.config = COM_CONFIG_VIDEO();
128 occ.connection = COM_CONNECTION_VIDEO();
129 occ.socket.type = VP_COM_SERVER;
130 occ.socket.protocol = VP_COM_TCP;
131 occ.socket.port = 5555;
132 occ.buffer_size = 320*240*3/2;
134 pipeline.nb_stages = 0;
136 stages[pipeline.nb_stages].type = VP_API_INPUT_FILE;
137 stages[pipeline.nb_stages].cfg = (void *)&ivc;
138 stages[pipeline.nb_stages++].funcs = vp_stages_input_v4l_funcs;
140 stages[pipeline.nb_stages].type = VP_API_OUTPUT_SOCKET;
141 stages[pipeline.nb_stages].cfg = (void *)&occ;
142 stages[pipeline.nb_stages++].funcs = vp_stages_output_com_funcs;
144 pipeline.stages = &stages[0];
146 vp_api_open(&pipeline, &pipeline_handle);
148 out.status = VP_API_STATUS_PROCESSING;
150 /////////////////////////////////////////////////////////////////////////////////////////
152 while(SUCCEED(vp_api_run(&pipeline, &out)) && (out.status == VP_API_STATUS_PROCESSING))
155 PRINT("image %d \n",i);
158 /////////////////////////////////////////////////////////////////////////////////////////
161 printf("temps ecoule : %d \n",time2-time1);
163 vp_api_close(&pipeline, &pipeline_handle);