52 #ifndef VIEWVIDEO_DOWNSIZE_FACTOR
53 #define VIEWVIDEO_DOWNSIZE_FACTOR 4
58 #ifndef VIEWVIDEO_QUALITY_FACTOR
59 #define VIEWVIDEO_QUALITY_FACTOR 50
64 #ifndef VIEWVIDEO_RTP_TIME_INC
65 #define VIEWVIDEO_RTP_TIME_INC 0
71 #define VIEWVIDEO_FPS 5
76 #ifndef VIEWVIDEO_NICE_LEVEL
77 #define VIEWVIDEO_NICE_LEVEL 5
82 #ifndef VIEWVIDEO_USE_NETCAT
83 #define VIEWVIDEO_USE_NETCAT FALSE
86 #if !VIEWVIDEO_USE_NETCAT && !(defined VIEWVIDEO_USE_RTP)
87 #define VIEWVIDEO_USE_RTP TRUE
90 #if VIEWVIDEO_USE_NETCAT
101 PRINT_CONFIG_VAR(VIEWVIDEO_HOST)
102 PRINT_CONFIG_VAR(VIEWVIDEO_PORT_OUT)
103 PRINT_CONFIG_VAR(VIEWVIDEO_PORT2_OUT)
110 #if !VIEWVIDEO_USE_NETCAT
132 #if VIEWVIDEO_USE_NETCAT
134 sprintf(nc_cmd,
"nc %s %d 2>/dev/null", STRINGIFY(VIEWVIDEO_HOST), VIEWVIDEO_PORT_OUT);
147 #if VIEWVIDEO_USE_NETCAT
152 printf(
"[viewvideo] Could not create netcat fork.\n");
153 }
else if (pid == 0) {
155 FILE *netcat = popen(nc_cmd,
"w");
156 if (netcat != NULL) {
160 printf(
"[viewvideo] Failed to open netcat process.\n");
178 (img->
ts.tv_sec * 1000000 + img->
ts.tv_usec),
191 #ifdef VIEWVIDEO_CAMERA
199 #ifdef VIEWVIDEO_CAMERA2
214 #if VIEWVIDEO_USE_NETCAT
216 sprintf(save_name,
"%s/netcat-recv.sh", STRINGIFY(VIEWVIDEO_SHOT_PATH));
217 FILE *fp = fopen(save_name,
"w");
219 fprintf(fp,
"i=0\n");
220 fprintf(fp,
"while true\n");
222 fprintf(fp,
"\tn=$(printf \"%%04d\" $i)\n");
223 fprintf(fp,
"\tnc -l 0.0.0.0 %d > img_${n}.jpg\n", (
int)(VIEWVIDEO_PORT_OUT));
224 fprintf(fp,
"\ti=$((i+1))\n");
225 fprintf(fp,
"done\n");
228 printf(
"[viewvideo] Failed to create netcat receiver file.\n");
232 #ifdef VIEWVIDEO_CAMERA
234 printf(
"[viewvideo]: failed to open view video socket, HOST=%s, port=%d\n", STRINGIFY(VIEWVIDEO_HOST),
239 #ifdef VIEWVIDEO_CAMERA2
241 printf(
"[viewvideo]: failed to open view video socket, HOST=%s, port=%d\n", STRINGIFY(VIEWVIDEO_HOST),
242 VIEWVIDEO_PORT2_OUT);
247 #ifdef VIEWVIDEO_CAMERA
250 fprintf(stderr,
"[viewvideo] Added asynchronous video streamer listener for CAMERA1 at %u FPS \n",
VIEWVIDEO_FPS);
253 #ifdef VIEWVIDEO_CAMERA2
256 fprintf(stderr,
"[viewvideo] Added asynchronous video streamer listener for CAMERA2 at %u FPS \n",
VIEWVIDEO_FPS);
uint32_t buf_size
The buffer size.
struct viewvideo_t viewvideo
bool use_rtp
Stream over RTP.
void image_yuv422_downsample(struct image_t *input, struct image_t *output, uint16_t downsample)
Simplified high-speed low CPU downsample function without averaging downsample factor must be 1...
#define VIEWVIDEO_RTP_TIME_INC
#define VIEWVIDEO_QUALITY_FACTOR
#define VIEWVIDEO_DOWNSIZE_FACTOR
void image_free(struct image_t *img)
Free the image.
void image_create(struct image_t *img, uint16_t width, uint16_t height, enum image_type type)
Create a new image.
Easily create and use UDP sockets.
#define VIEWVIDEO_USE_NETCAT
struct UdpSocket video_sock1
Image helper functions like resizing, color filter, converters...
void rtp_frame_send(struct UdpSocket *udp, struct image_t *img, uint8_t format_code, uint8_t quality_code, uint8_t has_dri_header, uint32_t frame_time, uint32_t *packet_number)
Send an RTP frame.
Computer vision framework for onboard processing.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
void * buf
Image buffer (depending on the image_type)
volatile bool is_streaming
When the device is streaming.
struct video_listener * cv_add_to_device_async(struct video_config_t *device, cv_function func, int nice_level, uint16_t fps)
#define VIEWVIDEO_USE_RTP
#define VIEWVIDEO_NICE_LEVEL
Encode images with the use of the JPEG encoding.
void viewvideo_init(void)
Initialize the view video.
Get live images from a RTP/UDP stream and save pictures on internal memory.
static struct image_t * viewvideo_function(struct UdpSocket *socket, struct image_t *img, uint32_t *rtp_frame_nr)
Handles all the video streaming and saving of the image shots This is a separate thread, so it needs to be thread safe!
struct timeval ts
The timestamp of creation.
void jpeg_encode_image(struct image_t *in, struct image_t *out, uint32_t quality_factor, bool add_dri_header)
Encode an YUV422 image.
UYVY format (uint16 per pixel)
uint8_t downsize_factor
Downsize factor during the stream.
Encodes a vide stream with RTP (JPEG)
struct UdpSocket video_sock2
int udp_socket_create(struct UdpSocket *sock, char *host, int port_out, int port_in, bool broadcast)
Create UDP socket and bind it.
An JPEG encoded image (not per pixel encoded)