How can I create a IMFBytestream out of a memory block which has audio data ?

Shakthi Prashanth 1 Reputation point
2020-08-10T07:56:19.733+00:00

Hi I've setup TCP server/client in Windows 10.

TCP server that sends uncompressed audio data to TCP client. In TCP Client, I would like to play received audio in Windows audio output device.
I am planning to use Windows Media Session APIs as found here: https://learn.microsoft.com/en-us/windows/win32/medfound/how-to-play-unprotected-media-files#overview

As I understand from API docs, Applications require me to pass media URL. But I don't have URL for audio data, rather audio buffer. There is an option to feed audio buffer https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imfsourceresolver-createobjectfrombytestream. But A bytestream object can only be created from a File: https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nn-mfobjects-imfbytestream#remarks

How can I create a bytestream out of a memory block which has audio data ?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rita Han - MSFT 2,161 Reputation points
    2020-08-10T08:49:06.79+00:00

    Hello,

    How can I create a IMFBytestream

    Maybe you can use MFCreateTempFile to create a file in the system temporary folder and get a pointer to the IMFByteStream interface of the byte stream for that file.

    Then use IMFByteStream::Write to write your received audio data into the stream for playing later.

    Thank you!

    1 person found this answer helpful.