This is especially useful for network streams playback - sometimes you should display something instead of a network stream (if the stream is disconnected, for example).
Though there is a reconnect feature for network streams in both MPlatform and MFormats SDKs, there is a way to get information about the network stream stability.
Reconnect feature
The feature is set with the PropsSet method:
myReader.PropsSet("network.reconnect", "true"); // MFormats SDK myFile.PropsSet("network.reconnect", "true"); // MPlatform SDK
or through the system registry:
MPlatform SDK
HKEY_CURRENT_USER\SOFTWARE\Medialooks\MPlatform\MFile\MFileFFM network.reconnect = true
MFormats SDK
HKEY_CURRENT_USER\SOFTWARE\Medialooks\MFormats\MFReader network.reconnect = true
Also, there are some extra parameters related to the reconnect feature:
- network.open_image - Sets a path to a custom image for reconnection;
- network.show_attempts - Shows attempts of reconnection for network streams.
Stability monitoring
You should analyze received frames for what flags do they have. In MPlatform SDK you should assign for OnFrame (or OnFrameSafe) event, and in MFormats SDK you just should add an extra check in your frame grabbing process.
You should get a frame time and check its flag. In a case of any problem, a None frame is received (with eMFF_None flag). Sometimes it might be just a skipped frame, for instance, in a case of unstable network bandwidth. But if there are many frames with None flag received in a row, then something is wrong with the stream.
MPlatform SDK
m_objFile.OnFrameSafe += M_objFile_OnFrameSafe; int counter = 0; private void M_objFile_OnFrameSafe(string bsChannelID, object pMFrame) { M_TIME pTime; ((IMFrame)pMFrame).FrameTimeGet(out pTime); if (pTime.eFFlags == eMFrameFlags.eMFF_None) { counter++; } else { counter = 0; } if (counter > 5) { MessageBox.Show("Connection is lost"); } }
MFormats SDK
MFFrame pFrame; mySource.SourceFrameGet(-1, out pFrame, ""); M_TIME pTime; pFrame.MFTimeGet(out pTime); if (pTime.eFFlags == eMFrameFlags.eMFF_AddedFrame) { counter++; } else { counter = 0; } if (counter > 5) { MessageBox.Show("Connection is lost"); }