mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-04-07 21:06:03 +00:00
added Deltacast support
This commit is contained in:
@@ -7,9 +7,9 @@ CFLAGS = -fPIC @DEFS@ @CFLAGS@ @X_CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @DXT_LIB@ @QUICKTIME_LIB@ @PORTAUDIO_LIB@ @SAGE_LIB@ @X_PRE_LIBS@ \
|
||||
LIBS = @DXT_LIB@ @DELTACAST_LIB@ @QUICKTIME_LIB@ @PORTAUDIO_LIB@ @SAGE_LIB@ @X_PRE_LIBS@ \
|
||||
@X_LIBS@ @X_EXTRA_LIBS@ @JACK_LIB@ @MATHLIBS@ @LIBS@ -lm -pthread
|
||||
INC = -I.. -Isrc -Itest @DVS_INC@ @DXT_INC@ @QUICKTIME_INC@ @DECKLINK_INC@ @PORTAUDIO_INC@ \
|
||||
INC = -I.. -Isrc -Itest @DVS_INC@ @DELTACAST_INC@ @DXT_INC@ @QUICKTIME_INC@ @DECKLINK_INC@ @PORTAUDIO_INC@ \
|
||||
@GL_INC@ @SAGE_INC@ @QUAD_INC@ @JACK_INC@
|
||||
DECKLINK_PATH = @DECKLINK_PATH@
|
||||
TARGET = bin/uv
|
||||
@@ -69,6 +69,7 @@ OBJS = src/bitstream.o \
|
||||
src/video_display/null.o \
|
||||
src/vo_postprocess.o \
|
||||
src/vo_postprocess/3d-interleaved.o \
|
||||
@DELTACAST_OBJ@ \
|
||||
@DVS_OBJ@ \
|
||||
@QUICKTIME_OBJ@ \
|
||||
@DECKLINK_OBJ@ \
|
||||
@@ -105,6 +106,12 @@ $(TARGET): src/version.h $(OBJS) src/main.o
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(INC) -c $< -o $@
|
||||
|
||||
src/video_capture/deltacast.o: src/video_capture/deltacast.cpp
|
||||
$(CXX) $(CXXFLAGS) $(INC) -fno-rtti -c $< -o $@
|
||||
|
||||
src/video_display/deltacast.o: src/video_display/deltacast.cpp
|
||||
$(CXX) $(CXXFLAGS) $(INC) -fno-rtti -c $< -o $@
|
||||
|
||||
src/video_capture/DeckLinkAPIDispatch.o: $(DECKLINK_PATH)/DeckLinkAPIDispatch.cpp
|
||||
$(CXX) $(CXXFLAGS) -Wno-multichar -fno-rtti -O3 -c $(INC) -o src/video_capture/DeckLinkAPIDispatch.o $(DECKLINK_PATH)/DeckLinkAPIDispatch.cpp
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ use_rt=no
|
||||
AC_ARG_ENABLE(dvs,
|
||||
AS_HELP_STRING([--enable-rt], [enable RT priority]),
|
||||
[use_rt=$enableval])
|
||||
if [ "$use_rt" = "yes" ]; then
|
||||
if test "$use_rt" = "yes"; then
|
||||
AC_DEFINE([USE_RT], [1], [We use RT priority])
|
||||
fi
|
||||
|
||||
@@ -257,7 +257,7 @@ AC_DEFINE([HAVE_DV_CODEC], [1], [We have libdv])
|
||||
dvs=no
|
||||
dvs_req=yes
|
||||
AC_ARG_ENABLE(dvs,
|
||||
AS_HELP_STRING([--enable-dvs], [enable DVS (default is enable)]),
|
||||
AS_HELP_STRING([--disable-dvs], [disable DVS (default is auto)]),
|
||||
[dvs_req=$enableval])
|
||||
|
||||
AC_ARG_WITH(dvs,
|
||||
@@ -299,7 +299,7 @@ DECKLINK_PATH=
|
||||
decklink=no
|
||||
decklink_req=yes
|
||||
|
||||
AC_ARG_ENABLE(decklink, AS_HELP_STRING([--enable-decklink], [enable DeckLink (default is enable)]),
|
||||
AC_ARG_ENABLE(decklink, AS_HELP_STRING([--disable-decklink], [disable DeckLink (default is auto)]),
|
||||
[decklink_req=$enableval])
|
||||
AC_ARG_WITH(decklink,
|
||||
[ --with-decklink=DIR specify location of DECKLINK],
|
||||
@@ -374,7 +374,7 @@ case $host in
|
||||
*-linux-*)
|
||||
|
||||
AC_ARG_ENABLE(quad,
|
||||
AS_HELP_STRING([--enable-quad], [enable Linsys Quad (default is enable)]),
|
||||
AS_HELP_STRING([--disable-quad], [disable Linsys Quad (default is auto)]),
|
||||
[quad_req=$enableval],
|
||||
[quad_req=yes]
|
||||
)
|
||||
@@ -409,6 +409,77 @@ AC_SUBST(QUAD_PATH)
|
||||
AC_SUBST(QUAD_INC)
|
||||
AC_SUBST(QUAD_OBJ)
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# DELTACAST stuff
|
||||
|
||||
DELTACAST_PATH=
|
||||
DELTACAST_OBJ=
|
||||
DELTACAST_INC=
|
||||
DELTACAST_LIB=
|
||||
deltacast_req=yes
|
||||
deltacast=no
|
||||
|
||||
case $host in
|
||||
*-linux-*)
|
||||
|
||||
AC_ARG_ENABLE(deltacast,
|
||||
AS_HELP_STRING([--disable-deltacast], [disable DELTACAST suppport (default is auto)]),
|
||||
[deltacast_req=$enableval],
|
||||
[deltacast_req=yes]
|
||||
)
|
||||
|
||||
AC_ARG_WITH(deltacast,
|
||||
[ --with-deltacast=DIR specify location of DELTACAST],
|
||||
[DELTACAST_PATH=$withval
|
||||
],
|
||||
[DELTACAST_PATH=${PARENT}/VideoMasterHD
|
||||
])
|
||||
|
||||
DELTACAST_INC=${DELTACAST_PATH}/Include
|
||||
|
||||
CXXFLAGS_SAVE=$CXXFLAGS
|
||||
CXXFLAGS+=" -I$DELTACAST_INC"
|
||||
CPPFLAGS_SAVE=$CPPFLAGS
|
||||
CPPFLAGS+=" -I$DELTACAST_INC"
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
|
||||
AC_CHECK_HEADERS([VideoMasterHD_Core.h VideoMasterHD_Sdi.h],
|
||||
FOUND_DELTACAST_H=yes, FOUND_DELTACAST_H=no,
|
||||
[[#ifdef HAVE_VIDEOMASTERHD_CORE_H
|
||||
# include <VideoMasterHD_Core.h>
|
||||
#endif
|
||||
]])
|
||||
AC_CHECK_LIB(videomasterhd, VHD_OpenBoardHandle, FOUND_DELTACAST_L=yes, FOUND_DELTACAST_L=no)
|
||||
|
||||
AC_LANG_POP(C++)
|
||||
|
||||
CXXFLAGS=$CXXFLAGS_SAVE
|
||||
CPPFLAGS=$CPPFLAGS_SAVE
|
||||
|
||||
if test $deltacast_req = yes -a $FOUND_DELTACAST_H = yes -a $FOUND_DELTACAST_L = yes
|
||||
then
|
||||
DELTACAST_INC="-I$DELTACAST_INC"
|
||||
DELTACAST_OBJ="src/video_capture/deltacast.o src/video_display/deltacast.o"
|
||||
DELTACAST_LIB="-lvideomasterhd"
|
||||
AC_DEFINE([HAVE_DELTACAST], [1], [Build with DELTACAST support])
|
||||
deltacast=yes
|
||||
else
|
||||
DELTACAST_PATH=
|
||||
DELTACAST_LIB=
|
||||
DELTACAST_INC=
|
||||
DELTACAST_OBJ=
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(DELTACAST_PATH)
|
||||
AC_SUBST(DELTACAST_INC)
|
||||
AC_SUBST(DELTACAST_LIB)
|
||||
AC_SUBST(DELTACAST_OBJ)
|
||||
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# QuickTime Stuff
|
||||
QUICKTIME_INC=
|
||||
@@ -417,7 +488,7 @@ QUICKTIME_OBJ=
|
||||
quicktime=no
|
||||
|
||||
AC_ARG_ENABLE(quicktime,
|
||||
AS_HELP_STRING([--enable-quicktime], [enable QuickTime support(default is enable)]),
|
||||
AS_HELP_STRING([--disable-quicktime], [disable QuickTime support(default is auto)]),
|
||||
[quicktime_req=$enableval],
|
||||
[quicktime_req=yes]
|
||||
)
|
||||
@@ -575,7 +646,7 @@ GL_OBJ=
|
||||
gl=no
|
||||
|
||||
AC_ARG_ENABLE(gl,
|
||||
AS_HELP_STRING([--enable-gl], [enable OpenGL (default is enable)]),
|
||||
AS_HELP_STRING([--disable-gl], [disable OpenGL (default is auto)]),
|
||||
[gl_req=$enableval],
|
||||
[gl_req=yes]
|
||||
)
|
||||
@@ -692,7 +763,7 @@ fastdxt_req=yes
|
||||
COMPRESS_OBJ=
|
||||
|
||||
AC_ARG_ENABLE(fastdxt,
|
||||
[ --enable-fastdxt enable FastDXT],
|
||||
[ --disable-fastdxt disable FastDXT],
|
||||
[fastdxt_req=$enableval])
|
||||
|
||||
AC_ARG_WITH(fastdxt,
|
||||
@@ -734,7 +805,7 @@ LIBS+=" $X_LIBS"
|
||||
rtdxt=no
|
||||
|
||||
AC_ARG_ENABLE(rtdxt,
|
||||
AS_HELP_STRING([--enable-rtdxt], [enable Real-Time OpenGL DXT compression (default is enable)]),
|
||||
AS_HELP_STRING([--disable-rtdxt], [disable Real-Time OpenGL DXT compression (default is auto)]),
|
||||
[rtdxt_req=$enableval],
|
||||
[rtdxt_req=yes])
|
||||
|
||||
@@ -772,7 +843,7 @@ SAGE_LIB=
|
||||
sage=no
|
||||
|
||||
AC_ARG_ENABLE(sage,
|
||||
AS_HELP_STRING([--enable-sage], [enable SAGE (default is enable)]),
|
||||
AS_HELP_STRING([--disable-sage], [disable SAGE (default is auto)]),
|
||||
[sage_req=$enableval],
|
||||
[sage_req=yes])
|
||||
|
||||
@@ -814,7 +885,7 @@ PORTAUDIO_OBJ=
|
||||
portaudio=no
|
||||
|
||||
AC_ARG_ENABLE(portaudio,
|
||||
AS_HELP_STRING([--enable-portaudio], [enable Portaudio (default is enable)]),
|
||||
AS_HELP_STRING([--disable-portaudio], [disable Portaudio (default is auto)]),
|
||||
[portaudio_req=$enableval],
|
||||
[portaudio_req=yes])
|
||||
|
||||
@@ -857,7 +928,7 @@ AC_SUBST(PORTAUDIO_OBJ)
|
||||
jack=no
|
||||
|
||||
AC_ARG_ENABLE(jack,
|
||||
AS_HELP_STRING([--enable-jack], [enable JACK (default is enable)]),
|
||||
AS_HELP_STRING([--disable-jack], [disable JACK (default is auto)]),
|
||||
[jack_req=$enableval],
|
||||
[jack_req=yes])
|
||||
|
||||
@@ -891,6 +962,7 @@ Configuration summary:
|
||||
RT priority ................. $use_rt
|
||||
|
||||
DeckLink .................... $decklink
|
||||
DELTACAST ................... $deltacast
|
||||
DVS ......................... $dvs
|
||||
Linsys Quad ................. $quad
|
||||
OpenGL ...................... $gl
|
||||
|
||||
@@ -61,7 +61,8 @@ typedef enum {
|
||||
DXT1_YUV,
|
||||
DXT5,
|
||||
RGB,
|
||||
DPX10
|
||||
DPX10,
|
||||
RAW
|
||||
} codec_t;
|
||||
|
||||
/* please note that tiles have also its own widths and heights */
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include "video_capture/testcard2.h"
|
||||
#include "video_capture/null.h"
|
||||
#include "video_capture/decklink.h"
|
||||
#include "video_capture/deltacast.h"
|
||||
#include "video_capture/quad.h"
|
||||
|
||||
#define VIDCAP_MAGIC 0x76ae98f0
|
||||
@@ -106,6 +107,15 @@ struct vidcap_device_api vidcap_device_table[] = {
|
||||
vidcap_decklink_done,
|
||||
vidcap_decklink_grab},
|
||||
#endif /* HAVE_DECKLINK */
|
||||
#ifdef HAVE_DELTACAST
|
||||
{
|
||||
/* The Blackmagic DeckLink capture card */
|
||||
0,
|
||||
vidcap_deltacast_probe,
|
||||
vidcap_deltacast_init,
|
||||
vidcap_deltacast_done,
|
||||
vidcap_deltacast_grab},
|
||||
#endif /* HAVE_DELTACAST */
|
||||
#ifdef HAVE_QUAD
|
||||
{
|
||||
/* The HD-SDI Master Quad capture card */
|
||||
|
||||
435
ultragrid/src/video_capture/deltacast.cpp
Normal file
435
ultragrid/src/video_capture/deltacast.cpp
Normal file
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
* FILE: deltacast.c
|
||||
* AUTHORS: Martin Benes <martinbenesh@gmail.com>
|
||||
* Lukas Hejtmanek <xhejtman@ics.muni.cz>
|
||||
* Petr Holub <hopet@ics.muni.cz>
|
||||
* Milos Liska <xliska@fi.muni.cz>
|
||||
* Jiri Matela <matela@ics.muni.cz>
|
||||
* Dalibor Matura <255899@mail.muni.cz>
|
||||
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
|
||||
*
|
||||
* Copyright (c) 2005-2010 CESNET z.s.p.o.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, is permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by CESNET z.s.p.o.
|
||||
*
|
||||
* 4. Neither the name of the CESNET nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "host.h"
|
||||
#include "config.h"
|
||||
#include "config_unix.h"
|
||||
#include "config_win32.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "video_codec.h"
|
||||
#include "video_capture.h"
|
||||
|
||||
#include "tv.h"
|
||||
|
||||
#include "audio/audio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // END of extern "C"
|
||||
#endif
|
||||
|
||||
#include "video_capture/deltacast.h"
|
||||
#include "video_display/deltacast.h"
|
||||
|
||||
#include <VideoMasterHD_Core.h>
|
||||
#include <VideoMasterHD_Sdi.h>
|
||||
|
||||
extern int should_exit;
|
||||
|
||||
struct vidcap_deltacast_state {
|
||||
struct video_frame *frame;
|
||||
struct tile *tile;
|
||||
HANDLE BoardHandle, StreamHandle;
|
||||
HANDLE SlotHandle;
|
||||
int mode;
|
||||
|
||||
struct timeval t, t0;
|
||||
int frames;
|
||||
};
|
||||
|
||||
static void usage(void);
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
ULONG Result,DllVersion,NbBoards;
|
||||
int i;
|
||||
printf("-t deltacast:<index>:<node>:<codec>\n");
|
||||
Result = VHD_GetApiInfo(&DllVersion,&NbBoards);
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
fprintf(stderr, "[DELTACAST] ERROR : Cannot query VideoMasterHD"
|
||||
" information. Result = 0x%08X\n",
|
||||
Result);
|
||||
return;
|
||||
}
|
||||
if (NbBoards == 0) {
|
||||
fprintf(stderr, "[DELTACAST] No DELTA board detected, exiting...\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\nAvailable cards:\n");
|
||||
/* Query DELTA boards information */
|
||||
for (ULONG i = 0; i < NbBoards; i++)
|
||||
{
|
||||
HANDLE BoardHandle = NULL;
|
||||
Result = VHD_OpenBoardHandle(i,&BoardHandle,NULL,0);
|
||||
if (Result == VHDERR_NOERROR)
|
||||
{
|
||||
printf("\tBoard %d\n", i);
|
||||
// Here woulc go detais
|
||||
VHD_CloseBoardHandle(BoardHandle);
|
||||
}
|
||||
}
|
||||
printf("\nAvailable modes:\n");
|
||||
for (i = 0; i < deltacast_frame_modes_count; ++i)
|
||||
{
|
||||
printf("\t%d: %s\n", deltacast_frame_modes[i].mode,
|
||||
deltacast_frame_modes[i].name);
|
||||
}
|
||||
|
||||
printf("\nAvailable codecs:\n");
|
||||
printf("\tUYVY\n");
|
||||
printf("\tv210\n");
|
||||
printf("\tRAW\n");
|
||||
}
|
||||
|
||||
struct vidcap_type *
|
||||
vidcap_deltacast_probe(void)
|
||||
{
|
||||
struct vidcap_type* vt;
|
||||
|
||||
vt = (struct vidcap_type *) malloc(sizeof(struct vidcap_type));
|
||||
if (vt != NULL) {
|
||||
vt->id = VIDCAP_QUAD_ID;
|
||||
vt->name = "deltacast";
|
||||
vt->description = "DELTACAST card";
|
||||
}
|
||||
return vt;
|
||||
}
|
||||
|
||||
void *
|
||||
vidcap_deltacast_init(char *init_fmt, unsigned int flags)
|
||||
{
|
||||
struct vidcap_deltacast_state *s;
|
||||
ULONG Result,DllVersion,NbBoards,ChnType;
|
||||
|
||||
ULONG BrdId = 0;
|
||||
ULONG ClockSystem,VideoStandard;
|
||||
ULONG Packing;
|
||||
ULONG Status = 0;
|
||||
int i;
|
||||
|
||||
printf("vidcap_deltacast_init\n");
|
||||
|
||||
s = (struct vidcap_deltacast_state *) malloc(sizeof(struct vidcap_deltacast_state));
|
||||
|
||||
if(s == NULL) {
|
||||
printf("Unable to allocate DELTACAST state\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s->frame = vf_alloc(1,1);
|
||||
s->tile = tile_get(s->frame, 0, 0);
|
||||
s->frames = 0;
|
||||
|
||||
s->frame->color_spec = UYVY;
|
||||
|
||||
s->BoardHandle = s->StreamHandle = s->SlotHandle = NULL;
|
||||
|
||||
if(!init_fmt || strcmp(init_fmt, "help") == 0) {
|
||||
usage();
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(init_fmt)
|
||||
{
|
||||
char *save_ptr = NULL;
|
||||
char *tok;
|
||||
|
||||
tok = strtok_r(init_fmt, ":", &save_ptr);
|
||||
if(!tok)
|
||||
{
|
||||
usage();
|
||||
goto error;
|
||||
}
|
||||
BrdId = atoi(tok);
|
||||
tok = strtok_r(NULL, ":", &save_ptr);
|
||||
if(tok) {
|
||||
s->mode = atoi(tok);
|
||||
} else {
|
||||
usage();
|
||||
goto error;
|
||||
}
|
||||
tok = strtok_r(NULL, ":", &save_ptr);
|
||||
if(tok) {
|
||||
if(strcmp(tok, "raw") == 0)
|
||||
s->frame->color_spec = RAW;
|
||||
else if(strcmp(tok, "UYVY") == 0)
|
||||
s->frame->color_spec = UYVY;
|
||||
else if(strcmp(tok, "v210") == 0)
|
||||
s->frame->color_spec = v210;
|
||||
} else {
|
||||
usage();
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* Query VideoMasterHD information */
|
||||
Result = VHD_GetApiInfo(&DllVersion,&NbBoards);
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
fprintf(stderr, "[DELTACAST] ERROR : Cannot query VideoMasterHD"
|
||||
" information. Result = 0x%08X\n",
|
||||
Result);
|
||||
goto error;
|
||||
}
|
||||
if (NbBoards == 0) {
|
||||
fprintf(stderr, "[DELTACAST] No DELTA board detected, exiting...\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(BrdId >= NbBoards) {
|
||||
fprintf(stderr, "[DELTACAST] Wrong index %d. Found %d cards.\n", BrdId, NbBoards);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Open a handle on first DELTA-hd/sdi/codec board */
|
||||
Result = VHD_OpenBoardHandle(BrdId,&s->BoardHandle,NULL,0);
|
||||
if (Result != VHDERR_NOERROR)
|
||||
{
|
||||
fprintf(stderr, "[DELTACAST] ERROR : Cannot open DELTA board %u handle. Result = 0x%08X\n",BrdId,Result);
|
||||
goto error;
|
||||
}
|
||||
VHD_GetBoardProperty(s->BoardHandle, VHD_CORE_BP_RX0_TYPE, &ChnType);
|
||||
if((ChnType!=VHD_CHNTYPE_SDSDI)&&(ChnType!=VHD_CHNTYPE_HDSDI)&&(ChnType!=VHD_CHNTYPE_3GSDI)) {
|
||||
fprintf(stderr, "[DELTACAST] ERROR : The selected channel is not an SDI one\n");
|
||||
goto bad_channel;
|
||||
}
|
||||
|
||||
/* Disable RX0-TX0 by-pass relay loopthrough */
|
||||
VHD_SetBoardProperty(s->BoardHandle,VHD_CORE_BP_BYPASS_RELAY_0,FALSE);
|
||||
|
||||
/* Wait for channel locked */
|
||||
printf("\nWaiting for channel locked...\n");
|
||||
do
|
||||
{
|
||||
Result = VHD_GetBoardProperty(s->BoardHandle, VHD_CORE_BP_RX0_STATUS, &Status);
|
||||
|
||||
if (Result != VHDERR_NOERROR)
|
||||
continue;
|
||||
|
||||
} while ((Status & VHD_CORE_RXSTS_UNLOCKED) && !should_exit);
|
||||
|
||||
|
||||
/* Auto-detect clock system */
|
||||
Result = VHD_GetBoardProperty(s->BoardHandle,VHD_SDI_BP_RX0_CLOCK_DIV,&ClockSystem);
|
||||
|
||||
if(Result != VHDERR_NOERROR) {
|
||||
fprintf(stderr, "[DELTACAST] ERROR : Cannot detect incoming clock system from RX0. Result = 0x%08X\n",Result);
|
||||
goto no_clock;
|
||||
} else {
|
||||
printf("\nIncoming clock system : %s\n",(ClockSystem==VHD_CLOCKDIV_1)?"European":"American");
|
||||
}
|
||||
|
||||
/* Select the detected clock system */
|
||||
VHD_SetBoardProperty(s->BoardHandle,VHD_SDI_BP_CLOCK_SYSTEM,ClockSystem);
|
||||
|
||||
/* Create a logical stream to receive from RX0 connector */
|
||||
if(s->frame->color_spec == RAW)
|
||||
Result = VHD_OpenStreamHandle(s->BoardHandle,VHD_ST_RX0,VHD_SDI_STPROC_RAW,NULL,&s->StreamHandle,NULL);
|
||||
else
|
||||
Result = VHD_OpenStreamHandle(s->BoardHandle,VHD_ST_RX0,VHD_SDI_STPROC_DISJOINED_VIDEO,NULL,&s->StreamHandle,NULL);
|
||||
|
||||
|
||||
if (Result != VHDERR_NOERROR)
|
||||
{
|
||||
fprintf(stderr, "ERROR : Cannot open RX0 stream on DELTA-hd/sdi/codec board handle. Result = 0x%08X\n",Result);
|
||||
goto no_stream;
|
||||
}
|
||||
/* Get auto-detected video standard */
|
||||
//Result = VHD_GetStreamProperty(s->StreamHandle,VHD_SDI_SP_VIDEO_STANDARD,&VideoStandard);
|
||||
|
||||
//if ((Result == VHDERR_NOERROR) && (VideoStandard != NB_VHD_VIDEOSTANDARDS))
|
||||
//{
|
||||
|
||||
/* Configure stream */
|
||||
VHD_SetStreamProperty(s->StreamHandle,VHD_SDI_SP_VIDEO_STANDARD, s->mode);
|
||||
for (i = 0; i < deltacast_frame_modes_count; ++i)
|
||||
{
|
||||
if(s->mode == deltacast_frame_modes[i].mode) {
|
||||
s->frame->fps = deltacast_frame_modes[i].fps;
|
||||
s->frame->aux = deltacast_frame_modes[i].interlacing;
|
||||
s->tile->width = deltacast_frame_modes[i].width;
|
||||
s->tile->height = deltacast_frame_modes[i].height;
|
||||
printf("[DELTACAST] %s mode selected.\n", deltacast_frame_modes[i].name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == deltacast_frame_modes_count) {
|
||||
fprintf(stderr, "[DELTACAST] Failed to obtain information about video format %d.\n", s->mode);
|
||||
goto no_format;
|
||||
}
|
||||
/*} else {
|
||||
fprintf(stderr, "ERROR : Cannot detect incoming video standard from RX0. Result = 0x%08X\n",Result);
|
||||
goto no_format;
|
||||
}*/
|
||||
|
||||
|
||||
Result = VHD_GetStreamProperty(s->StreamHandle, VHD_CORE_SP_BUFFER_PACKING, &Packing);
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
fprintf(stderr, "[DELTACAST] Unable to get pixel format\n");
|
||||
goto no_pixfmt;
|
||||
}
|
||||
if(s->frame->color_spec == v210)
|
||||
Packing = VHD_BUFPACK_VIDEO_YUV422_10;
|
||||
if(s->frame->color_spec == UYVY)
|
||||
Packing = VHD_BUFPACK_VIDEO_YUV422_8;
|
||||
Result = VHD_SetStreamProperty(s->StreamHandle, VHD_CORE_SP_BUFFER_PACKING, Packing);
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
fprintf(stderr, "[DELTACAST] Unable to set pixel format\n");
|
||||
goto no_pixfmt;
|
||||
}
|
||||
|
||||
|
||||
/* Start stream */
|
||||
Result = VHD_StartStream(s->StreamHandle);
|
||||
if (Result == VHDERR_NOERROR){
|
||||
printf("Stream started");
|
||||
} else {
|
||||
fprintf(stderr, "ERROR : Cannot start RX0 stream on DELTA-hd/sdi/codec board handle. Result = 0x%08X\n",Result);
|
||||
goto stream_failed;
|
||||
}
|
||||
|
||||
return s;
|
||||
stream_failed:
|
||||
no_pixfmt:
|
||||
no_format:
|
||||
/* Close stream handle */
|
||||
VHD_CloseStreamHandle(s->StreamHandle);
|
||||
no_stream:
|
||||
|
||||
no_clock:
|
||||
/* Re-establish RX0-TX0 by-pass relay loopthrough */
|
||||
VHD_SetBoardProperty(s->BoardHandle,VHD_CORE_BP_BYPASS_RELAY_0,TRUE);
|
||||
bad_channel:
|
||||
VHD_CloseBoardHandle(s->BoardHandle);
|
||||
error:
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
vidcap_deltacast_done(void *state)
|
||||
{
|
||||
struct vidcap_deltacast_state *s = (struct vidcap_deltacast_state *) state;
|
||||
|
||||
assert(s != NULL);
|
||||
|
||||
if(s->SlotHandle)
|
||||
VHD_UnlockSlotHandle(s->SlotHandle);
|
||||
VHD_StopStream(s->StreamHandle);
|
||||
VHD_CloseStreamHandle(s->StreamHandle);
|
||||
/* Re-establish RX0-TX0 by-pass relay loopthrough */
|
||||
VHD_SetBoardProperty(s->BoardHandle,VHD_CORE_BP_BYPASS_RELAY_0,TRUE);
|
||||
VHD_CloseBoardHandle(s->BoardHandle);
|
||||
|
||||
vf_free(s->frame);
|
||||
free(s);
|
||||
}
|
||||
|
||||
struct video_frame *
|
||||
vidcap_deltacast_grab(void *state, struct audio_frame **audio)
|
||||
{
|
||||
struct vidcap_deltacast_state *s = (struct vidcap_deltacast_state *) state;
|
||||
|
||||
ULONG /*SlotsCount, SlotsDropped,*/BufferSize;
|
||||
ULONG Result;
|
||||
BYTE *pBuffer=NULL;
|
||||
|
||||
*audio = NULL;
|
||||
/* Unlock slot */
|
||||
if(s->SlotHandle)
|
||||
VHD_UnlockSlotHandle(s->SlotHandle);
|
||||
Result = VHD_LockSlotHandle(s->StreamHandle,&s->SlotHandle);
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
if (Result != VHDERR_TIMEOUT) {
|
||||
fprintf(stderr, "ERROR : Cannot lock slot on RX0 stream. Result = 0x%08X\n",Result);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Timeout \n");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Result = VHD_GetSlotBuffer(s->SlotHandle, VHD_SDI_BT_VIDEO, &pBuffer, &BufferSize);
|
||||
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
fprintf(stderr, "\nERROR : Cannot get slot buffer. Result = 0x%08X\n",Result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s->tile->data = (char*) pBuffer;
|
||||
s->tile->data_len = BufferSize;
|
||||
|
||||
/* Print some statistics */
|
||||
/*VHD_GetStreamProperty(s->StreamHandle,VHD_CORE_SP_SLOTS_COUNT,&SlotsCount);
|
||||
VHD_GetStreamProperty(s->StreamHandle,VHD_CORE_SP_SLOTS_DROPPED,&SlotsDropped);
|
||||
printf("%u frames received (%u dropped) \r",SlotsCount,SlotsDropped);*/
|
||||
gettimeofday(&s->t, NULL);
|
||||
double seconds = tv_diff(s->t, s->t0);
|
||||
if (seconds >= 5) {
|
||||
float fps = s->frames / seconds;
|
||||
fprintf(stderr, "%d frames in %g seconds = %g FPS\n", s->frames, seconds, fps);
|
||||
s->t0 = s->t;
|
||||
s->frames = 0;
|
||||
}
|
||||
s->frames++;
|
||||
|
||||
return s->frame;
|
||||
}
|
||||
60
ultragrid/src/video_capture/deltacast.h
Normal file
60
ultragrid/src/video_capture/deltacast.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* FILE: deltacast.h
|
||||
* AUTHORS: Martin Benes <martinbenesh@gmail.com>
|
||||
* Lukas Hejtmanek <xhejtman@ics.muni.cz>
|
||||
* Petr Holub <hopet@ics.muni.cz>
|
||||
* Milos Liska <xliska@fi.muni.cz>
|
||||
* Jiri Matela <matela@ics.muni.cz>
|
||||
* Dalibor Matura <255899@mail.muni.cz>
|
||||
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
|
||||
*
|
||||
* Copyright (c) 2005-2010 CESNET z.s.p.o.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, is permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by CESNET z.s.p.o.
|
||||
*
|
||||
* 4. Neither the name of the CESNET nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#define VIDCAP_QUAD_ID 0x10265304
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct vidcap_type *vidcap_deltacast_probe(void);
|
||||
void *vidcap_deltacast_init(char *fmt, unsigned int flags);
|
||||
void vidcap_deltacast_done(void *state);
|
||||
struct video_frame *vidcap_deltacast_grab(void *state, struct audio_frame **audio);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // END extern "C"
|
||||
#endif
|
||||
@@ -70,6 +70,7 @@ const struct codec_info_t codec_info[] = {
|
||||
{DXT5, "DXT5", 'DXT5', 1, 1.0, 1},/* DXT5 YCoCg */
|
||||
{RGB, "RGB", 0x32424752, 1, 3.0, 1},
|
||||
{DPX10, "DPX10", 0, 1, 4.0, 1},
|
||||
{RAW, "RAW", 0, 0, 0.0, 0},
|
||||
{0, NULL, 0, 0, 0.0, 0}
|
||||
};
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "video_display/null.h"
|
||||
#include "video_display/sdl.h"
|
||||
#include "video_display/decklink.h"
|
||||
#include "video_display/deltacast.h"
|
||||
#include "video_display/dvs.h"
|
||||
#include "video_display/gl.h"
|
||||
#include "video_display/quicktime.h"
|
||||
@@ -145,6 +146,21 @@ static display_table_t display_device_table[] = {
|
||||
display_decklink_put_audio_frame,
|
||||
},
|
||||
#endif /* HAVE_DECKLINK */
|
||||
#ifdef HAVE_DELTACAST
|
||||
{
|
||||
0,
|
||||
display_deltacast_probe,
|
||||
display_deltacast_init,
|
||||
display_deltacast_run,
|
||||
display_deltacast_done,
|
||||
display_deltacast_getf,
|
||||
display_deltacast_putf,
|
||||
display_deltacast_reconfigure,
|
||||
display_deltacast_get_property,
|
||||
NULL,
|
||||
NULL,
|
||||
},
|
||||
#endif /* HAVE_DELTACAST */
|
||||
#ifdef HAVE_DVS
|
||||
{
|
||||
0,
|
||||
|
||||
384
ultragrid/src/video_display/deltacast.cpp
Normal file
384
ultragrid/src/video_display/deltacast.cpp
Normal file
@@ -0,0 +1,384 @@
|
||||
/*
|
||||
* FILE: video_display/deltacast.cpp
|
||||
* AUTHORS: Martin Benes <martinbenesh@gmail.com>
|
||||
* Lukas Hejtmanek <xhejtman@ics.muni.cz>
|
||||
* Petr Holub <hopet@ics.muni.cz>
|
||||
* Milos Liska <xliska@fi.muni.cz>
|
||||
* Jiri Matela <matela@ics.muni.cz>
|
||||
* Dalibor Matura <255899@mail.muni.cz>
|
||||
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
|
||||
* Colin Perkins <csp@isi.edu>
|
||||
*
|
||||
* Copyright (c) 2005-2010 CESNET z.s.p.o.
|
||||
* Copyright (c) 2001-2003 University of Southern California
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, is permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by the University of Southern
|
||||
* California Information Sciences Institute. This product also includes
|
||||
* software developed by CESNET z.s.p.o.
|
||||
*
|
||||
* 4. Neither the name of the University, Institute, CESNET nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "host.h"
|
||||
#include "debug.h"
|
||||
#include "config.h"
|
||||
#include "config_unix.h"
|
||||
#include "config_win32.h"
|
||||
#include "video_codec.h"
|
||||
#include "tv.h"
|
||||
#include "video_display/deltacast.h"
|
||||
#include "debug.h"
|
||||
#include "audio/audio.h"
|
||||
|
||||
#include "VideoMasterHD_Core.h"
|
||||
#include "VideoMasterHD_Sdi.h"
|
||||
|
||||
#define DELTACAST_MAGIC DISPLAY_DELTACAST_ID
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // END of extern "C"
|
||||
#endif
|
||||
|
||||
const struct deltacast_frame_mode_t deltacast_frame_modes[] = {
|
||||
{VHD_VIDEOSTD_S274M_1080p_25Hz, "SMPTE 274M 1080p 25 Hz", 1920u, 1080u, 25.0, AUX_PROGRESSIVE},
|
||||
{VHD_VIDEOSTD_S274M_1080p_30Hz, "SMPTE 274M 1080p 30 Hz", 1920u, 1080u, 30.0, AUX_PROGRESSIVE},
|
||||
{VHD_VIDEOSTD_S274M_1080i_50Hz, "SMPTE 274M 1080i 50 Hz", 1920u, 1080u, 25.0, AUX_INTERLACED},
|
||||
{VHD_VIDEOSTD_S274M_1080i_60Hz, "SMPTE 274M 1080i 60 Hz", 1920u, 1080u, 29.97, AUX_INTERLACED},
|
||||
{VHD_VIDEOSTD_S296M_720p_50Hz, "SMPTE 296M 720p 50 Hz", 1280u, 720u, 50.0, AUX_PROGRESSIVE},
|
||||
{VHD_VIDEOSTD_S296M_720p_60Hz, "SMPTE 296M 720p 60 Hz", 1280u, 720u, 60.0, AUX_PROGRESSIVE},
|
||||
{VHD_VIDEOSTD_S259M_PAL, "SMPTE 259M PAL", 720u, 576u, 25.0, AUX_INTERLACED},
|
||||
{VHD_VIDEOSTD_S259M_NTSC, "SMPTE 259M NTSC", 720u, 486u, 29.97, AUX_INTERLACED},
|
||||
{VHD_VIDEOSTD_S274M_1080p_24Hz, "SMPTE 274M 1080p 24 Hz", 1920u, 1080u, 24.0, AUX_PROGRESSIVE},
|
||||
{VHD_VIDEOSTD_S274M_1080p_60Hz, "SMPTE 274M 1080p 60 Hz", 1920u, 1080u, 60.0, AUX_PROGRESSIVE},
|
||||
{VHD_VIDEOSTD_S274M_1080p_24Hz, "SMPTE 274M 1080p 50 Hz", 1920u, 1080u, 50.0, AUX_PROGRESSIVE},
|
||||
{VHD_VIDEOSTD_S274M_1080psf_24Hz, "SMPTE 274M 1080psf 24 Hz", 1920u, 1080u, 24.0, AUX_SF},
|
||||
{VHD_VIDEOSTD_S274M_1080psf_25Hz, "SMPTE 274M 1080psf 25 Hz", 1920u, 1080u, 25.0, AUX_SF},
|
||||
{VHD_VIDEOSTD_S274M_1080psf_30Hz, "SMPTE 274M 1080psf 30 Hz", 1920u, 1080u, 30.0, AUX_SF}
|
||||
};
|
||||
|
||||
const int deltacast_frame_modes_count = sizeof(deltacast_frame_modes)/sizeof(deltacast_frame_mode_t);
|
||||
|
||||
struct state_deltacast {
|
||||
uint32_t magic;
|
||||
|
||||
struct timeval tv;
|
||||
struct video_frame *frame;
|
||||
struct tile *tile;
|
||||
|
||||
unsigned long int frames;
|
||||
unsigned long int frames_last;
|
||||
bool initialized;
|
||||
HANDLE BoardHandle, StreamHandle;
|
||||
HANDLE SlotHandle;
|
||||
};
|
||||
|
||||
static void show_help(void);
|
||||
|
||||
static void show_help(void)
|
||||
{
|
||||
printf("deltacast (output) options:\n");
|
||||
printf("\t-d deltacast:<device_number>\n");
|
||||
}
|
||||
|
||||
struct video_frame *
|
||||
display_deltacast_getf(void *state)
|
||||
{
|
||||
struct state_deltacast *s = (struct state_deltacast *)state;
|
||||
BYTE *pBuffer;
|
||||
ULONG BufferSize;
|
||||
ULONG Result;
|
||||
|
||||
assert(s->magic == DELTACAST_MAGIC);
|
||||
|
||||
if(!s->initialized)
|
||||
return s->frame;
|
||||
|
||||
Result = VHD_LockSlotHandle(s->StreamHandle, &s->SlotHandle);
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
fprintf(stderr, "[DELTACAST] Unable to lock slot.\n");
|
||||
return NULL;
|
||||
}
|
||||
Result = VHD_GetSlotBuffer(s->SlotHandle,VHD_SDI_BT_VIDEO,&pBuffer,&BufferSize);
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
fprintf(stderr, "[DELTACAST] Unable to get buffer.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s->tile->data = (char *) pBuffer;
|
||||
s->tile->data_len = BufferSize;
|
||||
|
||||
return s->frame;
|
||||
}
|
||||
|
||||
int display_deltacast_putf(void *state, char *frame)
|
||||
{
|
||||
int tmp;
|
||||
struct state_deltacast *s = (struct state_deltacast *)state;
|
||||
struct timeval tv;
|
||||
|
||||
UNUSED(frame);
|
||||
|
||||
assert(s->magic == DELTACAST_MAGIC);
|
||||
|
||||
VHD_UnlockSlotHandle(s->SlotHandle);
|
||||
s->SlotHandle = NULL;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
double seconds = tv_diff(tv, s->tv);
|
||||
if (seconds > 5) {
|
||||
double fps = s->frames / seconds;
|
||||
fprintf(stdout, "%lu frames in %g seconds = %g FPS\n",
|
||||
s->frames, seconds, fps);
|
||||
s->tv = tv;
|
||||
s->frames = 0;
|
||||
}
|
||||
s->frames++;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
display_deltacast_reconfigure(void *state, struct video_desc desc)
|
||||
{
|
||||
struct state_deltacast *s = (struct state_deltacast *)state;
|
||||
int VideoStandard;
|
||||
int i;
|
||||
ULONG Result;
|
||||
|
||||
if(s->initialized) {
|
||||
if(s->SlotHandle)
|
||||
VHD_UnlockSlotHandle(s->SlotHandle);
|
||||
VHD_StopStream(s->StreamHandle);
|
||||
VHD_CloseStreamHandle(s->StreamHandle);
|
||||
}
|
||||
|
||||
for (i = 0; i < deltacast_frame_modes_count; ++i)
|
||||
{
|
||||
if(fabs(desc.fps - deltacast_frame_modes[i].fps) < 0.01 &&
|
||||
(desc.aux & deltacast_frame_modes[i].interlacing) != 0 &&
|
||||
desc.width == deltacast_frame_modes[i].width &&
|
||||
desc.height == deltacast_frame_modes[i].height) {
|
||||
VideoStandard = deltacast_frame_modes[i].mode;
|
||||
fprintf(stderr, "[DELTACAST] %s mode selected.\n", deltacast_frame_modes[i].name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == deltacast_frame_modes_count) {
|
||||
//fprintf(stderr, "[DELTACAST] Failed to obtain information about video format.\n");
|
||||
error_with_code_msg(128, "[DELTACAST] Failed to obtain video format for incoming video");
|
||||
}
|
||||
|
||||
if(desc.color_spec == RAW) {
|
||||
Result = VHD_OpenStreamHandle(s->BoardHandle,VHD_ST_TX0,VHD_SDI_STPROC_RAW,NULL,&s->StreamHandle,NULL);
|
||||
} else {
|
||||
Result = VHD_OpenStreamHandle(s->BoardHandle,VHD_ST_TX0,VHD_SDI_STPROC_DISJOINED_VIDEO,NULL,&s->StreamHandle,NULL);
|
||||
}
|
||||
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
error_with_code_msg(128, "[DELTACAST] Failed to open stream handle.");
|
||||
}
|
||||
|
||||
VHD_SetStreamProperty(s->StreamHandle,VHD_SDI_SP_VIDEO_STANDARD,VideoStandard);
|
||||
VHD_SetStreamProperty(s->StreamHandle,VHD_CORE_SP_BUFFERQUEUE_DEPTH,4);
|
||||
VHD_SetStreamProperty(s->StreamHandle,VHD_CORE_SP_BUFFERQUEUE_PRELOAD,2);
|
||||
|
||||
Result = VHD_StartStream(s->StreamHandle);
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
error_with_code_msg(128, "[DELTACAST] Unable to start stream.");
|
||||
}
|
||||
|
||||
s->initialized = TRUE;
|
||||
}
|
||||
|
||||
|
||||
void *display_deltacast_init(char *fmt, unsigned int flags)
|
||||
{
|
||||
struct state_deltacast *s;
|
||||
ULONG Result,DllVersion,NbBoards,ChnType;
|
||||
ULONG BrdId = 0;
|
||||
|
||||
UNUSED(flags);
|
||||
|
||||
s = (struct state_deltacast *)calloc(1, sizeof(struct state_deltacast));
|
||||
s->magic = DELTACAST_MAGIC;
|
||||
|
||||
s->frame = vf_alloc(1, 1);
|
||||
s->tile = tile_get(s->frame, 0, 0);
|
||||
s->frames = 0;
|
||||
|
||||
gettimeofday(&s->tv, NULL);
|
||||
|
||||
s->initialized = FALSE;
|
||||
|
||||
s->BoardHandle = s->BoardHandle = s->SlotHandle = NULL;
|
||||
|
||||
if(!fmt || strcmp(fmt, "help") == 0) {
|
||||
show_help();
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(fmt)
|
||||
{
|
||||
char *save_ptr = NULL;
|
||||
char *tok;
|
||||
|
||||
tok = strtok_r(fmt, ":", &save_ptr);
|
||||
if(!tok)
|
||||
{
|
||||
show_help();
|
||||
goto error;
|
||||
}
|
||||
BrdId = atoi(tok);
|
||||
}
|
||||
|
||||
/* Query VideoMasterHD information */
|
||||
Result = VHD_GetApiInfo(&DllVersion,&NbBoards);
|
||||
if (Result != VHDERR_NOERROR) {
|
||||
fprintf(stderr, "[DELTACAST] ERROR : Cannot query VideoMasterHD"
|
||||
" information. Result = 0x%08X\n",
|
||||
Result);
|
||||
goto error;
|
||||
}
|
||||
if (NbBoards == 0) {
|
||||
fprintf(stderr, "[DELTACAST] No DELTA board detected, exiting...\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(BrdId >= NbBoards) {
|
||||
fprintf(stderr, "[DELTACAST] Wrong index %d. Found %d cards.\n", BrdId, NbBoards);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Open a handle on first DELTA-hd/sdi/codec board */
|
||||
Result = VHD_OpenBoardHandle(BrdId,&s->BoardHandle,NULL,0);
|
||||
if (Result != VHDERR_NOERROR)
|
||||
{
|
||||
fprintf(stderr, "[DELTACAST] ERROR : Cannot open DELTA board %u handle. Result = 0x%08X\n",BrdId,Result);
|
||||
goto error;
|
||||
}
|
||||
VHD_GetBoardProperty(s->BoardHandle, VHD_CORE_BP_TX0_TYPE, &ChnType);
|
||||
if((ChnType!=VHD_CHNTYPE_SDSDI)&&(ChnType!=VHD_CHNTYPE_HDSDI)&&(ChnType!=VHD_CHNTYPE_3GSDI)) {
|
||||
fprintf(stderr, "[DELTACAST] ERROR : The selected channel is not an SDI one\n");
|
||||
goto bad_channel;
|
||||
}
|
||||
|
||||
/* Disable RX0-TX0 by-pass relay loopthrough */
|
||||
VHD_SetBoardProperty(s->BoardHandle,VHD_CORE_BP_BYPASS_RELAY_0,FALSE);
|
||||
|
||||
/* Select a 1/1 clock system */
|
||||
VHD_SetBoardProperty(s->BoardHandle,VHD_SDI_BP_CLOCK_SYSTEM,VHD_CLOCKDIV_1);
|
||||
|
||||
return s;
|
||||
|
||||
bad_channel:
|
||||
VHD_CloseBoardHandle(s->BoardHandle);
|
||||
error:
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void display_deltacast_run(void *state)
|
||||
{
|
||||
UNUSED(state);
|
||||
}
|
||||
|
||||
void display_deltacast_done(void *state)
|
||||
{
|
||||
struct state_deltacast *s = (struct state_deltacast *)state;
|
||||
|
||||
if(s->initialized) {
|
||||
if(s->SlotHandle)
|
||||
VHD_UnlockSlotHandle(s->SlotHandle);
|
||||
VHD_StopStream(s->StreamHandle);
|
||||
VHD_CloseStreamHandle(s->StreamHandle);
|
||||
VHD_SetBoardProperty(s->BoardHandle,VHD_CORE_BP_BYPASS_RELAY_0,TRUE);
|
||||
VHD_CloseBoardHandle(s->BoardHandle);
|
||||
}
|
||||
|
||||
vf_free(s->frame);
|
||||
free(s);
|
||||
}
|
||||
|
||||
display_type_t *display_deltacast_probe(void)
|
||||
{
|
||||
display_type_t *dtype;
|
||||
|
||||
dtype = (display_type_t *) malloc(sizeof(display_type_t));
|
||||
if (dtype != NULL) {
|
||||
dtype->id = DISPLAY_DELTACAST_ID;
|
||||
dtype->name = "deltacast";
|
||||
dtype->description = "DELTACAST card";
|
||||
}
|
||||
return dtype;
|
||||
}
|
||||
|
||||
int display_deltacast_get_property(void *state, int property, void *val, int *len)
|
||||
{
|
||||
codec_t codecs[] = {v210, UYVY, RAW};
|
||||
|
||||
switch (property) {
|
||||
case DISPLAY_PROPERTY_CODECS:
|
||||
if(sizeof(codecs) <= *len) {
|
||||
memcpy(val, codecs, sizeof(codecs));
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*len = sizeof(codecs);
|
||||
break;
|
||||
case DISPLAY_PROPERTY_RSHIFT:
|
||||
*(int *) val = 0;
|
||||
*len = sizeof(int);
|
||||
break;
|
||||
case DISPLAY_PROPERTY_GSHIFT:
|
||||
*(int *) val = 8;
|
||||
*len = sizeof(int);
|
||||
break;
|
||||
case DISPLAY_PROPERTY_BSHIFT:
|
||||
*(int *) val = 16;
|
||||
*len = sizeof(int);
|
||||
break;
|
||||
case DISPLAY_PROPERTY_BUF_PITCH:
|
||||
*(int *) val = PITCH_DEFAULT;
|
||||
*len = sizeof(int);
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
76
ultragrid/src/video_display/deltacast.h
Normal file
76
ultragrid/src/video_display/deltacast.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* FILE: video_display/deltacast.h
|
||||
* AUTHOR: Colin Perkins <csp@isi.edu>
|
||||
*
|
||||
* Copyright (c) 2001-2002 University of Southern California
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, is permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by the University of Southern
|
||||
* California Information Sciences Institute.
|
||||
*
|
||||
* 4. Neither the name of the University nor of the Institute may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#include "video_display.h"
|
||||
|
||||
#define DISPLAY_DELTACAST_ID 0xf46d5550
|
||||
|
||||
struct audio_frame;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct deltacast_frame_mode_t {
|
||||
int mode;
|
||||
const char * name;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
double fps;
|
||||
int interlacing; /* AUX_* */
|
||||
};
|
||||
|
||||
extern const struct deltacast_frame_mode_t deltacast_frame_modes[];
|
||||
extern const int deltacast_frame_modes_count;
|
||||
|
||||
display_type_t *display_deltacast_probe(void);
|
||||
void *display_deltacast_init(char *fmt, unsigned int flags);
|
||||
void display_deltacast_run(void *state);
|
||||
void display_deltacast_done(void *state);
|
||||
struct video_frame *display_deltacast_getf(void *state);
|
||||
int display_deltacast_putf(void *state, char *frame);
|
||||
void display_deltacast_reconfigure(void *state,
|
||||
struct video_desc desc);
|
||||
int display_deltacast_get_property(void *state, int property, void *val, int *len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // END extern "C"
|
||||
#endif
|
||||
@@ -338,7 +338,7 @@ void display_dvs_reconfigure_audio(void *state, int quant_samples, int channels,
|
||||
static void show_help(void)
|
||||
{
|
||||
int i;
|
||||
sv_handle *sv = sv_open("");
|
||||
sv_handle *sv = sv_open("PCI,card:1");
|
||||
if (sv == NULL) {
|
||||
printf
|
||||
("Unable to open grabber: sv_open() failed (no card present or driver not loaded?)\n");
|
||||
|
||||
Reference in New Issue
Block a user