我在尝试将基于 directshow 的直播播放器编写为 ActiveX 控件时遇到了问题。
我首先用VS2010(VC++类)创建了一个MFC ActiveX控件项目,并在控件上附加了一个对话框,然后用一个简单的html页面对其进行了测试。
到目前为止它运行良好,但是当我尝试使用 CComPtr 添加一些 directshow 代码时,编译器显示以下错误(我还附上了行号和文件):
29 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 37)
30 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 38)
31 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 44)
32 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 44)
33 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 47)
34 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 48)
35 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 49)
36 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 19)
37 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 20)
38 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 21)
39 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 22)
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIceBaseLivestreamPlayerCore.h, Line 37)
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIceBaseLivestreamPlayerCore.h, Line 38)
Error 14 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 19)
Error 17 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 20)
Error 20 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 21)
Error 23 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 22)
Error 25 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_vInfTee' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 27 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_fileWriter' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 28 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_AVIMux' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 26 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_aInfTee' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 12 error C2614: 'CIceBaseLivestreamPlayerCore' : illegal member initialization: 'm_pGraph' is not a base or member (CIceBaseLivestreamPlayerCore.h, Line 18)
Error 11 error C2614: 'CIceBaseLivestreamPlayerCore' : illegal member initialization: 'm_pControl' is not a base or member (CIceBaseLivestreamPlayerCore.h, Line 18)
Error 3 error C2238: unexpected token(s) preceding ';' (CIceBaseLivestreamPlayerCore.h, Line 37)
Error 6 error C2238: unexpected token(s) preceding ';' (CIceBaseLivestreamPlayerCore.h, Line 38)
Error 15 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 19)
Error 18 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 20)
Error 21 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 21)
Error 24 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 22)
Error 1 error C2143: syntax error : missing ';' before '<' (CIceBaseLivestreamPlayerCore.h, Line 37)
Error 4 error C2143: syntax error : missing ';' before '<' (CIceBaseLivestreamPlayerCore.h, Line 38)
Error 13 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 19)
Error 16 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 20)
Error 19 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 21)
Error 22 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 22)
Error 7 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 44)
Error 8 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 47)
Error 9 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 48)
Error 10 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 49)
所有这些错误似乎都表明 CComPtr 有一些奇怪的地方,但我不知道出了什么问题。
我在 stdafx.h 的底部添加了两个头文件,如下所示:
#include <streams.h>
#include <atlbase.h>
我将列出部分我的 CIceBaseLivestreamPlayerCore.h 和 CIcePlayAndSaveAXCore.h 如下,上述错误中涉及的所有行都包括在内。
CIceBaseLivestreamPlayerCore.h:
#pragma once
#include "stdafx.h"
class CIceBaseLivestreamPlayerCore
{
...
15 CIceBaseLivestreamPlayerCore():
16 ..., m_pGraph(NULL), m_pControl(NULL),
17 ...
18 { ; }
...
37 CComPtr<IGraphBuilder> m_pGraph;
38 CComPtr<IMediaControl> m_pControl;
...
44 HRESULT ConnectFilters(CComPtr<IBaseFilter> pIn, CComPtr<IBaseFilter> pOut, const AM_MEDIA_TYPE& mType);
...
47 HRESULT MatchPin(CComPtr<IPin>, PIN_DIRECTION, BOOL, BOOL*);
48 HRESULT IsPinConnected(CComPtr<IPin>, BOOL*);
49 HRESULT IsPinDirection(CComPtr<IPin>, PIN_DIRECTION, BOOL*);
};
CIcePlayAndSaveAXCore.h:
#pragma once
#include "CIceBaseLivestreamPlayerCore.h"
class CIcePlayAndSaveAXCore : public CIceBaseLivestreamPlayerCore
{
...
7 CIcePlayAndSaveAXCore() :
8 m_AVIMux(NULL), m_fileWriter(NULL), m_aInfTee(NULL), m_vInfTee(NULL)
9 { ; }
...
19 CComPtr<IBaseFilter> m_AVIMux;
20 CComPtr<IBaseFilter> m_fileWriter;
21 CComPtr<IBaseFilter> m_aInfTee;
22 CComPtr<IBaseFilter> m_vInfTee;
};
我的项目的其他依赖项是“strmbasd.lib;winmm.lib;uuid.lib;”。
就是这样..希望有人能给我如何解决它的答案,或者只是给我任何建议或建议作为我应该做的方向。
任何帮助表示赞赏。
这是我第一次发布英语问题(虽然我不是母语人士..),所以请让我知道我在提问时是否有任何遗失或做错了什么。
非常感谢。:)