How to register a live media source - media foundation RRS feed

  • Question

  • Hello all,

    I am attempting to create a media source based on the Mpeg1Source sample.

    My source is a live source. For the time being, I will be outputting frames that are generated internally.


    I am following the guides from msdn:

    Writing a Custom Media Source


    Case Study: MPEG-1 Media Source


    and looking through the mpeg1source sample code. I see how the source is registered in the registry as a byte stream handler.


    My question is, how do I register my live source component? is there documentation for this?

    I am familiar with DirectShow filter registration, but Media Foundation is a new game to me!


    Thank you in advance.







    Wednesday, June 5, 2013 3:22 PM

All replies

  • Hello.

    Yes there is sample for bytestream handler registration, but not for the scheme handler.

    the bytestream handler is for file's extension, and the scheme handler is for the protocole.

    Take a look at my project : MFNode

    There are two media source (Kinect source and Screenshot source). Look the DllMain.cpp file from one of these projects. You will see a way on how to register the scheme handler.

    • Edited by Miaou77 Thursday, June 6, 2013 8:06 PM
    Thursday, June 6, 2013 8:02 PM
  • Hello,

    Thank you for the example code.

    Using the MFSrScreenCapture code as an example, I see how you are registering this component as a Scheme Handler with the extension 'screen:'.

    Whilst wearing my DS hat, I registered the DLL, ran Topoedit (from the Windows SDK), expecting there to be a component called 'screen' in the Add Video Capture Source category, but sadly, there is not.

    How would an application load your screen capture component?

    Does it not sit in a generic category that applications can enumerate? or is it only accessible to private apps?

    Many thanks.







    • Edited by supcugar Friday, June 7, 2013 2:17 PM
    Friday, June 7, 2013 2:16 PM
  • Hello.

    You didn't read the README.txt.

    You can use screenshot media source with MFplayer from mediafoundation SDK sample "MFPlayer2". Look at one of the jpg on my project page, you will understand how to launch the media source.

    Schemes handler are initalized with CreateObjectFromUrl. And i think that TopoEdit does not provide this, but MFPlayer does.

    Schemes handler are not capture device.

    • Edited by Miaou77 Friday, June 7, 2013 9:30 PM
    Friday, June 7, 2013 9:18 PM
  • Ahh I see...

    So if I registered my video source as a scheme handler, applications can access my component using the URL selection... but only if they know which one I am...

    So third party applications will not know about my device.

    Do you know of a way in which I can register the component so that it appears in the Video Capture Source category?

    My feeling is that it is not possible, and only ksproxy devices will appear there? In DS, it is possible to create a 'virtual' camera (VCam sample) that will sit in the video capture category; I guess my real question is, can this be done in MF? (and if so how?)

    Many thanks


    Monday, June 10, 2013 9:50 AM
  • Jimmy, have you find an answer?
    Friday, October 4, 2013 2:50 PM
  • Though it is technically possible to write a virtual driver that shows up as a capture device, policies will probably prevent this.  In Media Foundation, a device must have a certificate to appear as a capture device, and so far only actual hardware devices through the USB video class driver have been certified.  Supporting a scheme through a scheme handler, or a file type with a byte stream handler, is the way to expose a new source to applications.
    • Proposed as answer by Miaou77 Saturday, April 26, 2014 11:26 PM
    Thursday, October 10, 2013 10:30 PM
  • Matt,

    Can you provide a description (or link to) of how to write/register a MF virtual capture device?

    I have a capture device that creates video in user mode. Installing a KS proxy just to accept user mode data and return it to user mode MF stream doesn't seem to make any sense.

    Thank you.


    Wednesday, April 23, 2014 9:53 PM
  • Hello Larry.

    AFAIK, Mediafoundation doesn't provide a way to write a virtual capture device.

    Just write a virtual capture device. You can find source code other the net.

    Normally, both DirectShow and Mediafoundation are able to use it.

    For MediaFoundation check this : Audio/Video Capture

    Mediafoundation should be able to enumerate a compliant virtual capture device (UVC 1.1 and WASAPI).

    • Edited by Miaou77 Thursday, April 24, 2014 7:01 PM
    Thursday, April 24, 2014 6:53 PM
  • Sorry, I don't understand your reply:

    >> AFAIK, Mediafoundation doesn't provide a way to write a virtual capture device.
    >> Just write a virtual capture device. You can find source code other the net.

    I don't follow your meaning?

    My question is what needs to happen in DllRegisterServer() to register a video capture source?

    The link you provided (Audio/Video Capture) describes how to enumerate registered capture sources. How does my source get on the list without a KS Proxy?

    Thanks again.


    Thursday, April 24, 2014 11:45 PM
  • Hello.

    Without IKsPropertySet/IAMStreamConfig, there is scheme handler in MediaFoundation.

    If the application that uses your scheme handler, doesn't know your scheme type, this application needs to use MFGetSupportedSchemes in order to find your scheme. It is the same as enumerate capture device.

    The problem is that most application implements capture device enumeration, but not MFGetSupportedSchemes.

    So if it is not a problem, just use scheme handler. Like Matt says 'is the way to expose a new source to applications'.

    If you want to implement a pure Mediafoundation solution with scheme handler, check my project MFNode . There is two Mediafoundation sources with scheme handler (ScreenCapture and Kinect).

    • Edited by Miaou77 Friday, April 25, 2014 7:31 PM
    Friday, April 25, 2014 7:21 PM
  • Hopefully, I can clear up some confusion.

    I want to implement a video capture source, visible to Media Foundation applications, video conferencing applications, etc. The source should appear to any Media Foundation application. Microsoft recommended technique for finding video capture source is to enumerate devices with MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE == MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID.

    Unless a scheme handler can be provided that presents the scheme as MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID, the scheme handler approach is not a solution.

    I wasn't able to get any of the sources in your project (MFNode) to enumerate as a video capture source - using SimpleCapture for example.



    Friday, April 25, 2014 9:24 PM
  • Hello.

    Sorry, i've made a mistake when i said that MediaFoundation could handle usual virtual capture device.

    I tried to enumerate a virtual capture device (implements IKsPropertySet/IAMStreamConfig) wich works with DirectShow, under MediaFoundation. Unfortunatly, MediaFoundation is not able to enumerate it, DirectShow does.

    It seems the only way is to provide a KsProxy : USB Video Class Driver

    I'm ok with you, it doesn't make any sense to use it, if you don't implement an hardware device...

    The new way is scheme handler, and application have to use MFGetSupportedScheme

    I proposed Matt post as answer, because i don't see any other way to make capture device compliant to MediaFoundation.

    • Edited by Miaou77 Saturday, April 26, 2014 11:29 PM
    Saturday, April 26, 2014 11:24 PM