MFCreateMediaSession not supported for Metro apps?

Traitée MFCreateMediaSession not supported for Metro apps?

  • mercredi 18 avril 2012 01:43
     
     
    I'm learning Media Foundation and would like to use it from my own Metro apps.  Unfortunately, MFCreateMediaSession is not supported for Metro apps.  Why is that?  How would a Metro app create a media session to, say, play a stream of PCM audio generated on the fly by the app?

    • Modifié rwalters jeudi 19 avril 2012 00:57
    •  

Toutes les réponses

  • jeudi 19 avril 2012 07:32
    Modérateur
     
     

    Hello,

    Did you want to use MFCreateMediaSession to create playlist?
    If so, you can use Windows.Media.Playlists namespace to instead of it
    http://msdn.microsoft.com/library/windows/apps/BR206938

    There is the sample codes
    http://code.msdn.microsoft.com/windowsapps/Playlist-sample-3d80daee

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

  • jeudi 19 avril 2012 18:53
     
     
    No, I don't want to create a playlist.  I want to play a stream of PCM audio generated on the fly by the app.  This means my app creates the audio samples using an algorithm, and it runs continuously.  There is no file, no audio format, just plain audio samples.
  • jeudi 19 avril 2012 21:23
    Modérateur
     
     Traitée

    Hello rwalters,

    Here are two options for you:

    1) Use WASAPI and pump your synthesized PCM audio directly to the audio manager (preferred)

    2) Create a custom source that can plug into the Media Foundation Media Engine

    Either approach will work as expected. You will need to carefully review each method and compare them against your software requirements. For most synthesized audio scenarios, using the WASAPI is recommended.

    Win32 and COM for Metro style apps (multimedia)
    http://msdn.microsoft.com/en-us/library/windows/apps/hh452756.aspx

    Real-time communication sample
    http://code.msdn.microsoft.com/windowsapps/Simple-Communication-Sample-eac73290

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

  • jeudi 19 avril 2012 22:13
     
     

    Thanks James, but I find the "Win32 and COM for Metro style apps (multimedia)" reference confusing and unhelpful.  It's really only a list of functions that I can call from a Metro app.  What about the ones I can't?

    More specific questions on the two options proposed:

    1) WASAPI:  I'm missing one crucial piece in my understanding -- how to do the initial activation/instantiation of the required objects to access audio devices.  How do I even get a handle to an audio device when IMMDevice isn't supported for Metro style apps?

    2) Media Foundation Media Engine:  from studying the real-time communication sample, it seems the approach for play/record would be the following -- have I got it right so far?

    • Playback:  Use Windows.Media.MediaExtensionManager to register a scheme (in the example, it's "stsp://") handler which creates a custom source whenever a URL with this scheme is navigated to.
    • Recording:  Implement a custom sink and use Windows.Media.Capture.MediaCapture.StartRecordToCustomSinkAsync to capture media to it.
    • Modifié rwalters jeudi 19 avril 2012 22:59 Expanded upon original post, added more specific questions
    •  
  • lundi 23 avril 2012 17:13
     
     
    I'm unproposing as answer, for now, to get more attention.  Option #1 was sufficiently vague, given nobody seems to know how to do it in a Metro app (no examples, factories and interfaces such as IMMDevice not available to Metro apps, etc.)  I'll gladly mark it as an answer again if I could get clarification.  Thanks!
  • lundi 23 avril 2012 21:21
    Modérateur
     
     Traitée A du code

    Hello rwalters,

    Here are the answers to your questions:

    Q. How do I even get a handle to an audio device when IMMDevice isn't supported for Metro style apps?
    A. Code listed below:

    Platform::String^ id = Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId(Windows::Media::Devices::AudioDeviceRole::Console );
     
    Microsoft::WRL::ComPtr<IAudioClient> pAudioClient = NULL;
     
    ActivateAudioInterface( id->Data(), __uuidof( IAudioClient ), (void**)&pAudioClient );

    Q. ...it seems the approach for play/record would be the following -- have I got it right so far?
    A. Yes this seems like a reasonable approach.

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

  • lundi 23 avril 2012 21:45
     
     
    Thanks for the code example!  Where can I learn more about ActivateAudioInterface()?  I can't seem to find it in the MSDN or Dev Center.  The only hits when I search for it are here in the forums...
  • vendredi 27 avril 2012 00:33
    Modérateur
     
     

    I agree that is a big problem that we are trying to fix.

    -James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

  • vendredi 4 mai 2012 20:50
     
     
    Bumping this. I'm working on a WinRT component in C++. Trying to use ActivateAudioInterface results in an unresolved symbol. What am I doing wrong?
  • lundi 7 mai 2012 23:06
    Modérateur
     
     

    Hello Tom,

    Try "mmdeviceapi.h". If that doesn't work let me know.

    -James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

  • mardi 9 octobre 2012 12:21
     
     

    I'm newbie in this section, and  I have another questions about SimpleCommunication sample and custom media sink:

    - Can I get each picture in video stream while it is recording?

    - Can I change framerate and resolution of video stream while it is recording to custom media sink?

    - If I can get pictures from the video stream, can I edit it and fill it again in video stream?

    Thanks




    • Modifié CuongNC mercredi 10 octobre 2012 07:26
    •