CBaseObject class

[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The CBaseObject class is an abstract class for implementing DirectShow objects. To implement Component Object Model (COM) objects, use the CUnknown class, which derives from CBaseObject.

Class Methods Description
CBaseObject Constructor method.
~CBaseObject Destructor method.
ObjectsActive Retrieves the count of active objects.

Remarks

Most of the DirectShow base classes derive from CBaseObject. This class provides debugging assistance by keeping a count of all the DirectShow objects active during run time. The object count is stored in a class-static member variable:

class CBaseObject
{
private:
    static LONG m_cObjects;  // Total number of objects active. 
/* ... */
};

In debug builds, the DLL will assert if it is unloaded while the object count is greater than zero. This makes it easier to track down leaks caused by reference-counting problems.

The CBaseObject constructor takes one argument, a debugging name for the object. This name is stored in a global table in the DLL. The DbgDumpObjectRegister function formats a list of the objects active in the DLL, and sends it to the debug output.

Requirements

Requirement Value
Header
Combase.h (include Streams.h)
Library
Strmbase.lib (retail builds);
Strmbasd.lib (debug builds)

See also

DirectShow Base Classes