Using Custom Sinks
[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
If you have a special writing need, you can create your own writer sinks. The writer maintains one-way communication with a sink by making calls to the methods of IWMWriterSink. To create your own sink, implement the IWMWriterSink interface in a class in your application. This process is very similar to implementing any other callback interface used by the objects of the Windows Media Format SDK. For more information about callbacks, see Using the Callback Methods.
The buffer received in IWMWriterSink::OnHeader should be written to the beginning of the file, and all buffers received in OnDataUnit should be written out sequentially. OnHeader will be called at the beginning but might be called at other times, too, and if it is, you should, if possible, overwrite the original header. If your application is not able to do this for some reason, then simply ignore the subsequent OnHeader calls.
Your custom sink should communicate its status to your writing application by making calls to the IWMStatusCallback::OnStatus callback method. If you implement your sink as a COM object, you may want to expose the IWMRegisterCallback interface. However, you can pass the address of the OnStatus callback to your sink and set a context in any way you like.
Related topics