UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
bluefish444.cpp File Reference
#include "video_display.h"
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include "bluefish444_common.h"
#include "audio/types.h"
#include "debug.h"
#include "host.h"
#include "lib_common.h"
#include "tv.h"
#include "utils/ring_buffer.h"
#include "video.h"
Include dependency graph for bluefish444.cpp:

Go to the source code of this file.

Classes

struct  av_buffer
 
struct  display_bluefish444_state
 

Macros

#define BLUEFISH444_MAGIC   0x15b75db8
 
#define BUFFER_COUNT   4
 
#define MAX_BLUE_OUT_CHANNELS   4
 

Functions

static void display_bluefish444_done (void *state)
 
static bool display_bluefish444_get_property (void *state, int property, void *val, size_t *len)
 
static struct video_frame * display_bluefish444_getf (void *state)
 
static void * display_bluefish444_init (struct module *parent, const char *fmt, unsigned int flags)
 
static void display_bluefish444_probe (struct device_info **available_cards, int *count, void(**deleter)(void *))
 
static void display_bluefish444_put_audio_frame (void *state, const struct audio_frame *frame)
 
static bool display_bluefish444_putf (void *state, struct video_frame *frame, long long nonblock)
 
static bool display_bluefish444_reconfigure (void *state, struct video_desc desc)
 
static bool display_bluefish444_reconfigure_audio (void *state, int quant_samples, int channels, int sample_rate)
 
static void InitOutputChannel (BLUEVELVETC_HANDLE pSDK, ULONG DefaultOutputChannel, ULONG UpdateFormat, ULONG MemoryFormat, ULONG VideoEngine)
 
 REGISTER_MODULE (bluefish444, &display_bluefish444_info, LIBRARY_CLASS_VIDEO_DISPLAY, VIDEO_DISPLAY_ABI_VERSION)
 
static void RouteChannel (BLUEVELVETC_HANDLE pSDK, ULONG Source, ULONG Destination, ULONG LinkType)
 
static void show_help (void)
 

Variables

static const struct video_display_info display_bluefish444_info
 

Detailed Description

Author
Martin Pulec pulec.nosp@m.@ces.nosp@m.net.c.nosp@m.z

Definition in file bluefish444.cpp.

Macro Definition Documentation

◆ BLUEFISH444_MAGIC

#define BLUEFISH444_MAGIC   0x15b75db8
Todo
RGBA and v210 seem to be supported by reconfigure but not advertised by get_property.

Definition at line 70 of file bluefish444.cpp.

Referenced by display_bluefish444_state::~display_bluefish444_state().

◆ BUFFER_COUNT

#define BUFFER_COUNT   4

Definition at line 72 of file bluefish444.cpp.

Referenced by display_bluefish444_state::reconfigure().

◆ MAX_BLUE_OUT_CHANNELS

#define MAX_BLUE_OUT_CHANNELS   4

Definition at line 74 of file bluefish444.cpp.

Referenced by display_bluefish444_state::playback_loop().

Function Documentation

◆ display_bluefish444_done()

static void display_bluefish444_done ( void * state)
static

Definition at line 927 of file bluefish444.cpp.

928{
931
932 delete s;
933}
void ** state

References state.

◆ display_bluefish444_get_property()

static bool display_bluefish444_get_property ( void * state,
int property,
void * val,
size_t * len )
static

Definition at line 935 of file bluefish444.cpp.

