diff --git a/conf/airframes/ENAC/quadrotor/ard2_base_digit.xml b/conf/airframes/ENAC/quadrotor/ard2_base_digit.xml
index ae0fd8395e..97d522394f 100644
--- a/conf/airframes/ENAC/quadrotor/ard2_base_digit.xml
+++ b/conf/airframes/ENAC/quadrotor/ard2_base_digit.xml
@@ -40,9 +40,10 @@
-
+
+
diff --git a/conf/modules/bebop_front_camera.xml b/conf/modules/bebop_front_camera.xml
index 2990f8343d..fb2f3f2eb4 100644
--- a/conf/modules/bebop_front_camera.xml
+++ b/conf/modules/bebop_front_camera.xml
@@ -46,10 +46,10 @@
BEBOP_FRONT_CAMERA_BROADCAST ?= $(MODEM_BROADCAST)
BEBOPVIEWVID_CFLAGS = -DBEBOP_FRONT_CAMERA_HOST=$(BEBOP_FRONT_CAMERA_HOST) -DBEBOP_FRONT_CAMERA_PORT_OUT=$(BEBOP_FRONT_CAMERA_PORT_OUT)
- ifeq ($(BEBOP_FRONT_CAMERA_USE_NC),)
+ ifeq ($(BEBOP_FRONT_CAMERA_USE_NETCAT),)
ap.CFLAGS += $(BEBOPVIEWVID_CFLAGS) -DBEBOP_FRONT_CAMERA_BROADCAST=$(BEBOP_FRONT_CAMERA_BROADCAST)
else
- ap.CFLAGS += $(BEBOPVIEWVID_CFLAGS) -DBEBOP_FRONT_CAMERA_USE_NC
+ ap.CFLAGS += $(BEBOPVIEWVID_CFLAGS) -DBEBOP_FRONT_CAMERA_USE_NETCAT
endif
diff --git a/conf/modules/video_rtp_stream.xml b/conf/modules/video_rtp_stream.xml
index 4c9759c614..6bf61e0693 100644
--- a/conf/modules/video_rtp_stream.xml
+++ b/conf/modules/video_rtp_stream.xml
@@ -10,10 +10,11 @@
- Possibility to save an image(shot) on internal or external storage space even in full size, best quality
Example to add to ARdrone2 airframe with extra USB stick plugger in:
+
+
-
-
+
@@ -41,13 +42,14 @@
VIEWVIDEO_HOST ?= $(MODEM_HOST)
VIEWVIDEO_PORT_OUT ?= 5000
VIEWVIDEO_BROADCAST ?= $(MODEM_BROADCAST)
+ VIEWVIDEO_USE_NETCAT ?= FALSE
VIEWVID_CFLAGS = -DVIEWVIDEO_HOST=$(VIEWVIDEO_HOST) -DVIEWVIDEO_PORT_OUT=$(VIEWVIDEO_PORT_OUT)
- ifeq ($(VIEWVIDEO_USE_NC),)
+ ifneq (,$(findstring $(VIEWVIDEO_USE_NETCAT),0 FALSE))
ap.CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_BROADCAST=$(VIEWVIDEO_BROADCAST)
nps.CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_BROADCAST=FALSE
else
- $(TARGET).CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_USE_NC
+ $(TARGET).CFLAGS += $(VIEWVID_CFLAGS) -DVIEWVIDEO_USE_NETCAT
endif
diff --git a/sw/airborne/modules/computer_vision/viewvideo.c b/sw/airborne/modules/computer_vision/viewvideo.c
index 8f99f29744..8062987e49 100644
--- a/sw/airborne/modules/computer_vision/viewvideo.c
+++ b/sw/airborne/modules/computer_vision/viewvideo.c
@@ -64,22 +64,32 @@ PRINT_CONFIG_VAR(VIEWVIDEO_QUALITY_FACTOR)
#endif
PRINT_CONFIG_VAR(VIEWVIDEO_RTP_TIME_INC)
+// Default image folder
+#ifndef VIEWVIDEO_SHOT_PATH
+#ifdef VIDEO_THREAD_SHOT_PATH
+#define VIEWVIDEO_SHOT_PATH VIDEO_THREAD_SHOT_PATH
+#else
+#define VIEWVIDEO_SHOT_PATH /data/video/images
+#endif
+#endif
+PRINT_CONFIG_VAR(VIEWVIDEO_SHOT_PATH)
+
// Check if we are using netcat instead of RTP/UDP
#ifndef VIEWVIDEO_USE_NETCAT
#define VIEWVIDEO_USE_NETCAT FALSE
#endif
-#ifndef VIEWVIDEO_USE_RTP
+
+#if !VIEWVIDEO_USE_NETCAT && !(defined VIEWVIDEO_USE_RTP)
#define VIEWVIDEO_USE_RTP TRUE
#endif
-#if VIEWVIDEO_USE_NETCAT && VIEWVIDEO_USE_RTP
-#error "Can't set VIEWVIDEO_USE_NETCAT and VIEWVIDEO_USE_RTP to true at the same time."
-#endif
-
#if VIEWVIDEO_USE_NETCAT
+#include
PRINT_CONFIG_MSG("[viewvideo] Using netcat.")
-#elif VIEWVIDEO_USE_RTP
+#else
+struct UdpSocket video_sock;
PRINT_CONFIG_MSG("[viewvideo] Using RTP/UDP stream.")
+PRINT_CONFIG_VAR(VIEWVIDEO_USE_RTP)
#endif
/* These are defined with configure */
@@ -91,14 +101,15 @@ struct viewvideo_t viewvideo = {
.is_streaming = FALSE,
.downsize_factor = VIEWVIDEO_DOWNSIZE_FACTOR,
.quality_factor = VIEWVIDEO_QUALITY_FACTOR,
+#if !VIEWVIDEO_USE_NETCAT
.use_rtp = VIEWVIDEO_USE_RTP,
+#endif
};
/**
* Handles all the video streaming and saving of the image shots
* This is a sepereate thread, so it needs to be thread safe!
*/
-struct UdpSocket video_sock;
bool_t viewvideo_function(struct image_t *img);
bool_t viewvideo_function(struct image_t *img)
{
@@ -116,7 +127,6 @@ bool_t viewvideo_function(struct image_t *img)
#if VIEWVIDEO_USE_NETCAT
char nc_cmd[64];
sprintf(nc_cmd, "nc %s %d 2>/dev/null", STRINGIFY(VIEWVIDEO_HOST), VIEWVIDEO_PORT_OUT);
-#else
#endif
if (viewvideo.is_streaming) {
@@ -139,7 +149,7 @@ bool_t viewvideo_function(struct image_t *img)
// We are the child and want to send the image
FILE *netcat = popen(nc_cmd, "w");
if (netcat != NULL) {
- fwrite(jpegbuf, sizeof(uint8_t), size, netcat);
+ fwrite(img_jpeg.buf, sizeof(uint8_t), img_jpeg.buf_size, netcat);
pclose(netcat); // Ignore output, because it is too much when not connected
} else {
printf("[viewvideo] Failed to open netcat process.\n");
@@ -188,8 +198,6 @@ bool_t viewvideo_function(struct image_t *img)
void viewvideo_init(void)
{
char save_name[512];
-// struct UdpSocket video_sock;
- udp_socket_create(&video_sock, STRINGIFY(VIEWVIDEO_HOST), VIEWVIDEO_PORT_OUT, -1, VIEWVIDEO_BROADCAST);
cv_add(viewvideo_function);
@@ -208,8 +216,13 @@ void viewvideo_init(void)
fprintf(fp, "\ti=$((i+1))\n");
fprintf(fp, "done\n");
fclose(fp);
+ } else {
+ printf("[viewvideo] Failed to create netcat receiver file.\n");
}
#else
+ // Open udp socket
+ udp_socket_create(&video_sock, STRINGIFY(VIEWVIDEO_HOST), VIEWVIDEO_PORT_OUT, -1, VIEWVIDEO_BROADCAST);
+
// Create an SDP file for the streaming
sprintf(save_name, "%s/stream.sdp", STRINGIFY(VIEWVIDEO_SHOT_PATH));
FILE *fp = fopen(save_name, "w");
@@ -218,6 +231,8 @@ void viewvideo_init(void)
fprintf(fp, "m=video %d RTP/AVP 26\n", (int)(VIEWVIDEO_PORT_OUT));
fprintf(fp, "c=IN IP4 0.0.0.0\n");
fclose(fp);
+ } else {
+ printf("[viewvideo] Failed to create SDP file.\n");
}
#endif
}