1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
|
#include "OBSVideoFrame.h"
OBSVideoFrame::OBSVideoFrame(long width, long height,
BMDPixelFormat pixelFormat)
{
int bpp = 2;
this->width = width;
this->height = height;
this->rowBytes = width * bpp;
this->data = new unsigned char[width * height * bpp + 1];
this->pixelFormat = pixelFormat;
}
OBSVideoFrame::~OBSVideoFrame()
{
delete this->data;
}
HRESULT OBSVideoFrame::SetFlags(BMDFrameFlags newFlags)
{
flags = newFlags;
return S_OK;
}
HRESULT OBSVideoFrame::SetTimecode(BMDTimecodeFormat format,
IDeckLinkTimecode *timecode)
{
UNUSED_PARAMETER(format);
UNUSED_PARAMETER(timecode);
return 0;
}
HRESULT
OBSVideoFrame::SetTimecodeFromComponents(BMDTimecodeFormat format,
uint8_t hours, uint8_t minutes,
uint8_t seconds, uint8_t frames,
BMDTimecodeFlags flags)
{
UNUSED_PARAMETER(format);
UNUSED_PARAMETER(hours);
UNUSED_PARAMETER(minutes);
UNUSED_PARAMETER(seconds);
UNUSED_PARAMETER(frames);
UNUSED_PARAMETER(flags);
return 0;
}
HRESULT OBSVideoFrame::SetAncillaryData(IDeckLinkVideoFrameAncillary *ancillary)
{
UNUSED_PARAMETER(ancillary);
return 0;
}
HRESULT OBSVideoFrame::SetTimecodeUserBits(BMDTimecodeFormat format,
BMDTimecodeUserBits userBits)
{
UNUSED_PARAMETER(format);
UNUSED_PARAMETER(userBits);
return 0;
}
long OBSVideoFrame::GetWidth()
{
return width;
}
long OBSVideoFrame::GetHeight()
{
return height;
}
long OBSVideoFrame::GetRowBytes()
{
return rowBytes;
}
BMDPixelFormat OBSVideoFrame::GetPixelFormat()
{
return pixelFormat;
}
BMDFrameFlags OBSVideoFrame::GetFlags()
{
return flags;
}
HRESULT OBSVideoFrame::GetBytes(void **buffer)
{
*buffer = this->data;
return S_OK;
}
#define CompareREFIID(iid1, iid2) (memcmp(&iid1, &iid2, sizeof(REFIID)) == 0)
HDRVideoFrame::HDRVideoFrame(IDeckLinkMutableVideoFrame *frame)
: m_videoFrame(frame),
m_refCount(1)
{
}
HRESULT HDRVideoFrame::QueryInterface(REFIID iid, LPVOID *ppv)
{
if (ppv == nullptr)
return E_INVALIDARG;
CFUUIDBytes unknown = CFUUIDGetUUIDBytes(IUnknownUUID);
if (CompareREFIID(iid, unknown))
*ppv = static_cast<IDeckLinkVideoFrame *>(this);
else if (CompareREFIID(iid, IID_IDeckLinkVideoFrame))
*ppv = static_cast<IDeckLinkVideoFrame *>(this);
else if (CompareREFIID(iid, IID_IDeckLinkVideoFrameMetadataExtensions))
*ppv = static_cast<IDeckLinkVideoFrameMetadataExtensions *>(
this);
else {
*ppv = nullptr;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
ULONG HDRVideoFrame::AddRef(void)
{
return ++m_refCount;
}
ULONG HDRVideoFrame::Release(void)
{
ULONG newRefValue = --m_refCount;
if (newRefValue == 0)
delete this;
return newRefValue;
}
HRESULT HDRVideoFrame::GetInt(BMDDeckLinkFrameMetadataID metadataID,
int64_t *value)
{
HRESULT result = S_OK;
switch (metadataID) {
case bmdDeckLinkFrameMetadataHDRElectroOpticalTransferFunc:
*value = 2;
break;
case bmdDeckLinkFrameMetadataColorspace:
// Colorspace is fixed for this sample
*value = bmdColorspaceRec2020;
break;
default:
result = E_INVALIDARG;
}
return result;
}
HRESULT HDRVideoFrame::GetFloat(BMDDeckLinkFrameMetadataID metadataID,
double *value)
{
HRESULT result = S_OK;
switch (metadataID) {
case bmdDeckLinkFrameMetadataHDRDisplayPrimariesRedX:
*value = 0.708;
break;
case bmdDeckLinkFrameMetadataHDRDisplayPrimariesRedY:
*value = 0.292;
break;
case bmdDeckLinkFrameMetadataHDRDisplayPrimariesGreenX:
*value = 0.17;
break;
case bmdDeckLinkFrameMetadataHDRDisplayPrimariesGreenY:
*value = 0.797;
break;
case bmdDeckLinkFrameMetadataHDRDisplayPrimariesBlueX:
*value = 0.131;
break;
case bmdDeckLinkFrameMetadataHDRDisplayPrimariesBlueY:
*value = 0.046;
break;
case bmdDeckLinkFrameMetadataHDRWhitePointX:
*value = 0.3127;
break;
case bmdDeckLinkFrameMetadataHDRWhitePointY:
*value = 0.329;
break;
case bmdDeckLinkFrameMetadataHDRMaxDisplayMasteringLuminance:
*value = obs_get_video_hdr_nominal_peak_level();
break;
case bmdDeckLinkFrameMetadataHDRMinDisplayMasteringLuminance:
*value = 0.00001;
break;
case bmdDeckLinkFrameMetadataHDRMaximumContentLightLevel:
*value = obs_get_video_hdr_nominal_peak_level();
break;
case bmdDeckLinkFrameMetadataHDRMaximumFrameAverageLightLevel:
*value = obs_get_video_hdr_nominal_peak_level();
break;
default:
result = E_INVALIDARG;
}
return result;
}
HRESULT HDRVideoFrame::GetFlag(BMDDeckLinkFrameMetadataID, decklink_bool_t *)
{
// Not expecting GetFlag
return E_INVALIDARG;
}
HRESULT HDRVideoFrame::GetString(BMDDeckLinkFrameMetadataID,
decklink_string_t *)
{
// Not expecting GetString
return E_INVALIDARG;
}
HRESULT HDRVideoFrame::GetBytes(BMDDeckLinkFrameMetadataID, void *,
uint32_t *bufferSize)
{
*bufferSize = 0;
// Not expecting GetBytes
return E_INVALIDARG;
}
|