Output to a device is managed by MRenderer (in MPlatform SDK) and MFRenderer (in MFormats SDK) objects.
MPlatform SDK
Create an instance of MRenderer object
MRendererClass pRender = new MRendererClass();
Enumerate devices
int nDevices = 0; //Get renderers count pRender.DeviceGetCount(0, "renderer", out nDevices); for (int i = 0; i < nDevices; i++) { string strName; string strXML; pRender.DeviceGetByIndex(0, "renderer", i, out strName, out strXML); // add strName to a list of devices myDevicesList.Add(strName); }
Specify the required device name
pRender.DeviceSet("renderer", myDevicesList[targetIndex], ""); // for example, "UltraStudio Express"
Set output line
// enumerate available lines int nCount = 0; try { // if there is no output lines available the method returns an error pRender.DeviceGetCount(0, "renderer::line-out", out nCount); } catch { } if (nCount > 0) { for (int i = 0; i < nCount; i++) { string strName; string strDesc; pRender.DeviceGetByIndex(0, "renderer::line-out", i, out strName, out strDesc); myLinesList.Add(strName); } }
Set the desired line:
pRender.DeviceSet("renderer::line-out", myLinesList[targetIndex], ""); // for example, "SDI & HDMI & S-Video"
Start output
(pRenderer as IMObject).ObjectStart(sourceObject);
MFormats SDK
Create an instance of MFRenderer
MFRenderer myRenderer = new MFRenderer();
Set up the device name
Renderers are video devices so you should use eMFDT_Video for set up. To collect all the available devices you should call:
int rendererCount = 0; myRenderer.DeviceGetCount(eMFDeviceType.eMFDT_Video, out rendererCount); string[] renderersArray; if (rendererCount > 0) { renderersArray = new string[rendererCount]; for (int rendererIndex = 0; rendererIndex < nCount; rendererIndex++) { string rendererName; int isBusy; myRenderer.DeviceGetByIndex(eMFDeviceType.eMFDT_Video, rendererIndex, out rendererName, out isBusy); renderersArray[rendererIndex] = rendererName; } }
and to set the device:
myRenderer.DeviceSet(eMFDeviceType.eMFDT_Video, targetRendererIndex, "");
Specify the output line
Get a number of available output lines:
int nCount; myRenderer.PropsOptionGetCount("line-out", out nCount); for (int i = 0; i < nCount; i++) { string strXML = string.Empty; try { myRenderer.PropsOptionGetByIndex("line-out", i, out strNameKeying, out strXML); } catch (Exception) { } }
Set the desired one:
myRenderer.PropsOptionSetByIndex("line-out", targetLineOutIndex);
Output to the device
The core method to send frames to the output device looks like:
// a frame object MFFrame myFrame; // grab a frame ((IMFSource)myLiveSource).SourceFrameGet(-1, out myFrame, ""); // send to receiver ((IMFReceiver)myRenderer).ReceiverFramePut(myFrame, -1, "");
To specify any properties of the MFRenderer object you should cast it to IMProps interface and use its methods, like PropsSet:
(myRenderer as IMProps).PropsSet("output.10bit", "true");