m_objPanelPreview = new Panel[9] { panel1, panel2, panel3, panel4, panel5, panel6, panel7, panel8, panel9 };
private void NineViewForm_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
m_objMFReader = new MFReaderClass[9];
m_objPreview = new MFPreviewClass[9];
m_objAudioMeter = new Object[9] { mAudioMeter1, mAudioMeter2, mAudioMeter3, mAudioMeter4, mAudioMeter5,
mAudioMeter6, mAudioMeter7, mAudioMeter8, mAudioMeter9 };
m_objPanelPreview = new Panel[9] { panel1, panel2, panel3, panel4, panel5, panel6, panel7, panel8, panel9 };
for (int i = 0; i < 9; i++)
{
m_objMFReader[i] = new MFReaderClass();
m_objPreview[i] = new MFPreviewClass();
m_objPreview[i].PreviewWindowSet("", m_objPanelPreview[i].Handle.ToInt32());
m_objPreview[i].PreviewEnable("", 0, 1);
//mAudioMeter1.ChannelsUpdated += mAudioMeter1_ChannelsUpdated;
}
//showUdpData();
cancelSource = new CancellationTokenSource();
m_threadWorker = new Thread(() => thread_DoWork(cancelSource.Token));
m_threadWorker.Name = "thread_DoWork";
m_threadWorker.Start();
}
#region CALL THREAD
private void thread_DoWork(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
DisplayFrame();
}
}
private void DisplayFrame()
{
lock (m_objLock)
{
if (playerState.Count > 0)
{
foreach (var state in playerState)
{
if (state.ViewType == "file")
{
int index = state.playerIndex;
MFFrame pFrame;
m_objMFReader[index].SourceFrameGetByTime(-1, -1, out pFrame, "");
if (pFrame != null)
{
((MAudioMeter)m_objAudioMeter[index]).pFrame = pFrame;
((MAudioMeter)m_objAudioMeter[index]).UpdateControl();
((MAudioMeter)m_objAudioMeter[index]).SetValues();
((MFPreviewClass)m_objPreview[index]).ReceiverFramePut(pFrame, -1, "");
}
Marshal.ReleaseComObject(pFrame);
}
else if (state.ViewType == "udp")
{
int index = state.playerIndex;
MFFrame pFrame;
m_objMFReader[index].SourceFrameGetByNumber(-1, -1, out pFrame, "");
if (pFrame != null)
{
((MAudioMeter)m_objAudioMeter[index]).pFrame = pFrame;
((MAudioMeter)m_objAudioMeter[index]).UpdateControl();
((MAudioMeter)m_objAudioMeter[index]).SetValues();
((MFPreviewClass)m_objPreview[index]).ReceiverFramePut(pFrame, -1, "");
}
Marshal.ReleaseComObject(pFrame);
}
}
}
}
}
#endregion