BMD采集卡(BlackMagic DeckLink) 如何判断哪个视频口有信号输入?

deckLink官方回复

 

一、获取DeckLink设备

    (1)、同步获取

    IDeckLinkIterator *deckLinkIterator = nullptr;
	if (FAILED(CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, 
    IID_IDeckLinkIterator, (void**)deckLinkIterator)))
	{
		fprintf(stderr, "A DeckLink iterator could not be created.  The DeckLink drivers 
        may not be installed.\n");
		return;
	}
	
	IDeckLink *deckLink = nullptr;
	while(deckLinkIterator->next(&deckLink) == S_OK)
	{
		// save
	}

  (2)、异步获取

       实现IDeckLinkDeviceNotificationCallback,调用callBack

class BMDDeviceDiscovery : public IDeckLinkDeviceNotificationCallback
{
	using Callback = std::function<void(CComPtr<IDeckLink>&)>;

public:
	BMDDeviceDiscovery();
	virtual ~BMDDeviceDiscovery() = default;

	void		onDeviceArrival(const Callback& callback) { m_deckLinkArrivedCallback = callback; }
	void		onDeviceRemoval(const Callback& callback) { m_deckLinkRemovedCallback = callback; }

	bool		enable();
	void		disable();

	// IDeckLinkDeviceArrivalNotificationCallback interface
	HRESULT		STDMETHODCALLTYPE DeckLinkDeviceArrived(IDeckLink* deckLinkDevice) override;
	HRESULT		STDMETHODCALLTYPE DeckLinkDeviceRemoved(IDeckLink* deckLinkDevice) override;

	// IUnknown needs only a dummy implementation
	HRESULT		STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) override;
	ULONG		STDMETHODCALLTYPE AddRef() override;
	ULONG		STDMETHODCALLTYPE Release() override;

private:
	CComPtr<IDeckLinkDiscovery>		m_deckLinkDiscovery;

	Callback						m_deckLinkArrivedCallback;
	Callback						m_deckLinkRemovedCallback;

	std::atomic<ULONG>				m_refCount;
};
/* -LICENSE-START-
** Copyright (c) 2020 Blackmagic Design
**
** Permission is hereby granted, free of charge, to any person or organization
** obtaining a copy of the software and accompanying documentation covered by
** this license (the "Software") to use, reproduce, display, distribute,
** execute, and transmit the Software, and to prepare derivative works of the
** Software, and to permit third-parties to whom the Software is furnished to
** do so, all subject to the following:
**
** The copyright notices in the Software and this entire statement, including
** the above license grant, this restriction and the following disclaimer,
** must be included in all copies of the Software, in whole or in part, and
** all derivative works of the Software, unless such copies or derivative
** works are solely in the form of machine-executable object code generated by
** a source language processor.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
** DEALINGS IN THE SOFTWARE.
** -LICENSE-END-
*/

#include <stdexcept>
#include "BMDDeviceDiscovery.h"

BMDDeviceDiscovery::BMDDeviceDiscovery() :
	m_deckLinkDiscovery(nullptr),
	m_refCount(1)
{
	if (CoCreateInstance(CLSID_CDeckLinkDiscovery, NULL, CLSCTX_ALL, IID_IDeckLinkDiscovery, (void**)&m_deckLinkDiscovery) != S_OK)
		throw std::runtime_error("Unable to create IDeckLinkDiscovery interface object");
}

bool BMDDeviceDiscovery::enable()
{
	HRESULT result = E_FAIL;

	// Install device arrival notifications
	if (m_deckLinkDiscovery)
		result = m_deckLinkDiscovery->InstallDeviceNotifications(this);

	return result == S_OK;
}

void BMDDeviceDiscovery::disable()
{
	// Uninstall device arrival notifications
	if (m_deckLinkDiscovery)
		m_deckLinkDiscovery->UninstallDeviceNotifications();
}

HRESULT BMDDeviceDiscovery::DeckLinkDeviceArrived(/* in */ IDeckLink* deckLink)
{
	if (m_deckLinkArrivedCallback)
	{
		CComPtr<IDeckLink> deckLinkDevice = deckLink;
		m_deckLinkArrivedCallback(deckLinkDevice);
	}

	return S_OK;
}

