通过FireMonKey/C 在OS X中的地址com
Address COM in OS X via FireMonkey/C++
可用于Windows和OS X的基于COM的Blackmagic Decklink API。我希望在OS X中解决它,但在C 中使用FiremonKey(FMX)。问题在于他们的样本代码*是为可可编写的,我不知道如何为firemonkey重写它。有人对此有任何经验吗?
或,是否有一种通用方式可以在FiremonKey/OS X?
中解决具有COM接口的库根据请求,这是可可代码的一部分。
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();
}
*在此处包括的时间太长,但您可以在此处下载。
在没有本机com支持的平台上(例如OS X),应提供c入口点以访问接口,在Decklink API中,有这样的工厂方法:
IDeckLinkIterator *deckLinkIterator = CreateDeckLinkIteratorInstance();
因此,您可以简单地使用C 构建器中的DeckLink API。但是存在问题,C 构建器已定义了一些com类型,例如sysmac.h中的iunknown(由system.hpp包括),如果您的项目包括system.hpp,则在cfplugincom.h中定义了与相同类型的冲突。例如所有FireMonkey项目编译器都会显示一个错误:
[bccosx Error] sysmac.h(287): E2238 Multiple declaration for 'IUnknown'
有一个名为 DeckControl 在Decklink API的样品目录中的样本,这是一个控制台程序,您可以通过C 构建器对其进行编译:
- 创建一个控制台项目并将Main.CPP指定为项目来源。
- 选择"无"作为目标框架
- 添加" OSX"平台
该项目是成功的。
和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++ 指针的内存地址和指向数组的内存地址如何相同?
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 在C++中打印指向不同基元数据类型的指针的内存地址
- 如何在c++程序中找到函数的地址
- 向量元素的引用地址与它所指向的向量元素的地址不同.为什么
- 被解释为低级别const的const对象的地址
- 将地址分配给本地指针后,公共对象的变量将消失
- 为什么我在leetcode上收到AddressSanitizer:地址0x602000000058上的堆缓冲区溢出错误
- 内联程序集printf将整数解释为地址
- 为什么指针不写入类的地址?
- 如何在C++中获取该对象的类声明中对象的地址?
- 通过按地址访问变量
- 当一个新对象被分配到它的地址时,对象是否必须被销毁
- 函数名是c中该函数的第一条指令的地址吗
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- ReadProcessMemory() 不适用于像 0x2840C6C68D8 这样的长地址
- 通过FireMonKey/C 在OS X中的地址com
- 如何获取 COM 对象的成员函数的地址?