IMFSourceReaderCallback:base class undefined [英] IMFSourceReaderCallback: base class undefined

查看:1153
本文介绍了IMFSourceReaderCallback:base class undefined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Media Foundation从摄像机读取样本时遇到了一些问题。我在Windows SDK示例文件夹MFCaptureToFile中的示例。

I am having some trouble reading samples from a video camera via Media Foundation. I am following the example in the windows SDK samples folder MFCaptureToFile.

我的类设置正确从继承抽象IMFSourceReaderCallback类,就我可以告诉: / p>

My class is set up correctly to inherit from the abstract IMFSourceReaderCallback class, as far as I can tell:

#include <windows.h>
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>

class WinCapture : public IMFSourceReaderCallback{

public:

    static HRESULT CreateInstance(
        std::string deviceName,
        WinCapture **winCapture 
        );

    // IUnknown methods
    STDMETHODIMP QueryInterface(REFIID iid, void** ppv);
    STDMETHODIMP_(ULONG) AddRef();
    STDMETHODIMP_(ULONG) Release();

    // IMFSourceReaderCallback methods
    STDMETHODIMP OnReadSample(
        HRESULT hrStatus,
        DWORD dwStreamIndex,
        DWORD dwStreamFlags,
        LONGLONG llTimestamp,
        IMFSample *pSample
        );

    STDMETHODIMP OnEvent(DWORD, IMFMediaEvent *)
    {
        return S_OK;
    }

    STDMETHODIMP OnFlush(DWORD)
    {
        return S_OK;
    }

}

如果我自己编译这个代码,它编译良好。但是,如果我想在一个更大的项目中使用这个类,它给我的错误。有什么关于我如何包括winCapture.h在其他文件是抛出这个错误?为什么它会自己编译而不是在一个更大的项目的上下文中?

If I compile this code on its own, it compiles fine. However, if I wish to use this class in a larger project it gives me the error. Is there something about how I am including winCapture.h in the other files that is tossing this error? Why will it compile on its own but not in the context of a larger project?

我想有一个循环依赖,但我不知道如何跟踪这下来。

I guess there is a circular dependency going on, but I'm not sure how to track this down. It certainly doesn't appear to be of my own making, it's more likely hidden withing included headers somewhere.

推荐答案

解决方案看起来似乎是我自己做的,要使用

The solution seems to be to use

#define WIN32_LEAN_AND_MEAN

,并将所有包含的头文件移动到包含它的任何其他文件中的任何#include指令的顶部。此代码现在编译为独立的,并在一个更大的项目的上下文中。

in the header file and to move all includes of this header to the top of any #include directives in any other files that include it. This code now compiles both stand alone, and in the context of a larger project.

这篇关于IMFSourceReaderCallback:base class undefined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