936{
937 UNUSED(state);
938 codec_t codecs[] = { UYVY };
940 int rgb_shift[] = {0, 8, 16};
941
942 switch (property) {
944 if(sizeof(codecs) <= *len) {
945 memcpy(val, codecs, sizeof(codecs));
946 } else {
947 return false;
948 }
949
950 *len = sizeof(codecs);
951 break;
953 if(sizeof(rgb_shift) > *len) {
954 return false;
955 }
956 memcpy(val, rgb_shift, sizeof(rgb_shift));
957 *len = sizeof(rgb_shift);
958 break;
960 *(int *) val = PITCH_DEFAULT;
961 *len = sizeof(int);
962 break;
964 if(sizeof(supported_il_modes) <= *len) {
965 memcpy(val, supported_il_modes, sizeof(supported_il_modes));
966 } else {
967 return false;
968 }
969 *len = sizeof(supported_il_modes);
970 break;
973 break;
975 {
976 assert(*len == sizeof(struct audio_desc));
977 struct audio_desc *desc = (struct audio_desc *) val;
978 desc->sample_rate = 48000;
979 desc->ch_count = max(desc->ch_count, 4);
980 desc->codec = AC_PCM;
981 desc->bps = desc->bps < 3 ? 2 : 3;
982 }
983 break;
984 default:
985 return false;
986 }
987 return true;
988}
#define UNUSED(x)
int void * val
struct video_desc desc
int void size_t * len
int property
@ AC_PCM
Definition types.h:53
#define PITCH_DEFAULT
default pitch, i. e. respective linesize
@ DISPLAY_PROPERTY_BUF_PITCH
requested framebuffer pitch - int (bytes), may be PITCH_DEFAULT
@ DISPLAY_PROPERTY_RGB_SHIFT
red,green,blue shift - int[3] (bits)
@ DISPLAY_PROPERTY_SUPPORTED_IL_MODES
display supported interlacing modes - enum interlacing_t[]
@ DISPLAY_PROPERTY_VIDEO_MODE
requested video mode - int (one of display_prop_vid_mode)
@ DISPLAY_PROPERTY_CODECS
list of natively supported codecs - codec_t[]
@ DISPLAY_PROPERTY_AUDIO_FORMAT
@ DISPLAY_PROPERTY_VIDEO_SEPARATE_TILES
framebuffer consists of separate tiles
#define max(a, b)
Definition rtp.c:98
interlacing_t
Definition types.h:163
@ PROGRESSIVE
progressive frame
Definition types.h:164
@ SEGMENTED_FRAME
Segmented frame. Contains the same data as progressive frame.
Definition types.h:168
@ INTERLACED_MERGED
Columngs of both fields are interlaced together.
Definition types.h:167
codec_t
Definition types.h:65
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
Definition types.h:71
static struct @76 codecs[]

References AC_PCM, codecs, desc, DISPLAY_PROPERTY_AUDIO_FORMAT, DISPLAY_PROPERTY_BUF_PITCH, DISPLAY_PROPERTY_CODECS, DISPLAY_PROPERTY_RGB_SHIFT, DISPLAY_PROPERTY_SUPPORTED_IL_MODES, DISPLAY_PROPERTY_VIDEO_MODE, DISPLAY_PROPERTY_VIDEO_SEPARATE_TILES, INTERLACED_MERGED, len, max, PITCH_DEFAULT, PROGRESSIVE, property, SEGMENTED_FRAME, state, UNUSED, UYVY, and val.

◆ display_bluefish444_getf()

static struct video_frame * display_bluefish444_getf ( void * state)
static

Definition at line 882 of file bluefish444.cpp.

883{
886 struct video_frame *frame = NULL;
887
888 try {
889 frame = s->getf();
890 } catch(runtime_error &e) {
891 cerr << "[Blue444 disp] " << e.what() << endl;
892 }
893
894 return frame;
895}
struct video_frame * frame
struct video_frame * getf() noexcept
Struct video_frame represents a video frame and contains video description.
Definition types.h:305

References frame, display_bluefish444_state::getf(), and state.

Here is the call graph for this function:

◆ display_bluefish444_init()

static void * display_bluefish444_init ( struct module * parent,
const char * fmt,
unsigned int flags )
static

Definition at line 855 of file bluefish444.cpp.

856{
857 UNUSED(parent);
858 int deviceId = 1;
859 if(fmt){
860 if(strcmp(fmt, "help") == 0) {
861 show_help();
862 return NULL;
863 } else if(strncasecmp(fmt, "device=", strlen("device=")) == 0) {
864 deviceId = atoi(fmt + strlen("device="));
865 } else {
866 cerr << "[Blue444 disp] Unknown parameter: " << fmt << endl;
867 return NULL;
868 }
869 }
870
871 void *state = NULL;
872
873 try {
874 state = new display_bluefish444_state(flags, deviceId);
875 } catch(runtime_error &e) {
876 cerr << "[Blue444 disp] " << e.what() << endl;
877 }
878 return state;
879}
const char * fmt
const char unsigned int flags
const char * parent
Definition settings.cpp:198
static void show_help(void)

