You can use mp:// links as live sources in both MFormats and MPlatform SDK.
You can read more about mp://-links and virtual object in MFormats SDK in this article - Virtual objects in MFormats SDK. About MPlatform's approach - Multiple objects usage.
MFormats and eMFDT_MPLink device type
You create an mp://-link and an MFLive object. You can send with the mp://-link a frame from any source you want (a device, a file, a stream) without any delay and in the order you want. In this case, it is important to use SourceFrameConvertedGet methods to avoid different problems with synchronization and framerate.
// Set or change file name
m_objMFReader.ReaderOpen(openFileDialog.FileName, "");
//Create and init MFSink object
m_objMFSink = new MFSinkClass();
m_objMFSink.SinkInit("MFReaderSink", "MFormats VSource", "");
//Create MFLive object
m_objMFLiveSink = new MFLiveClass();
//In the thread
void m_threadWorker_DoWork(CancellationToken token)
{
while(!token.IsCancellationRequested)
{
try
{
...
M_AV_PROPS props = new M_AV_PROPS();
// Get next frame from file
m_objMFReader.SourceFrameConvertedGetByNumber(ref props, -1, -1, out pFrameFile, "");
//Send the frame with the mp:// link.
m_objMFSink.ReceiverFramePut(pFrameFile, -1, "");
// to keep a frame rate stable (to avoid fast decoding), we need to use a preview object m_objPreview.ReceiverFramePut(pFrameFile, -1, "");
}
}
The mp://link here is just like a video device in MFLive object. So you can set external audio for mixing. If the source contains original audio, the audio is used as "From video" in eMFDT_Audio device type. As a result, you have the mix of the source that you send with the mp://link and external audio sources.
After you send the frame to the MFSink object you have to find the list of the available mp://links. For this, there is an eMFDT_MPLink type of eMFDeviceType:
int count;
m_objMFLiveSink.DeviceGetCount(eMFDeviceType.eMFDT_MPLink, out count);
if (count > 0)
{
for (int i = 0; i < count; i++)
{
string name = string.Empty;
int busy;
m_objMFLiveSink.DeviceGetByIndex(eMFDeviceType.eMFDT_MPLink, i, out name, out busy);
MFSink_cmb.Items.Add(name);
}
}
The list of available audio sources is just like it is for capture devices - "From Video" (you use original audio) and "No Audio" (you don't use the original audio).
The list of available external audio devices:
int count;
m_objMFLiveSink.DeviceGetCount(eMFDeviceType.eMFDT_ExtAudio, out count);
if (count > 0)
{
for (int i = 0; i < count; i++)
{
string name = string.Empty;
int busy;
m_objMFLiveSink.DeviceGetByIndex(eMFDeviceType.eMFDT_ExtAudio, i, out name, out busy);
extAudio_cmb.Items.Add(name);
}
}
Now you can set the mp://-link as a video device in the MFLive object
m_objMFLiveSink.DeviceSet(eMFDeviceType.eMFDT_MPLink, MFSink_cmb.SelectedIndex, "");
and set the external audio.
m_objMFLiveSink.DeviceSet(eMFDeviceType.eMFDT_ExtAudio, extAudio_cmb.SelectedIndex, "");
Now you can take the frame from the m_objMFLiveSink object.
m_objMFLiveSink.SourceFrameConvertedGetByNumber(ref props, -1, -1, out pFrameSink, "");
MPlatform and "mplink"
A common way to configure MLive object is to set DeviceSet("video",...) and after that configure all the other sources. In case of mp:// links as MLive source, the scenario is the same. The only difference is that you use "mplink" as the device type in DeviceSet method. The rest is just the same as in a configuration MLive object.
myLive.DeviceSet("mplink", "mp://mplaylist", "")