Bug-fixing: DirectShow and Flash Player integration

Trying to integrate your DirectShow input filter with Adobe Flash player and can’t get it work? Chances are you started out with Vivek’s sample implementation which features a not-so-trivial omission which causes Chrome to simply refuse playback of the video stream, even though no error is shown. What’s worse is that other DirectShow-dependent applications (Adobe Live Encoder, Skype, VirtualDub, etc.) will continue to work – it seems as if there was something wrong with Flash.. but then other drivers work – how come?

The problem is – as usual – banal 🙂 It’s one of those issues that are difficult to spot but trivial to fix, once you know where to look. In our case, we need to focus at:

HRESULT STDMETHODCALLTYPE CCamMuxerStream::SetFormat(AM_MEDIA_TYPE* media_type_ptr)
{
   IPin* pin_ptr = NULL;

   m_mt = *media_type_ptr;
   
(...)

Easy peasy – the original example does not do a null-pointer check! If you return S_OK whenever media_type_ptr is NULL, things go extra fine! Just like in the gif animation below:

1357589524021

Leave a Reply

Your email address will not be published. Required fields are marked *