14.01.2013 Views

A.R.Drone Developer Guide - Abstract

A.R.Drone Developer Guide - Abstract

A.R.Drone Developer Guide - Abstract

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Listing 5.7: Building a video pipeline<br />

#include <br />

#include <br />

#include <br />

#include <br />

#include <br />

vp_api_io_pipeline_t pipeline;<br />

vp_api_io_data_t out;<br />

vp_api_io_stage_t stages[NB_STAGES];<br />

video_com_config_t icc;<br />

icc.com = COM_VIDEO();<br />

icc.buffer_size = 100000;<br />

icc.protocol = VP_COM_UDP;<br />

COM_CONFIG_SOCKET_VIDEO(&icc.socket, VP_COM_CLIENT, VIDEO_PORT, wifi_ardrone_ip);<br />

pipeline.nb_stages = 0;<br />

stages[pipeline.nb_stages].type = VP_API_INPUT_SOCKET;<br />

stages[pipeline.nb_stages].cfg = (void *)&icc;<br />

stages[pipeline.nb_stages].funcs = video_com_funcs;<br />

pipeline.nb_stages++;<br />

Listing 5.8: Running a video pipeline<br />

res = vp_api_open(&pipeline, &pipeline_handle);<br />

if( SUCCEED(res) )<br />

{<br />

int loop = SUCCESS;<br />

out.status = VP_API_STATUS_PROCESSING;<br />

while(loop == SUCCESS)<br />

{<br />

if( SUCCEED(vp_api_run(&pipeline, &out)) )<br />

{<br />

if( (out.status == VP_API_STATUS_PROCESSING || out.status ==<br />

VP_API_STATUS_STILL_RUNNING) )<br />

{<br />

loop = SUCCESS;<br />

}<br />

}<br />

else loop = -1; // Finish this thread<br />

}<br />

vp_api_close(&pipeline, &pipeline_handle);<br />

}<br />

27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!