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.
MediaInfo MI;
MI.Open_Buffer_Init();
size_t From_Buffer_Size;
do
{
From_Buffer_Size=From.Read(From_Buffer, 1316);
if ((MI.Open_Buffer_Continue(From_Buffer, From_Buffer_Size)&0x02)==1)
{
int64u File_GoTo=MI.Open_Buffer_GoTo();
...
}
}
while (From_Buffer_Size>0);
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.
MediaInfo MI;
MI.Options(_T("File_IsSeekable"), _T("0"));
MI.Open_Buffer_Init();
size_t From_Buffer_Size;
do
{
From_Buffer_Size=From.Read(From_Buffer, 1316);
if (MI.Open_Buffer_Continue(From_Buffer, From_Buffer_Size)==0)
From_Buffer_Size=0;
}
while (From_Buffer_Size>0);
MediaInfoLib::String Text=MI.Inform();