[directshow - directdraw - c++]how to retrieve primary directdraw surface?

Started by
10 comments, last by TANSTAAFL 16 years, 7 months ago
hi I am using the IDirectDrawVideo interface of the Video Renderer Filter. Thanks to GetDirectDraw method I can retrieve the DIRECTDRAW object (the video renderer filter is connected to a source). Then to retrieve the primary directdraw I used IDirectDrawVideo::GetSurfaceDesc that should give me surface descriptor which has lpSurface pointer to the DirectDraw surface but the pointer is NULL. So I tried to retrieve IDirectDrawVideo after paused the graph ( as it said in doc : "Surfaces are allocated only when the renderer is paused") then the surfaceType is equals to AMDDS_YUVFLP and dwWidth and dwHeight of the surfaceDesc are correct : 320 * 240 (and that is the size of my capture source) But lpSurface is still NULL. What's wrong? thx
Advertisement
arf I cant understand why the size is correct and the lpSurface pointer is still null
any idea?
anyone already try it?
I'm just getting into DirectShow too, so this would be a good learning experience for me as well.

From the looks of IDirectDrawVideo::GetSurfaceDesc(), it needs the address of a structure to be filled. You said that "the pointer is NULL" which makes me wonder if you're passing in a pointer of type DDSURFACEDESC instead of passing the address of a DDSURFACEDESC structure like you should. If that's not the case, are you making sure to set the dwSize member of the structure before you pass it in?

Beyond that, I don't know what the error could be without seeing some code first. However, I recommend that you look through the DirectShow sample files to see how they set up code to do something similar to what you want.
first thx for helping me.

I am so confused, i did not see in documentation: "dwSize: Size of the structure. Must be initialized prior to use."

So I tried to initialized it :
DDSURFACEDESC surfaceDesc ;surfaceDesc.dwSize = sizeof(DDSURFACEDESC) ;IDirectDrawVideo* m_pdd ;m_pdd->GetSurfaceDesc(&surfaceDesc) ;


Then I print properties's with cout, and i got :

surfaceDesc.dwSize: 108 (dot not know if it is correct)
surfaceDesc.dwWidth: 320 (good, correct)
surfaceDesc.dwHeight: 240 (good, correct)
surfaceDesc.dwBackBufferCount: 0 (dot not know if it is correct)
surfaceDesc.dwFlags: 4111 (dot not know if it is correct)
surfaceDesc.lpSurface: NULL (BAD, why still NULL ?)

any idea ? what could I try ?

thx




Hmm... I'm not really sure. Here's what the DirectX documentation says about GetSurfaceDesc()

Quote:Return Values

Returns an HRESULT value. If no surface has been allocated, this method will return E_FAIL. If a DCI primary surface is in use, the DDSURFACEDESC structure will not be filled in and the call will return S_FALSE.

Remarks

Surfaces are allocated only when the renderer is paused. After the renderer has been paused, it cannot release the surfaces when stopped.
Check the HRESULT of the function to see if it's failing.
yeah sure I already checked and all result are equals to S_OK, but I did not write "hr =" and "if (FAILED(hr))" in this forum because it takes a lot of lines. And you right about pause the graph, but I did not write into this forum for same reasons.

--------------------------
...
IBaseFilter *m_pVideoRenderer;
CoCreateInstance(CLSID_VideoRenderer, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&m_pVideoRenderer);
m_pVideoRenderer->QueryInterface(IID_IDirectDrawVideo, (LPVOID *) &m_pdd);
...
m_g_pGraph->QueryInterface(IID_IMediaControl,(LPVOID *) &m_g_pMC);
...
m_g_pMC->Run() ;
...
...
...
m_g_pMC->Pause() ;
DDSURFACEDESC surfaceDesc ;
ZeroMemory(&surfaceDesc, sizeof(surfaceDesc));
surfaceDesc.dwSize = sizeof(surfaceDesc);
IDirectDrawVideo* m_pdd ;
m_pdd->GetSurfaceDesc(&surfaceDesc) ;
--------------------------

-> all result are OK

then after printing, there is:

surfaceDesc.dwSize: 108
surfaceDesc.dwWidth: 320
surfaceDesc.dwHeight: 240
surfaceDesc.dwBackBufferCount: 0
surfaceDesc.dwFlags: 4111
surfaceDesc.lpSurface: NULL


An other idea ?

[Edited by - CaptainL on September 10, 2007 6:44:26 AM]
Did someone already test it ? ( to retrieve primary directdraw surface from Video Renderer Filter )
?

This topic is closed to new replies.

Advertisement