Skip to content

Commit

Permalink
DecklinkInput eine ebene höher gezogen unddamit Ring-Referenz aufgelö…
Browse files Browse the repository at this point in the history
…st und sauberes abräumen der Referenzen sicher gestellt
  • Loading branch information
MaZderMind committed Feb 17, 2019
1 parent 5b415db commit f8036c2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 30 deletions.
23 changes: 2 additions & 21 deletions CaptureDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@

#define LLOG(x) LOG(x) << "CaptureDelegate: "

CaptureDelegate::CaptureDelegate(IDeckLink* deckLink) :
CaptureDelegate::CaptureDelegate(IDeckLink* deckLink, IDeckLinkInput *deckLinkInput) :
m_refCount(1),

m_deckLink(deckLink),
m_deckLinkReleaser(&m_deckLink),
m_deckLinkInput(deckLinkInput),

m_lastFrame(nullptr),
m_lastFrameReleaser(&m_lastFrame),

m_deckLinkInput(nullptr),
m_deckLinkInputReleaser(&m_deckLinkInput),

m_deckLinkConfiguration(nullptr),
m_deckLinkConfigurationReleaser(&m_deckLinkConfiguration),

Expand All @@ -37,29 +34,13 @@ CaptureDelegate::CaptureDelegate(IDeckLink* deckLink) :
m_pixelFormat(0),
m_activeConnection(0)
{
m_deckLink->AddRef();

setDuplexToHalfDuplexModeIfSupported();

m_deckLinkInput = queryInputInterface();
m_deckLinkConfiguration = queryConfigurationInterface();
m_deckLinkAttributes = queryAttributesInterface();
m_decklinkConnections = queryInputConnections();
}

IDeckLinkInput* CaptureDelegate::queryInputInterface()
{
LLOG(INFO) << __PRETTY_FUNCTION__;

HRESULT result;
IDeckLinkInput* deckLinkInput = nullptr;

result = m_deckLink->QueryInterface(IID_IDeckLinkInput, (void**)&deckLinkInput);
throwIfNotOk(result, "Failed to get Input Interface");

return deckLinkInput;
}

IDeckLinkConfiguration* CaptureDelegate::queryConfigurationInterface()
{
LLOG(INFO) << __PRETTY_FUNCTION__;
Expand Down
8 changes: 2 additions & 6 deletions CaptureDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class CaptureDelegate : public IDeckLinkInputCallback
{
public:
CaptureDelegate(IDeckLink* deckLink);
CaptureDelegate(IDeckLink* deckLink, IDeckLinkInput* deckLinkInput);

virtual HRESULT QueryInterface(UNUSED REFIID iid, UNUSED LPVOID *ppv) { return E_NOINTERFACE; }
virtual ULONG AddRef();
Expand All @@ -33,7 +33,6 @@ class CaptureDelegate : public IDeckLinkInputCallback
ULONG m_refCount;

IDeckLinkDisplayMode* queryFirstDisplayMode();
IDeckLinkInput* queryInputInterface();
IDeckLinkConfiguration* queryConfigurationInterface();
IDeckLinkAttributes* queryAttributesInterface();

Expand All @@ -53,14 +52,11 @@ class CaptureDelegate : public IDeckLinkInputCallback

private:
IDeckLink* m_deckLink;
RefReleaser<IDeckLink> m_deckLinkReleaser;
IDeckLinkInput* m_deckLinkInput;

IDeckLinkVideoInputFrame* m_lastFrame;
RefReleaser<IDeckLinkVideoInputFrame> m_lastFrameReleaser;

IDeckLinkInput* m_deckLinkInput;
RefReleaser<IDeckLinkInput> m_deckLinkInputReleaser;

IDeckLinkConfiguration* m_deckLinkConfiguration;
RefReleaser<IDeckLinkConfiguration> m_deckLinkConfigurationReleaser;

Expand Down
11 changes: 9 additions & 2 deletions DeviceProber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ DeviceProber::DeviceProber(IDeckLink* deckLink) :
m_deckLink(deckLink),
m_deckLinkReleaser(&m_deckLink),

m_deckLinkInput(nullptr),
m_deckLinkInputReleaser(&m_deckLinkInput),

m_captureDelegate(nullptr),
m_captureDelegateReleaser(&m_captureDelegate)
{
Expand All @@ -40,9 +43,13 @@ DeviceProber::DeviceProber(IDeckLink* deckLink) :

if (m_canAutodetect && m_canInput)
{
LLOG(DEBUG) << "querying IID_IDeckLinkInput interface";
HRESULT result = m_deckLink->QueryInterface(IID_IDeckLinkInput, (void**)&m_deckLinkInput);
throwIfNotOk(result, "Failed to query IID_IDeckLinkInput Interface");

LLOG(DEBUG) << "creating CaptureDelegate";
m_captureDelegate = new CaptureDelegate(m_deckLink);
//m_captureDelegate->Start();
m_captureDelegate = new CaptureDelegate(m_deckLink, m_deckLinkInput);
m_captureDelegate->Start();
}
}

Expand Down
3 changes: 3 additions & 0 deletions DeviceProber.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class DeviceProber
IDeckLink* m_deckLink;
RefReleaser<IDeckLink> m_deckLinkReleaser;

IDeckLinkInput* m_deckLinkInput;
RefReleaser<IDeckLinkInput> m_deckLinkInputReleaser;

CaptureDelegate* m_captureDelegate;
RefReleaser<CaptureDelegate> m_captureDelegateReleaser;

Expand Down
8 changes: 7 additions & 1 deletion decklink-debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ void _main() {
throw "No DeckLink devices found";
}


LOG(INFO) << "=============================";

LOG(INFO) << "starting Capturing";
for(DeviceProber* deviceProber: deviceProbers) {
deviceProber->Start();
LOG(INFO) << "-----------------------------";
}

LOG(DEBUG) << "creating HttpServer";
Expand Down Expand Up @@ -119,15 +123,16 @@ std::vector<DeviceProber*> createDeviceProbers()
try {
while (deckLinkIterator->Next(&deckLink) == S_OK)
{
RefReleaser<IDeckLink> deckLinkReleaser(&deckLink);
i++;
LOG(DEBUG1) << "creating DeviceProber for Device " << i;
deviceProbers.push_back(new DeviceProber(deckLink));
deckLink->Release();
LOG(INFO) << "-----------------------------";
}
}
catch(...) {
LOG(ERROR) << "cought exception, freeing already created DeviceProbers";
LOG(INFO) << "-----------------------------";
freeDeviceProbers(deviceProbers);
throw;
}
Expand All @@ -143,6 +148,7 @@ void freeDeviceProbers(std::vector<DeviceProber*> deviceProbers)
i++;
LOG(DEBUG1) << "freeing DeviceProber for Device " << i;
delete deviceProber;
LOG(INFO) << "-----------------------------";
}
deviceProbers.clear();
}
Expand Down

0 comments on commit f8036c2

Please sign in to comment.