Re: Filters\Async sample with WMA?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Alessandro Angeli [MVP::DigitalMedia] (nobody_at_nowhere.in.the.net)
Date: 09/29/04


Date: Wed, 29 Sep 2004 22:11:51 +0200

Ryan Melville wrote:

> The DirectX 9.0 SDK includes an "Async" sample in
> Samples\C++\DirectShow\Filteres that can play from a
> memory byte stream instead of from a file. This is
> terrific, but the sample only includes some video formats
> and WAV. Adding MP3 support wasn't hard - just added
> MEDIATYPE_Stream/MEDIASUBTYPE_MPEG1Audio.

Adding support for (almost) any file type is quite easy
since the media type is always stream, the format is always
null and you only need to guess at the subtype. I did it
with an hardcoded lookup table containing
<extension,subtype> pairs. You can even do it the same way
the stock file source filter does using the registry (but it
requires some work).

> Adding WMA support is proving more difficult. Either I
> don't know the correct meda/sub types or there is a trick
> I'm missing. DirectShow cannot render the output pin of
> the filter... Depending on what I try I get
> VFW_E_CANNOT_RENDER or VFW_E_INVALIDMEDIATYPE.

All the stream sources, both the stock file and URL sources
and the async sample, are simply data readers and know
nothing about the stream format. Thus they require a
parser/splitter filter downstream that reads the data from
them in pull mode and actually does the parsing. DirectShow
includes splitters for MPEG1, MPEG2, WAV, AVI... but not ASF
(WMA is an audio-only ASF). The only ASF parser is embedded
in the 2 WindowsMedia source filters and can not be used in
any way as a generic splitter.

> I need to play from a memory location and not a file
> system file. If anyone has some suggestions or knows how
> to play a WMA through the Async sample I would appreciate
> the help!

You need to write your own ASF splitter filter either using
the synchronous WMReader object with an IStream data source
(it is not the easiest of things but it's not that hard
either - Jeremey here did it not long ago IIRC) or parsing
the ASF yourself (ASF is documented but it is quite
difficult to parse). Otherwise, you can hack the WMASFReader
source filter to make it read from an IStream: the hack is
very easy to implement using the Detours library from MSR,
but if you are going to redistribute your application
commercially you'll break the license and it may even be
illegal to distribute a hack.

-- 
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net


Relevant Pages

  • Re: compressed samples in a source filter?
    ... I presume for some reason you are parsing an ASF format stream ... rather than using one of the ASF source filter that come with DS. ... I believe it is possible to pass a stream into one of the DS ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: compressed samples in a source filter?
    ... I presume for some reason you are parsing an ASF format stream ... rather than using one of the ASF source filter that come with DS. ... I believe it is possible to pass a stream into one of the DS ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Is there a way to create ASF MJPEG formatted file?
    ... > for video capture. ... > images to a file that has the ability to stream it to Windows Media player. ... > I have done this with AVI file format, ... ASF ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: Can not start playing video wherever I want in an ASF file being b
    ... > WMFormat v9.5 SDK), it is impossible to start playing ... > of the ASF format? ... I have only one stream, ...
    (microsoft.public.windowsmedia.sdk)
  • CAsfMuxFilter audio/video sync problem
    ... Back here again after a few more days of investigating ASF streaming ... same when the stream is rendered to a file. ... when I add both audio and video input to the Asf ... So it seems like there is a problem in the ASF mux filter, ...
    (microsoft.public.win32.programmer.directx.video)