References flags, fmt, parent, show_help(), state, and UNUSED.

Here is the call graph for this function:

◆ display_bluefish444_probe()

static void display_bluefish444_probe ( struct device_info ** available_cards,
int * count,
void(** deleter )(void *) )
static

Definition at line 839 of file bluefish444.cpp.

840{
842 BLUE_S32 iDevices;
843 BLUEVELVETC_HANDLE pSDK = bfcFactory();
844 bfcEnumerate(pSDK, &iDevices);
845 bfcDestroy(pSDK);
846
847 *available_cards = (struct device_info *) calloc(iDevices, sizeof(struct device_info));
848 *count = iDevices;
849 for (int i = 0; i < iDevices; i++) {
850 snprintf((*available_cards)[i].dev, sizeof (*available_cards)[i].dev, ":device=%d", iDevices);
851 snprintf((*available_cards)[i].name, sizeof (*available_cards)[i].name, "Bluefish444 card #%d", iDevices);
852 }
853}
int void(** deleter)(void *))
int count
Definition hd-rum.c:44
const char * name
Definition settings.cpp:193
char dev[1024]
Definition types.h:383

References count, deleter, device_info::dev, name, and UNUSED.

◆ display_bluefish444_put_audio_frame()

static void display_bluefish444_put_audio_frame ( void * state,
const struct audio_frame * frame )
static

Definition at line 1009 of file bluefish444.cpp.

1010{
1011#ifdef HAVE_BLUE_AUDIO
1014
1015 try {
1016 s->put_audio_frame(frame);
1017 } catch(runtime_error &e) {
1018 cerr << "[Blue444 disp] " << e.what() << endl;
1019 }
1020#endif
1021}

References frame, and state.

◆ display_bluefish444_putf()

static bool display_bluefish444_putf ( void * state,
struct video_frame * frame,
long long nonblock )
static

Definition at line 897 of file bluefish444.cpp.

898{
902 try {
903 s->putf(frame);
904 return true;
905 } catch(runtime_error &e) {
906 cerr << "[Blue444 disp] " << e.what() << endl;
907 }
908 return false;
909}
struct video_frame long long nonblock
void putf(struct video_frame *) noexcept(false)

References frame, nonblock, display_bluefish444_state::putf(), state, and UNUSED.

Here is the call graph for this function:

◆ display_bluefish444_reconfigure()

static bool display_bluefish444_reconfigure ( void * state,
struct video_desc desc )
static

Definition at line 912 of file bluefish444.cpp.

913{
916
917 try {
918 s->reconfigure(desc);
919 } catch(runtime_error &e) {
920 cerr << "[Blue444 disp] " << e.what() << endl;
921 return false;
922 }
923
924 return true;
925}
void reconfigure(struct video_desc) noexcept(false)

References desc, display_bluefish444_state::reconfigure(), and state.

Here is the call graph for this function:

◆ display_bluefish444_reconfigure_audio()

static bool display_bluefish444_reconfigure_audio ( void * state,
int quant_samples,
int channels,
int sample_rate )
static

Definition at line 990 of file bluefish444.cpp.

992{
993#ifdef HAVE_BLUE_AUDIO
996 try {
997 s->reconfigure_audio(quant_samples, channels, sample_rate);
998 } catch(runtime_error &e) {
999 cerr << "[Blue444 disp] " << e.what() << endl;
1000 return false;
1001 }
1002
1003 return true;
1004#else
1005 return false;
1006#endif
1007}
int int int sample_rate
int int channels
int quant_samples

References channels, quant_samples, sample_rate, and state.

◆ InitOutputChannel()

