locked
MediaStreamSource SampleRequested

    Question

  •        I have a question in regard to MediastreamSource GetSamples for WinRT , and below are the details.
    

    I have 30s duration Mp4 files fetching from the server, then AVC h.264 stream, and i parse for SPS, PPS NAL units from Mp4 , then i construct one complete stream by appending start codes for each NAL unit (3 byte 001) and with SPS and PPS at the start of the stream, the stream plays nicely, each sample i feed on SampleRequested is one MP4 file (30 s duration). so there is no problem in Playback when i have the mp4 file chunks locally. 

    But I have problems when downloading the file simultaneously and feeding it to SampleRequested. 

    if i have a sample to 10 mp4 chunks playing a certain video, when i receive one mp4 chunk i immediately feed it to the samplerequest from MediaStreamSource, if the samples are downloading i first request for deferral and Asynchronous block until i receive a sample . 

    Even though i and sending the sample when i receive to the sample request callback, it does not play until there are no more samples to load , that is i send NULL for sample request. 

    Problem is it does not play immediately as soon as i feed the first sample.But plays all 10 samples once ,and when i say no more samples. Null to sample request. 

    not sure whats happening here. 

        my code sample is at the following location (http://1drv.ms/1uAjJ8q) , its a very simple code for prototyping, please check and let me know what mistakes  i am doing here , its just waiting for all chunks and then playing. 



    Appreciate your HELP, Please let me know what i am doing wrong here. 

    CIrano

    Friday, November 21, 2014 4:50 AM

All replies

  • One thing I did notice was that you don't seem to be calling request.ReportSampleProgress. 

    The docs indicate that you should call this at when a sample is being retrieved and isn't currently available:

    The application should invoke this method when it is unable to immediately to deliver the MediaStreamSample, which is accomplished by assigning it to the Sample property.  The application should continue to invoke ReportSampleProgress on a regular basis until it is able to deliver the requested MediaStreamSample.

    The recommended interval between each invocation of ReportSampleProgress is 500 milliseconds.

    It may be that the system is buffering (getting no progress) and when you finish, the Media player then realizes you aren't 0% finished buffering, because there isn't anymore and then plays it.


    Darin R.

    Friday, November 21, 2014 6:17 PM
  • Hello Darin,

                     Sorry for the late reply , i was on vacation. Please find my code updated with progress , even with progress the mediastreamsource waits for certain number of samples before its starts video playback, setting MediaStreamSource.BufferTime has no effect. please appreciate your help.

    The playback does not start immediately after setting samples to mediastreamsource but after certain number of MediaSample which has no particular pattern.

    new CODE link http://1drv.ms/1vN2Wj1

    Cirani

     

    Wednesday, December 3, 2014 12:00 PM
  • following up on my question from this post https://social.msdn.microsoft.com/Forums/windowsapps/en-US/aa1d7ec1-ed4f-448c-b06e-4ee9a0f40577/mediastreamsource-samplerequested?forum=winappswithcsharp#aa1d7ec1-ed4f-448c-b06e-4ee9a0f40577

    if that post is closed opening new one here.

    if i have a sample to 10 mp4 chunks playing a certain video, when i receive one mp4 chunk i immediately feed it to the samplerequest from MediaStreamSource, if the sample is downloading i first request for deferral and Asynchronous block until i receive a sample . 

    Even though i and sending the sample when i receive to the sample request callback, it does not play until there are no more samples to load , that is i send NULL for sample request. 

    Problem is it does not play immediately as soon as i feed the first sample.But plays all 10 samples once ,and when i say no more samples. Null to sample request. 

    I am updating progress with ReportSampleProgress  when sample is unavailable, regularly every 500ms.

    MediaStreamSource.SetBufferTime has no effect.

    The playback does not start immediately after setting first sample  to mediastreamsource but after certain number of MediaSamples, with no particular pattern in number of samples.

    My code sample at the following location http://1drv.ms/1vN2Wj1appreciate your help

    Cirano

    Wednesday, December 3, 2014 12:06 PM