|
平台:WINCE6.0+S3C6410
camera 驱动已写好,用BSP里面的CameraDshowApp.exe,能正常地进行120x160、320x240、 640x480进行预览,
但是现在用了某家开发板的camera App DEMO,能用120x160进行预览,但是当调到640x480进行预览,就出现了如下的崩溃信息:
- Exception 'Data Abort' (4): Thread-Id=076e013e(pth=86484480), Proc-Id=040e01ca(pprc=864846c0) 'CameraDemo.exe', VM-active=040e01ca(pprc=864846c0) 'CameraDemo.exe'
- PC=00013ca8(CameraDemo.exe+0x00003ca8) RA=00013c90(CameraDemo.exe+0x00003c90) SP=001be9f4, BVA=00000000
- Exception 'Raised Exception' (-1): Thread-Id=076e013e(pth=86484480), Proc-Id=00400002(pprc=80430308) 'NK.EXE', VM-active=040e01ca(pprc=864846c0) 'CameraDemo.exe'
- PC=c003bd00(k.coredll.dll+0x0001bd00) RA=8012d4c8(kernel.dll+0x000064c8) SP=d73cf3b8, BVA=ffffffff
复制代码
问题:
1、我估计是申请的缓存空间不够,请问是不是?请高手指点
2、我在应用程序源码里面找不到申请缓存的代码,不知directshow架构,是在哪里申请的缓存?
3、请问哪位有CameraDshowApp.exe的源码?请给我一份,谢谢,我邮箱:aulyp@163.com
下面赋上我preview的源码,大家帮我分析一下,谢谢
- BOOL PreviewCamera(HWND hVideoWnd /*视频显示窗口*/
- ,LPCTSTR strFileName /*录像文件名*/)
- {
- HRESULT hResult = S_FALSE;
- LONGLONG dwStart = 0, dwEnd = 0;
- WORD wStartCookie = 1, wEndCookie = 2;
- CRect rectVideo; //视频窗口尺寸
- CComVariant varCamName; //定义摄像头设备名称
- WCHAR wzDeviceName[ MAX_PATH + 1 ]; //摄像头设备名称
- CPropertyBag PropBag; //摄像头属性页
- //--定义录像用到的编码、写文件等FILTER
- CComPtr pVideoEncoder;
- CComPtr pASFMultiplexer;
- CComPtr pFileSinkFilter;
- CComPtr pWrapperFilter;
- //默认先释放DSHOW接口
- FreeDShow();
- //1,创建ICaptureGraphBuilder2接口,用于管理媒体捕捉对象
- CHK(m_pCaptureGraphBuilder.CoCreateInstance(CLSID_CaptureGraphBuilder));
- //2,创建IGraphBuilder接口
- CHK(m_pGraphBuilder.CoCreateInstance(CLSID_FilterGraph));
- //3,
- CHK(m_pCaptureGraphBuilder->SetFiltergraph(m_pGraphBuilder ));
- //4,得到IMediaControl接口,用于控制流播放
- CHK(m_pGraphBuilder.QueryInterface(&m_pMediaControl));
- //5,得到IMediaSeeking接口,用于设置播放位置
- CHK(m_pGraphBuilder.QueryInterface(&m_pMediaSeeking));
- //6,得到m_pMediaEvent接口,用于获取媒体事件
- CHK(m_pGraphBuilder.QueryInterface(&m_pMediaEvent));
- //7,创建视频捕捉Filter
- CHK(m_pVideoCaptureFilter.CoCreateInstance(CLSID_VideoCapture));
- //8,得到视频捕捉属性页接口
- CHK(m_pVideoCaptureFilter->QueryInterface(&m_pPropertyBag ));
- //9,选择视频捕捉设备
- //得到第1个视频捕捉设备名。
- if (!GetFirstCameraDriver( wzDeviceName ))
- {
- goto Cleanup;
- }
- varCamName = wzDeviceName;
- if(( varCamName.vt == VT_BSTR ) == NULL ) {
- return FALSE;
- }
- //设置视频捕捉为第1个捕捉设备
- PropBag.Write( L"VCapName", &varCamName );
- CHK(m_pPropertyBag->Load( &PropBag, NULL ));
- //10,将视频捕捉FILTER添加到FILTER图中。
- CHK(m_pGraphBuilder->AddFilter( m_pVideoCaptureFilter, L"Video capture source" ));
- //11,创建IDMOWrapperFilter接口
- CHK(pVideoEncoder.CoCreateInstance( CLSID_DMOWrapperFilter ));
- CHK(pVideoEncoder.QueryInterface( &pWrapperFilter ));
- //12,加载WMV9 DMO
- CHK(pWrapperFilter->Init( CLSID_CWMV9EncMediaObject, DMOCATEGORY_VIDEO_ENCODER ));
- // 13,将编码器FILTER加入到过滤器图中
- CHK(m_pGraphBuilder->AddFilter( pVideoEncoder, L"WMV9 DMO Encoder" ));
- //14,创建ASF多路(复用)器,并加入到过滤器图中
- CHK(m_pCaptureGraphBuilder->SetOutputFileName( &MEDIASUBTYPE_Asf,strFileName, &pASFMultiplexer, &pFileSinkFilter ));
- //15,渲染预览视频PIN
- CHK(m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_PREVIEW,
- &MEDIATYPE_Video, m_pVideoCaptureFilter,
- NULL, NULL ));
- //16,设置视频预览窗口
- CHK(m_pGraphBuilder.QueryInterface(&m_pVideoWindow));
- ////设置视频播放的WINDOWS窗口
- m_pVideoWindow->put_Owner((OAHWND)hVideoWnd);//把IVideoWindow视频播放窗口赋给hVideoWnd 窗口,在程序退出前一定要记得put_Owner((NULL)
- m_pVideoWindow->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); //输出视频的窗口的属性
- //设置视频尺寸
- GetClientRect(hVideoWnd,&rectVideo); //这个是获得我们做的界面显示窗口的参数的,
- m_pVideoWindow->SetWindowPosition(0,0,rectVideo.Width(),rectVideo.Height()); //设置video输出窗口的位置
- m_pVideoWindow->put_Visible(OATRUE);
- RETAILMSG(1,(TEXT("Width = %d, Height = %d \r\n"),rectVideo.Width(),rectVideo.Height()));
- //17,渲染捕捉PIN, 用于录像
- CHK(m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pVideoCaptureFilter, pVideoEncoder, pASFMultiplexer ));
- //18,创建Still Pin,用于抓图
- CHK(m_pImageSinkFilter.CoCreateInstance(CLSID_IMGSinkFilter));
- CHK(m_pGraphBuilder->AddFilter(m_pImageSinkFilter, L"Still image filter" ));
- CHK(m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_STILL, &MEDIATYPE_Video, m_pVideoCaptureFilter, NULL, m_pImageSinkFilter ));
- //19,设置捕捉流暂停
- CHK(m_pCaptureGraphBuilder->ControlStream( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pVideoCaptureFilter, 0, 0 ,0,0 ));
- IAMStreamConfig* m_pPreviewStreamConfig;
- int iCount,iSize;
- int i;
- m_pCaptureGraphBuilder->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, NULL, IID_IAMStreamConfig, (void **) &m_pPreviewStreamConfig);
- ////获得你的设备所支持的图像大小
- //m_pPreviewStreamConfig->GetNumberOfCapabilities(&iCount, &iSize);
- ////遍历,找到你所需要的大小
- VIDEO_STREAM_CONFIG_CAPS scc;
- //AM_MEDIA_TYPE *m_pamtCaptureStream;
- AM_MEDIA_TYPE * m_pamtPreviewStream;
- m_pPreviewStreamConfig->GetStreamCaps(0, &m_pamtPreviewStream, (BYTE*)&scc);
- m_pPreviewStreamConfig->SetFormat(m_pamtPreviewStream) ;
- //DeleteMediaType(m_pamtCaptureStream);
- //
- //for(i=0; i
- //{
- // // m_pCaptureStreamConfig->GetStreamCaps(i, &m_pamtCaptureStream, (BYTE*)&scc);
- // m_pPreviewStreamConfig->GetStreamCaps(i, &m_pamtCaptureStream, (BYTE*)&scc);
- //if (...)
- //m_pPreviewStreamConfig->SetFormat(m_pamtPreviewStream)
- //DeleteMediaType(m_pamtCaptureStream);
- //}
- //20,预览视频
- CHK(m_pMediaControl->Run());
- Sleep(1000);
- Cleanup:
- //释放接口
- if (pVideoEncoder != NULL)
- {
- pVideoEncoder.Release();
- pVideoEncoder = NULL;
- }
- if (pASFMultiplexer != NULL)
- {
- pASFMultiplexer.Release();
- pASFMultiplexer = NULL;
- }
- if (pFileSinkFilter != NULL)
- {
- pFileSinkFilter.Release();
- pFileSinkFilter = NULL;
- }
- if (pWrapperFilter != NULL)
- {
- pWrapperFilter.Release();
- pWrapperFilter = NULL;
- }
- if( FAILED( hResult ))
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
复制代码
|
|