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
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm
#pragma once
#include "libvideostitch/profile.hpp"
#include "libvideostitch/input.hpp"
#include "libvideostitch/ptv.hpp"
#include "libvideostitch/plugin.hpp"
#if defined(_WIN32)
#include "DeckLinkAPI_h.h"
#else
#include "DeckLinkAPI.h"
#endif
#include <condition_variable>
#include <mutex>
#include <memory>
/**
* BlackMagic DeckLink capture card reader.
*/
namespace VideoStitch {
namespace Input {
class DeckLinkReader : public VideoReader, public IDeckLinkInputCallback {
public:
virtual ~DeckLinkReader();
static DeckLinkReader* create(readerid_t id, const Ptv::Value* config, const int64_t width, const int64_t height);
static bool handles(const Ptv::Value* config);
ReadStatus readFrame(mtime_t& timestamp, unsigned char* videoFrame);
Status seekFrame(frameid_t date);
HRESULT QueryInterface(REFIID riid, void** ppv) { return E_FAIL; }
ULONG AddRef() { return 0; }
ULONG Release() { return 0; }
HRESULT VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*);
HRESULT VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*,
BMDDetectedVideoInputFormatFlags);
private:
DeckLinkReader(readerid_t id, int64_t width, int64_t height, PixelFormat pixelFormat, Plugin::DisplayMode displayMode,
int64_t frameSize, FrameRate frameRate, std::shared_ptr<IDeckLink> subDevice,
std::shared_ptr<IDeckLinkInput> input, std::string name);
std::shared_ptr<IDeckLink> subDevice;
std::shared_ptr<IDeckLinkConfiguration> configurationForHalfDuplex; // We need to keep the configuration because
// In Decklink SDK doc: "Changes will persist until the IDeckLinkConfiguration object is released"
// Be careful: the configuration is not necessarily the one of the above sub device. It can be the configuration of
// the paired sub device (for Quad 2 and Duo 2)
std::shared_ptr<IDeckLinkInput> input;
const std::string name;
const Plugin::DisplayMode displayMode;
std::mutex m;
std::condition_variable cv;
std::vector<unsigned char> currentVideoFrame;
bool frameAvailable;
mtime_t videoTimeStamp;
};
} // namespace Input
} // namespace VideoStitch