how to create custom media sink?

mc 5,426 Reputation points
2023-11-10T03:38:27.8466667+00:00

I created MediaCapture to capture usb webcam and want to post the stream to the api.

there is StartRecordToCustomSinkAsync and how to create custom sink?

I want a stream sink and when data received I can post the data to the remote api.

Windows development Windows App SDK
0 comments No comments
{count} votes

Accepted answer
  1. Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff
    2023-11-10T06:35:24.3933333+00:00

    Hello,

    Welcome to Microsoft Q&A!

    If you want to create custom sink.

    I suggest you could refer to the Doc: Using Custom Sinks

    To create your own sink, implement the IWMWriterSink interface in a class in your application.

    If you want to know how to get the IMediaExtension.

    I suggest you could refer to the sample:https://github.com/microsoft/Windows-universal-samples/blob/main/Samples/SimpleCommunication/cs/CaptureDevice.cs

    // Create new sink
                    mediaSink = new StspMediaSinkProxy();
                    mediaSink.IncomingConnectionEvent += mediaSink_IncomingConnectionEvent;
    
                    var mfExtension = await mediaSink.InitializeAsync(encodingProfile.Audio, encodingProfile.Video);
                    await mediaCapture.StartRecordToCustomSinkAsync(encodingProfile, mfExtension);
    
    

    According to the sample, as far as I'm concerned, you could get IMediaExtension from MediaEncodingProfile.

    Thank you.

    Jeanine


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.