UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
dvs.c
Go to the documentation of this file.
1/*
2 * FILE: video_capture/dvs.c
3 * AUTHOR: Colin Perkins <csp@isi.edu>
4 * Martin Benes <martinbenesh@gmail.com>
5 * Lukas Hejtmanek <xhejtman@ics.muni.cz>
6 * Petr Holub <hopet@ics.muni.cz>
7 * Milos Liska <xliska@fi.muni.cz>
8 * Jiri Matela <matela@ics.muni.cz>
9 * Dalibor Matura <255899@mail.muni.cz>
10 * Ian Wesley-Smith <iwsmith@cct.lsu.edu>
11 *
12 * Copyright (c) 2001-2003 University of Southern California
13 * Copyright (c) 2005-2023 CESNET z.s.p.o.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, is permitted provided that the following conditions
17 * are met:
18 *
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 *
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 *
26 * 3. All advertising materials mentioning features or use of this software
27 * must display the following acknowledgement:
28 *
29 * This product includes software developed by the University of Southern
30 * California Information Sciences Institute. This product also includes
31 * software developed by CESNET z.s.p.o.
32 *
33 * 4. Neither the name of the University, Institute, CESNET nor the names of
34 * its contributors may be used to endorse or promote products derived from
35 * this software without specific prior written permission.
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
38 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
39 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
40 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
41 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
42 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
46 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
47 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
48 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 *
50 */
51
52#include "host.h"
53#include "config.h"
54#include "config_unix.h"
55#include "config_win32.h"
56
57#include "audio/types.h"
58#include "audio/utils.h"
59#include "debug.h"
60#include "lib_common.h"
61#include "video.h"
62#include "video_capture.h"
63#include "video_display.h"
64#include "video_display/dvs.h"
65#include "tv.h"
66#include "dvs_clib.h" /* From the DVS SDK */
67#include "dvs_fifo.h" /* From the DVS SDK */
68
70 sv_handle *sv;
71 sv_fifo *fifo;
72 sv_fifo_buffer *dma_buffer;
75 pthread_t thread_id;
76 pthread_mutex_t lock;
77 pthread_cond_t boss_cv;
78 pthread_cond_t worker_cv;
82 char *bufs[2];
83 char *audio_bufs[2];
85 uint32_t hd_video_mode;
87 struct tile *tile;
90 unsigned grab_audio:1;
91
92 int frames;
93 struct timeval t, t0;
94
96};
97
98static void show_help(void);
99
100static void *vidcap_dvs_grab_thread(void *arg)
101{
102 int res;
103 struct vidcap_dvs_state *s = (struct vidcap_dvs_state *)arg;
104 int fifo_flags = SV_FIFO_FLAG_FLUSH |
105 SV_FIFO_FLAG_NODMAADDR;
106
107 if(!s->grab_audio)
108 fifo_flags |= SV_FIFO_FLAG_VIDEOONLY;
109
110 while (1) {
111 // we need this additional check in case we do not get any data
112 pthread_mutex_lock(&(s->lock));
113 if(s->should_exit) {
114 pthread_mutex_unlock(&(s->lock));
115 break;
116 }
117 pthread_mutex_unlock(&(s->lock));
118
119 s->dma_buffer = NULL;
120 res = sv_fifo_vsyncwait(s->sv, s->fifo);
121
122 res =
123 sv_fifo_getbuffer(s->sv, s->fifo, &(s->dma_buffer), NULL,
124 fifo_flags);
125 if (res != SV_OK) {
126 printf("Unable to getbuffer %s\n",
127 sv_geterrortext(res));
128 continue;
129 }
130 s->bufs_index = (s->bufs_index + 1) % 2;
131 s->dma_buffer->video[0].addr = s->bufs[s->bufs_index];
132 s->dma_buffer->video[0].size = s->tile->data_len;
133 if(s->grab_audio) {
134 s->dma_buffer->audio[0].addr[0] = s->audio_bufs[s->bufs_index];
135 //fprintf(stderr, "%d ", s->dma_buffer->audio[0].size);
136 //s->dma_buffer->audio[0].size = 12800;
137 }
138
139 res = sv_fifo_putbuffer(s->sv, s->fifo, s->dma_buffer, NULL);
140 if (res != SV_OK) {
141 printf("Unable to putbuffer %s\n",
142 sv_geterrortext(res));
143 }
144
145 pthread_mutex_lock(&(s->lock));
146
147 while (s->work_to_do == FALSE) {
148 pthread_cond_wait(&(s->worker_cv), &(s->lock));
149 }
150
151 if(s->should_exit) {
152 pthread_mutex_unlock(&(s->lock));
153 break;
154 }
155
156 s->tmp_buffer = s->dma_buffer->video[0].addr;
157
158 if(s->audio.ch_count == 1) {
159 demux_channel(s->audio.data, s->dma_buffer->audio[0].addr[0], s->audio.bps, s->dma_buffer->audio[0].size, 2, 0);
160 s->audio.data_len = s->dma_buffer->audio[0].size / 2;
161 } else {
162 s->audio.data = s->dma_buffer->audio[0].addr[0];
163 s->audio.data_len = s->dma_buffer->audio[0].size;
164 }
165
166 s->work_to_do = FALSE;
167 pthread_cond_signal(&(s->boss_cv));
168
169 pthread_mutex_unlock(&(s->lock));
170 }
171 return NULL;
172}
173
174static void show_help(void)
175{
176 int i;
177 int card_idx = 0;
178 sv_handle *sv;
179 char name[128];
180 int res;
181
182 printf("DVS options:\n\n");
183 printf("\t -t dvs[:<mode>:<codec>[:<card>]] | help\n");
184 printf("\tor\n");
185 printf("\t -t dvs[:device=<card>][:mode=<mode>][:codec=<codec>] | help\n\n");
186 snprintf(name, 128, "PCI,card:%d", card_idx);
187
188 //sv = sv_open(name);
189 res = sv_openex(&sv, name, SV_OPENPROGRAM_DEFAULT, SV_OPENTYPE_DEFAULT, 0, 0);
190 if (res != SV_OK) {
191 printf
192 ("Unable to open grabber: sv_open() failed (no card present or driver not loaded?)\n");
193 printf("Error %s\n", sv_geterrortext(res));
194 return;
195 }
196 while (res == SV_OK) {
197 printf("\tCard \"%d\" - supported modes:\n\n", card_idx);
198 for(i=0; hdsp_mode_table[i].width !=0; i++) {
199 int res;
200 sv_query(sv, SV_QUERY_MODE_AVAILABLE, hdsp_mode_table[i].mode, & res);
201 if(res) {
202 const char *interlacing;
203 if(hdsp_mode_table[i].aux & AUX_INTERLACED) {
204 interlacing = "interlaced";
205 } else if(hdsp_mode_table[i].aux & AUX_PROGRESSIVE) {
206 interlacing = "progressive";
207 } else if(hdsp_mode_table[i].aux & AUX_SF) {
208 interlacing = "progressive segmented";
209 } else {
210 interlacing = "unknown (!)";
211 }
212 printf ("\t%4d: %4d x %4d @ %2.2f %s\n", hdsp_mode_table[i].mode,
213 hdsp_mode_table[i].width, hdsp_mode_table[i].height,
214 hdsp_mode_table[i].fps, interlacing);
215 }
216 }
217 sv_close(sv);
218 card_idx++;
219 snprintf(name, 128, "PCI,card:%d", card_idx);
220 res = sv_openex(&sv, name, SV_OPENPROGRAM_DEFAULT, SV_OPENTYPE_DEFAULT, 0, 0);
221 printf("\n");
222 }
223 printf("\n");
224 codec_t codecs_8b[] = {RGBA, RGB, UYVY, VIDEO_CODEC_NONE};
225 codec_t codecs_10b[] = {DVS10, VIDEO_CODEC_NONE};
226 show_codec_help("dvs", codecs_8b, codecs_10b, NULL);
227}
228
229/* External API ***********************************************************************************/
230
231static int vidcap_dvs_init(struct vidcap_params *params, void **state)
232{
233 struct vidcap_dvs_state *s;
234 int i;
235 int res;
236 int mode_index = 0;
237 char card_name[128] = "";
238
239 s = (struct vidcap_dvs_state *)
240 calloc(1, sizeof(struct vidcap_dvs_state));
241
242 if (s == NULL) {
243 debug_msg("Unable to allocate DVS state\n");
244 return VIDCAP_INIT_FAIL;
245 }
246
247 s->frame = vf_alloc(1);
248 s->tile = vf_get_tile(s->frame, 0);
249 s->frames = 0;
250
251 if (vidcap_params_get_fmt(params) != NULL) {
252 if (strcmp(vidcap_params_get_fmt(params), "help") == 0) {
253 show_help();
254 free(s);
255 return VIDCAP_INIT_NOERR;
256 }
257
258 char *fmt = strdup(vidcap_params_get_fmt(params));
259 char *item;
260
261 if (isdigit(fmt[0])) {
262 item = strtok(fmt, ":");
263 if (!item) {
264 fprintf(stderr, "Wrong config %s\n", fmt);
265 free(fmt);
266 free(s);
267 return VIDCAP_INIT_FAIL;
268 }
269 mode_index = atoi(item);
270 for(i=0; hdsp_mode_table[i].width != 0; i++) {
271 if(hdsp_mode_table[i].mode == mode_index) {
272 s->mode = &hdsp_mode_table[i];
273 break;
274 }
275 }
276 if(s->mode == NULL) {
277 fprintf(stderr, "dvs: unknown video mode: %d\n", mode_index);
278 free(fmt);
279 free(s);
280 return VIDCAP_INIT_FAIL;
281 }
282
283 item = strtok(NULL, ":");
284 if (!item) {
285 fprintf(stderr, "Wrong config %s\n", fmt);
286 free(fmt);
287 free(s);
288 return VIDCAP_INIT_FAIL;
289 }
290
292 if (s->frame->color_spec == VIDEO_CODEC_NONE) {
293 fprintf(stderr, "dvs: unknown codec: %s\n", item);
294 free(fmt);
295 free(s);
296 return VIDCAP_INIT_FAIL;
297 }
298
299 /* card name */
300 item = strtok(NULL, ":");
301 if(item) {
302 snprintf(card_name, sizeof card_name, "PCI,card:%s", item);
303 printf("[DVS] Choosen card: %s.\n", card_name);
304 }
305 } else { // new format - key=value
306 char *tmp = fmt;
307 while ((item = strtok(tmp, ":"))) {
308 if (strncmp(item, "mode=", sizeof("mode=")) == 0) {
309 mode_index = atoi(strchr(item, '=') + 1);
310 for(i=0; hdsp_mode_table[i].width != 0; i++) {
311 if(hdsp_mode_table[i].mode == mode_index) {
312 s->mode = &hdsp_mode_table[i];
313 break;
314 }
315 }
316 if(s->mode == NULL) {
317 fprintf(stderr, "dvs: unknown video mode: %d\n", mode_index);
318 free(fmt);
319 free(s);
320 return VIDCAP_INIT_FAIL;
321 }
322 } else if (strncmp(item, "device=", sizeof("device=")) == 0) {
323 snprintf(card_name, sizeof card_name, "PCI,card:%s", strchr(item, '=') + 1);
324 printf("[DVS] Choosen card: %s.\n", card_name);
325 } else if (strncmp(item, "codec=", sizeof("codec=")) == 0) {
326 s->frame->color_spec = get_codec_from_name(strchr(item, '=') + 1);
327 if (s->frame->color_spec == VIDEO_CODEC_NONE) {
328 fprintf(stderr, "dvs: unknown codec: %s\n", item);
329 free(fmt);
330 free(s);
331 return VIDCAP_INIT_FAIL;
332 }
333 } else {
334 log_msg(LOG_LEVEL_ERROR, "dvs: unknown option: %s\n", item);
335 free(fmt);
336 free(s);
337 return VIDCAP_INIT_FAIL;
338 }
339 }
340 }
341
342 free(fmt);
343 }
344
345 gettimeofday(&s->t0, NULL);
346
347 res = sv_openex(&s->sv, card_name, SV_OPENPROGRAM_DEFAULT, SV_OPENTYPE_DEFAULT, 0, 0);
348 if (s->sv == NULL) {
349 printf
350 ("Unable to open grabber: sv_open() failed (no card present or driver not loaded?)\n");
351 printf("Error %s\n", sv_geterrortext(res));
352 free(s);
353 return VIDCAP_INIT_FAIL;
354 }
355
357 s->grab_audio = TRUE;
358 } else {
360 free(s);
362 }
363 s->grab_audio = FALSE;
364 }
365
366 s->hd_video_mode = 0;
367
368 if (s->mode) {
369 switch(s->frame->color_spec) {
370 case DVS10:
371 s->hd_video_mode |= SV_MODE_COLOR_YUV422 | SV_MODE_NBIT_10BDVS;
372 break;
373 case UYVY:
374 s->hd_video_mode |= SV_MODE_COLOR_YUV422;
375 break;
376 case RGBA:
377 s->hd_video_mode |= SV_MODE_COLOR_RGBA;
378 break;
379 case RGB:
380 s->hd_video_mode |= SV_MODE_COLOR_RGB_RGB;
381 break;
382 default:
383 fprintf(stderr, "[dvs] Unsupported video codec passed!");
384 free(s);
385 return VIDCAP_INIT_FAIL;
386 }
387
388 s->hd_video_mode |= s->mode->mode;
389 } else {
390 int val;
391 int res;
392 res = sv_query(s->sv, SV_QUERY_INPUTRASTER, 0, &val);
393 if(res != SV_OK) {
394 printf("[DVS] Could not detect video format %s\n",
395 sv_geterrortext(res));
396 goto error_detect;
397 }
398 if(val == -1) {
399 printf("[DVS] No signal detected, cannot autodetect format.\n");
400 goto error_detect;
401 }
402 for(i=0; hdsp_mode_table[i].width != 0; i++) {
403 if(hdsp_mode_table[i].mode == val) {
404 s->mode = &hdsp_mode_table[i];
405 break;
406 }
407 }
408 s->hd_video_mode |= val;
409 if (s->mode == NULL) {
410 log_msg(LOG_LEVEL_ERROR, "[DVS] Mode detected, however unknown. Report to " PACKAGE_BUGREPORT ".\n");
411 goto error_detect;
412 }
413 printf("[DVS] Autodetected video mode: %dx%d @ %2.2fFPS.\n", s->mode->width, s->mode->height, s->mode->fps);
414
415 res = sv_query(s->sv, SV_QUERY_IOMODE, 0, &val);
416 if(res != SV_OK) {
417 printf("Could not detect IO mode %s\n",
418 sv_geterrortext(res));
419 goto error_detect;
420 }
421 printf("[DVS] Autodetected IO mode: %d.\n", val);
422
423 switch (val) {
424 case SV_IOMODE_YUV422:
425 case SV_IOMODE_YUV444:
426 case SV_IOMODE_YUV422A:
427 case SV_IOMODE_YUV444A:
428 case SV_IOMODE_YUV422_12:
429 case SV_IOMODE_YUV444_12:
430 s->hd_video_mode |= SV_MODE_COLOR_YUV422;
431 s->frame->color_spec = UYVY;
432 break;
433 case SV_IOMODE_RGB:
434 case SV_IOMODE_RGB_12:
435 s->hd_video_mode |= SV_MODE_COLOR_RGBA;
436 s->frame->color_spec = RGB;
437 break;
438 case SV_IOMODE_RGBA:
439 s->hd_video_mode |= SV_MODE_COLOR_RGB_RGB;
440 s->frame->color_spec = RGBA;
441 break;
442 }
443 }
444 s->hd_video_mode |= SV_MODE_STORAGE_FRAME;
445
446 s->tile->width = s->mode->width;
447 s->tile->height = s->mode->height;
448 s->frame->fps = s->mode->fps;
449 switch(s->mode->aux) {
450 case AUX_PROGRESSIVE:
451 case AUX_SF:
453 break;
454 case AUX_INTERLACED:
456 break;
457 }
458
459
461 s->tile->height;
462
463
464 //res = sv_videomode(s->sv, s->hd_video_mode);
465 res = sv_option(s->sv, SV_OPTION_VIDEOMODE, s->hd_video_mode);
466 if (res != SV_OK) {
467 goto error;
468 }
469 res = sv_black(s->sv);
470 if (res != SV_OK) {
471 goto error;
472 }
473
474 s->audio.data = NULL;
475
476 if(s->grab_audio) {
477 int i;
478 res = sv_option(s->sv, SV_OPTION_AUDIOINPUT, SV_AUDIOINPUT_AIV);
479 if (res != SV_OK) {
480 goto error;
481 }
483 if (s->audio.ch_count != 2 && s->audio.ch_count != 1) {
484 fprintf(stderr, "[DVS cap.] Invalid channel count %d. "
485 "Currently only 1 or 2 channels are supported.\n",
486 s->audio.ch_count);
487 goto error;
488 }
489 res = sv_option(s->sv, SV_OPTION_AUDIOCHANNELS, 1); // one pair
490 if (res != SV_OK) {
491 goto error;
492 }
493
494 sv_query(s->sv, SV_QUERY_AUDIOBITS, 0, &i);
495 s->audio.bps = i / 8;
496 sv_query(s->sv, SV_QUERY_AUDIOFREQ, 0, &i);
497 s->audio.sample_rate = i;
498 s->audio.data_len = 0;
499
500 /* two 1-sec buffers */
501 s->audio_bufs[0] = malloc(s->audio.sample_rate * 2 * s->audio.bps);
502 s->audio_bufs[1] = malloc(s->audio.sample_rate * 2 * s->audio.bps);
503
504 if (s->audio.ch_count == 1) {
505 // data need to be demultiplexed
507 s->audio.data = (char *) malloc(s->audio.max_size);
508 }
509
510 log_msg(LOG_LEVEL_NOTICE, "[DVS] Capturing audio: %d channels, %d Bps, sample rate %d Hz\n", s->audio.ch_count, s->audio.bps, s->audio.sample_rate);
511 }
512
513 res = sv_fifo_init(s->sv, &(s->fifo), 1, /* jack - must be 1 for default input FIFO */
514 0, /* obsolete - must be 0 */
515 SV_FIFO_DMA_ON,
516 SV_FIFO_FLAG_NODMAADDR,
517 0 /* frames in FIFO - 0 meens let API set the default maximal value*/
518 );
519 if (res != SV_OK) {
520 goto error;
521 }
522 res = sv_fifo_start(s->sv, s->fifo);
523 if (res != SV_OK) {
524 goto error;
525 }
526
527 pthread_mutex_init(&(s->lock), NULL);
528 pthread_cond_init(&(s->boss_cv), NULL);
529 pthread_cond_init(&(s->worker_cv), NULL);
530
531 s->rtp_buffer = NULL;
532 s->dma_buffer = NULL;
533 s->tmp_buffer = NULL;
534 s->work_to_do = FALSE;
535 s->bufs[0] = malloc(s->tile->data_len);
536 s->bufs[1] = malloc(s->tile->data_len);
537 s->bufs_index = 0;
538
539 if (pthread_create
540 (&(s->thread_id), NULL, vidcap_dvs_grab_thread, s) != 0) {
541 perror("Unable to create grabbing thread");
542 return VIDCAP_INIT_FAIL;
543 }
544
545 printf("DVS capture set to %dx%d, bpp %f\n", s->tile->width, s->tile->height, get_bpp(s->frame->color_spec));
546
547 debug_msg("DVS capture device enabled\n");
548 *state = s;
549 return VIDCAP_INIT_OK;
550error_detect:
551 sv_close(s->sv);
552error:
553 free(s);
554 printf("Error %s\n", sv_geterrortext(res));
555 debug_msg("Unable to open grabber: %s\n", sv_geterrortext(res));
556 return VIDCAP_INIT_FAIL;
557}
558
559static void vidcap_dvs_done(void *state)
560{
561 struct vidcap_dvs_state *s =
562 (struct vidcap_dvs_state *)state;
563
564 pthread_mutex_lock(&s->lock);
565 s->work_to_do = TRUE;
566 s->should_exit = true;
567 pthread_cond_signal(&s->worker_cv);
568 pthread_mutex_unlock(&s->lock);
569
570 pthread_join(s->thread_id, NULL);
571
572 if(s->grab_audio && s->audio.ch_count == 1) {
573 free(s->audio.data);
574 }
575
576 sv_fifo_free(s->sv, s->fifo);
577 sv_close(s->sv);
578 vf_free(s->frame);
579 free(s);
580}
581
582static struct video_frame *vidcap_dvs_grab(void *state, struct audio_frame **audio)
583{
584 struct vidcap_dvs_state *s =
585 (struct vidcap_dvs_state *)state;
586 struct timespec ts;
587 struct timeval tp;
588 int rc = 0;
589
590 // get time for timeout
591 gettimeofday(&tp, NULL);
592 ts.tv_sec = tp.tv_sec;
593 ts.tv_nsec = tp.tv_usec * 1000;
594 ts.tv_nsec += 2 * 1000 * 1000 * 1000 / s->frame->fps;
595 // make it correct
596 ts.tv_sec += ts.tv_nsec / 1000000000;
597 ts.tv_nsec = ts.tv_nsec % 1000000000;
598
599 pthread_mutex_lock(&(s->lock));
600
601 /* Wait for the worker to finish... */
602 while (s->work_to_do && rc != ETIMEDOUT) {
603 rc = pthread_cond_timedwait(&s->boss_cv, &s->lock, &ts);
604 }
605
606 if (rc == ETIMEDOUT) {
607 pthread_mutex_unlock(&(s->lock));
608 return NULL;
609 }
610
611 /* ...and give it more to do... */
612 s->rtp_buffer = s->tmp_buffer;
613 s->work_to_do = TRUE;
614
615 /* ...and signal the worker... */
616 pthread_cond_signal(&(s->worker_cv));
617
618 pthread_mutex_unlock(&(s->lock));
619
620 if (s->rtp_buffer != NULL) {
621 s->tile->data = s->rtp_buffer;
622
623 s->frames++;
624 gettimeofday(&s->t, NULL);
625 double seconds = tv_diff(s->t, s->t0);
626 if (seconds >= 5) {
627 float fps = s->frames / seconds;
628 log_msg(LOG_LEVEL_INFO, "[DVS cap.] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps);
629 s->t0 = s->t;
630 s->frames = 0;
631 }
632
633 if(s->grab_audio && s->audio.data_len) {
634 *audio = &s->audio;
635 } else {
636 *audio = NULL;
637 }
638 return s->frame;
639 }
640
641 return NULL;
642}
643
644static void vidcap_dvs_probe(struct device_info **available_cards, int *count, void (**deleter)(void *))
645{
646 *deleter = free;
647
648 struct device_info *cards = NULL;
649 int card_count = 0;
650
651 int card_idx = 0;
652 sv_handle *sv;
653 char name[128];
654 int res;
655 snprintf(name, 128, "PCI,card:%d", card_idx);
656 res = sv_openex(&sv, name, SV_OPENPROGRAM_DEFAULT, SV_OPENTYPE_DEFAULT, 0, 0);
657 while (res == SV_OK) {
658 card_count = card_idx + 1;
659 cards = realloc(cards, card_count * sizeof(struct device_info));
660 memset(&cards[card_idx], 0, sizeof(struct device_info));
661 snprintf(cards[card_idx].dev, sizeof cards[card_idx].dev,
662 ":device=%d", card_idx);
663 snprintf(cards[card_idx].name, sizeof cards[card_idx].name,
664 "DVS card #%d", card_idx);
665 snprintf(cards[card_idx].extra, sizeof cards[card_idx].extra,
666 "\"embeddedAudioAvailable\":\"t\"", card_idx);
667
668 sv_close(sv);
669 card_idx++;
670 snprintf(name, 128, "PCI,card:%d", card_idx);
671 res = sv_openex(&sv, name, SV_OPENPROGRAM_DEFAULT, SV_OPENTYPE_DEFAULT, 0, 0);
672 }
673 *available_cards = cards;
674 *count = card_count;
675}
676
684
686
void ** state
int void * val
const char * fmt
struct audio_frame ** audio
int void(** deleter)(void *))
struct video_frame * vf_alloc(int count)
Allocates blank video frame.
void vf_free(struct video_frame *buf)
Frees video_frame structure.
int vc_get_linesize(unsigned int width, codec_t codec)
codec_t get_codec_from_name(const char *name)
This file contains definition of some common audio types.
#define TRUE
#define FALSE
void log_msg(int level, const char *format,...)
Definition debug.cpp:130
#define LOG_LEVEL_NOTICE
information that may be interesting
Definition debug.h:61
#define LOG_LEVEL_INFO
normal reporting
Definition debug.h:62
#define LOG_LEVEL_ERROR
general errors
Definition debug.h:59
#define debug_msg(...)
#define debug_msg(...) log_msg(LOG_LEVEL_DEBUG, "[pid/%d +%d %s] ", getpid(), LINE,...
Definition debug.h:92
#define VIDCAP_INIT_NOERR
state not initialized, other action performed (typically help)
#define VIDCAP_INIT_OK
initialization successful
#define VIDCAP_NO_GENERIC_FPS_INDICATOR
#define VIDEO_CAPTURE_ABI_VERSION
#define VIDCAP_INIT_FAIL
error ocured
#define VIDCAP_INIT_AUDIO_NOT_SUPPORTED
card does not support audio
int count
Definition hd-rum.c:44
unsigned int audio_capture_channels
Definition host.cpp:163
#define DEFAULT_AUDIO_CAPTURE_CHANNELS
Definition host.h:89
@ LIBRARY_CLASS_VIDEO_CAPTURE
Definition lib_common.h:78
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
Definition lib_common.h:144
enum openssl_mode mode
const char * name
Definition settings.cpp:193
struct used to comunicate with audio capture/playback device
Definition types.h:99
int sample_rate
Definition types.h:101
char * data
Definition types.h:102
int ch_count
Definition types.h:104
int data_len
Definition types.h:103
int bps
Definition types.h:100
int max_size
Definition types.h:105
char extra[1024]
Definition types.h:389
char dev[1024]
Definition types.h:383
unsigned int height
Definition dvs.h:46
double fps
Definition dvs.h:47
unsigned int width
Definition dvs.h:45
Definition hd-rum.c:27
Struct tile is an area of video_frame.
Definition types.h:279
unsigned int width
Definition types.h:280
char * data
Raw tile data. Pointer must be at least 4B aligned.
Definition types.h:287
unsigned int data_len
length of the data
Definition types.h:288
unsigned int height
Definition types.h:281
sv_handle * sv
Definition dvs.c:70
const hdsp_mode_table_t * mode
Definition dvs.c:89
char * bufs[2]
Definition dvs.c:82
char * rtp_buffer
Definition dvs.c:73
int bufs_index
Definition dvs.c:84
uint32_t hd_video_mode
Definition dvs.c:85
sv_fifo_buffer * dma_buffer
Definition dvs.c:72
int work_to_do
Definition dvs.c:81
pthread_cond_t boss_cv
Definition dvs.c:77
sv_fifo * fifo
Definition dvs.c:71
struct video_frame * frame
Definition dvs.c:86
struct audio_frame audio
Definition dvs.c:88
int boss_waiting
Definition dvs.c:79
pthread_cond_t worker_cv
Definition dvs.c:78
pthread_t thread_id
Definition dvs.c:75
bool should_exit
Definition dvs.c:95
pthread_mutex_t lock
Definition dvs.c:76
unsigned grab_audio
Definition dvs.c:90
struct tile * tile
Definition dvs.c:87
char * tmp_buffer
Definition dvs.c:74
int worker_waiting
Definition dvs.c:80
struct timeval t t0
Definition dvs.c:93
char * audio_bufs[2]
Definition dvs.c:83
Struct video_frame represents a video frame and contains video description.
Definition types.h:305
enum interlacing_t interlacing
Definition types.h:307
double fps
Definition types.h:308
codec_t color_spec
Definition types.h:306
uint32_t ts
Definition tfrc.c:101
double tv_diff(struct timeval curr_time, struct timeval prev_time)
Definition tv.c:97
@ PROGRESSIVE
progressive frame
Definition types.h:164
@ INTERLACED_MERGED
Columngs of both fields are interlaced together.
Definition types.h:167
codec_t
Definition types.h:65
@ RGB
RGB 8-bit (packed into 24-bit word)
Definition types.h:80
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
Definition types.h:71
@ VIDEO_CODEC_NONE
dummy color spec
Definition types.h:66
@ DVS10
DVS 10-bit format.
Definition types.h:76
@ RGBA
RGBA 8-bit, big-endian.
Definition types.h:70
void demux_channel(char *out, char *in, int bps, int in_len, int in_stream_channels, int pos_in_stream)
Definition utils.cpp:334
This is an umbrella header for video functions.
static void * vidcap_dvs_grab_thread(void *arg)
Definition dvs.c:100
static void vidcap_dvs_done(void *state)
Definition dvs.c:559
static const struct video_capture_info vidcap_dvs_info
Definition dvs.c:677
static void vidcap_dvs_probe(struct device_info **available_cards, int *count, void(**deleter)(void *))
Definition dvs.c:644
static struct video_frame * vidcap_dvs_grab(void *state, struct audio_frame **audio)
Definition dvs.c:582
static int vidcap_dvs_init(struct vidcap_params *params, void **state)
Definition dvs.c:231
static void show_help(void)
Definition dvs.c:174
const char * vidcap_params_get_fmt(const struct vidcap_params *params)
unsigned int vidcap_params_get_flags(const struct vidcap_params *params)
#define VIDCAP_FLAG_AUDIO_ANY
#define VIDCAP_FLAG_AUDIO_EMBEDDED
HD-SDI embedded audio.
double get_bpp(codec_t codec)
void show_codec_help(const char *module, const codec_t *codecs8, const codec_t *codecs10, const codec_t *codecs_ge12)
Prints list of suppored codecs for video module.
const hdsp_mode_table_t hdsp_mode_table[]
Definition dvs.c:71
struct tile * vf_get_tile(struct video_frame *buf, int pos)
Returns pointer to n-th tile from video frame Equivalent to &video_frame::tiles[pos].
#define AUX_SF
#define AUX_INTERLACED
#define AUX_PROGRESSIVE