locked
How to use a specific media source component RRS feed

  • Question

  • Hi All!

    I am looking for a way of using a specific media source component.

    When I try to play back a WAVE file on the BasicPlayBack sample,
    SourceResolver loads WavSource.dll in order to create a MediaSource component.

    【Question 1】
    In order to create a MediaSource component, how does SourceResolver choose
    which media source dll to be loaded?

    【Question 2】
    Is there any way for our app to specify a media source dll to use?
    Is there any way not to make other apps use such as MERIT_DO_NOT_USE of DShow filter?

    My best regards.

    Thanks.

    Monday, July 31, 2006 3:22 AM

Answers

  • A1. The appropriate DLL, at DllRegisterServer (regsvr32) time, will have put an entry in the registry to associate itself with the extension in question (".wav", in this example).  The registry key in question is at HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsMediaFoundation\ByteStreamHandlers, and each "custom" extension that is handled by a Media Source on the system there will get its own subkey.  Specifically, in this registry key, the DLL writes a CLSID for a class that implements IMFByteStreamHandler and can take a file with the specified extension and create a Media Source that can read it.  The rest is standard COM CoCreate stuff: When the Source Resolver looks up the ".wav" extension in the registry, it finds that CLSID, which it will try to CoCreateInstance, and this will cause the appropriate DLL to be loaded.  Take a look at dllmain.cpp from the WavSource sample for details on how this registration is done.

    A2. There is no analogous "merit" concept in Media Foundation.  For any extensions other than the standard ones that MF handles natively (asf, wma, wmv, mp3), if there's a Media Source on the system to handle it, there will be a subkey at the registry location I mentioned above that points to a CLSID for the appropriate Byte Stream Handler. 

     

    Hope this helps,

    Becky

    Monday, July 31, 2006 3:31 PM
  • The source resolver goes in the following order:

    1. Get a scheme handler 
      • Parse the "scheme" portion of the URL. e.g. "http".
      • Create the scheme handler registered for that scheme, pass it the URL, and get back a byte stream. If there are multiple scheme handlers registered for that scheme, iterate through all of them until one succeeds. The iteration order is undefined (do not rely on any order you see in the implementation)
      • If no scheme handler is registered for this scheme, or if the scheme handlers registered for this scheme do not recognize this URL, iterate through all the registered scheme handlers until one succeeds. The iteration order is undefined.
    2. If the previous step succeeded, you now have a byte stream from that URL. Now get a byte stream handler. The algorithm is similar.
      • Parse the "extension" portion of the URL. e.g. "wav".
      • Create the byte stream handler registered for that scheme, pass it the URL and the byte stream, and get back a media source. If there are multiple byte stream handlers registered for that scheme, iterate through all of them until one succeeds. The iteration order is undefined.
      • If no byte stream handler is registered for this scheme, or if the byte stream handlers registered for this extension do not recognize this URL, iterate through all the registered byte stream handlers until one succeeds. The iteration order is undefined.

    In step 2, the byte stream handler is expected to inspect the byte stream to see if it recognizes it.

    The merit concept in DirectShow was heavily abused. People registered their filter at the highest merit, effectively making it an undefined order between those filters. As a result Media Foundation does not have that concept.

    So to create your own media source you can do the following:

    1. If your application knows the type of content it is handling, you can skip the source resolver and create the media source directly.
    2. If your application does not know the type of content, use the source resolver. If your content is obtained via one of the built-in schemes in Vista (http://, file://), then you need to write only a byte stream handler and register it. If you have your own custom scheme, then you need to additionally write a scheme handler and register that too.

    -Sumedh

    Monday, July 31, 2006 3:33 PM

All replies

  • A1. The appropriate DLL, at DllRegisterServer (regsvr32) time, will have put an entry in the registry to associate itself with the extension in question (".wav", in this example).  The registry key in question is at HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsMediaFoundation\ByteStreamHandlers, and each "custom" extension that is handled by a Media Source on the system there will get its own subkey.  Specifically, in this registry key, the DLL writes a CLSID for a class that implements IMFByteStreamHandler and can take a file with the specified extension and create a Media Source that can read it.  The rest is standard COM CoCreate stuff: When the Source Resolver looks up the ".wav" extension in the registry, it finds that CLSID, which it will try to CoCreateInstance, and this will cause the appropriate DLL to be loaded.  Take a look at dllmain.cpp from the WavSource sample for details on how this registration is done.

    A2. There is no analogous "merit" concept in Media Foundation.  For any extensions other than the standard ones that MF handles natively (asf, wma, wmv, mp3), if there's a Media Source on the system to handle it, there will be a subkey at the registry location I mentioned above that points to a CLSID for the appropriate Byte Stream Handler. 

     

    Hope this helps,

    Becky

    Monday, July 31, 2006 3:31 PM
  • The source resolver goes in the following order:

    1. Get a scheme handler 
      • Parse the "scheme" portion of the URL. e.g. "http".
      • Create the scheme handler registered for that scheme, pass it the URL, and get back a byte stream. If there are multiple scheme handlers registered for that scheme, iterate through all of them until one succeeds. The iteration order is undefined (do not rely on any order you see in the implementation)
      • If no scheme handler is registered for this scheme, or if the scheme handlers registered for this scheme do not recognize this URL, iterate through all the registered scheme handlers until one succeeds. The iteration order is undefined.
    2. If the previous step succeeded, you now have a byte stream from that URL. Now get a byte stream handler. The algorithm is similar.
      • Parse the "extension" portion of the URL. e.g. "wav".
      • Create the byte stream handler registered for that scheme, pass it the URL and the byte stream, and get back a media source. If there are multiple byte stream handlers registered for that scheme, iterate through all of them until one succeeds. The iteration order is undefined.
      • If no byte stream handler is registered for this scheme, or if the byte stream handlers registered for this extension do not recognize this URL, iterate through all the registered byte stream handlers until one succeeds. The iteration order is undefined.

    In step 2, the byte stream handler is expected to inspect the byte stream to see if it recognizes it.

    The merit concept in DirectShow was heavily abused. People registered their filter at the highest merit, effectively making it an undefined order between those filters. As a result Media Foundation does not have that concept.

    So to create your own media source you can do the following:

    1. If your application knows the type of content it is handling, you can skip the source resolver and create the media source directly.
    2. If your application does not know the type of content, use the source resolver. If your content is obtained via one of the built-in schemes in Vista (http://, file://), then you need to write only a byte stream handler and register it. If you have your own custom scheme, then you need to additionally write a scheme handler and register that too.

    -Sumedh

    Monday, July 31, 2006 3:33 PM