diff options
| author | Koen Kooi <koen@dominion.thruhere.net> | 2012-06-22 11:28:27 +0000 |
|---|---|---|
| committer | Koen Kooi <koen@dominion.thruhere.net> | 2012-06-25 09:07:25 +0200 |
| commit | c26f69aab1abb7eeea2c9240feb16506e7200320 (patch) | |
| tree | afaefedf42d4ee94ff971d156f758856a516ea60 /meta-oe/recipes-multimedia | |
| parent | 7e14b17c3725a4baf7558bbe108eb41f0a5f3f67 (diff) | |
| download | meta-openembedded-c26f69aab1abb7eeea2c9240feb16506e7200320.tar.gz | |
yavta: add patch to enable streaming to stdout
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Diffstat (limited to 'meta-oe/recipes-multimedia')
| -rw-r--r-- | meta-oe/recipes-multimedia/v4l2apps/yavta/0001-Add-stdout-mode-to-allow-streaming-over-the-network-.patch | 854 | ||||
| -rw-r--r-- | meta-oe/recipes-multimedia/v4l2apps/yavta_git.bb | 5 |
2 files changed, 857 insertions, 2 deletions
diff --git a/meta-oe/recipes-multimedia/v4l2apps/yavta/0001-Add-stdout-mode-to-allow-streaming-over-the-network-.patch b/meta-oe/recipes-multimedia/v4l2apps/yavta/0001-Add-stdout-mode-to-allow-streaming-over-the-network-.patch new file mode 100644 index 0000000000..430836fee1 --- /dev/null +++ b/meta-oe/recipes-multimedia/v4l2apps/yavta/0001-Add-stdout-mode-to-allow-streaming-over-the-network-.patch | |||
| @@ -0,0 +1,854 @@ | |||
| 1 | From 1146a0f01fc8730d5633b46b85d00154a721abbe Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Koen Kooi <koen@dominion.thruhere.net> | ||
| 3 | Date: Fri, 22 Jun 2012 12:40:23 +0200 | ||
| 4 | Subject: [PATCH] Add stdout mode to allow streaming over the network with nc | ||
| 5 | |||
| 6 | Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> | ||
| 7 | --- | ||
| 8 | yavta.c | 288 ++++++++++++++++++++++++++++++++++----------------------------- | ||
| 9 | 1 file changed, 157 insertions(+), 131 deletions(-) | ||
| 10 | |||
| 11 | diff --git a/yavta.c b/yavta.c | ||
| 12 | index f3deae0..8020209 100644 | ||
| 13 | --- a/yavta.c | ||
| 14 | +++ b/yavta.c | ||
| 15 | @@ -188,12 +188,12 @@ static int video_open(struct device *dev, const char *devname, int no_query) | ||
| 16 | |||
| 17 | dev->fd = open(devname, O_RDWR); | ||
| 18 | if (dev->fd < 0) { | ||
| 19 | - printf("Error opening device %s: %s (%d).\n", devname, | ||
| 20 | + fprintf(stderr, "Error opening device %s: %s (%d).\n", devname, | ||
| 21 | strerror(errno), errno); | ||
| 22 | return dev->fd; | ||
| 23 | } | ||
| 24 | |||
| 25 | - printf("Device %s opened.\n", devname); | ||
| 26 | + fprintf(stderr, "Device %s opened.\n", devname); | ||
| 27 | |||
| 28 | if (no_query) { | ||
| 29 | /* Assume capture device. */ | ||
| 30 | @@ -211,13 +211,13 @@ static int video_open(struct device *dev, const char *devname, int no_query) | ||
| 31 | else if (cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) | ||
| 32 | dev->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; | ||
| 33 | else { | ||
| 34 | - printf("Error opening device %s: neither video capture " | ||
| 35 | + fprintf(stderr, "Error opening device %s: neither video capture " | ||
| 36 | "nor video output supported.\n", devname); | ||
| 37 | close(dev->fd); | ||
| 38 | return -EINVAL; | ||
| 39 | } | ||
| 40 | |||
| 41 | - printf("Device `%s' on `%s' is a video %s device.\n", | ||
| 42 | + fprintf(stderr, "Device `%s' on `%s' is a video %s device.\n", | ||
| 43 | cap.card, cap.bus_info, | ||
| 44 | dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE ? "capture" : "output"); | ||
| 45 | return 0; | ||
| 46 | @@ -280,7 +280,7 @@ static int get_control(struct device *dev, unsigned int id, int type, | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | - printf("unable to get control 0x%8.8x: %s (%d).\n", | ||
| 51 | + fprintf(stderr, "unable to get control 0x%8.8x: %s (%d).\n", | ||
| 52 | id, strerror(errno), errno); | ||
| 53 | return -1; | ||
| 54 | } | ||
| 55 | @@ -322,12 +322,12 @@ static void set_control(struct device *dev, unsigned int id, int type, | ||
| 56 | val = old.value; | ||
| 57 | } | ||
| 58 | if (ret == -1) { | ||
| 59 | - printf("unable to set control 0x%8.8x: %s (%d).\n", | ||
| 60 | + fprintf(stderr, "unable to set control 0x%8.8x: %s (%d).\n", | ||
| 61 | id, strerror(errno), errno); | ||
| 62 | return; | ||
| 63 | } | ||
| 64 | |||
| 65 | - printf("Control 0x%08x set to %" PRId64 ", is %" PRId64 "\n", | ||
| 66 | + fprintf(stderr, "Control 0x%08x set to %" PRId64 ", is %" PRId64 "\n", | ||
| 67 | id, old_val, val); | ||
| 68 | } | ||
| 69 | |||
| 70 | @@ -341,7 +341,7 @@ static int video_get_format(struct device *dev) | ||
| 71 | |||
| 72 | ret = ioctl(dev->fd, VIDIOC_G_FMT, &fmt); | ||
| 73 | if (ret < 0) { | ||
| 74 | - printf("Unable to get format: %s (%d).\n", strerror(errno), | ||
| 75 | + fprintf(stderr, "Unable to get format: %s (%d).\n", strerror(errno), | ||
| 76 | errno); | ||
| 77 | return ret; | ||
| 78 | } | ||
| 79 | @@ -351,7 +351,7 @@ static int video_get_format(struct device *dev) | ||
| 80 | dev->bytesperline = fmt.fmt.pix.bytesperline; | ||
| 81 | dev->imagesize = fmt.fmt.pix.bytesperline ? fmt.fmt.pix.sizeimage : 0; | ||
| 82 | |||
| 83 | - printf("Video format: %s (%08x) %ux%u (stride %u) buffer size %u\n", | ||
| 84 | + fprintf(stderr, "Video format: %s (%08x) %ux%u (stride %u) buffer size %u\n", | ||
| 85 | v4l2_format_name(fmt.fmt.pix.pixelformat), fmt.fmt.pix.pixelformat, | ||
| 86 | fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.bytesperline, | ||
| 87 | fmt.fmt.pix.sizeimage); | ||
| 88 | @@ -374,12 +374,12 @@ static int video_set_format(struct device *dev, unsigned int w, unsigned int h, | ||
| 89 | |||
| 90 | ret = ioctl(dev->fd, VIDIOC_S_FMT, &fmt); | ||
| 91 | if (ret < 0) { | ||
| 92 | - printf("Unable to set format: %s (%d).\n", strerror(errno), | ||
| 93 | + fprintf(stderr, "Unable to set format: %s (%d).\n", strerror(errno), | ||
| 94 | errno); | ||
| 95 | return ret; | ||
| 96 | } | ||
| 97 | |||
| 98 | - printf("Video format set: %s (%08x) %ux%u (stride %u) buffer size %u\n", | ||
| 99 | + fprintf(stderr, "Video format set: %s (%08x) %ux%u (stride %u) buffer size %u\n", | ||
| 100 | v4l2_format_name(fmt.fmt.pix.pixelformat), fmt.fmt.pix.pixelformat, | ||
| 101 | fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.bytesperline, | ||
| 102 | fmt.fmt.pix.sizeimage); | ||
| 103 | @@ -396,16 +396,16 @@ static int video_set_framerate(struct device *dev, struct v4l2_fract *time_per_f | ||
| 104 | |||
| 105 | ret = ioctl(dev->fd, VIDIOC_G_PARM, &parm); | ||
| 106 | if (ret < 0) { | ||
| 107 | - printf("Unable to get frame rate: %s (%d).\n", | ||
| 108 | + fprintf(stderr, "Unable to get frame rate: %s (%d).\n", | ||
| 109 | strerror(errno), errno); | ||
| 110 | return ret; | ||
| 111 | } | ||
| 112 | |||
| 113 | - printf("Current frame rate: %u/%u\n", | ||
| 114 | + fprintf(stderr, "Current frame rate: %u/%u\n", | ||
| 115 | parm.parm.capture.timeperframe.numerator, | ||
| 116 | parm.parm.capture.timeperframe.denominator); | ||
| 117 | |||
| 118 | - printf("Setting frame rate to: %u/%u\n", | ||
| 119 | + fprintf(stderr, "Setting frame rate to: %u/%u\n", | ||
| 120 | time_per_frame->numerator, | ||
| 121 | time_per_frame->denominator); | ||
| 122 | |||
| 123 | @@ -414,19 +414,19 @@ static int video_set_framerate(struct device *dev, struct v4l2_fract *time_per_f | ||
| 124 | |||
| 125 | ret = ioctl(dev->fd, VIDIOC_S_PARM, &parm); | ||
| 126 | if (ret < 0) { | ||
| 127 | - printf("Unable to set frame rate: %s (%d).\n", strerror(errno), | ||
| 128 | + fprintf(stderr, "Unable to set frame rate: %s (%d).\n", strerror(errno), | ||
| 129 | errno); | ||
| 130 | return ret; | ||
| 131 | } | ||
| 132 | |||
| 133 | ret = ioctl(dev->fd, VIDIOC_G_PARM, &parm); | ||
| 134 | if (ret < 0) { | ||
| 135 | - printf("Unable to get frame rate: %s (%d).\n", strerror(errno), | ||
| 136 | + fprintf(stderr, "Unable to get frame rate: %s (%d).\n", strerror(errno), | ||
| 137 | errno); | ||
| 138 | return ret; | ||
| 139 | } | ||
| 140 | |||
| 141 | - printf("Frame rate set: %u/%u\n", | ||
| 142 | + fprintf(stderr, "Frame rate set: %u/%u\n", | ||
| 143 | parm.parm.capture.timeperframe.numerator, | ||
| 144 | parm.parm.capture.timeperframe.denominator); | ||
| 145 | return 0; | ||
| 146 | @@ -449,12 +449,12 @@ static int video_alloc_buffers(struct device *dev, int nbufs, | ||
| 147 | |||
| 148 | ret = ioctl(dev->fd, VIDIOC_REQBUFS, &rb); | ||
| 149 | if (ret < 0) { | ||
| 150 | - printf("Unable to request buffers: %s (%d).\n", strerror(errno), | ||
| 151 | + fprintf(stderr, "Unable to request buffers: %s (%d).\n", strerror(errno), | ||
| 152 | errno); | ||
| 153 | return ret; | ||
| 154 | } | ||
| 155 | |||
| 156 | - printf("%u buffers requested.\n", rb.count); | ||
| 157 | + fprintf(stderr, "%u buffers requested.\n", rb.count); | ||
| 158 | |||
| 159 | buffers = malloc(rb.count * sizeof buffers[0]); | ||
| 160 | if (buffers == NULL) | ||
| 161 | @@ -470,35 +470,35 @@ static int video_alloc_buffers(struct device *dev, int nbufs, | ||
| 162 | buf.memory = dev->memtype; | ||
| 163 | ret = ioctl(dev->fd, VIDIOC_QUERYBUF, &buf); | ||
| 164 | if (ret < 0) { | ||
| 165 | - printf("Unable to query buffer %u: %s (%d).\n", i, | ||
| 166 | + fprintf(stderr, "Unable to query buffer %u: %s (%d).\n", i, | ||
| 167 | strerror(errno), errno); | ||
| 168 | return ret; | ||
| 169 | } | ||
| 170 | - printf("length: %u offset: %u\n", buf.length, buf.m.offset); | ||
| 171 | + fprintf(stderr, "length: %u offset: %u\n", buf.length, buf.m.offset); | ||
| 172 | |||
| 173 | switch (dev->memtype) { | ||
| 174 | case V4L2_MEMORY_MMAP: | ||
| 175 | buffers[i].mem = mmap(0, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, dev->fd, buf.m.offset); | ||
| 176 | if (buffers[i].mem == MAP_FAILED) { | ||
| 177 | - printf("Unable to map buffer %u: %s (%d)\n", i, | ||
| 178 | + fprintf(stderr, "Unable to map buffer %u: %s (%d)\n", i, | ||
| 179 | strerror(errno), errno); | ||
| 180 | return ret; | ||
| 181 | } | ||
| 182 | buffers[i].size = buf.length; | ||
| 183 | buffers[i].padding = 0; | ||
| 184 | - printf("Buffer %u mapped at address %p.\n", i, buffers[i].mem); | ||
| 185 | + fprintf(stderr, "Buffer %u mapped at address %p.\n", i, buffers[i].mem); | ||
| 186 | break; | ||
| 187 | |||
| 188 | case V4L2_MEMORY_USERPTR: | ||
| 189 | ret = posix_memalign(&buffers[i].mem, page_size, buf.length + offset + padding); | ||
| 190 | if (ret < 0) { | ||
| 191 | - printf("Unable to allocate buffer %u (%d)\n", i, ret); | ||
| 192 | + fprintf(stderr, "Unable to allocate buffer %u (%d)\n", i, ret); | ||
| 193 | return -ENOMEM; | ||
| 194 | } | ||
| 195 | buffers[i].mem += offset; | ||
| 196 | buffers[i].size = buf.length; | ||
| 197 | buffers[i].padding = padding; | ||
| 198 | - printf("Buffer %u allocated at address %p.\n", i, buffers[i].mem); | ||
| 199 | + fprintf(stderr, "Buffer %u allocated at address %p.\n", i, buffers[i].mem); | ||
| 200 | break; | ||
| 201 | |||
| 202 | default: | ||
| 203 | @@ -525,7 +525,7 @@ static int video_free_buffers(struct device *dev) | ||
| 204 | case V4L2_MEMORY_MMAP: | ||
| 205 | ret = munmap(dev->buffers[i].mem, dev->buffers[i].size); | ||
| 206 | if (ret < 0) { | ||
| 207 | - printf("Unable to unmap buffer %u: %s (%d)\n", i, | ||
| 208 | + fprintf(stderr, "Unable to unmap buffer %u: %s (%d)\n", i, | ||
| 209 | strerror(errno), errno); | ||
| 210 | return ret; | ||
| 211 | } | ||
| 212 | @@ -549,12 +549,12 @@ static int video_free_buffers(struct device *dev) | ||
| 213 | |||
| 214 | ret = ioctl(dev->fd, VIDIOC_REQBUFS, &rb); | ||
| 215 | if (ret < 0) { | ||
| 216 | - printf("Unable to release buffers: %s (%d).\n", | ||
| 217 | + fprintf(stderr, "Unable to release buffers: %s (%d).\n", | ||
| 218 | strerror(errno), errno); | ||
| 219 | return ret; | ||
| 220 | } | ||
| 221 | |||
| 222 | - printf("%u buffers released.\n", dev->nbufs); | ||
| 223 | + fprintf(stderr, "%u buffers released.\n", dev->nbufs); | ||
| 224 | |||
| 225 | free(dev->buffers); | ||
| 226 | dev->nbufs = 0; | ||
| 227 | @@ -589,7 +589,7 @@ static int video_queue_buffer(struct device *dev, int index, enum buffer_fill_mo | ||
| 228 | |||
| 229 | ret = ioctl(dev->fd, VIDIOC_QBUF, &buf); | ||
| 230 | if (ret < 0) | ||
| 231 | - printf("Unable to queue buffer: %s (%d).\n", | ||
| 232 | + fprintf(stderr, "Unable to queue buffer: %s (%d).\n", | ||
| 233 | strerror(errno), errno); | ||
| 234 | |||
| 235 | return ret; | ||
| 236 | @@ -602,7 +602,7 @@ static int video_enable(struct device *dev, int enable) | ||
| 237 | |||
| 238 | ret = ioctl(dev->fd, enable ? VIDIOC_STREAMON : VIDIOC_STREAMOFF, &type); | ||
| 239 | if (ret < 0) { | ||
| 240 | - printf("Unable to %s streaming: %s (%d).\n", | ||
| 241 | + fprintf(stderr, "Unable to %s streaming: %s (%d).\n", | ||
| 242 | enable ? "start" : "stop", strerror(errno), errno); | ||
| 243 | return ret; | ||
| 244 | } | ||
| 245 | @@ -623,9 +623,9 @@ static void video_query_menu(struct device *dev, struct v4l2_queryctrl *query) | ||
| 246 | continue; | ||
| 247 | |||
| 248 | if (query->type == V4L2_CTRL_TYPE_MENU) | ||
| 249 | - printf(" %u: %.32s\n", menu.index, menu.name); | ||
| 250 | + fprintf(stderr, " %u: %.32s\n", menu.index, menu.name); | ||
| 251 | else | ||
| 252 | - printf(" %u: %lld\n", menu.index, menu.value); | ||
| 253 | + fprintf(stderr, " %u: %lld\n", menu.index, menu.value); | ||
| 254 | }; | ||
| 255 | } | ||
| 256 | |||
| 257 | @@ -655,7 +655,7 @@ static void video_list_controls(struct device *dev) | ||
| 258 | continue; | ||
| 259 | |||
| 260 | if (query.type == V4L2_CTRL_TYPE_CTRL_CLASS) { | ||
| 261 | - printf("--- %s (class 0x%08x) ---\n", query.name, query.id); | ||
| 262 | + fprintf(stderr, "--- %s (class 0x%08x) ---\n", query.name, query.id); | ||
| 263 | continue; | ||
| 264 | } | ||
| 265 | |||
| 266 | @@ -665,7 +665,7 @@ static void video_list_controls(struct device *dev) | ||
| 267 | else | ||
| 268 | sprintf(value, "%" PRId64, val64); | ||
| 269 | |||
| 270 | - printf("control 0x%08x `%s' min %d max %d step %d default %d current %s.\n", | ||
| 271 | + fprintf(stderr, "control 0x%08x `%s' min %d max %d step %d default %d current %s.\n", | ||
| 272 | query.id, query.name, query.minimum, query.maximum, | ||
| 273 | query.step, query.default_value, value); | ||
| 274 | |||
| 275 | @@ -677,9 +677,9 @@ static void video_list_controls(struct device *dev) | ||
| 276 | } | ||
| 277 | |||
| 278 | if (nctrls) | ||
| 279 | - printf("%u control%s found.\n", nctrls, nctrls > 1 ? "s" : ""); | ||
| 280 | + fprintf(stderr, "%u control%s found.\n", nctrls, nctrls > 1 ? "s" : ""); | ||
| 281 | else | ||
| 282 | - printf("No control found.\n"); | ||
| 283 | + fprintf(stderr, "No control found.\n"); | ||
| 284 | } | ||
| 285 | |||
| 286 | static void video_enum_frame_intervals(struct device *dev, __u32 pixelformat, | ||
| 287 | @@ -700,30 +700,30 @@ static void video_enum_frame_intervals(struct device *dev, __u32 pixelformat, | ||
| 288 | break; | ||
| 289 | |||
| 290 | if (i != ival.index) | ||
| 291 | - printf("Warning: driver returned wrong ival index " | ||
| 292 | + fprintf(stderr, "Warning: driver returned wrong ival index " | ||
| 293 | "%u.\n", ival.index); | ||
| 294 | if (pixelformat != ival.pixel_format) | ||
| 295 | - printf("Warning: driver returned wrong ival pixel " | ||
| 296 | + fprintf(stderr, "Warning: driver returned wrong ival pixel " | ||
| 297 | "format %08x.\n", ival.pixel_format); | ||
| 298 | if (width != ival.width) | ||
| 299 | - printf("Warning: driver returned wrong ival width " | ||
| 300 | + fprintf(stderr, "Warning: driver returned wrong ival width " | ||
| 301 | "%u.\n", ival.width); | ||
| 302 | if (height != ival.height) | ||
| 303 | - printf("Warning: driver returned wrong ival height " | ||
| 304 | + fprintf(stderr, "Warning: driver returned wrong ival height " | ||
| 305 | "%u.\n", ival.height); | ||
| 306 | |||
| 307 | if (i != 0) | ||
| 308 | - printf(", "); | ||
| 309 | + fprintf(stderr, ", "); | ||
| 310 | |||
| 311 | switch (ival.type) { | ||
| 312 | case V4L2_FRMIVAL_TYPE_DISCRETE: | ||
| 313 | - printf("%u/%u", | ||
| 314 | + fprintf(stderr, "%u/%u", | ||
| 315 | ival.discrete.numerator, | ||
| 316 | ival.discrete.denominator); | ||
| 317 | break; | ||
| 318 | |||
| 319 | case V4L2_FRMIVAL_TYPE_CONTINUOUS: | ||
| 320 | - printf("%u/%u - %u/%u", | ||
| 321 | + fprintf(stderr, "%u/%u - %u/%u", | ||
| 322 | ival.stepwise.min.numerator, | ||
| 323 | ival.stepwise.min.denominator, | ||
| 324 | ival.stepwise.max.numerator, | ||
| 325 | @@ -731,7 +731,7 @@ static void video_enum_frame_intervals(struct device *dev, __u32 pixelformat, | ||
| 326 | return; | ||
| 327 | |||
| 328 | case V4L2_FRMIVAL_TYPE_STEPWISE: | ||
| 329 | - printf("%u/%u - %u/%u (by %u/%u)", | ||
| 330 | + fprintf(stderr, "%u/%u - %u/%u (by %u/%u)", | ||
| 331 | ival.stepwise.min.numerator, | ||
| 332 | ival.stepwise.min.denominator, | ||
| 333 | ival.stepwise.max.numerator, | ||
| 334 | @@ -761,23 +761,23 @@ static void video_enum_frame_sizes(struct device *dev, __u32 pixelformat) | ||
| 335 | break; | ||
| 336 | |||
| 337 | if (i != frame.index) | ||
| 338 | - printf("Warning: driver returned wrong frame index " | ||
| 339 | + fprintf(stderr, "Warning: driver returned wrong frame index " | ||
| 340 | "%u.\n", frame.index); | ||
| 341 | if (pixelformat != frame.pixel_format) | ||
| 342 | - printf("Warning: driver returned wrong frame pixel " | ||
| 343 | + fprintf(stderr, "Warning: driver returned wrong frame pixel " | ||
| 344 | "format %08x.\n", frame.pixel_format); | ||
| 345 | |||
| 346 | switch (frame.type) { | ||
| 347 | case V4L2_FRMSIZE_TYPE_DISCRETE: | ||
| 348 | - printf("\tFrame size: %ux%u (", frame.discrete.width, | ||
| 349 | + fprintf(stderr, "\tFrame size: %ux%u (", frame.discrete.width, | ||
| 350 | frame.discrete.height); | ||
| 351 | video_enum_frame_intervals(dev, frame.pixel_format, | ||
| 352 | frame.discrete.width, frame.discrete.height); | ||
| 353 | - printf(")\n"); | ||
| 354 | + fprintf(stderr, ")\n"); | ||
| 355 | break; | ||
| 356 | |||
| 357 | case V4L2_FRMSIZE_TYPE_CONTINUOUS: | ||
| 358 | - printf("\tFrame size: %ux%u - %ux%u (", | ||
| 359 | + fprintf(stderr, "\tFrame size: %ux%u - %ux%u (", | ||
| 360 | frame.stepwise.min_width, | ||
| 361 | frame.stepwise.min_height, | ||
| 362 | frame.stepwise.max_width, | ||
| 363 | @@ -785,11 +785,11 @@ static void video_enum_frame_sizes(struct device *dev, __u32 pixelformat) | ||
| 364 | video_enum_frame_intervals(dev, frame.pixel_format, | ||
| 365 | frame.stepwise.max_width, | ||
| 366 | frame.stepwise.max_height); | ||
| 367 | - printf(")\n"); | ||
| 368 | + fprintf(stderr, ")\n"); | ||
| 369 | break; | ||
| 370 | |||
| 371 | case V4L2_FRMSIZE_TYPE_STEPWISE: | ||
| 372 | - printf("\tFrame size: %ux%u - %ux%u (by %ux%u) (\n", | ||
| 373 | + fprintf(stderr, "\tFrame size: %ux%u - %ux%u (by %ux%u) (\n", | ||
| 374 | frame.stepwise.min_width, | ||
| 375 | frame.stepwise.min_height, | ||
| 376 | frame.stepwise.max_width, | ||
| 377 | @@ -799,7 +799,7 @@ static void video_enum_frame_sizes(struct device *dev, __u32 pixelformat) | ||
| 378 | video_enum_frame_intervals(dev, frame.pixel_format, | ||
| 379 | frame.stepwise.max_width, | ||
| 380 | frame.stepwise.max_height); | ||
| 381 | - printf(")\n"); | ||
| 382 | + fprintf(stderr, ")\n"); | ||
| 383 | break; | ||
| 384 | |||
| 385 | default: | ||
| 386 | @@ -823,19 +823,19 @@ static void video_enum_formats(struct device *dev, enum v4l2_buf_type type) | ||
| 387 | break; | ||
| 388 | |||
| 389 | if (i != fmt.index) | ||
| 390 | - printf("Warning: driver returned wrong format index " | ||
| 391 | + fprintf(stderr, "Warning: driver returned wrong format index " | ||
| 392 | "%u.\n", fmt.index); | ||
| 393 | if (type != fmt.type) | ||
| 394 | - printf("Warning: driver returned wrong format type " | ||
| 395 | + fprintf(stderr, "Warning: driver returned wrong format type " | ||
| 396 | "%u.\n", fmt.type); | ||
| 397 | |||
| 398 | - printf("\tFormat %u: %s (%08x)\n", i, | ||
| 399 | + fprintf(stderr, "\tFormat %u: %s (%08x)\n", i, | ||
| 400 | v4l2_format_name(fmt.pixelformat), fmt.pixelformat); | ||
| 401 | - printf("\tType: %s (%u)\n", v4l2_buf_type_name(fmt.type), | ||
| 402 | + fprintf(stderr, "\tType: %s (%u)\n", v4l2_buf_type_name(fmt.type), | ||
| 403 | fmt.type); | ||
| 404 | - printf("\tName: %.32s\n", fmt.description); | ||
| 405 | + fprintf(stderr, "\tName: %.32s\n", fmt.description); | ||
| 406 | video_enum_frame_sizes(dev, fmt.pixelformat); | ||
| 407 | - printf("\n"); | ||
| 408 | + fprintf(stderr, "\n"); | ||
| 409 | } | ||
| 410 | } | ||
| 411 | |||
| 412 | @@ -853,13 +853,13 @@ static void video_enum_inputs(struct device *dev) | ||
| 413 | break; | ||
| 414 | |||
| 415 | if (i != input.index) | ||
| 416 | - printf("Warning: driver returned wrong input index " | ||
| 417 | + fprintf(stderr, "Warning: driver returned wrong input index " | ||
| 418 | "%u.\n", input.index); | ||
| 419 | |||
| 420 | - printf("\tInput %u: %s.\n", i, input.name); | ||
| 421 | + fprintf(stderr, "\tInput %u: %s.\n", i, input.name); | ||
| 422 | } | ||
| 423 | |||
| 424 | - printf("\n"); | ||
| 425 | + fprintf(stderr, "\n"); | ||
| 426 | } | ||
| 427 | |||
| 428 | static int video_get_input(struct device *dev) | ||
| 429 | @@ -869,7 +869,7 @@ static int video_get_input(struct device *dev) | ||
| 430 | |||
| 431 | ret = ioctl(dev->fd, VIDIOC_G_INPUT, &input); | ||
| 432 | if (ret < 0) { | ||
| 433 | - printf("Unable to get current input: %s (%d).\n", | ||
| 434 | + fprintf(stderr, "Unable to get current input: %s (%d).\n", | ||
| 435 | strerror(errno), errno); | ||
| 436 | return ret; | ||
| 437 | } | ||
| 438 | @@ -884,7 +884,7 @@ static int video_set_input(struct device *dev, unsigned int input) | ||
| 439 | |||
| 440 | ret = ioctl(dev->fd, VIDIOC_S_INPUT, &_input); | ||
| 441 | if (ret < 0) | ||
| 442 | - printf("Unable to select input %u: %s (%d).\n", input, | ||
| 443 | + fprintf(stderr, "Unable to select input %u: %s (%d).\n", input, | ||
| 444 | strerror(errno), errno); | ||
| 445 | |||
| 446 | return ret; | ||
| 447 | @@ -903,14 +903,14 @@ static int video_set_quality(struct device *dev, unsigned int quality) | ||
| 448 | |||
| 449 | ret = ioctl(dev->fd, VIDIOC_S_JPEGCOMP, &jpeg); | ||
| 450 | if (ret < 0) { | ||
| 451 | - printf("Unable to set quality to %u: %s (%d).\n", quality, | ||
| 452 | + fprintf(stderr, "Unable to set quality to %u: %s (%d).\n", quality, | ||
| 453 | strerror(errno), errno); | ||
| 454 | return ret; | ||
| 455 | } | ||
| 456 | |||
| 457 | ret = ioctl(dev->fd, VIDIOC_G_JPEGCOMP, &jpeg); | ||
| 458 | if (ret >= 0) | ||
| 459 | - printf("Quality set to %u\n", jpeg.quality); | ||
| 460 | + fprintf(stderr, "Quality set to %u\n", jpeg.quality); | ||
| 461 | |||
| 462 | return 0; | ||
| 463 | } | ||
| 464 | @@ -930,7 +930,7 @@ static int video_load_test_pattern(struct device *dev, const char *filename) | ||
| 465 | |||
| 466 | if (filename == NULL) { | ||
| 467 | if (dev->bytesperline == 0) { | ||
| 468 | - printf("Compressed format detect and no test pattern filename given.\n" | ||
| 469 | + fprintf(stderr, "Compressed format detect and no test pattern filename given.\n" | ||
| 470 | "The test pattern can't be generated automatically.\n"); | ||
| 471 | return -EINVAL; | ||
| 472 | } | ||
| 473 | @@ -947,7 +947,7 @@ static int video_load_test_pattern(struct device *dev, const char *filename) | ||
| 474 | |||
| 475 | fd = open(filename, O_RDONLY); | ||
| 476 | if (fd == -1) { | ||
| 477 | - printf("Unable to open test pattern file '%s': %s (%d).\n", | ||
| 478 | + fprintf(stderr, "Unable to open test pattern file '%s': %s (%d).\n", | ||
| 479 | filename, strerror(errno), errno); | ||
| 480 | return -errno; | ||
| 481 | } | ||
| 482 | @@ -956,7 +956,7 @@ static int video_load_test_pattern(struct device *dev, const char *filename) | ||
| 483 | close(fd); | ||
| 484 | |||
| 485 | if (ret != (int)size && dev->bytesperline != 0) { | ||
| 486 | - printf("Test pattern file size %u doesn't match image size %u\n", | ||
| 487 | + fprintf(stderr, "Test pattern file size %u doesn't match image size %u\n", | ||
| 488 | ret, size); | ||
| 489 | return -EINVAL; | ||
| 490 | } | ||
| 491 | @@ -1012,16 +1012,16 @@ static void video_verify_buffer(struct device *dev, int index) | ||
| 492 | } | ||
| 493 | |||
| 494 | if (errors) { | ||
| 495 | - printf("Warning: %u bytes overwritten among %u first padding bytes\n", | ||
| 496 | + fprintf(stderr, "Warning: %u bytes overwritten among %u first padding bytes\n", | ||
| 497 | errors, dirty); | ||
| 498 | |||
| 499 | dirty = (dirty + 15) & ~15; | ||
| 500 | dirty = dirty > 32 ? 32 : dirty; | ||
| 501 | |||
| 502 | for (i = 0; i < dirty; ++i) { | ||
| 503 | - printf("%02x ", data[i]); | ||
| 504 | + fprintf(stderr, "%02x ", data[i]); | ||
| 505 | if (i % 16 == 15) | ||
| 506 | - printf("\n"); | ||
| 507 | + fprintf(stderr, "\n"); | ||
| 508 | } | ||
| 509 | } | ||
| 510 | } | ||
| 511 | @@ -1061,15 +1061,29 @@ static void video_save_image(struct device *dev, struct v4l2_buffer *buf, | ||
| 512 | close(fd); | ||
| 513 | |||
| 514 | if (ret < 0) | ||
| 515 | - printf("write error: %s (%d)\n", strerror(errno), errno); | ||
| 516 | + fprintf(stderr, "write error: %s (%d)\n", strerror(errno), errno); | ||
| 517 | else if (ret != (int)buf->bytesused) | ||
| 518 | - printf("write error: only %d bytes written instead of %u\n", | ||
| 519 | + fprintf(stderr, "write error: only %d bytes written instead of %u\n", | ||
| 520 | + ret, buf->bytesused); | ||
| 521 | +} | ||
| 522 | + | ||
| 523 | +static void video_stdout_image(struct device *dev, struct v4l2_buffer *buf) | ||
| 524 | +{ | ||
| 525 | + int ret; | ||
| 526 | + | ||
| 527 | + fprintf(stderr, "stdout"); | ||
| 528 | + ret = fwrite(dev->buffers[buf->index].mem, buf->bytesused, 1, stdout); | ||
| 529 | + | ||
| 530 | + if (ret < 0) | ||
| 531 | + fprintf(stderr, "write error: %s (%d)\n", strerror(errno), errno); | ||
| 532 | + else if (ret != (int)buf->bytesused) | ||
| 533 | + fprintf(stderr, "write error: only %d bytes written instead of %u\n", | ||
| 534 | ret, buf->bytesused); | ||
| 535 | } | ||
| 536 | |||
| 537 | static int video_do_capture(struct device *dev, unsigned int nframes, | ||
| 538 | unsigned int skip, unsigned int delay, const char *pattern, | ||
| 539 | - int do_requeue_last, enum buffer_fill_mode fill) | ||
| 540 | + int do_requeue_last, enum buffer_fill_mode fill, int do_stdout) | ||
| 541 | { | ||
| 542 | struct timespec start; | ||
| 543 | struct timeval last; | ||
| 544 | @@ -1099,7 +1113,7 @@ static int video_do_capture(struct device *dev, unsigned int nframes, | ||
| 545 | ret = ioctl(dev->fd, VIDIOC_DQBUF, &buf); | ||
| 546 | if (ret < 0) { | ||
| 547 | if (errno != EIO) { | ||
| 548 | - printf("Unable to dequeue buffer: %s (%d).\n", | ||
| 549 | + fprintf(stderr, "Unable to dequeue buffer: %s (%d).\n", | ||
| 550 | strerror(errno), errno); | ||
| 551 | goto done; | ||
| 552 | } | ||
| 553 | @@ -1111,7 +1125,7 @@ static int video_do_capture(struct device *dev, unsigned int nframes, | ||
| 554 | |||
| 555 | if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && | ||
| 556 | dev->imagesize != 0 && buf.bytesused != dev->imagesize) | ||
| 557 | - printf("Warning: bytes used %u != image size %u\n", | ||
| 558 | + fprintf(stderr, "Warning: bytes used %u != image size %u\n", | ||
| 559 | buf.bytesused, dev->imagesize); | ||
| 560 | |||
| 561 | if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 562 | @@ -1124,7 +1138,7 @@ static int video_do_capture(struct device *dev, unsigned int nframes, | ||
| 563 | fps = fps ? 1000000.0 / fps : 0.0; | ||
| 564 | |||
| 565 | clock_gettime(CLOCK_MONOTONIC, &ts); | ||
| 566 | - printf("%u (%u) [%c] %u %u bytes %ld.%06ld %ld.%06ld %.3f fps\n", i, buf.index, | ||
| 567 | + fprintf(stderr, "%u (%u) [%c] %u %u bytes %ld.%06ld %ld.%06ld %.3f fps\n", i, buf.index, | ||
| 568 | (buf.flags & V4L2_BUF_FLAG_ERROR) ? 'E' : '-', | ||
| 569 | buf.sequence, buf.bytesused, buf.timestamp.tv_sec, | ||
| 570 | buf.timestamp.tv_usec, ts.tv_sec, ts.tv_nsec/1000, fps); | ||
| 571 | @@ -1132,8 +1146,13 @@ static int video_do_capture(struct device *dev, unsigned int nframes, | ||
| 572 | last = buf.timestamp; | ||
| 573 | |||
| 574 | /* Save the image. */ | ||
| 575 | - if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pattern && !skip) | ||
| 576 | + if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pattern && !skip) { | ||
| 577 | video_save_image(dev, &buf, pattern, i); | ||
| 578 | + } | ||
| 579 | + | ||
| 580 | + if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && do_stdout && !skip) { | ||
| 581 | + video_stdout_image(dev, &buf); | ||
| 582 | + } | ||
| 583 | |||
| 584 | if (skip) | ||
| 585 | --skip; | ||
| 586 | @@ -1149,7 +1168,7 @@ static int video_do_capture(struct device *dev, unsigned int nframes, | ||
| 587 | |||
| 588 | ret = video_queue_buffer(dev, buf.index, fill); | ||
| 589 | if (ret < 0) { | ||
| 590 | - printf("Unable to requeue buffer: %s (%d).\n", | ||
| 591 | + fprintf(stderr, "Unable to requeue buffer: %s (%d).\n", | ||
| 592 | strerror(errno), errno); | ||
| 593 | goto done; | ||
| 594 | } | ||
| 595 | @@ -1159,7 +1178,7 @@ static int video_do_capture(struct device *dev, unsigned int nframes, | ||
| 596 | video_enable(dev, 0); | ||
| 597 | |||
| 598 | if (nframes == 0) { | ||
| 599 | - printf("No frames captured.\n"); | ||
| 600 | + fprintf(stderr, "No frames captured.\n"); | ||
| 601 | goto done; | ||
| 602 | } | ||
| 603 | |||
| 604 | @@ -1176,7 +1195,7 @@ static int video_do_capture(struct device *dev, unsigned int nframes, | ||
| 605 | bps = size/(ts.tv_nsec/1000.0+1000000.0*ts.tv_sec)*1000000.0; | ||
| 606 | fps = i/(ts.tv_nsec/1000.0+1000000.0*ts.tv_sec)*1000000.0; | ||
| 607 | |||
| 608 | - printf("Captured %u frames in %lu.%06lu seconds (%f fps, %f B/s).\n", | ||
| 609 | + fprintf(stderr, "Captured %u frames in %lu.%06lu seconds (%f fps, %f B/s).\n", | ||
| 610 | i, ts.tv_sec, ts.tv_nsec/1000, fps, bps); | ||
| 611 | |||
| 612 | done: | ||
| 613 | @@ -1188,37 +1207,38 @@ done: | ||
| 614 | |||
| 615 | static void usage(const char *argv0) | ||
| 616 | { | ||
| 617 | - printf("Usage: %s [options] device\n", argv0); | ||
| 618 | - printf("Supported options:\n"); | ||
| 619 | - printf("-c, --capture[=nframes] Capture frames\n"); | ||
| 620 | - printf("-C, --check-overrun Verify dequeued frames for buffer overrun\n"); | ||
| 621 | - printf("-d, --delay Delay (in ms) before requeuing buffers\n"); | ||
| 622 | - printf("-f, --format format Set the video format\n"); | ||
| 623 | - printf("-F, --file[=name] Read/write frames from/to disk\n"); | ||
| 624 | - printf("\tFor video capture devices, the first '#' character in the file name is\n"); | ||
| 625 | - printf("\texpanded to the frame sequence number. The default file name is\n"); | ||
| 626 | - printf("\t'frame-#.bin'.\n"); | ||
| 627 | - printf("-h, --help Show this help screen\n"); | ||
| 628 | - printf("-i, --input input Select the video input\n"); | ||
| 629 | - printf("-I, --fill-frames Fill frames with check pattern before queuing them\n"); | ||
| 630 | - printf("-l, --list-controls List available controls\n"); | ||
| 631 | - printf("-n, --nbufs n Set the number of video buffers\n"); | ||
| 632 | - printf("-p, --pause Pause before starting the video stream\n"); | ||
| 633 | - printf("-q, --quality n MJPEG quality (0-100)\n"); | ||
| 634 | - printf("-r, --get-control ctrl Get control 'ctrl'\n"); | ||
| 635 | - printf("-R, --realtime=[priority] Enable realtime RR scheduling\n"); | ||
| 636 | - printf("-s, --size WxH Set the frame size\n"); | ||
| 637 | - printf("-t, --time-per-frame num/denom Set the time per frame (eg. 1/25 = 25 fps)\n"); | ||
| 638 | - printf("-u, --userptr Use the user pointers streaming method\n"); | ||
| 639 | - printf("-w, --set-control 'ctrl value' Set control 'ctrl' to 'value'\n"); | ||
| 640 | - printf(" --enum-formats Enumerate formats\n"); | ||
| 641 | - printf(" --enum-inputs Enumerate inputs\n"); | ||
| 642 | - printf(" --no-query Don't query capabilities on open\n"); | ||
| 643 | - printf(" --offset User pointer buffer offset from page start\n"); | ||
| 644 | - printf(" --requeue-last Requeue the last buffers before streamoff\n"); | ||
| 645 | - printf(" --skip n Skip the first n frames\n"); | ||
| 646 | - printf(" --sleep-forever Sleep forever after configuring the device\n"); | ||
| 647 | - printf(" --stride value Line stride in bytes\n"); | ||
| 648 | + fprintf(stderr, "Usage: %s [options] device\n", argv0); | ||
| 649 | + fprintf(stderr, "Supported options:\n"); | ||
| 650 | + fprintf(stderr, "-c, --capture[=nframes] Capture frames\n"); | ||
| 651 | + fprintf(stderr, "-C, --check-overrun Verify dequeued frames for buffer overrun\n"); | ||
| 652 | + fprintf(stderr, "-d, --delay Delay (in ms) before requeuing buffers\n"); | ||
| 653 | + fprintf(stderr, "-f, --format format Set the video format\n"); | ||
| 654 | + fprintf(stderr, "-F, --file[=name] Read/write frames from/to disk\n"); | ||
| 655 | + fprintf(stderr, "\tFor video capture devices, the first '#' character in the file name is\n"); | ||
| 656 | + fprintf(stderr, "\texpanded to the frame sequence number. The default file name is\n"); | ||
| 657 | + fprintf(stderr, "\t'frame-#.bin'.\n"); | ||
| 658 | + fprintf(stderr, " --stdout write frames to stdout\n"); | ||
| 659 | + fprintf(stderr, "-h, --help Show this help screen\n"); | ||
| 660 | + fprintf(stderr, "-i, --input input Select the video input\n"); | ||
| 661 | + fprintf(stderr, "-I, --fill-frames Fill frames with check pattern before queuing them\n"); | ||
| 662 | + fprintf(stderr, "-l, --list-controls List available controls\n"); | ||
| 663 | + fprintf(stderr, "-n, --nbufs n Set the number of video buffers\n"); | ||
| 664 | + fprintf(stderr, "-p, --pause Pause before starting the video stream\n"); | ||
| 665 | + fprintf(stderr, "-q, --quality n MJPEG quality (0-100)\n"); | ||
| 666 | + fprintf(stderr, "-r, --get-control ctrl Get control 'ctrl'\n"); | ||
| 667 | + fprintf(stderr, "-R, --realtime=[priority] Enable realtime RR scheduling\n"); | ||
| 668 | + fprintf(stderr, "-s, --size WxH Set the frame size\n"); | ||
| 669 | + fprintf(stderr, "-t, --time-per-frame num/denom Set the time per frame (eg. 1/25 = 25 fps)\n"); | ||
| 670 | + fprintf(stderr, "-u, --userptr Use the user pointers streaming method\n"); | ||
| 671 | + fprintf(stderr, "-w, --set-control 'ctrl value' Set control 'ctrl' to 'value'\n"); | ||
| 672 | + fprintf(stderr, " --enum-formats Enumerate formats\n"); | ||
| 673 | + fprintf(stderr, " --enum-inputs Enumerate inputs\n"); | ||
| 674 | + fprintf(stderr, " --no-query Don't query capabilities on open\n"); | ||
| 675 | + fprintf(stderr, " --offset User pointer buffer offset from page start\n"); | ||
| 676 | + fprintf(stderr, " --requeue-last Requeue the last buffers before streamoff\n"); | ||
| 677 | + fprintf(stderr, " --skip n Skip the first n frames\n"); | ||
| 678 | + fprintf(stderr, " --sleep-forever Sleep forever after configuring the device\n"); | ||
| 679 | + fprintf(stderr, " --stride value Line stride in bytes\n"); | ||
| 680 | } | ||
| 681 | |||
| 682 | #define OPT_ENUM_FORMATS 256 | ||
| 683 | @@ -1229,6 +1249,7 @@ static void usage(const char *argv0) | ||
| 684 | #define OPT_USERPTR_OFFSET 261 | ||
| 685 | #define OPT_REQUEUE_LAST 262 | ||
| 686 | #define OPT_STRIDE 263 | ||
| 687 | +#define OPT_STDOUT 264 | ||
| 688 | |||
| 689 | static struct option opts[] = { | ||
| 690 | {"capture", 2, 0, 'c'}, | ||
| 691 | @@ -1238,6 +1259,7 @@ static struct option opts[] = { | ||
| 692 | {"enum-inputs", 0, 0, OPT_ENUM_INPUTS}, | ||
| 693 | {"file", 2, 0, 'F'}, | ||
| 694 | {"fill-frames", 0, 0, 'I'}, | ||
| 695 | + {"stdout", 0, 0, OPT_STDOUT}, | ||
| 696 | {"format", 1, 0, 'f'}, | ||
| 697 | {"help", 0, 0, 'h'}, | ||
| 698 | {"input", 1, 0, 'i'}, | ||
| 699 | @@ -1274,7 +1296,8 @@ int main(int argc, char *argv[]) | ||
| 700 | int do_list_controls = 0, do_get_control = 0, do_set_control = 0; | ||
| 701 | int do_sleep_forever = 0, do_requeue_last = 0; | ||
| 702 | int do_rt = 0; | ||
| 703 | - int no_query = 0; | ||
| 704 | + int no_query = 0; | ||
| 705 | + int do_stdout = 0; | ||
| 706 | char *endptr; | ||
| 707 | int c; | ||
| 708 | |||
| 709 | @@ -1321,7 +1344,7 @@ int main(int argc, char *argv[]) | ||
| 710 | do_set_format = 1; | ||
| 711 | pixelformat = v4l2_format_code(optarg); | ||
| 712 | if (pixelformat == 0) { | ||
| 713 | - printf("Unsupported video format '%s'\n", optarg); | ||
| 714 | + fprintf(stderr, "Unsupported video format '%s'\n", optarg); | ||
| 715 | return 1; | ||
| 716 | } | ||
| 717 | break; | ||
| 718 | @@ -1357,7 +1380,7 @@ int main(int argc, char *argv[]) | ||
| 719 | case 'r': | ||
| 720 | ctrl_name = strtol(optarg, &endptr, 0); | ||
| 721 | if (*endptr != 0) { | ||
| 722 | - printf("Invalid control name '%s'\n", optarg); | ||
| 723 | + fprintf(stderr, "Invalid control name '%s'\n", optarg); | ||
| 724 | return 1; | ||
| 725 | } | ||
| 726 | do_get_control = 1; | ||
| 727 | @@ -1371,12 +1394,12 @@ int main(int argc, char *argv[]) | ||
| 728 | do_set_format = 1; | ||
| 729 | width = strtol(optarg, &endptr, 10); | ||
| 730 | if (*endptr != 'x' || endptr == optarg) { | ||
| 731 | - printf("Invalid size '%s'\n", optarg); | ||
| 732 | + fprintf(stderr, "Invalid size '%s'\n", optarg); | ||
| 733 | return 1; | ||
| 734 | } | ||
| 735 | height = strtol(endptr + 1, &endptr, 10); | ||
| 736 | if (*endptr != 0) { | ||
| 737 | - printf("Invalid size '%s'\n", optarg); | ||
| 738 | + fprintf(stderr, "Invalid size '%s'\n", optarg); | ||
| 739 | return 1; | ||
| 740 | } | ||
| 741 | break; | ||
| 742 | @@ -1384,12 +1407,12 @@ int main(int argc, char *argv[]) | ||
| 743 | do_set_time_per_frame = 1; | ||
| 744 | time_per_frame.numerator = strtol(optarg, &endptr, 10); | ||
| 745 | if (*endptr != '/' || endptr == optarg) { | ||
| 746 | - printf("Invalid time per frame '%s'\n", optarg); | ||
| 747 | + fprintf(stderr, "Invalid time per frame '%s'\n", optarg); | ||
| 748 | return 1; | ||
| 749 | } | ||
| 750 | time_per_frame.denominator = strtol(endptr + 1, &endptr, 10); | ||
| 751 | if (*endptr != 0) { | ||
| 752 | - printf("Invalid time per frame '%s'\n", optarg); | ||
| 753 | + fprintf(stderr, "Invalid time per frame '%s'\n", optarg); | ||
| 754 | return 1; | ||
| 755 | } | ||
| 756 | break; | ||
| 757 | @@ -1399,12 +1422,12 @@ int main(int argc, char *argv[]) | ||
| 758 | case 'w': | ||
| 759 | ctrl_name = strtol(optarg, &endptr, 0); | ||
| 760 | if (*endptr != ' ' || endptr == optarg) { | ||
| 761 | - printf("Invalid control name '%s'\n", optarg); | ||
| 762 | + fprintf(stderr, "Invalid control name '%s'\n", optarg); | ||
| 763 | return 1; | ||
| 764 | } | ||
| 765 | ctrl_value = strtol(endptr + 1, &endptr, 0); | ||
| 766 | if (*endptr != 0) { | ||
| 767 | - printf("Invalid control value '%s'\n", optarg); | ||
| 768 | + fprintf(stderr, "Invalid control value '%s'\n", optarg); | ||
| 769 | return 1; | ||
| 770 | } | ||
| 771 | do_set_control = 1; | ||
| 772 | @@ -1433,15 +1456,18 @@ int main(int argc, char *argv[]) | ||
| 773 | case OPT_USERPTR_OFFSET: | ||
| 774 | userptr_offset = atoi(optarg); | ||
| 775 | break; | ||
| 776 | + case OPT_STDOUT: | ||
| 777 | + do_stdout = 1; | ||
| 778 | + break; | ||
| 779 | default: | ||
| 780 | - printf("Invalid option -%c\n", c); | ||
| 781 | - printf("Run %s -h for help.\n", argv[0]); | ||
| 782 | + fprintf(stderr, "Invalid option -%c\n", c); | ||
| 783 | + fprintf(stderr, "Run %s -h for help.\n", argv[0]); | ||
| 784 | return 1; | ||
| 785 | } | ||
| 786 | } | ||
| 787 | |||
| 788 | if ((fill_mode & BUFFER_FILL_PADDING) && memtype != V4L2_MEMORY_USERPTR) { | ||
| 789 | - printf("Buffer overrun can only be checked in USERPTR mode.\n"); | ||
| 790 | + fprintf(stderr, "Buffer overrun can only be checked in USERPTR mode.\n"); | ||
| 791 | return 1; | ||
| 792 | } | ||
| 793 | |||
| 794 | @@ -1470,7 +1496,7 @@ int main(int argc, char *argv[]) | ||
| 795 | ret = get_control(&dev, ctrl_name, | ||
| 796 | get_control_type(&dev, ctrl_name), &val); | ||
| 797 | if (ret >= 0) | ||
| 798 | - printf("Control 0x%08x value %" PRId64 "\n", ctrl_name, val); | ||
| 799 | + fprintf(stderr, "Control 0x%08x value %" PRId64 "\n", ctrl_name, val); | ||
| 800 | } | ||
| 801 | |||
| 802 | if (do_set_control) | ||
| 803 | @@ -1481,21 +1507,21 @@ int main(int argc, char *argv[]) | ||
| 804 | video_list_controls(&dev); | ||
| 805 | |||
| 806 | if (do_enum_formats) { | ||
| 807 | - printf("- Available formats:\n"); | ||
| 808 | + fprintf(stderr, "- Available formats:\n"); | ||
| 809 | video_enum_formats(&dev, V4L2_BUF_TYPE_VIDEO_CAPTURE); | ||
| 810 | video_enum_formats(&dev, V4L2_BUF_TYPE_VIDEO_OUTPUT); | ||
| 811 | video_enum_formats(&dev, V4L2_BUF_TYPE_VIDEO_OVERLAY); | ||
| 812 | } | ||
| 813 | |||
| 814 | if (do_enum_inputs) { | ||
| 815 | - printf("- Available inputs:\n"); | ||
| 816 | + fprintf(stderr, "- Available inputs:\n"); | ||
| 817 | video_enum_inputs(&dev); | ||
| 818 | } | ||
| 819 | |||
| 820 | if (do_set_input) { | ||
| 821 | video_set_input(&dev, input); | ||
| 822 | ret = video_get_input(&dev); | ||
| 823 | - printf("Input %d selected\n", ret); | ||
| 824 | + fprintf(stderr, "Input %d selected\n", ret); | ||
| 825 | } | ||
| 826 | |||
| 827 | /* Set the video format. */ | ||
| 828 | @@ -1537,7 +1563,7 @@ int main(int argc, char *argv[]) | ||
| 829 | } | ||
| 830 | |||
| 831 | if (do_pause) { | ||
| 832 | - printf("Press enter to start capture\n"); | ||
| 833 | + fprintf(stderr, "Press enter to start capture\n"); | ||
| 834 | getchar(); | ||
| 835 | } | ||
| 836 | |||
| 837 | @@ -1546,12 +1572,12 @@ int main(int argc, char *argv[]) | ||
| 838 | sched.sched_priority = rt_priority; | ||
| 839 | ret = sched_setscheduler(0, SCHED_RR, &sched); | ||
| 840 | if (ret < 0) | ||
| 841 | - printf("Failed to select RR scheduler: %s (%d)\n", | ||
| 842 | + fprintf(stderr, "Failed to select RR scheduler: %s (%d)\n", | ||
| 843 | strerror(errno), errno); | ||
| 844 | } | ||
| 845 | |||
| 846 | if (video_do_capture(&dev, nframes, skip, delay, filename, | ||
| 847 | - do_requeue_last, fill_mode) < 0) { | ||
| 848 | + do_requeue_last, fill_mode, do_stdout) < 0) { | ||
| 849 | video_close(&dev); | ||
| 850 | return 1; | ||
| 851 | } | ||
| 852 | -- | ||
| 853 | 1.7.10 | ||
| 854 | |||
diff --git a/meta-oe/recipes-multimedia/v4l2apps/yavta_git.bb b/meta-oe/recipes-multimedia/v4l2apps/yavta_git.bb index 054912d66a..d007bcb609 100644 --- a/meta-oe/recipes-multimedia/v4l2apps/yavta_git.bb +++ b/meta-oe/recipes-multimedia/v4l2apps/yavta_git.bb | |||
| @@ -2,11 +2,12 @@ DESCRIPTION = "Yet Another V4L2 Test Application" | |||
| 2 | LICENSE = "GPLv2" | 2 | LICENSE = "GPLv2" |
| 3 | LIC_FILES_CHKSUM = "file://COPYING.GPL;md5=751419260aa954499f7abaabaa882bbe" | 3 | LIC_FILES_CHKSUM = "file://COPYING.GPL;md5=751419260aa954499f7abaabaa882bbe" |
| 4 | 4 | ||
| 5 | SRC_URI = "git://git.ideasonboard.org/yavta.git;protocol=git" | 5 | SRC_URI = "git://git.ideasonboard.org/yavta.git;protocol=git \ |
| 6 | file://0001-Add-stdout-mode-to-allow-streaming-over-the-network-.patch" | ||
| 6 | SRCREV = "82ff2efdb9787737b9f21b6f4759f077c827b238" | 7 | SRCREV = "82ff2efdb9787737b9f21b6f4759f077c827b238" |
| 7 | 8 | ||
| 8 | PV = "0.0" | 9 | PV = "0.0" |
| 9 | PR = "r1" | 10 | PR = "r2" |
| 10 | S = "${WORKDIR}/git" | 11 | S = "${WORKDIR}/git" |
| 11 | 12 | ||
| 12 | do_install() { | 13 | do_install() { |
