- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
基于 COM 的 Blackmagic DeckLink API 可用于 Windows 和 OS X。我希望在 OS X 中解决它,但在 C++ 中使用 FireMonkey (FMX)。问题是他们的示例代码* 是为 Cocoa 编写的,我不知道如何为 FireMonkey 重写它。有没有人有这方面的经验,甚至有可能。
或者,是否有一种通用方法可以在 FireMonkey/OS X 中寻址具有 COM 接口(interface)的库?
根据请求,这是 Cocoa 的部分代码。
void InitDeckLinkAPI (void)
{
CFURLRef bundleURL;
bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR(kDeckLinkAPI_BundlePath), kCFURLPOSIXPathStyle, true);
if (bundleURL != NULL)
{
gDeckLinkAPIBundleRef = CFBundleCreate(kCFAllocatorDefault, bundleURL);
if (gDeckLinkAPIBundleRef != NULL)
{
gCreateIteratorFunc = (CreateIteratorFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateDeckLinkIteratorInstance_0002"));
gCreateAPIInformationFunc = (CreateAPIInformationFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateDeckLinkAPIInformationInstance_0001"));
gCreateOpenGLPreviewFunc = (CreateOpenGLScreenPreviewHelperFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateOpenGLScreenPreviewHelper_0001"));
gCreateCocoaPreviewFunc = (CreateCocoaScreenPreviewFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateCocoaScreenPreview_0001"));
gCreateVideoConversionFunc = (CreateVideoConversionInstanceFunc)CFBundleGetFunctionPointerForName(gDeckLinkAPIBundleRef, CFSTR("CreateVideoConversionInstance_0001"));
}
CFRelease(bundleURL);
}
}
bool IsDeckLinkAPIPresent (void)
{
// If the DeckLink API bundle was successfully loaded, return this knowledge to the caller
if (gDeckLinkAPIBundleRef != NULL)
return true;
return false;
}
IDeckLinkIterator* CreateDeckLinkIteratorInstance (void)
{
pthread_once(&gDeckLinkOnceControl, InitDeckLinkAPI);
if (gCreateIteratorFunc == NULL)
return NULL;
return gCreateIteratorFunc();
}
*此处太长,但您可以下载 here .
最佳答案
在没有本地 COM 支持的平台上(例如 OS X),应该提供一个 C 入口点来访问接口(interface),在 DeckLink API 中有这样的工厂方法:
IDeckLinkIterator *deckLinkIterator = CreateDeckLinkIteratorInstance();
因此您可以在 C++Builder 中简单地使用 DeckLink API。但是有一个问题,C++Builder在sysmac.h中定义了一些COM类型比如IUnknown(包含在System.hpp中)与CFPluginCOM.h中定义的相同类型冲突,如果你的项目包含System.hpp例如所有 firemonkey 项目编译器都会显示错误:
[bccosx Error] sysmac.h(287): E2238 Multiple declaration for 'IUnknown'
DeckLink API的samples目录下有一个名为DeckControl的sample,是一个console程序,可以用C++Builder编译:
项目编译成功
那么 Fmx 项目(使用 System.hpp)呢?
创建一个包装器单元(例如 bcb_deck),将所需的 API 放入其中。请注意,不要在单元头中包含“DeckLinkAPI.h”,这会导致与上述相同的问题,但将其放在 cpp (bcb_deck.cpp) 中,例如:
bcb_deck.cpp:
void* createDeckLinkIteratorInstance() // use camel case to prevent conflict
{
return (void*) CreateDeckLinkIteratorInstance();
}
bool deckLinkIteratorNext(void *hDeckLinkIterator, void *hDeckLink)
{
IDeckLinkIterator *deckLinkIterator = (IDeckLinkIterator*) hDeckLinkIterator;
IDeckLink *deckLink = (IDeckLink*) hDeckLink;
return deckLinkIterator->Next(&deckLink) == S_OK;
}
用法:
#include "bcb_deck.h"
void *hDeckLinkIterator, *hDeckLink;
hDeckLinkIterator = createDeckLinkIteratorInstance();
if (hDeckLinkIterator)
{
// Enumerate all cards in this system
while (deckLinkIteratorNext(hDeckLinkIterator, hDeckLink))
{
// ...
}
}
关于c++ - 通过 FireMonkey/C++ 在 OS X 中寻址 COM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21287972/
我是一名优秀的程序员,十分优秀!