static void InitOutputChannel ( BLUEVELVETC_HANDLE pSDK,
ULONG DefaultOutputChannel,
ULONG UpdateFormat,
ULONG MemoryFormat,
ULONG VideoEngine )
static

Definition at line 740 of file bluefish444.cpp.

742{
743 uint32_t val32;
744
745 //MOST IMPORTANT: as the first step set the channel that we want to work with
746 val32 = DefaultOutputChannel;
747 bfcSetCardProperty32(pSDK, DEFAULT_VIDEO_OUTPUT_CHANNEL, val32);
748
749 //make sure the FIFO hasn't been left running (e.g. application crash before), otherwise we can't change card properties
750 bfcVideoPlaybackStop(pSDK, 1, 1);
751
752 val32 = UpdateFormat;
753 bfcSetCardProperty32(pSDK, VIDEO_UPDATE_TYPE, val32);
754
755 val32 = MemoryFormat;
756 bfcSetCardProperty32(pSDK, VIDEO_MEMORY_FORMAT, val32);
757
758 //Only set the Video Engine after setting up the required video mode, update type and memory format
759 val32 = VideoEngine;
760 bfcSetCardProperty32(pSDK, VIDEO_OUTPUT_ENGINE, val32);
761
762 val32 = ENUM_BLACKGENERATOR_OFF;
763 bfcSetCardProperty32(pSDK, VIDEO_BLACKGENERATOR, val32);
764}

Referenced by display_bluefish444_state::reconfigure().

◆ REGISTER_MODULE()

REGISTER_MODULE ( bluefish444 ,
& display_bluefish444_info,
LIBRARY_CLASS_VIDEO_DISPLAY ,
VIDEO_DISPLAY_ABI_VERSION  )

◆ RouteChannel()

static void RouteChannel ( BLUEVELVETC_HANDLE pSDK,
ULONG Source,
ULONG Destination,
ULONG LinkType )
static

Definition at line 766 of file bluefish444.cpp.

767{
768 uint32_t val32;
769
770 val32 = EPOCH_SET_ROUTING(Source, Destination, LinkType);
771 bfcSetCardProperty32(pSDK, MR2_ROUTING, val32);
772}

Referenced by display_bluefish444_state::reconfigure().

◆ show_help()

static void show_help ( void )
static

Definition at line 820 of file bluefish444.cpp.

821{
822 BLUE_S32 iDevices;
823 BLUEVELVETC_HANDLE pSDK = bfcFactory();
824 bfcEnumerate(pSDK, &iDevices);
825 bfcDestroy(pSDK);
826
827 cout << "bluefish444 (output) options:" << endl
828 << "\tbluefish444[:device=<device_id>]" << endl
829 << "\t\tID of the Bluefish device (if more present)" << endl
830 << "\t\t" << iDevices << " Bluefish devices found in this system" << endl;
831 if(iDevices == 1) {
832 cout << " (default)" << endl;
833 } else if(iDevices > 1) {
834 cout << ", valid indices [1," << iDevices << "]" << endl;
835 cout << "default is 1" << endl;
836 }
837}

Referenced by display_bluefish444_init().

Variable Documentation

◆ display_bluefish444_info

const struct video_display_info display_bluefish444_info
static
Initial value:
= {
NULL,
}
#define DISPLAY_NO_GENERIC_FPS_INDICATOR
static bool display_bluefish444_reconfigure(void *state, struct video_desc desc)
static void display_bluefish444_done(void *state)
static bool display_bluefish444_reconfigure_audio(void *state, int quant_samples, int channels, int sample_rate)
static bool display_bluefish444_get_property(void *state, int property, void *val, size_t *len)
static void * display_bluefish444_init(struct module *parent, const char *fmt, unsigned int flags)
static struct video_frame * display_bluefish444_getf(void *state)
static bool display_bluefish444_putf(void *state, struct video_frame *frame, long long nonblock)
static void display_bluefish444_put_audio_frame(void *state, const struct audio_frame *frame)
static void display_bluefish444_probe(struct device_info **available_cards, int *count, void(**deleter)(void *))

Definition at line 1023 of file bluefish444.cpp.