change avi source files in real-time




this is just texture3d9 sample.

this sample loads "wFileName" and play it.

I guess
" hr = g_pGB->AddSourceFilter (wFileName, L"SOURCE", &pFSrc); "
this is loading part.

I have a question now.

I want to stop current AVI and want to load new AVI file.
and play it.

where should I modifty in this source code ?

and another question is
if I want to play 7 avi files sequently ,
if I make 7 g_pGB instances and play it, it have problem ?


HRESULT InitDShowTextureRenderer()
{
HRESULT hr = S_OK;
CComPtr<IBaseFilter> pFSrc; // Source Filter
CComPtr<IPin> pFSrcPinOut; // Source Filter Output Pin
CTextureRenderer *pCTR=0; // DirectShow Texture renderer

// Create the filter graph
if (FAILED(g_pGB.CoCreateInstance(CLSID_FilterGraph, NULL,
CLSCTX_INPROC)))
return E_FAIL;

#ifdef REGISTER_FILTERGRAPH
// Register the graph in the Running Object Table (for debug purposes)
AddToROT(g_pGB);
#endif

// Create the Texture Renderer object
pCTR = new CTextureRenderer(NULL, &hr);
if (FAILED(hr) || !pCTR)
{
Msg(TEXT("Could not create texture renderer object! hr=0x%x"), hr);
return E_FAIL;
}

// Get a pointer to the IBaseFilter on the TextureRenderer, add it to
graph
g_pRenderer = pCTR;
if (FAILED(hr = g_pGB->AddFilter(g_pRenderer, L"TEXTURERENDERER")))
{
Msg(TEXT("Could not add renderer filter to graph! hr=0x%x"), hr);
return hr;
}

// Determine the file to load based on DirectX Media path (from SDK)
// Use a helper function included in DXUtils.cpp
TCHAR strFileName[MAX_PATH] = {NULL,};
WCHAR wFileName[MAX_PATH] = {NULL,};


//lstrcpyn( strFileName, DXUtil_GetDXSDKMediaPath(), MAX_PATH-1 );
//lstrcat( strFileName, SOURCE_FILE );
lstrcpy( strFileName, SOURCE_FILE );
strFileName[MAX_PATH-1] = 0; // NULL-terminate
wFileName[MAX_PATH-1] = 0; // NULL-terminate

USES_CONVERSION;
wcsncpy(wFileName, T2W(strFileName), NUMELMS(wFileName));

// Add the source filter to the graph.
hr = g_pGB->AddSourceFilter (wFileName, L"SOURCE", &pFSrc);

// If the media file was not found, inform the user.
if (hr == VFW_E_NOT_FOUND)
{
Msg(TEXT("Could not add source filter to graph!
(hr==VFW_E_NOT_FOUND)\r\n\r\n")
TEXT("This sample reads a media file from the DirectX SDK's
media path.\r\n")
TEXT("Please install the DirectX 9 SDK on this machine."));
return hr;
}
else if(FAILED(hr))
{
Msg(TEXT("Could not add source filter to graph! hr=0x%x"), hr);
return hr;
}

if (FAILED(hr = pFSrc->FindPin(L"Output", &pFSrcPinOut)))
{
Msg(TEXT("Could not find output pin! hr=0x%x"), hr);
return hr;
}

#ifdef NO_AUDIO_RENDERER

// If no audio component is desired, directly connect the two video pins
// instead of allowing the Filter Graph Manager to render all pins.

CComPtr<IPin> pFTRPinIn; // Texture Renderer Input Pin

// Find the source's output pin and the renderer's input pin
if (FAILED(hr = pFTR->FindPin(L"In", &pFTRPinIn)))
{
Msg(TEXT("Could not find input pin! hr=0x%x"), hr);
return hr;
}

// Connect these two filters
if (FAILED(hr = g_pGB->Connect(pFSrcPinOut, pFTRPinIn)))
{
Msg(TEXT("Could not connect pins! hr=0x%x"), hr);
return hr;
}

#else

// Render the source filter's output pin. The Filter Graph Manager
// will connect the video stream to the loaded CTextureRenderer
// and will load and connect an audio renderer (if needed).

if (FAILED(hr = g_pGB->Render(pFSrcPinOut)))
{
Msg(TEXT("Could not render source output pin! hr=0x%x"), hr);
return hr;
}

#endif

// Get the graph's media control, event & position interfaces
g_pGB.QueryInterface(&g_pMC);
g_pGB.QueryInterface(&g_pMP);
g_pGB.QueryInterface(&g_pME);

// Start the graph running;
if (FAILED(hr = g_pMC->Run()))
{
Msg(TEXT("Could not run the DirectShow graph! hr=0x%x"), hr);
return hr;
}


return S_OK;
}


.



Relevant Pages

  • Re: help with design - reload image on image load; avoid infinite loop
    ... to the graph image. ... Just remove the event listener ... It depends on the DOM which elements support the `load' event, ... and which DOM objects may also support the proprietary `onload' ...
    (comp.lang.javascript)
  • IMediaControl and IMediaSeeking issues
    ... Immediately after building the graph, I set the rectangles for the ... IMediaSeeking::SetPositionsto position the video at some random ... When the WM_CREATE handler returns and the window becomes visible, ... I added a menu with Play and Stop. ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Media Conversion.
    ... the clip doesn't reach the end, stopping just a few seconds before. ... Also, when I attempt to play it in VLC, the clip plays all the way ... exit (and I think that Stop is not called on the graph prior to exit). ...
    (microsoft.public.win32.programmer.directx.video)
  • more then one instace of MPEG Layer-3 Audio Compression in the same application
    ... are in the same Filter Graph then when I run the graph 0x80070057 (The ... - When second instance of the MPEG Layer-3 Audio Compression filter is in ... the different Filter Graph then when I ...
    (microsoft.public.win32.programmer.directx.video)
  • How to play clips back to back using VMR?
    ... I was thinking about having 2 graphs: play and cue. ... The cue graph will ... visible artefacts. ... I think I could grab the last frame of the play graph ...
    (microsoft.public.win32.programmer.directx.video)