104 int fifo_flags = SV_FIFO_FLAG_FLUSH |
105 SV_FIFO_FLAG_NODMAADDR;
108 fifo_flags |= SV_FIFO_FLAG_VIDEOONLY;
112 pthread_mutex_lock(&(s->
lock));
114 pthread_mutex_unlock(&(s->
lock));
117 pthread_mutex_unlock(&(s->
lock));
120 res = sv_fifo_vsyncwait(s->
sv, s->
fifo);
126 printf(
"Unable to getbuffer %s\n",
127 sv_geterrortext(res));
141 printf(
"Unable to putbuffer %s\n",
142 sv_geterrortext(res));
145 pthread_mutex_lock(&(s->
lock));
152 pthread_mutex_unlock(&(s->
lock));
167 pthread_cond_signal(&(s->
boss_cv));
169 pthread_mutex_unlock(&(s->
lock));
182 printf(
"DVS options:\n\n");
183 printf(
"\t -t dvs[:<mode>:<codec>[:<card>]] | help\n");
185 printf(
"\t -t dvs[:device=<card>][:mode=<mode>][:codec=<codec>] | help\n\n");
186 snprintf(
name, 128,
"PCI,card:%d", card_idx);
189 res = sv_openex(&
sv,
name, SV_OPENPROGRAM_DEFAULT, SV_OPENTYPE_DEFAULT, 0, 0);
192 (
"Unable to open grabber: sv_open() failed (no card present or driver not loaded?)\n");
193 printf(
"Error %s\n", sv_geterrortext(res));
196 while (res == SV_OK) {
197 printf(
"\tCard \"%d\" - supported modes:\n\n", card_idx);
202 const char *interlacing;
204 interlacing =
"interlaced";
206 interlacing =
"progressive";
208 interlacing =
"progressive segmented";
210 interlacing =
"unknown (!)";
219 snprintf(
name, 128,
"PCI,card:%d", card_idx);
220 res = sv_openex(&
sv,
name, SV_OPENPROGRAM_DEFAULT, SV_OPENTYPE_DEFAULT, 0, 0);
237 char card_name[128] =
"";
243 debug_msg(
"Unable to allocate DVS state\n");
261 if (isdigit(
fmt[0])) {
264 fprintf(stderr,
"Wrong config %s\n",
fmt);
269 mode_index = atoi(
item);
276 if(s->
mode == NULL) {
277 fprintf(stderr,
"dvs: unknown video mode: %d\n", mode_index);
283 item = strtok(NULL,
":");
285 fprintf(stderr,
"Wrong config %s\n",
fmt);
293 fprintf(stderr,
"dvs: unknown codec: %s\n",
item);
300 item = strtok(NULL,
":");
302 snprintf(card_name,
sizeof card_name,
"PCI,card:%s",
item);
303 printf(
"[DVS] Choosen card: %s.\n", card_name);
307 while ((
item = strtok(tmp,
":"))) {
308 if (strncmp(
item,
"mode=",
sizeof(
"mode=")) == 0) {
309 mode_index = atoi(strchr(
item,
'=') + 1);
316 if(s->
mode == NULL) {
317 fprintf(stderr,
"dvs: unknown video mode: %d\n", mode_index);
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) {
328 fprintf(stderr,
"dvs: unknown codec: %s\n",
item);
345 gettimeofday(&s->
t0, NULL);
347 res = sv_openex(&s->
sv, card_name, SV_OPENPROGRAM_DEFAULT, SV_OPENTYPE_DEFAULT, 0, 0);
350 (
"Unable to open grabber: sv_open() failed (no card present or driver not loaded?)\n");
351 printf(
"Error %s\n", sv_geterrortext(res));
371 s->
hd_video_mode |= SV_MODE_COLOR_YUV422 | SV_MODE_NBIT_10BDVS;
383 fprintf(stderr,
"[dvs] Unsupported video codec passed!");
392 res = sv_query(s->
sv, SV_QUERY_INPUTRASTER, 0, &
val);
394 printf(
"[DVS] Could not detect video format %s\n",
395 sv_geterrortext(res));
399 printf(
"[DVS] No signal detected, cannot autodetect format.\n");
409 if (s->
mode == NULL) {
415 res = sv_query(s->
sv, SV_QUERY_IOMODE, 0, &
val);
417 printf(
"Could not detect IO mode %s\n",
418 sv_geterrortext(res));
421 printf(
"[DVS] Autodetected IO mode: %d.\n",
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:
434 case SV_IOMODE_RGB_12:
469 res = sv_black(s->
sv);
478 res = sv_option(s->
sv, SV_OPTION_AUDIOINPUT, SV_AUDIOINPUT_AIV);
484 fprintf(stderr,
"[DVS cap.] Invalid channel count %d. "
485 "Currently only 1 or 2 channels are supported.\n",
489 res = sv_option(s->
sv, SV_OPTION_AUDIOCHANNELS, 1);
494 sv_query(s->
sv, SV_QUERY_AUDIOBITS, 0, &i);
496 sv_query(s->
sv, SV_QUERY_AUDIOFREQ, 0, &i);
513 res = sv_fifo_init(s->
sv, &(s->
fifo), 1,
516 SV_FIFO_FLAG_NODMAADDR,
522 res = sv_fifo_start(s->
sv, s->
fifo);
527 pthread_mutex_init(&(s->
lock), NULL);
528 pthread_cond_init(&(s->
boss_cv), NULL);
529 pthread_cond_init(&(s->
worker_cv), NULL);
541 perror(
"Unable to create grabbing thread");
547 debug_msg(
"DVS capture device enabled\n");
554 printf(
"Error %s\n", sv_geterrortext(res));
555 debug_msg(
"Unable to open grabber: %s\n", sv_geterrortext(res));
564 pthread_mutex_lock(&s->
lock);
568 pthread_mutex_unlock(&s->
lock);
576 sv_fifo_free(s->
sv, s->
fifo);
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;
596 ts.tv_sec +=
ts.tv_nsec / 1000000000;
597 ts.tv_nsec =
ts.tv_nsec % 1000000000;
599 pthread_mutex_lock(&(s->
lock));
606 if (rc == ETIMEDOUT) {
607 pthread_mutex_unlock(&(s->
lock));
618 pthread_mutex_unlock(&(s->
lock));
624 gettimeofday(&s->t, NULL);
627 float fps = s->
frames / seconds;
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);
670 snprintf(
name, 128,
"PCI,card:%d", card_idx);
671 res = sv_openex(&sv,
name, SV_OPENPROGRAM_DEFAULT, SV_OPENTYPE_DEFAULT, 0, 0);
673 *available_cards = cards;
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.
void log_msg(int level, const char *format,...)
#define LOG_LEVEL_NOTICE
information that may be interesting
#define LOG_LEVEL_INFO
normal reporting
#define LOG_LEVEL_ERROR
general errors
#define debug_msg(...)
#define debug_msg(...) log_msg(LOG_LEVEL_DEBUG, "[pid/%d +%d %s] ", getpid(), LINE,...
#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
unsigned int audio_capture_channels
#define DEFAULT_AUDIO_CAPTURE_CHANNELS
@ LIBRARY_CLASS_VIDEO_CAPTURE
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
struct used to comunicate with audio capture/playback device
Struct tile is an area of video_frame.
char * data
Raw tile data. Pointer must be at least 4B aligned.
unsigned int data_len
length of the data
const hdsp_mode_table_t * mode
sv_fifo_buffer * dma_buffer
struct video_frame * frame
Struct video_frame represents a video frame and contains video description.
enum interlacing_t interlacing
double tv_diff(struct timeval curr_time, struct timeval prev_time)
@ PROGRESSIVE
progressive frame
@ INTERLACED_MERGED
Columngs of both fields are interlaced together.
@ RGB
RGB 8-bit (packed into 24-bit word)
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
@ VIDEO_CODEC_NONE
dummy color spec
@ DVS10
DVS 10-bit format.
@ RGBA
RGBA 8-bit, big-endian.
void demux_channel(char *out, char *in, int bps, int in_len, int in_stream_channels, int pos_in_stream)
This is an umbrella header for video functions.
static void * vidcap_dvs_grab_thread(void *arg)
static void vidcap_dvs_done(void *state)
static const struct video_capture_info vidcap_dvs_info
static void vidcap_dvs_probe(struct device_info **available_cards, int *count, void(**deleter)(void *))
static struct video_frame * vidcap_dvs_grab(void *state, struct audio_frame **audio)
static int vidcap_dvs_init(struct vidcap_params *params, void **state)
static void show_help(void)
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[]
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].