HRESULT BMDDeviceDiscovery::DeckLinkDeviceRemoved(/* in */ IDeckLink* deckLink)
{
	if (m_deckLinkRemovedCallback)
	{
		CComPtr<IDeckLink> deckLinkDevice = deckLink;
		m_deckLinkRemovedCallback(deckLinkDevice);
	}

	return S_OK;
}

HRESULT BMDDeviceDiscovery::QueryInterface(REFIID iid, LPVOID *ppv)
{
	HRESULT result = E_NOINTERFACE;

	if (ppv == NULL)
		return E_INVALIDARG;

	// Initialise the return result
	*ppv = NULL;

	// Obtain the IUnknown interface and compare it the provided REFIID
	if (iid == IID_IUnknown)
	{
		*ppv = this;
		AddRef();
		result = S_OK;
	}
	else if (iid == IID_IDeckLinkDeviceNotificationCallback)
	{
		*ppv = static_cast<IDeckLinkDeviceNotificationCallback*>(this);
		AddRef();
		result = S_OK;
	}

	return result;
}

ULONG BMDDeviceDiscovery::AddRef(void)
{
	return ++m_refCount;
}

ULONG BMDDeviceDiscovery::Release(void)
{
	ULONG newRefValue = --m_refCount;
	if (newRefValue == 0)
		delete this;

	return newRefValue;
}

二、获取IDeckLinkInput 并调用flag    bmdVideoInputEnableFormatDetection(注:这条必不可少,不然获取不到信号)

IDeckLinkInput *pInput = nullptr;
if (deckLink->QueryInterface(IID_IDeckLinkInput, (void**)&pInput) == S_FALSE)
{
	return;
}

// 必须要
if (pInput->EnableVideoInput(bmdModeNTSC, bmdFormat8BitYUV, bmdVideoInputEnableFormatDetection) != S_OK)
{
	return;
}

三、获取IDeckLinkStatus,并读取相应的属性

IDeckLinkStatus *deckLinkStatus = nullptr;
if (deckLink->QueryInterface(IID_IDeckLinkStatus, (void**)&deckLinkStatus) != S_OK || deckLinkStatus == nullptr)
{
	return;
}

BOOL bLock;
if (deckLinkStatus->GetFlag(bmdDeckLinkStatusVideoInputSignalLocked, &bLock) != S_OK)
{
	return;
}
	
int64_t inputFormat;
if (deckLinkStatus->GetInt(bmdDeckLinkStatusDetectedVideoInputFormatFlags, &inputFormat) != S_OK)
{
	return;
}

// 输入类型
int64_t	statusInt;
if (deckLinkStatus->GetInt(bmdDeckLinkStatusDetectedVideoInputMode, &statusInt) != S_OK)
{
	return;
}
if (statusInt == bmdModeUnknown)
{
	return;
}

 

在半导体中,BMD(Bulk Micro Defects)是指材料内部存在的微观缺陷。BMD缺陷对半导体器件的性能和可靠性有着重要影响,因此有一定的要求。 首先,半导体中的BMD缺陷应该尽量减少。这是因为BMD缺陷会导致材料的结晶缺陷、离子杂质等,在材料的晶格结构中形成能级,从而影响电子的运动和能带结构。高浓度的BMD缺陷会导致电子和空穴的复合速率增加,从而降低材料的载流子迁移率和电导率,并增加材料的电阻。因此,降低BMD缺陷的浓度对于提高半导体材料的性能至关重要。 其次,BMD缺陷应该具有一定的尺寸和分布要求。尺寸过小的BMD缺陷可能由于其体积小,无法有效地影响材料的性能。而尺寸过大的BMD缺陷则可能成为材料中的局部势垒,导致局部电压的变化,进而影响器件的电性能。因此,BMD缺陷的尺寸应该在一定范围内,以确保其对半导体器件的影响处于可控的范围之内。 此外,BMD缺陷的分布应该均匀,并且避免出现局部集中的情况。均匀的BMD缺陷分布可以降低电子与BMD缺陷之间的反射和散射,提高电子的迁移率和扩散性能。而局部集中的BMD缺陷则可能导致器件中形成势垒,降低电子的自由度,从而影响器件的整体性能。 综上所述,半导体材料中的BMD缺陷应该尽量减少,尺寸适中,分布均匀。这些要求有助于提高半导体器件的性能和可靠性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值