91static void usage(
void);
95 printf(
"\t-t deltacast[:device=<index>][:mode=<mode>][:codec=<codec>]\n");
99 printf(
"\nAvailable modes:\n");
105 printf(
"\t\t(no autodetection)");
109 printf(
"\nAvailable codecs:\n");
114 printf(
"\nDefault board is 0. If mode is omitted, it will be autodetected "
115 "(except of UHD modes). Default codec is UYVY.\n");
122 ULONG Result,DllVersion,NbBoards;
123 Result = VHD_GetApiInfo(&DllVersion,&NbBoards);
124 if (Result == VHDERR_NOERROR) {
127 for (ULONG i = 0; i < NbBoards; ++i) {
128 auto& card = (*available_cards)[i];
129 snprintf(card.dev,
sizeof(card.dev),
":device=%" PRIu_ULONG, i);
130 snprintf(card.name,
sizeof(card.name),
"DELTACAST SDI board %" PRIu_ULONG, i);
131 snprintf(card.extra,
sizeof(card.extra),
"\"embeddedAudioAvailable\":\"t\"");
139#define DELTA_TRY_CMD(cmd, msg) \
142 if (Result != VHDERR_NOERROR) {\
143 log_msg(LOG_LEVEL_ERROR, "[DELTACAST] " msg " Result = 0x%08" PRIX_ULONG "\n", Result);\
144 throw delta_init_exception();\
162 Result = VHD_GetBoardProperty(s->
BoardHandle, VHD_CORE_BP_RX0_STATUS, &Status);
164 if (Result != VHDERR_NOERROR) {
170 if(Status & VHD_CORE_RXSTS_UNLOCKED) {
177 if(Result != VHDERR_NOERROR) {
181 printf(
"\nIncoming clock system : %s\n",(s->
ClockSystem==VHD_CLOCKDIV_1)?
"European":
"American");
193 Result = VHD_OpenStreamHandle(s->
BoardHandle,VHD_ST_RX0,VHD_SDI_STPROC_DISJOINED_VIDEO,NULL,&s->
StreamHandle,NULL);
197 if (Result != VHDERR_NOERROR)
207 if ((Result == VHDERR_NOERROR) && (s->
VideoStandard != NB_VHD_VIDEOSTANDARDS)) {
234 "Unable to set interface.");
236 "Unable to set video standard.");
238 VHD_TRANSFER_SLAVED),
239 "Unable to set transfer scheme.");
242 Result = VHD_GetStreamProperty(s->
StreamHandle, VHD_CORE_SP_BUFFER_PACKING, &Packing);
243 if (Result != VHDERR_NOERROR) {
247 if(Packing == VHD_BUFPACK_VIDEO_YUV422_10) {
249 }
else if(Packing == VHD_BUFPACK_VIDEO_YUV422_8) {
257 Packing = VHD_BUFPACK_VIDEO_YUV422_10;
259 Packing = VHD_BUFPACK_VIDEO_YUV422_8;
265 Result = VHD_SetStreamProperty(s->
StreamHandle, VHD_CORE_SP_BUFFER_PACKING, Packing);
266 if (Result != VHDERR_NOERROR) {
280 memset(&s->
AudioInfo, 0,
sizeof(VHD_AUDIOINFO));
283 s->
pAudioChn->BufferFormat = s->
AudioInfo.pAudioGroups[0].pAudioChannels[1].BufferFormat=VHD_AF_24;
300 if (Result == VHDERR_NOERROR){
301 printf(
"[DELTACAST] Stream started.\n");
314 ULONG Result,DllVersion,NbBoards,ChnType;
317 printf(
"vidcap_deltacast_init\n");
320 if (init_fmt && strcmp(init_fmt,
"help") == 0) {
329 printf(
"Unable to allocate DELTACAST state\n");
335 gettimeofday(&s->
t0, NULL);
348 char *save_ptr = NULL;
350 char *tmp = init_fmt;
352 while ((tok = strtok_r(tmp,
":", &save_ptr)) != NULL) {
353 if (strncasecmp(tok,
"device=", strlen(
"device=")) == 0) {
354 BrdId = atoi(tok + strlen(
"device="));
355 }
else if (strncasecmp(tok,
"board=", strlen(
"board=")) == 0) {
357 BrdId = atoi(tok + strlen(
"board="));
358 }
else if (strncasecmp(tok,
"mode=", strlen(
"mode=")) == 0) {
361 }
else if (strncasecmp(tok,
"codec=", strlen(
"codec=")) == 0) {
362 tok = tok + strlen(
"codec=");
363 if(strcasecmp(tok,
"raw") == 0)
365 else if(strcmp(tok,
"UYVY") == 0)
367 else if(strcmp(tok,
"v210") == 0)
385 printf(
"[DELTACAST] Selected device %" PRIu_ULONG "\n", BrdId);
388 printf(
"DELTACAST] We will try to autodetect incoming video format.\n");
392 Result = VHD_GetApiInfo(&DllVersion,&NbBoards);
393 if (Result != VHDERR_NOERROR) {
395 " information. Result = 0x%08" PRIX_ULONG "\n",
404 if(BrdId >= NbBoards) {
410 Result = VHD_OpenBoardHandle(BrdId,&s->
BoardHandle,NULL,0);
411 if (Result != VHDERR_NOERROR)
421 VHD_GetBoardProperty(s->
BoardHandle, VHD_CORE_BP_RX0_TYPE, &ChnType);
422 if((ChnType!=VHD_CHNTYPE_SDSDI)&&(ChnType!=VHD_CHNTYPE_HDSDI)&&(ChnType!=VHD_CHNTYPE_3GSDI)) {
434 printf(
"\nWaiting for channel locked...\n");
511 if (Result != VHDERR_NOERROR) {
512 if (Result != VHDERR_TIMEOUT) {
529 if(Result==VHDERR_NOERROR) {
539 Result = VHD_GetSlotBuffer(s->
SlotHandle, VHD_SDI_BT_VIDEO, &pBuffer, &BufferSize);
541 if (Result != VHDERR_NOERROR) {
553 gettimeofday(&s->t, NULL);
556 float fps = s->
frames / seconds;
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.
const char * get_codec_name(codec_t codec)
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
static void print_available_delta_boards()
static const int deltacast_frame_modes_count
static bool delta_set_nb_channels(ULONG BrdId, HANDLE BoardHandle, ULONG RequestedRx, ULONG RequestedTx)
static const struct deltacast_frame_mode_t deltacast_frame_modes[]
#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
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
enum interlacing_t interlacing
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
struct video_frame * frame
unsigned int initialize_flags
VHD_AUDIOCHANNEL * pAudioChn
struct audio_frame audio_frame
unsigned int autodetect_format
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)
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
@ v210
YCbCr 422 10-bit - xVY0U|xY2UY1|xUY3V|xY5VY4, little-endian (2 bit padding /'x'/),...
struct audio_desc audio_desc_from_frame(const struct audio_frame *frame)
This is an umbrella header for video functions.
static const struct video_capture_info vidcap_deltacast_info
static int vidcap_deltacast_init(struct vidcap_params *params, void **state)
static void vidcap_deltacast_probe(device_info **available_cards, int *count, void(**deleter)(void *))
static struct video_frame * vidcap_deltacast_grab(void *state, struct audio_frame **audio)
#define DELTA_TRY_CMD(cmd, msg)
static bool wait_for_channel(struct vidcap_deltacast_state *s)
static void vidcap_deltacast_done(void *state)
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_EMBEDDED
HD-SDI embedded audio.
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].
const char * get_interlacing_description(enum interlacing_t interlacing)
Returns description of interlacing Eg. "progressive".