0

I have written a push source filter that I use privately in my Delphi 6 application. The application uses the DSPACK DirectShow component library. By privately I mean I simply add instances of the filter directly to my Filter Graph, instead of the filter residing in an external DLL (.ax file).

Should I create a unique class ID (GUID) for each instance of the Filter I create, or is it safe to use the same class ID between all instances created? I am concerned about this because each instance of the Filter creates a local data storage object for holding data queued for the Filter. The local data storage object is written to by other code within the host application thereby pushing data into into the Filter Graph via my push source filter .

I don't now enough about DirectShow to know how method pointers lookups are done to know if my design is safe. When I add an instance of a Filter to a graph directly, does DirectShow store the interface method pointers the Filter Graph will call by object reference, or by the class ID? If it's the former then everything will be fine, but if it's the latter, then that could be a problem if the same instance gets all the method calls. Does anyone know the answer to this design question?

Robert Oschler
  • 14,153
  • 18
  • 94
  • 227

1 Answers1

2

Class identifier is specific to a class, not to class instance. Your filter class should have its own unique identifier, and all instances of the class would share it on runtime. If you are copying code from another project, you need to make sure you replace all existing CLSID, IID, LIBID identifiers with newly generated ones.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Yes, thanks, I knew that. But if I add multiple instances of my Filter class to the same Filter Graph, will the first instance I create end up getting all the DX calls (FillBuffer(), DecideBufferSize(), etc.), or will the Filter Graph route those calls to the correct class instance, based on the pin connections? – Robert Oschler Nov 01 '11 at 20:28
  • 1
    As soon as filters are instantiated and in the graph, their `CLSID` are only used for persistence purposes (only if it comes as far as to saving state!) so they need to expose the same `CLSID`. The graph distinguishes fitlers by their interface pointers, and it also gives them unique names. – Roman R. Nov 01 '11 at 21:06