Jump to content
  • Advertisement
Sign in to follow this  
Sawsan Emam

IMediaControl does not run

This topic is 3630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi everyone, i hope you are all OK, i have tried to build a graph to texture render a video but the graph's output was just a while screen ... after long time debugging i found out that the IMediaControl's run function does not return S_OK here's the code that i use .. i hope that someone could find what's the problem is : HRESULT PlayVideoOnTexture() { HRESULT hr = S_OK; CComPtr<IBaseFilter> pFTR=NULL; CComPtr<IPin> pFTRPinIn=NULL; CComPtr<IBaseFilter> pFSrc=NULL; CComPtr<IPin> pFSrcPinOut=NULL; CTextureRenderer *pCTR=NULL; JIF(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_SERVER, IID_IGraphBuilder, (void **) & g_pGB)); if(FAILED (hr)) { //Release all filters //Display Error } pCTR = new CTextureRenderer(NULL, &hr); if(FAILED(hr)) { //Release all filters //Display Error } pCTR->m_pd3dDevice = m_pd3dDevice; pFTR = pCTR; if(FAILED( hr = g_pGB->AddFilter(pFTR, L"TEXTURERENDERER"))) { //release all the filters //Display Error } WCHAR wFile[] = L"c:\\data\\temp.avi"; if(FAILED( hr = g_pGB->AddSourceFilter(wFile, L"SOURCE", &pFSrc))) { //release all filters //Display Error } if(FAILED(hr = pFTR->FindPin(L"In", &pFTRPinIn))) { //release filters //Display Error } if (FAILED(hr = pFSrc->FindPin(L"Output", &pFSrcPinOut))) { //release all filters //Display Error } if (FAILED(hr = g_pGB->Connect(pFSrcPinOut, pFTRPinIn))) { //release all the filters //Display Error } // Clean Up all filters if(pFTR != NULL) pFTR.Release(); if(pFTR != NULL) pFTR.Release(); if(pFSrc != NULL) pFSrc.Release(); if(pFTRPinIn != NULL) pFTRPinIn.Release(); // End of the Graph JIF(g_pGB->QueryInterface(IID_IMediaControl, (void **)&g_pMC)); if(FAILED(hr = g_pMC->Run())) { MessageBox(NULL, "Unable to run the Graph", "NULL", MB_OK); return E_FAIL; } return hr; } Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Sawsan Emam
after long time debugging i found out that the IMediaControl's run function does not return S_OK
Ok... so what does it return? You can look the error code up in the Error Lookup tool (View it as a 8-digit hex number, e.g. 0x80004005).

Share this post


Link to post
Share on other sites
Quote:
Original post by Sawsan Emam
it returns S_FALSE
According to the Documentation, S_FALSE (Which is a success code) means:
Quote:
The graph is preparing to run, but some filters have not completed the transition to a running state.

[snip]

If the return value is S_FALSE, you can wait for the transition to complete by calling the IMediaControl::GetState method. If the method fails, some filters might be in a running state. In a multistream graph, entire streams might be playing successfully. The application must determine whether to stop the graph.

Share this post


Link to post
Share on other sites
the IMediaControl->getState returns State_Running which means that the graph is supposed to be running but it give just white screen ...

so any idea why it gives this white screen :S?

Thanks in Advance,

P.S: here's the code i tried to know which state it return:

hr = g_pMC->Run();
if(hr != S_OK)
{
FILTER_STATE fs;
hr = g_pMC->GetState(1000, (OAFilterState*)&fs);
switch (fs)
{
case State_Stopped:
MessageBox(NULL, "Graph Stopped", "Info", MB_OK);
break;
case State_Paused:
MessageBox(NULL, "Graph Paused", "Info", MB_OK);
break;
case State_Running:
MessageBox(NULL, "Graph Running", "Info", MB_OK);
break;
}
}

Share this post


Link to post
Share on other sites
Your given code look like from DShowSDK's Texture3D9 example. In example where to cylinder shape drawing (texture.cpp) above texture variable defined on top. In CTextureRenderer class's DoRenderSample(...) function use same variable for copying IMediaSample bitmap buffer to g_pTexture.

LPDIRECT3DTEXTURE9 g_pTexture = NULL; // Our texture


Relationship is like above and you need to build same.


-Texture.cpp-
LPDIRECT3DTEXTURE9 g_pTexture = NULL; // Our texture

Render(){
lpDevice->SetTexture(g_pTexture)
//draw mesh
}

-Texture.h-
extern LPDIRECT3DTEXTURE9 g_pTexture;


-DShowTextures.cpp-
#include "Textures.h"


HRESULT CTextureRenderer::DoRenderSample( IMediaSample * pSample )
{

BYTE *pBmpBuffer, *pTxtBuffer; // Bitmap buffer, texture buffer
LONG lTxtPitch; // Pitch of bitmap, texture

BYTE * pbS = NULL;
DWORD * pdwS = NULL;
DWORD * pdwD = NULL;
UINT row, col, dwordWidth;

CheckPointer(pSample,E_POINTER);
CheckPointer(g_pTexture,E_UNEXPECTED);

// Get the video bitmap buffer
pSample->GetPointer( &pBmpBuffer );

// Lock the Texture
D3DLOCKED_RECT d3dlr;
if( m_bUseDynamicTextures )
{
if( FAILED(g_pTexture->LockRect(0, &d3dlr, 0, D3DLOCK_DISCARD)))
return E_FAIL;
}
else
{
if (FAILED(g_pTexture->LockRect(0, &d3dlr, 0, 0)))
return E_FAIL;
}
// Get the texture buffer & pitch
pTxtBuffer = (byte *)d3dlr.pBits;
lTxtPitch = d3dlr.Pitch;
...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!