How to combine SurfaceImageSource with Media Foundation?

Hi,
I am using following walkthrough, it works just fine but don't know how to integrate with SurfaceImageSource as a singleton.
https://msdn.microsoft.com/en-us/library/windows/apps/jj207074(v=vs.105).aspx
Could you give me some advise, any document that relevant to this scenarios? I am new to this.
Thanks and Best Regards,
Weera

Hello,
You should be familiar with this sample from our previous conversations:
Media engine native C++ video playback sample. This sample should give you what you need to render the video from the Media Engine onto a D3D surface. You should then be able to use D3D and XAML interop to integrate with the SurfaceImageSource.
Keep in mind that with the SurfaceImageSource the XAML compositing stack handles when the frame is updated. Because of this is it very likely that you will see tearing of the video when mixing the Media Engine render with the SurfaceImageSource. Because
of this it is not recommended.
I hope this helps,
James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

Similar Messages

  • Play audio from file to speaker with Media Foundation

    I'm attempting to play the audio track from an mp4 file to my speaker. I know Media Foundation is able to decode the audio stream as I can play it with the TopoEdit tool.
    In the sample code below I'm not using a media session or topology. I'm attempting to manually connect the media source to the sink writer. The reason I want to do this is that I ultimately intend to be getting the source samples from the network rather than
    from a file.
    The error I get on the pSinkWriter->WriteSample line when running the sample below is MF_E_INVALIDREQUEST (0xC00D36B2). So I suspect there's something I haven't wired up correctly.
    #include <stdio.h>
    #include <tchar.h>
    #include <mfapi.h>
    #include <mfplay.h>
    #include <mfreadwrite.h>
    #pragma comment(lib, "mf.lib")
    #pragma comment(lib, "mfplat.lib")
    #pragma comment(lib, "mfplay.lib")
    #pragma comment(lib, "mfreadwrite.lib")
    #pragma comment(lib, "mfuuid.lib")
    #define CHECK_HR(hr, msg) if (hr != S_OK) { printf(msg); printf("Error: %.2X.\n", hr); goto done; }
    int _tmain(int argc, _TCHAR* argv[])
    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
    MFStartup(MF_VERSION);
    IMFSourceResolver *pSourceResolver = NULL;
    IUnknown* uSource = NULL;
    IMFMediaSource *mediaFileSource = NULL;
    IMFSourceReader *pSourceReader = NULL;
    IMFMediaType *pAudioOutType = NULL;
    IMFMediaType *pFileAudioMediaType = NULL;
    MF_OBJECT_TYPE ObjectType = MF_OBJECT_INVALID;
    IMFMediaSink *pAudioSink = NULL;
    IMFStreamSink *pStreamSink = NULL;
    IMFMediaTypeHandler *pMediaTypeHandler = NULL;
    IMFMediaType *pMediaType = NULL;
    IMFMediaType *pSinkMediaType = NULL;
    IMFSinkWriter *pSinkWriter = NULL;
    // Set up the reader for the file.
    CHECK_HR(MFCreateSourceResolver(&pSourceResolver), "MFCreateSourceResolver failed.\n");
    CHECK_HR(pSourceResolver->CreateObjectFromURL(
    L"big_buck_bunny.mp4", // URL of the source.
    MF_RESOLUTION_MEDIASOURCE, // Create a source object.
    NULL, // Optional property store.
    &ObjectType, // Receives the created object type.
    &uSource // Receives a pointer to the media source.
    ), "Failed to create media source resolver for file.\n");
    CHECK_HR(uSource->QueryInterface(IID_PPV_ARGS(&mediaFileSource)), "Failed to create media file source.\n");
    CHECK_HR(MFCreateSourceReaderFromMediaSource(mediaFileSource, NULL, &pSourceReader), "Error creating media source reader.\n");
    CHECK_HR(pSourceReader->GetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, &pFileAudioMediaType), "Error retrieving current media type from first audio stream.\n");
    // printf("File Media Type:\n");
    // Dump pFileAudioMediaType.
    // Set the audio output type on the source reader.
    CHECK_HR(MFCreateMediaType(&pAudioOutType), "Failed to create audio output media type.\n");
    CHECK_HR(pAudioOutType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), "Failed to set audio output media major type.\n");
    CHECK_HR(pAudioOutType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_Float), "Failed to set audio output audio sub type (Float).\n");
    CHECK_HR(pSourceReader->SetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, NULL, pAudioOutType), "Error setting reader audio output type.\n");
    // printf("Source Reader Output Type:");
    // Dump pAudioOutType.
    CHECK_HR(MFCreateAudioRenderer(NULL, &pAudioSink), "Failed to create audio sink.\n");
    CHECK_HR(pAudioSink->GetStreamSinkByIndex(0, &pStreamSink), "Failed to get audio renderer stream by index.\n");
    CHECK_HR(pStreamSink->GetMediaTypeHandler(&pMediaTypeHandler), "Failed to get media type handler.\n");
    // My speaker has 3 audio types of which I got the furthesr with the third one.
    CHECK_HR(pMediaTypeHandler->GetMediaTypeByIndex(2, &pSinkMediaType), "Failed to get sink media type.\n");
    CHECK_HR(pMediaTypeHandler->SetCurrentMediaType(pSinkMediaType), "Failed to set current media type.\n");
    // printf("Sink Media Type:\n");
    // Dump pSinkMediaType.
    CHECK_HR(MFCreateSinkWriterFromMediaSink(pAudioSink, NULL, &pSinkWriter), "Failed to create sink writer from audio sink.\n");
    printf("Read audio samples from file and write to speaker.\n");
    IMFSample *audioSample = NULL;
    DWORD streamIndex, flags;
    LONGLONG llAudioTimeStamp;
    for (int index = 0; index < 10; index++)
    //while (true)
    // Initial read results in a null pSample??
    CHECK_HR(pSourceReader->ReadSample(
    MF_SOURCE_READER_FIRST_AUDIO_STREAM,
    0, // Flags.
    &streamIndex, // Receives the actual stream index.
    &flags, // Receives status flags.
    &llAudioTimeStamp, // Receives the time stamp.
    &audioSample // Receives the sample or NULL.
    ), "Error reading audio sample.");
    if (flags & MF_SOURCE_READERF_ENDOFSTREAM)
    printf("End of stream.\n");
    break;
    if (flags & MF_SOURCE_READERF_STREAMTICK)
    printf("Stream tick.\n");
    pSinkWriter->SendStreamTick(0, llAudioTimeStamp);
    if (!audioSample)
    printf("Null audio sample.\n");
    else
    CHECK_HR(audioSample->SetSampleTime(llAudioTimeStamp), "Error setting the audio sample time.\n");
    CHECK_HR(pSinkWriter->WriteSample(0, audioSample), "The stream sink writer was not happy with the sample.\n");
    done:
    printf("finished.\n");
    getchar();
    return 0;
    I've omitted the code that dumps the media types for brevity but their output is shown below. It could well be that I haven't got the
    media types connected properly.
    File Media Type:
    Audio: MAJOR_TYPE=Audio, PREFER_WAVEFORMATEX=1, {BFBABE79-7434-4D1C-94F0-72A3B9E17188}=0, {7632F0E6-9538-4D61-ACDA-EA29C8C14456}=0, SUBTYPE={00001610-0000-0010-8000-00AA00389B71}, NUM_CHANNELS=2, SAMPLES_PER_SECOND=22050, BLOCK_ALIGNMENT=1, AVG_BYTES_PER_SECOND=8000,
    BITS_PER_SAMPLE=16, USER_DATA=<BLOB>, {73D1072D-1870-4174-A063-29FF4FF6C11E}={05589F81-C356-11CE-BF01-00AA0055595A}, ALL_SAMPLES_INDEPENDENT=1, FIXED_SIZE_SAMPLES=1, SAMPLE_SIZE=1, MPEG4_SAMPLE_DESCRIPTION=<BLOB>, MPEG4_CURRENT_SAMPLE_ENTRY=0,
    AVG_BITRATE=64000, 
    Source Reader Output Type:
    Audio: MAJOR_TYPE=Audio, SUBTYPE=Float, 
    Sink Media Type:
    Audio: MAJOR_TYPE=Audio, SUBTYPE=Float, NUM_CHANNELS=2, SAMPLES_PER_SECOND=48000, BLOCK_ALIGNMENT=8, AVG_BYTES_PER_SECOND=384000, BITS_PER_SAMPLE=32, ALL_SAMPLES_INDEPENDENT=1, CHANNEL_MASK=3, 
    Any hints as to where I could look next would be appreciated.

    Needed:
    pSinkWriter->BeginWriting()

  • How to combine rows with small numbers into single "other" row?

    How can I combine rows with value 6(for example) or lower to single row representing the SUM of all this values and label OTHER, so the pie chart will have a chance to display all small values combined?
    I'm using Numbers 09

    HI Peter,
    When you write a decimal number, is the decimal separator a period ( . ) or a comma ( , )? If it's a comma, then the syntax error can be corrected by replacing the list separator in the formula, a comma in Jerry's formula, with a semi colon ( ; ):
    =SUMIF(B; "<6"; B)
    (Added): The two Bs appear in blue 'lozenges' in Jerry's image because that is the way cell (or column) references are displayed in Numbers when a formula has correct syntax.
    Regards,
    Barry
    Message was edited by: Barry

  • How to combine sound with video to an AVI Using IMAQ?

    I need to combine sound with video I capture and write it out as an AVI. Is there anyway in Labview to combine sound with and AVI? Or an easy to use third party product?

    Hello,
    The AVI tools that are provided with Vision allow for data to be added to your video.  Sound information can be stored this way, but if you are looking for a way to add audio support to your video (such that it will play the sound file when the video is played in Windows Media Player or other applications) you may want to look into finding a shareware or freeware product that can accomplish this.  LabVIEW does not have tools specifically targetted to this operation.
    Good luck,
    Robert

  • How to combine TrivialPageFlowEngine with JAZN XML-based provider ?

    With help TrivialPageFlowEngine possible will limit access to pages, and also to set pages for logon. However, JAZN XML-provider provides the same functionality. How to combine these two approaches

    Rustam,
    can you help me with "TrivialPageFlowEngine"? Where can I get documentation for it to have a quick lokk before replying to your request. Oracle9iAS JAAS (aka JAZN) is based on the Java Authentication and Authorization Service and implements it's own provider.
    If you look in the OC4J demos for jazn, there are two samples explaining how to setup JAZN (If installing OC4J with Oracle9iDS or Oracle9iAS then jazn already is defined to be the default provider).
    If e.g. you use Oracle9iAS and configure (and deploy) a Servlet for basic authentication, then this automatically is performed by the Oracle Single Sign-on server (if configured for OID) or direct jazn-data.xml (if not using OID). All your code needs to do is to get the authenticated principal's name.
    From your posting it is not clear if you require authentication or authorization alike. Authorization requires permission classes to be written and assigned.
    Fran

  • How to combine BOMs with Free Goods?

    Dear all.
    I am currently working on setting up a retail store in SAP ERP (6.0). Our client requires from us creating a functionality that would allow to create sets and add free goods to a certain set. For example: if you buy a set consisting of a hammer and a drill at a regular price, you get a pair of gloves free of charge.
    We used BOMs to create the sets and attempted to combine them with Free Goods, which prooved impossible -- FGs don't work with BOMs. We also tried to use Bonus Buys, but these seem to be working only with SAP Retail, which is not available to us.
    Do you know any way around this problem?
    Grzegorz

    Shantanu
    It sounds pretty helpful, however, what we just found out it is impossible to give away free goods according to the local tax standards - so we have to give them away for a fraction of the price rather than free of charge. This forced us to create a separate logic to deduce different item categories in a sales order and different prices according to that.
    Thanks anyway.
    Grzegorz

  • How to combine text with variable in process flow

    Hi,
    I have created a function that returns the environment that a process flow is running in, Production, Test or Development. I have been able to bind the output of the function into a variable in a process flow and bind the variable to the subject of an email activity. I'd like to go one step more and combine the value of the variable with some text to explain which step in the process flow generated the email. Is there a way to concatenate text to a variable or to add an OWB system variable? I've seen an example where the subject of the email is
    "Failed mapping <mapping name>"
    but I want my subject to be "PROD Failed mapping <mapping name>" where the "PROD" is from a process flow variable or function return value.
    Is this possible?
    Thanks
    Don Keyes

    Hi Don,
    you can perform this task with ASSIGN activity.
    For example, you have two variable V_ENV_TYPE (with type of environment) and V_TEXT ("Failed mapping <mapping name>"). Define additinal variable V_NEW_TEXT, bind Variable parameter of Assign activity to V_NEW_TEXT variable and define value in Assign activity as
    V_ENV_TYPE || ' ' || V_TEXTRegards,
    Oleg

  • How to combine integers with JTextFields?

    Hello
    I have 2 textFields and i want to add on each a integer
    I also have 3 buttons 1for the "+"function 2 for the "-" function and 3 for the "="
    function
    How can i put integers and make the above functions using (JTextFields which are working with Strings as far i know)without throwing me exception thread String needed?
    thanks

    Why not just set the text to whatever number you want (or have the user do it by typing in the JTextField), then use getText() to retrieve the text and do your operations on it?
    User enters stuff into textfields
    User hits "enter" (or whatever)
    Use JTextField.getText()
    Use Integer.valueOf(String)
    etcOr whatever floats your boat.

  • How to combine HexByte with StringByte

    I have Hex string number, for example 1234. "" is equal to 2 bytes. Then I have a string, for example "HelloWorld", equal to 10bytes. In principle, the combination have to be 12 bytes.
    I want to combine them together and the result is given 1234HelloWorld, equal to 12 bytes. Meaning, the frist 4 charachters are still considered as HexString. How can I do that...
    I convert HexByte to string and combine them... but that gives the answer 14 bytes

    package util.encode.combine;
    import util.encode.convert.HexToByte;
    import util.encode.convert.toHexString;
    public class CombineByte {
         //Constructor
         public CombineByte() {
         //Method
         public byte[] merge (byte[] Array1, byte[] Array2) {
              StringBuffer Sbuff = new StringBuffer();
              //Calling constructor
              toHexString con1 = new toHexString();
              HexToByte con2 = new HexToByte();
              //Converting byte into hex-string --display purpose
              String printA1 = con1.convert(Array1);
              return outputArray;
         } // End of merge method.
              String printA2 = con1.convert(Array2);
              return outputArray;
         } // End of merge method.
              //Adding two string together & casing back to string
              Sbuff.append(printA1).append(printA2);
              String addString = Sbuff.toString();
              //Convert the output string into a byte array
              byte[] outputArray = con2.convert(addString);     
              return outputArray;
         } // End of merge method.
    } //End of class
              return outputArray;
              return outputArray;
         } // End of merge method.
         } // End of merge method.
    This class is the example which works perfectly well to combine 2 Hexbyte(Array1 and Array2). con2.convert(addString) give a result of OutputArray, which is HexByte.
    file:///usr/share/doc/HTML/index.html
    However if Array 2 is not Hexnumber...... For example, it the byte[] represent "HelloWorld".. My problem is how can modified to combine Array1 and Array2...(I still want Array 1 represent HexNumber).
    I've been tried to solve this for a couple of day, if someone know, could you please kindly tell me?
    Regard

  • How to combine apex with mail

    Hi,
    I know how to send an e-mail to someone registered in a database maintained with an apex-application, but now I want to store the message itself in my database. Or the other way: by typing the content in my application and sending it as message.
    Has anyone an example how to solve any of these ?
    Any reaction will be appreciated.
    Leo

    <p>Leo,</p>
    <p>These posts can help you:<ul><li>Mail from Application Express</li>
    <li>Mail from Application Express again</li></ul></p>
    <p>With kind regards,</p>
    <p>Jornica</p>

  • How to Combine Forms with .PDF files?

    Hello. Several employees at my company frequently generate reports which are then edited in Acrobat 7. Life was good in the days of Acrobat 5. Then something changed between Acrobat 5 and 6, making this virtually impossible.
    Then along came Acrobat 7. We rejoiced when we realized we could edit all but one table in Acrobat 7, and that one could be edited using ALCD 7. Now here's the rub:
    The tables are generated individually using Crystal Reports as the compiler. Separate .PDFs are generated for each table and edited in Acrobat or ALCD when necessary. When all editing is complete, the reports are compiled in one .PDF for printing/publication.
    The problem is that once we edit a table in Designer, it cannot then be merged with the other .PDFs.
    Is there anything we can do to get around this? Thanks!

    Hi Katherine,
    Unfortunately Designer creates an XFA PDF form, which is not inherently compatible with AcroPDF files. (Their internal structure is different.)
    You could try one or both of the following things and see if they work - I haven't the opportunity to test these just now myself, but this is what I would try..
    Option 1 - When saving the table in Designer, select save as type option of "Acrobat 6 compatible static PDF" option and try if this can be merged into the rest of the file.
    Option 2 - After completing all changes, see if you can set up a batch process in Acrobat professional to print the Design files back to AcroPDF format, and then merge into the bigger file.
    I hope this helps,
    Sanna

  • How to share files with media player kaiboer K670 ?

    I am trying to share a file between my macbook air and my media player Kaiboer K670.
    The issue I have it's this :
    - When I find my macbook air on the media player, it ask me for a login and password that I cant find.......i tried my usual login name and password when I log into my macbook air but nothing is happening.....can someone help ?

    well as far as i can see, media sharing is enabled, i can't see anything else that wouls stop it other than the network discovery function does not seem to stay on, according to the pages above it needs to be on to allow other computers to see it and vica versa? heeeeelp aaaaaagh

  • How to utilize media.windows-media-foundation.enabled?

    I have read all the articles I can find on media.foundation. But, I do not know what firefox is looking to on the host os for the appropriate codex.
    I am running windows xp pro sp3 and firefox 22. I interpret various forum questions that firefox should play an mp3 file if the os has the appropriate codex. Under windows device manager I have a registered system codex for mp3. Firefox will not play the file but rather offers to d/l it. Is Firefox looking to windows media player for this information?
    I would like to know how firefox is using the media.foundation preference in order to adjust my system to it. Any help would be appreciated.

    i'm not very good at the technical level but from past crash reports i know that the mfplat.dll library is called which handles the media foundation stuff...
    http://msdn.microsoft.com/en-us/library/windows/desktop/bb970511%28v=vs.85%29.aspx
    <br>http://msdn.microsoft.com/en-us/library/windows/desktop/ee663600%28v=vs.85%29.aspx

  • Media Engine (Media Foundation) sample WP8 app decodes sample video incorrectly

    The
    Media Engine sample  compiles fine on my machine and I can run it on my phone, but I can't get it to play any video correctly. Specifically, the video that is being drawn every frame is wrong.  I'll try and attach a screenshot to show what it
    looks like, but if you can picture a bunch of blocks that have a distorted piece of the original video, that's it. The sound plays just fine. What in the world could be causing this?  (The video is the sample video that comes with the code... a dog drinking
    from a pool.)
    I've even tried to recreate the sample using the
    walkthrough but I get the same result.  I have taken the sample and removed the MediaEngine and tried just drawing a static texture to see if there was some hidden code screwing up the shaders, but it worked fine... 
    so something is wrong with Media Foundation.  Is it possible I have a library that is not working correctly?  I'm using VS2013 (Pro) with all the latest updates.
    Lee McPherson

    I get the same result (and exceptions running in the debugger) on my HTC 8X.  I will investigate further and update this forum post when I know more!
    Jeff Sanders (MSFT)
    @jsandersrocks - Windows Store Developer Solutions
    @WSDevSol
    Getting Started With Windows Azure Mobile Services development?
    Click here
    Getting Started With Windows Phone or Store app development?
    Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

  • Help Me please How to combine one tab press and continuesly press on keyboard

    Hy all, I am new here... Btw I have a problem when I making a game Flash with action script 3,. I want to
    make my character move when the key helding and I want  my character attack
    with one tab press either ,.. how to make  it work?? please give me sample to make it ... Thanks before

    yea thats correct but.. how to combine it with continuesly press.. I have script like this :
    package
        import flash.display.MovieClip;
        import flash.events.KeyboardEvent;
        import flash.ui.Keyboard;
        import flash.events.Event;
        public class Main extends MovieClip
            var vx:int;
            var vy:int;
            var attack:Boolean=true;   
            public function Main()
                init();
            function init():void
                vx=0;
                vy=0;
                attack=false;
                stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownF);
                stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUpF);
                stage.addEventListener(Event.ENTER_FRAME, onEnterframe);
             function onKeyDownF(event:KeyboardEvent):void
                if (event.keyCode == Keyboard.LEFT)
                    vx = -5;
                    Player.gotoAndStop(2);
                    Player.scaleX = -0.3;
                else if (event.keyCode == Keyboard.RIGHT)
                    vx = 5;
                    Player.gotoAndStop(2);
                    Player.scaleX = 0.3;
                else if (event.keyCode == Keyboard.DOWN)
                    vy = 5;
                    Player.gotoAndStop(2);
                else if (event.keyCode == Keyboard.UP)
                    vy = -5;
                    Player.gotoAndStop(2);
              else if (event.keyCode == Keyboard.SPACE)
                   Player.gotoAndStop(3);
            function onKeyUpF(event:KeyboardEvent):void
                if (event.keyCode == Keyboard.LEFT || event.keyCode == Keyboard.RIGHT)
                    vx = 0;
                    Player.gotoAndStop(1);
                else if (event.keyCode == Keyboard.UP || event.keyCode == Keyboard.DOWN || event.keyCode == Keyboard.SPACE)
                    vy = 0;
                    Player.gotoAndStop(1);
            function onEnterframe(event:Event):void
                Player.x+=vx;
                Player.y+=vy;
    when I try to include key code SPACE to moving character to attack.... It will going continuesly attack when I helding the key,.. and It stop when I relase the key.. I need one press to attack.. please help me.. :'(

