Directly Accessing the DirectShow Compression Filters

Direct access to the underlying DirectShow audio and video compression filters can be accomplished through the IltmmObjectWrapper interface. This allows the user to programmatically manipulate the individual compressor’s properties. Please consult the individual compression filter’s documentation to determine the capabilities of that filter.

For example, let’s assume that you have selected a particular compressor Also known as an encoder Also known as compressor, this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder., this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder Also known as a decompressor, this is a module or algorithm to decompress data.. into the ltmmConvert object

1.

The first step would be to obtain the video compressor’s collection from the ltmmConvert object using the following code:

IltmmCompressors* pCompressors;

convert->get_VideoCompressors(&pCompressors); // get the  video compressor collection

2.

Next, you would get the selected compressor:

IltmmCompressor* pCompressor;

long index;

pCompressors->get_Selection (&index);  // get the index of the selected compressor

pCompressors->Item(index, &pCompressor); // get the compressor

pCompressors->Release();  // don’t need the collection anymore

3.

Now, you can obtain the IltmmObjectWrapper interface:

IltmmObjectWrapper* pWrapper;
pCompressor->QueryInterface(IID_IltmmObjectWrapper, (void**) &pWrapper); // get the wrapper interface
pCompressor->Release();  // don’t need this anymore

4.

And finally, you can get the underlying DirectShow filter:

IUnknown* pObject;
pWrapper->GetWrappedObject(&pObject); // get the DirectShow filter
pWrapper->Release();  // don’t need this anymore

pObject now contains the IUnknown interface pointer to the filter. You can access all of the interfaces that the compressor implements through this interface pointer.