Answered by:
How to add a filter in a graph
Question
-
Hi
i wrote a simple transform filter to rotate 180 degree and checked its functionality in graphedit.
Now i want to add this filter in my application where i play a media file.
In my application i do a RenderFile and then Run to play the file.
Now how do i add my transform filter in the existing application??
Can a filter be added when a graph is in run state because i want to rotate the video while it is playing.Tuesday, September 2, 2008 9:40 AM
Answers
-
neo1# wrote: > First of all you need to check if your DLL is successfully registered with regsvr32.
it must be otherwise i wont be able to use it in graphedit right??
Check registry at "HKEY_CLASSES_ROOT\CLSID\<your-CLSID-here>\InprocServer32" where you need to have default value having full path to your DLL + ThreadingModel "Both" value.->[HKEY_CLASSES_ROOT\CLSID\{083863F1-70DE-11d0-BD40-00A0C911CE86}\Instance\{C308036D-A147-4B3A-8074-1E8B8CB1CE21}] "FriendlyName"="Image Effects (EZRGB24)" "CLSID"="{C308036D-A147-4B3A-8074-1E8B8CB1CE21}" "FilterData"=hex:02,00,00,00,00,00,20,00,02,00,00,00,00,00,00,00,30,70,69,33,\ 00,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,00,00,00,00,30,74,79,33,00,\ 00,00,00,60,00,00,00,70,00,00,00,31,70,69,33,08,00,00,00,00,00,00,00,01,00,\ 00,00,00,00,00,00,00,00,00,00,30,74,79,33,00,00,00,00,60,00,00,00,70,00,00,\ 00,76,69,64,73,00,00,10,00,80,00,00,aa,00,38,9b,71,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00 @=""Defalt value is not set and also no entry called ThreadingModel .But i see them under HKEY_CLASSES_ROOT\CLSID\{083863F1-70DE-11d0-BD40-00A0C911CE86}\InprocServer32default - c:\windows\system32\devenum.dll and ThreadingModel as "both".
> it must be otherwise i wont be able to use it in graphedit right??
Yes and no. This registry data is not used in CoCreateInstance.
You need to check HKEY_CLASSES_ROOT\CLSID\{C308036D-A147-4B3A-8074-1E8B8CB1CE21}
Can you still use your filter in GraphEdit?Friday, September 5, 2008 11:00 AM
All replies
-
You need to create your filter and add it to the graph before doing the RenderFile, so that (if you did program it correctly) it will be inserted at the correct place in the graph. Then you do Run().
Tuesday, September 2, 2008 12:57 PM -
Actually you have several options. Yes you anyway need to add your filter to the graph manually as suggested by Michel.
Then you can:
- Instead of IGraphBuilder:: RenderFile call IGraphBuilder:: AddSourceFilter to only auto-add first filter for the sourec file. After that use IGraphBuilder::Connect (or ICaptureGraphBuilder:: RenderStream) where you can provide your filter (filter's pin) interface to engage it into rendering explicitly
- You can still IGraphBuilder:: RenderFile but before Run'ning break the connection using IFilterGraph:: Disconnect and re-connect pins through your filter at the point of interest
Tuesday, September 2, 2008 1:35 PM -
Hi
ok so we need to build the graph before we run it...
but my requirement is to rotate it once it has started playing ...how do we achieve that??Tuesday, September 2, 2008 3:02 PM -
Insert your filter well in advance, that is before running graph, but have its default mode to pass samples through without rotating. When you need to start rotating, notify your filter on this and have it start processing samples rotating the data.Tuesday, September 2, 2008 3:28 PM
-
Do you mean : play normally, and at a given time, while playing, rotate the image?
If this is the case, then you need to make your filter a little more flexible, with two modes : passthrough (no rotation) and rotate.
Implement an interface on your filter, so that you can switch it from passthrough mode to rotate mode when needed.
(See the EZRGB24 sample on how to implement a simple interface).
Tuesday, September 2, 2008 3:32 PM -
Hii am trying to add the filter in my application byCoCreateInstance(CLSID_Rotate, NULL,CLSCTX_INPROC_SERVER, IID_IBaseFilter,(void **)&mytransform);and then AddFilter.But it gave error 'CLSID_Rotate' : undeclared identifier.Then i declared CLSID_Rotate in my file asDEFINE_GUID(CLSID_Rotate ,0x8B498501,0X1218,0X11CF,0XAD,0XC4,0X00,0XA0,0XD1,0X00,0X04,0X1B);Same definition is in my Filter.Now it gave some link error: error LNK2001: unresolved external symbol CLSID_Rotate .Where am i doing wrong ?? How do i include my filter in my application???Thursday, September 4, 2008 1:14 PM
-
neo1# wrote: ... Then i declared CLSID_Rotate in my file asDEFINE_GUID(CLSID_Rotate ,0x8B498501,0X1218,0X11CF,);Same definition is in my Filter.Now it gave some link error: error LNK2001: unresolved external symbol CLSID_Rotate .
static const CLSID CLSID_Rotate = { 0x8B498501,0X1218,0X11CF, { 0XAD,0XC4,0X00,0XA0,0XD1,0X00,0X04,0X1B } };
HRESULT nResult = CoCreateInstance(CLSID_Rotate, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter,(void **)&mytransform);Thursday, September 4, 2008 1:41 PM -
Hiyour above solution solved my link error.But when i run my code now it fails atHRESULT nResult = CoCreateInstance(CLSID_Rotate, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter,(void **)&mytransform);withnResult = {Class not registered}.I thought that there might be something wrong in my filter so i build the EZRGB24 filter under directshow samples.i registered it through regsrv32 and it showed up in GraphEdit under Directshow filters as "Image Effects (EZRGB24)"i tested it and it worked fine.Now i tried to include it in my file bystatic const CLSID CLSID_EZrgb24 = { 0x8B498501,0X1218,0X11CF, { 0XAD,0XC4,.....}hr = CoCreateInstance(CLSID_EZrgb24, NULL,CLSCTX_INPROC_SERVER, IID_IBaseFilter,(void **)&mytransform);But still it fails here giving the same error {class not registered}.Can you please help me on this??Friday, September 5, 2008 5:08 AM
-
I think you are provising wrong CLSID. Open GraphEdit, Insert Filters and find your filter in the list, you will see Filter Moniker something like: @device: sw: {083863F1-70DE-11D0-BD40-00A0C911CE86}\{FADCD667-FFB1-4344-8FE4-7666F58F9BDA}
The final part of the moniker is your CLSID ({FADCD667-FFB1-4344-8FE4-7666F58F9BDA}) make sure you are using it in your code and it matches registration information.
If this is OK but the filter still does not start, try re-registering filter dll with OS using regsvr32. Is it worth mentioning that all UUIDs (CLSID, IID, LIBID etc) should be unique? I see your CLSID_Rotate and CLSID_EZrgb24 in the code snippets above are equal, are they equal in your code? If so, this is a mistake. You need to create new GUIDs (see GUIDGEN utility, e.g. C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\guidgen.exe) so that all GUIDs through your projects are unique.Friday, September 5, 2008 5:39 AM -
HiSorry i did not provide full details in the last posti created new CLSID for EZRGB24 and added it to ezuids.h of EZRGB project.
// {C308036D-A147-4b3a-8074-1E8B8CB1CE21}static const GUID CLSID_EZrgb24 ={ 0xc308036d, 0xa147, 0x4b3a, { 0x80, 0x74, 0x1e, 0x8b, 0x8c, 0xb1, 0xce, 0x21 } };then i build it and registered it.i can see it in grapheditImage Effects (EZRGB24)-@device
w:{083863F1-70DE-11D0-BD40-00A0C911CE86}\{C308036D-A147-4B3A-8074-1E8B8CB1CE21}-{C308036D-A147-4B3A-8074-1E8B8CB1CE21}-C:\Program Files\Microsoft SDKs\Windows\v6.1\Samples\Multimedia\DirectShow\Filters\EZRGB24\Release\EZRGB.dllthen i tried to add the filter in my application asstatic const CLSID CLSID_EZrgb24 = { 0xc308036d, 0xa147, 0x4b3a, { 0x80, 0x74, 0x1e, 0x8b, 0x8c, 0xb1, 0xce, 0x21 } };IBaseFilter *mytransform;hr = CoCreateInstance(CLSID_EZrgb24, NULL,CLSCTX_INPROC_SERVER, IID_IBaseFilter,(void **)&mytransform);m_pGraph->AddFilter(mytransform,L"Image Effects (EZRGB24)");But the return code i get here is hr ={class not registered}can you please help on this??Friday, September 5, 2008 7:05 AM -
If you are having REGDB_E_CLASSNOTREG with CoCreateInstance, the problem is outside DirectShow and is related to COM.
First of all you need to check if your DLL is successfully registered with regsvr32.
Do you have any dependent DLLs referenced from your DLL which are not on default search path?
Check registry at "HKEY_CLASSES_ROOT\CLSID\<your-CLSID-here>\InprocServer32" where you need to have default value having full path to your DLL + ThreadingModel "Both" value.
I think you will have a problem with any of the three mentioned above.Friday, September 5, 2008 8:57 AM -
First of all you need to check if your DLL is successfully registered with regsvr32.Code Snippet
-> it must be otherwise i wont be able to use it in graphedit right??
Do you have any dependent DLLs referenced from your DLL which are not on default search path?
-> NoCheck registry at "HKEY_CLASSES_ROOT\CLSID\<your-CLSID-here>\InprocServer32" where you need to have default value having full path to your DLL + ThreadingModel "Both" value.->[HKEY_CLASSES_ROOT\CLSID\{083863F1-70DE-11d0-BD40-00A0C911CE86}\Instance\{C308036D-A147-4B3A-8074-1E8B8CB1CE21}] "FriendlyName"="Image Effects (EZRGB24)" "CLSID"="{C308036D-A147-4B3A-8074-1E8B8CB1CE21}" "FilterData"=hex:02,00,00,00,00,00,20,00,02,00,00,00,00,00,00,00,30,70,69,33,\ 00,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,00,00,00,00,30,74,79,33,00,\ 00,00,00,60,00,00,00,70,00,00,00,31,70,69,33,08,00,00,00,00,00,00,00,01,00,\ 00,00,00,00,00,00,00,00,00,00,30,74,79,33,00,00,00,00,60,00,00,00,70,00,00,\ 00,76,69,64,73,00,00,10,00,80,00,00,aa,00,38,9b,71,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00 @=""Defalt value is not set and also no entry called ThreadingModel .But i see them under HKEY_CLASSES_ROOT\CLSID\{083863F1-70DE-11d0-BD40-00A0C911CE86}\InprocServer32default - c:\windows\system32\devenum.dll and ThreadingModel as "both".Friday, September 5, 2008 10:26 AM -
neo1# wrote: > First of all you need to check if your DLL is successfully registered with regsvr32.
it must be otherwise i wont be able to use it in graphedit right??
Check registry at "HKEY_CLASSES_ROOT\CLSID\<your-CLSID-here>\InprocServer32" where you need to have default value having full path to your DLL + ThreadingModel "Both" value.->[HKEY_CLASSES_ROOT\CLSID\{083863F1-70DE-11d0-BD40-00A0C911CE86}\Instance\{C308036D-A147-4B3A-8074-1E8B8CB1CE21}] "FriendlyName"="Image Effects (EZRGB24)" "CLSID"="{C308036D-A147-4B3A-8074-1E8B8CB1CE21}" "FilterData"=hex:02,00,00,00,00,00,20,00,02,00,00,00,00,00,00,00,30,70,69,33,\ 00,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,00,00,00,00,30,74,79,33,00,\ 00,00,00,60,00,00,00,70,00,00,00,31,70,69,33,08,00,00,00,00,00,00,00,01,00,\ 00,00,00,00,00,00,00,00,00,00,30,74,79,33,00,00,00,00,60,00,00,00,70,00,00,\ 00,76,69,64,73,00,00,10,00,80,00,00,aa,00,38,9b,71,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00 @=""Defalt value is not set and also no entry called ThreadingModel .But i see them under HKEY_CLASSES_ROOT\CLSID\{083863F1-70DE-11d0-BD40-00A0C911CE86}\InprocServer32default - c:\windows\system32\devenum.dll and ThreadingModel as "both".
> it must be otherwise i wont be able to use it in graphedit right??
Yes and no. This registry data is not used in CoCreateInstance.
You need to check HKEY_CLASSES_ROOT\CLSID\{C308036D-A147-4B3A-8074-1E8B8CB1CE21}
Can you still use your filter in GraphEdit?Friday, September 5, 2008 11:00 AM -
i checked it...it seems to be correct[HKEY_CLASSES_ROOT\CLSID\{C308036D-A147-4B3A-8074-1E8B8CB1CE21}\InprocServer32]@="C:\\Program Files\\Microsoft SDKs\\Windows\\v6.1\\Samples\\Multimedia\\DirectShow\\Filters\\EZRGB24\\Release\\EZRGB24.dll""ThreadingModel"="Both"Ya i can use the filter in the graphedit, but unable to add it in my application.Friday, September 5, 2008 12:48 PM
-
Hiit finally worked.There was something wrong with the clsid.i regenerated the clsid and followed the above procedure and it worked fine.Thanks,satyamSaturday, September 6, 2008 10:41 AM