|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
52 #ifndef VIEWVIDEO_DOWNSIZE_FACTOR
53 #define VIEWVIDEO_DOWNSIZE_FACTOR 4
58 #ifndef VIEWVIDEO_QUALITY_FACTOR
59 #define VIEWVIDEO_QUALITY_FACTOR 50
65 #define VIEWVIDEO_FPS 5
70 #ifndef VIEWVIDEO_NICE_LEVEL
71 #define VIEWVIDEO_NICE_LEVEL 5
76 #ifndef VIEWVIDEO_USE_NETCAT
77 #define VIEWVIDEO_USE_NETCAT FALSE
80 #if !VIEWVIDEO_USE_NETCAT && !(defined VIEWVIDEO_USE_RTP)
81 #define VIEWVIDEO_USE_RTP TRUE
84 #if VIEWVIDEO_USE_NETCAT
95 PRINT_CONFIG_VAR(VIEWVIDEO_HOST)
96 PRINT_CONFIG_VAR(VIEWVIDEO_PORT_OUT)
97 PRINT_CONFIG_VAR(VIEWVIDEO_PORT2_OUT)
104 #if !VIEWVIDEO_USE_NETCAT
118 if(img_small->
buf != NULL){
128 if(img_jpeg->
w != img_small->
w || img_jpeg->
h != img_small->
h)
130 if(img_jpeg->
buf != NULL){
136 #if VIEWVIDEO_USE_NETCAT
138 sprintf(nc_cmd,
"nc %s %d 2>/dev/null", STRINGIFY(VIEWVIDEO_HOST), VIEWVIDEO_PORT_OUT);
150 #if VIEWVIDEO_USE_NETCAT
155 printf(
"[viewvideo] Could not create netcat fork.\n");
156 }
else if (pid == 0) {
158 FILE *netcat = popen(nc_cmd,
"w");
159 if (netcat != NULL) {
163 printf(
"[viewvideo] Failed to open netcat process.\n");
193 #ifdef VIEWVIDEO_CAMERA
194 static struct image_t *viewvideo_function1(
struct image_t *img,
uint8_t camera_id __attribute__((unused)))
198 static struct image_t img_small = {.
buf=NULL, .buf_size=0};
199 static struct image_t img_jpeg = {.
buf=NULL, .buf_size=0};
204 #ifdef VIEWVIDEO_CAMERA2
205 static struct image_t *viewvideo_function2(
struct image_t *img,
uint8_t camera_id __attribute__((unused)))
209 static struct image_t img_small = {.
buf=NULL, .buf_size=0};
210 static struct image_t img_jpeg = {.
buf=NULL, .buf_size=0};
231 #if VIEWVIDEO_USE_NETCAT
233 sprintf(save_name,
"%s/netcat-recv.sh", STRINGIFY(VIEWVIDEO_SHOT_PATH));
234 FILE *fp = fopen(save_name,
"w");
236 fprintf(fp,
"i=0\n");
237 fprintf(fp,
"while true\n");
239 fprintf(fp,
"\tn=$(printf \"%%04d\" $i)\n");
240 fprintf(fp,
"\tnc -l 0.0.0.0 %d > img_${n}.jpg\n", (
int)(VIEWVIDEO_PORT_OUT));
241 fprintf(fp,
"\ti=$((i+1))\n");
242 fprintf(fp,
"done\n");
245 printf(
"[viewvideo] Failed to create netcat receiver file.\n");
249 #ifdef VIEWVIDEO_CAMERA
251 printf(
"[viewvideo]: failed to open view video socket, HOST=%s, port=%d\n", STRINGIFY(VIEWVIDEO_HOST),
256 #ifdef VIEWVIDEO_CAMERA2
258 printf(
"[viewvideo]: failed to open view video socket, HOST=%s, port=%d\n", STRINGIFY(VIEWVIDEO_HOST),
259 VIEWVIDEO_PORT2_OUT);
264 #ifdef VIEWVIDEO_CAMERA
267 fprintf(stderr,
"[viewvideo] Added asynchronous video streamer listener for CAMERA1 at %u FPS \n",
VIEWVIDEO_FPS);
270 #ifdef VIEWVIDEO_CAMERA2
273 fprintf(stderr,
"[viewvideo] Added asynchronous video streamer listener for CAMERA2 at %u FPS \n",
VIEWVIDEO_FPS);
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
void jpeg_encode_image(struct image_t *in, struct image_t *out, uint32_t quality_factor, bool add_dri_header)
Encode an YUV422 image.
int udp_socket_create(struct UdpSocket *sock, char *host, int port_out, int port_in, bool broadcast)
Create UDP socket and bind it.
#define VIEWVIDEO_DOWNSIZE_FACTOR
struct viewvideo_t viewvideo
void image_free(struct image_t *img)
Free the image.
struct video_listener * cv_add_to_device_async(struct video_config_t *device, cv_function func, int nice_level, uint16_t fps, uint8_t id)
void rtp_frame_send(struct UdpSocket *udp, struct image_t *img, uint8_t format_code, uint8_t quality_code, uint8_t has_dri_header, float average_frame_rate, uint16_t *packet_number, uint32_t *rtp_time_counter)
Send an RTP frame.
bool use_rtp
Stream over RTP.
#define VIEWVIDEO_QUALITY_FACTOR
struct UdpSocket video_sock1
uint32_t buf_size
The buffer size.
#define VIEWVIDEO_USE_NETCAT
void image_yuv422_downsample(struct image_t *input, struct image_t *output, uint8_t downsample)
Simplified high-speed low CPU downsample function without averaging downsample factor must be 1,...
void viewvideo_init(void)
Initialize the view video.
static struct image_t * viewvideo_function(struct UdpSocket *viewvideo_socket, struct image_t *img, uint16_t *rtp_packet_nr, uint32_t *rtp_frame_time, struct image_t *img_small, struct image_t *img_jpeg)
Handles all the video streaming and saving of the image shots This is a separate thread,...
@ IMAGE_JPEG
An JPEG encoded image (not per pixel encoded)
#define VIEWVIDEO_NICE_LEVEL
#define VIEWVIDEO_USE_RTP
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
uint8_t quality_factor
Quality factor during the stream.
volatile bool is_streaming
When the device is streaming.
@ IMAGE_YUV422
UYVY format (uint16 per pixel)
struct UdpSocket video_sock2
void * buf
Image buffer (depending on the image_type)
uint8_t downsize_factor
Downsize factor during the stream.