PDA

View Full Version : Chaning properties of MV Resize during runtime



nfelix
December 12, 2006, 01:59:34
Hi,

I would like to change the properties of the MV Resize Filter during runtime.

the following code results in an errer, most possibly becaus I have to detach the output-pin of MV Resize before I can change the size:

MVResize.IMVResize m_Resize = (MVResize.IMVResize)m_FilterGraph.GetFilter("MV Resize");
m_Resize.OutputWidth = 1024;

Is there a way to detach and reattach pins during runtime? Or is there anything else, I'm doing wrong? Im working in c#, using the MV Smart Control and currently loading the config from a file.

Thanks for any hint!
Felix

Marc Cymontkowski
December 12, 2006, 08:58:21
Hi Felix,

unfortunately it is not possible to change the output dimension at runtime. You have to reload the MVP file and set the desired output dimension in the Smart Controls OnOutputPinConnected event.


Best Regards,

Marc Cymontkowski

Aaron Torpy
December 13, 2006, 01:33:06
Hi Felix,

You can connect pins at runtime, with the graph stopped, using the Connect method of the DirectShow IGraphBuilder interface. It takes as arguments two IPins. You'll have to make sure that all of the affected filters are disconnected beforehand, as you can't change the media type/size of a connected pin pair.

I'm not sure if you're using IGraphBuilder, but if you're not, you can build your entire graph manually by calling CoCreateInstance to make your filters and then IGraphBuilder::AddFilter to insert them into the DirectShow graph. You can also load graphs from .grf files (editable in graphedt.exe) using code such as that below (pulled from MSDN (http://msdn2.microsoft.com/en-us/library/ms787251.aspx)):



HRESULT LoadGraphFile(IGraphBuilder *pGraph, const WCHAR* wszName) {
IStorage *pStorage = 0;
if (S_OK != StgIsStorageFile(wszName)) {
return E_FAIL;
}
HRESULT hr = StgOpenStorage(wszName, 0,
STGM_TRANSACTED | STGM_READ | STGM_SHARE_DENY_WRITE,
0, 0, &pStorage);
if (FAILED(hr)) {
return hr;
}
IPersistStream *pPersistStream = 0;
hr = pGraph->QueryInterface(IID_IPersistStream,
reinterpret_cast<void**>(&pPersistStream));
if (SUCCEEDED(hr)) {
IStream *pStream = 0;
hr = pStorage->OpenStream(L"ActiveMovieGraph", 0,
STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);
if(SUCCEEDED(hr)) {
hr = pPersistStream->Load(pStream);
pStream->Release();
}
pPersistStream->Release();
}
pStorage->Release();
return hr;
}


Cheers,
Aaron.