Using a buffer instead of a file name

Steps

Initialization

For each buffer stream, you must initialize MediaInfo:
MediaInfo::Open_Buffer_Init()

Send data

When you have data to send to MediaInfo:
MediaInfo::Open_Buffer_Continue(***The pointer to the buffer***, ***The buffer size***)
Result:
  • All bits are unset (Result=0) if you must continue to provide data
  • Bit 0 is set if MediaInfo has enough data for providing information (no more data is required)
  • Bit 1 is set if MediaInfo must go to a specific offset of the buffer stream (Not yet implemented)
  • Bit 2 is set if MediaInfo can provide full information (Not yet implemented)

Finalize

When you don't want to provide anymore data to MediaInfo, you must inform MediaInfo:
MediaInfo::Open_Buffer_Finalize()
Note: You must not do it if the buffer stream is not seekable. MediaInfo will do it itself.

Options

If the buffer stream is not seakable

By default, MediaInfo thinks that you can provide a seekable buffer stream. If you can't provide a seekable buffer stream, you must inform MediaInfo first:
MediaInfo::Options("File_IsSeekable", "0")
Note: In this case, you don't have to "Finalize" the parsing, MediaInfo thinks that the buffer stream is unlimitated and finalyze it as soon it has enough buffer.

Examples

Basic example

Parse a buffer, provided by the user with 1316 byte chunks.
//Preparing to fill MediaInfo with a buffer MediaInfo MI; MI.Open_Buffer_Init(); //The parsing loop size_t From_Buffer_Size; do { //Reading data somewhere, do what you want for this. From_Buffer_Size=From.Read(From_Buffer, 1316); //Sending the buffer to MediaInfo if ((MI.Open_Buffer_Continue(From_Buffer, From_Buffer_Size)&0x02)==1) //Test bit 1 from the result { int64u File_GoTo=MI.Open_Buffer_GoTo(); //Retrieving where MediaInfo want we go into the stream. ... //The user must seek the stream. } } while (From_Buffer_Size>0); //Info MI.Open_Buffer_Finalize(); MediaInfoLib::String Text=MI.Inform();

If the buffer stream is not seakable

Parse a buffer, provided by the user with 1316 byte chunks, and is non-seakable.
//Setting MediaInfo as parsing a non seakable file MediaInfo MI; MI.Options(_T("File_IsSeekable"), _T("0")); //Preparing to fill MediaInfo with a buffer MI.Open_Buffer_Init(); //The parsing loop size_t From_Buffer_Size; do { //Reading data somewhere, do what you want for this. From_Buffer_Size=From.Read(From_Buffer, 1316); //Sending the buffer to MediaInfo if (MI.Open_Buffer_Continue(From_Buffer, From_Buffer_Size)==0) From_Buffer_Size=0; //Get out of the loop, no more data is needed by the parser } while (From_Buffer_Size>0); //Info MediaInfoLib::String Text=MI.Inform();