Maybe you are looking for

  • New Desktop, from A to Z

    I'm fairly familiar with Linux, but am more accustomed to distros that come with a fancy GUI that has front ends for everything. So what I want to know, is how to install a good smoothe, easy to control and fairly simple to config LIGHT WEIGHT GUI. I

  • Enable Exclude Options Only : Using SELECT_OPTIONS_RESTRICT

    Hello Experts, I have select options for one field. I would like to include only "Excluded Single Values" Tab Only. Can anybody will suggest me how to do that? I had tried to use various ways but didn't succeed. Below sample code for your reference.

  • Loading U3D via JS

    Hi;      I tried to find in the forums but didn't find anything that worked.      I have some u3d files attached to my pdf and I want to load them in the same annotation depending on the user input.      I know how to reference them but i dont know h

  • Source table name on ? ? level

    hi I would like to store in Java Variable source table name on <? ?> level. <? String table_name = Source_Table_Name; ?> When I use: <? String p = "<%=odiRef.getSrcTablesList("", "[TABLE_NAME]", ", ", "")%>"; ?> then this code is translated to: <? St

  • File attachment problem when posting the email

    Hi all, I have some problems here with the email posting. When i send the email with text attachment and I view in the SOST is correct. But after i sent it through the SCOT, the attachment that receives by receiver becomes PDF. Can somebody tell me w