4 #include <VP_Api/vp_api.h>
5 #include <VP_Api/vp_api_thread_helper.h>
6 #include <VP_Api/vp_api_error.h>
7 #include <VP_Stages/vp_stages_configs.h>
8 #include <VP_Stages/vp_stages_io_console.h>
9 #include <VP_Stages/vp_stages_o_sdl.h>
10 #include <VP_Stages/vp_stages_io_console.h>
11 #include <VP_Stages/vp_stages_io_com.h>
12 #include <VP_Stages/vp_stages_io_file.h>
13 #include <VP_Stages/vp_stages_buffer_to_picture.h>
14 #include <VP_Os/vp_os_print.h>
15 #include <VP_Os/vp_os_malloc.h>
16 #include <VP_Os/vp_os_delay.h>
19 #define SERVER_HOST "172.20.22.245"
25 #define NB_STAGES_MAX 10
28 #define ACQ_HEIGHT 240
31 #define COM_VIDEO() wired_com()
32 #define COM_CONFIG_VIDEO() wired_config()
33 #define COM_CONNECTION_VIDEO() wired_connection()
34 #define COM_CONFIG_SOCKET_VIDEO(socket, type, opt, serverhost) wired_config_socket(socket, type, opt, serverhost)
37 PROTO_THREAD_ROUTINE(escaper,nomParams);
38 PROTO_THREAD_ROUTINE(app,nomParams);
41 THREAD_TABLE_ENTRY(escaper,20)
42 THREAD_TABLE_ENTRY(app,10)
46 static vp_stages_input_com_config_t icc;
47 static vp_stages_buffer_to_picture_config_t bpc;
48 static vp_stages_output_sdl_config_t osc;
50 static PIPELINE_HANDLE pipeline_handle;
52 static vp_api_picture_t picture;
55 vp_com_t* wired_com(void)
57 static vp_com_t com = {
81 vp_com_config_t* wired_config(void)
83 static vp_com_wired_config_t config = {
90 return (vp_com_config_t*) &config;
93 vp_com_connection_t* wired_connection(void)
95 static vp_com_wired_connection_t connection = {
99 return (vp_com_connection_t*) (void*) &connection;
102 void wired_config_socket(vp_com_socket_t* socket, VP_COM_SOCKET_TYPE type, int32_t port, const char* serverhost)
104 vp_os_memset(socket, 0, sizeof(vp_com_socket_t));
107 socket->protocol = VP_COM_TCP;
110 if(serverhost && socket->type == VP_COM_CLIENT)
111 strcpy(socket->serverHost, serverhost);
116 main(int argc, char **argv)
118 START_THREAD(escaper, NO_PARAM);
119 START_THREAD(app, argv);
121 JOIN_THREAD(escaper);
128 PROTO_THREAD_ROUTINE(app,argv)
130 vp_api_io_pipeline_t pipeline;
131 vp_api_io_data_t out;
132 vp_api_io_stage_t stages[NB_STAGES_MAX];
134 vp_os_memset( &icc, 0, sizeof(icc) );
135 vp_os_memset( &bpc, 0, sizeof(bpc) );
136 vp_os_memset( &osc, 0, sizeof(osc) );
138 icc.com = COM_VIDEO();
139 icc.buffer_size = ACQ_WIDTH*ACQ_HEIGHT*3/2;
140 icc.socket.protocol = VP_COM_TCP;
141 COM_CONFIG_SOCKET_VIDEO(&icc.socket, VP_COM_CLIENT, 5555, SERVER_HOST);
143 /// Picture configuration
144 picture.format = PIX_FMT_YUV420P;
145 picture.width = ACQ_WIDTH;
146 picture.height = ACQ_HEIGHT;
147 picture.framerate = 30;
148 picture.y_buf = vp_os_malloc( ACQ_WIDTH*ACQ_HEIGHT );
149 picture.cr_buf = vp_os_malloc( ACQ_WIDTH*ACQ_HEIGHT/4 );
150 picture.cb_buf = vp_os_malloc( ACQ_WIDTH*ACQ_HEIGHT/4 );
151 picture.y_line_size = ACQ_WIDTH;
152 picture.cb_line_size = ACQ_WIDTH / 2;
153 picture.cr_line_size = ACQ_WIDTH / 2;
157 bpc.picture = &picture;
158 bpc.block_mode_enable = FALSE;
159 bpc.y_buffer_size = ACQ_WIDTH * ACQ_HEIGHT;
160 bpc.y_blockline_size = ACQ_WIDTH * 16; // each blockline have 16 lines
161 bpc.y_current_size = 0;
163 bpc.y_buf_ptr = NULL;
164 bpc.luma_only = FALSE;
165 bpc.cr_buf_ptr = NULL;
166 bpc.cb_buf_ptr = NULL;
168 osc.width = ACQ_WIDTH;
169 osc.height = ACQ_HEIGHT;
171 osc.window_width = ACQ_WIDTH;
172 osc.window_height = ACQ_HEIGHT;
173 osc.pic_width = ACQ_WIDTH;
174 osc.pic_height = ACQ_HEIGHT;
175 osc.y_size = ACQ_WIDTH*ACQ_HEIGHT;
176 osc.c_size = (ACQ_WIDTH*ACQ_HEIGHT) >> 2;
178 pipeline.nb_stages = 0;
180 stages[pipeline.nb_stages].type = VP_API_INPUT_SOCKET;
181 stages[pipeline.nb_stages].cfg = (void *)&icc;
182 stages[pipeline.nb_stages++].funcs = vp_stages_input_com_funcs;
184 stages[pipeline.nb_stages].type = VP_API_FILTER_DECODER;
185 stages[pipeline.nb_stages].cfg = (void*)&bpc;
186 stages[pipeline.nb_stages++].funcs = vp_stages_buffer_to_picture_funcs;
188 stages[pipeline.nb_stages].type = VP_API_OUTPUT_SDL;
189 stages[pipeline.nb_stages].cfg = (void *)&osc;
190 stages[pipeline.nb_stages++].funcs = vp_stages_output_sdl_funcs;
192 pipeline.stages = &stages[0];
194 vp_api_open(&pipeline, &pipeline_handle);
195 out.status = VP_API_STATUS_PROCESSING;
196 while(SUCCEED(vp_api_run(&pipeline, &out)) && (out.status == VP_API_STATUS_PROCESSING || out.status == VP_API_STATUS_STILL_RUNNING))
200 vp_api_close(&pipeline, &pipeline_handle);