locked
Updating the header on the ASF Media Sink via IMFASFContentInfo::SetProfile only works with one stream ? RRS feed

  • Question

  • Hello,

    i am altering the header on the ASF Media Sink before it gets written to the file.

    This works very well with one stream on the IMFASFProfile, but with multiple streams it shows some odd behavior. When i have more than one stream on the profile then a call to IMFASFContentInfo::SetProfile will fail and the first stream is deleted from the final file.

    I went exactly after the documentation and payed very close attention to the clones of objects like the IMFASFStreamConfig or IMFASFProfile. I know my updated profile is correct, because i printed the whole thing after i made some changes to the streams.

    The problem must be inside IMFASFContentInfo::SetProfile, because when i do not set the updated profile the streams and its headers appear normal in file, but of course with no changes. The MSDN documentary states that on SetProfile it replaces the old profile with the new one, but from my experience it only does when you have one stream in the profile.

    Current behavior of IMFASFContentInfo::SetProfile :

    With only one stream in a profile the function replaces the existent profile with the new one. With multiple streams on a profile the function always fails ( even if the profile is the original one with no changes ) and deletes the first stream from the final file.

    I would realy like to hear from the MS team what attributes SetProfile is checking on the profile and how to get it to work with multiple streams.

    regards

    co0Kie













    • Edited by Francis Grave Saturday, November 29, 2014 11:40 AM Edit
    Thursday, November 27, 2014 10:38 AM

Answers

  • I solved it.

    You have to use ParseHeader instead of SetProfile. On SetProfile there are internal comparisons and computations that can lead to errors ( undefined behavior as the documentary states ), it seems to work with one but fails with multiple streams in the profile. ParseHeader just overwrites the current data ( all data ) in the content info object without any tests.

    You have to do the following if you have multiple streams :

    -

    1. Clone the profile

    2. Make your changes on the stream config object in the cloned profile

    3. Create an empty IMFASFContentInfo object

    4. Set the cloned profile with SetProfile on the empty content info object

    5. Generate a header from the new content info object by calling GenerateHeader

    6. Parse the new header to the media sinks content info object by calling ParseHeader.

    -

    If you have only one stream in a profile you dont need to do all this and you can simply call GetProfile, then edit the Profile, and finaly call SetProfile. But with multiple streams you have to follow the way i described above.

    regards

    co0Kie






    • Marked as answer by Francis Grave Friday, November 28, 2014 11:24 PM
    • Edited by Francis Grave Saturday, November 29, 2014 11:52 AM Edit
    Friday, November 28, 2014 11:24 PM