Beispiel #1
0
        private void OpenFile(string _filename)
        {
            mAudioMeter1.SizeChanged -= mAudioMeter1_SizeChanged;
            mAudioMeter1.SizeChanged += mAudioMeter1_SizeChanged;
            // Open next file
            // Change current reader with new one
            lock (m_objLock) // For preview access from worker thread
            {
                try
                {
                    if (m_objMFReader == null)
                    {
                        m_objMFReader = new MFReaderClass();
                    }

                    m_avProps = new M_AV_PROPS();
                    m_avProps.vidProps.eVideoFormat = (eMVideoFormat)comboBoxVideoFormat.SelectedItem;

                    m_objMFReader.ReaderOpen(_filename, "");
                    checkBoxCG.Enabled     = true;
                    checkBoxHTML.Enabled   = true;
                    textBoxHTMLURL.Enabled = true;
                    pause();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error open file:" + _filename + "\n\n" + ex.Message);
                    return;
                }

                //Get file duration
                m_objMFReader.ReaderDurationGet(out m_playerState.dblDuration);
                m_playerState.strFileName = _filename;


                // Update audio track & TS programm Combo
                getAudioTracks();
                getTSPrograms();
                MFFrame pFrame;
                m_objMFReader.SourceFrameGetByTime(-1, -1, out pFrame, "");
                if (pFrame != null)
                {
                    mAudioMeter1.pFrame = pFrame;
                    mAudioMeter1.UpdateControl();
                    mAudioMeter1.SetValues();
                }

                if (m_threadWorker == null || !m_threadWorker.IsAlive)
                {
                    m_threadWorker      = new Thread(() => thread_DoWork(cancelSource.Token));
                    m_threadWorker.Name = "thread_DoWork";
                    m_threadWorker.Start();
                }
            }

            rewindToStart();

            GC.Collect();
        }
Beispiel #2
0
 private void comboVF_SelectedIndexChanged(object sender, EventArgs e)
 {
     lock (m_objLock)
     {
         m_avProps = new M_AV_PROPS();
         m_avProps.vidProps.eVideoFormat = (eMVideoFormat)comboBoxVideoFormat.SelectedItem;
     }
 }
Beispiel #3
0
        private void FillVideoFormats()
        {
            comboBoxVideoFormat.Items.Clear();

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_Custom);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_NTSC);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_NTSC_2398);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_NTSC_16x9);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_PAL);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_PAL_16x9);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD720_50p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD720_5994p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD720_60p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_2398p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_24p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_25p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_2997p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_30p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_50i);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_5994i);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_60i);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_50p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_5994p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_60p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_2398p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_24p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_25p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_50p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_5994p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_60p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_2398p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_24p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_25p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_DCI_2398p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_DCI_24p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_DCI_25p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_50i);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_5994i);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_60i);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_50p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_5994p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_60p);
            comboBoxVideoFormat.SelectedIndex = 0;

            m_avProps = new M_AV_PROPS();
            m_avProps.vidProps.eVideoFormat = (eMVideoFormat)comboBoxVideoFormat.SelectedItem;
        }
        private bool NextFrame()
        {
            // Get request pos and set pause and reverse flags
            double dblRequest = -1.0;
            string strParams  = string.Empty;

            // Update player state
            lock (m_playerState.stateLock)
            {
                if (m_playerState.state == eState.eST_Pause)
                {
                    strParams = " pause=true";
                }
                else if (m_playerState.state == eState.eST_PlayRev || m_playerState.state == eState.eST_StepRev)
                {
                    strParams = " reverse=true";
                }

                // Update player state
                if (m_playerState.state == eState.eST_StepFwd || m_playerState.state == eState.eST_StepRev)
                {
                    // Pause on next iteration - because single frame was requested
                    m_playerState.state = eState.eST_Pause;
                }

                // Get request time and set next cycle request to next frame
                // -1 as first parameter means "give me next frame", -5 means "give me next next 5th frame" etc,
                // this works accordingly when the reverse=true parameter is set.
                // positive values are uninterpreted as "give me frame at position"
                dblRequest = m_playerState.dblFrameRequest;
                m_playerState.dblFrameRequest = -1 * (int)(m_playerState.dblRate);
            }

            // Next frame cycle:
            // Get frame from reader and send to preview
            // Note: Preview keep frame according to frame time

            MFFrame pFrame  = null;
            MFFrame pFrame2 = null;

            lock (m_objLock) // For prevent reader replace in OpenFile() and overlay change
            {
                // Get next frame or frame by position
                // -1 as first parameter means "give me next frame", -5 means "give me next next 5th frame" etc,
                // this works accordingly when the reverse=true parameter is set.
                // positive values are uninterpreted as "give me frame at position"
                try
                {
                    if (m_objMFReader != null)
                    {
                        M_AV_PROPS m_avProps = new M_AV_PROPS();
                        m_avProps.vidProps.eVideoFormat = eMVideoFormat.eMVF_HD1080_25p;
                        M_AV_PROPS m_avProps2 = new M_AV_PROPS();
                        m_avProps2.vidProps.nHeight = 300;
                        m_avProps2.vidProps.nWidth  = 300;
                        m_avProps2.vidProps.dblRate = 25;


                        m_objMFReader.SourceFrameConvertedGetByTime(ref m_avProps, dblRequest, -1, out pFrame, "");
                        if (m_objMFReader2 != null)
                        {
                            m_objMFReader2.SourceFrameConvertedGetByTime(ref m_avProps2, dblRequest, -1, out pFrame2, "");
                        }
                    }
                    if (Overlay_chb.Checked & pFrame != null & pFrame2 != null)
                    {
                        pFrame.MFOverlay(pFrame2, null, 100, 100, 1, "audio_gain=-10", "ch1");
                    }


                    // Update avProps. Need for HTML plugin.
                    if (pFrame != null)
                    {
                        int nASamples = 0;
                        pFrame.MFAVPropsGet(out m_avProps, out nASamples);
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Error occurs during file decoding:\n\n" + ex.Message, m_playerState.strFileName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }

            if (pFrame == null)
            {
                Thread.Sleep(5);
                return(true);
            }

            try
            {
                // Demonstrate overlay - overlay another frame if any
                if (m_frOverlay != null)
                {
                    pFrame.MFOverlay(m_frOverlay, null, 50, 100, 0.5, "", "");
                }

                // Show CG object
                if (checkBoxCG.Checked)
                {
                    ShowPluggin(m_objCharGen, ref pFrame);
                    if (cgEditor != null)
                    {
                        cgEditor.m_objEditor_FrameProcessed(pFrame, null);
                    }
                }

                // Show CC
                if (checkBoxCC.Checked)
                {
                    if (m_objCCDisplay != null)
                    {
                        ShowPluggin(m_objCCDisplay, ref pFrame);
                    }
                }

                // Show HTML
                if (checkBoxHTML.Checked)
                {
                    lock (m_objHTMLLock)
                    {
                        if (m_objOverlayHTML != null)
                        {
                            ShowPluggin(m_objOverlayHTML, ref pFrame);
                            if (overlayHTMLWind != null && !overlayHTMLWind.IsDisposed)
                            {
                                overlayHTMLWind.UpdatePreview(pFrame);
                            }
                        }
                    }
                }

                mAudioMeter1.pFrame = pFrame;
                mAudioMeter1.SetValues();
                // Get frame timings
                pFrame.MFTimeGet(out mTime);

                double dblDur = 0;
                m_objMFReader.ReaderDurationGet(out dblDur);
                if (m_playerState.dblDuration != dblDur)
                {
                    m_playerState.dblDuration = dblDur;
                }

                // Send frame to Renderer
                SendToRenderer(pFrame);


                //pFrame.MFResize(eMFCC.eMFCC_Default, 250, 250, 0, out pFrame, "", "");


                //Send frame to the preview
                m_objPreview.ReceiverFramePut(pFrame, checkBoxRenderer.Checked ? 0 : -1, "");

                //Send to Sink
                SendToSink(pFrame);

                //Release frame - DO NOT FORGOT TO DO THIS !!!
                releaseComObj(pFrame);
                if (pFrame2 != null)
                {
                    releaseComObj(pFrame2);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Error occurs during frame processing:\n\n" + ex.Message, m_playerState.strFileName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            // Check for the last frame
            if ((mTime.eFFlags & eMFrameFlags.eMFF_Last) != 0)
            {
                lock (m_playerState.stateLock)
                {
                    // Pause playback at the end of the file if loop is disabled
                    if (!m_playerState.bLoop)
                    {
                        pause();
                    }

                    if (m_playerState.state == eState.eST_PlayRev)
                    {
                        // Rewind to end in case of reverse playback
                        rewindToEnd();
                    }
                    else if (m_playerState.state == eState.eST_PlayFwd)
                    {
                        // Rewind to start in case of direct playback
                        rewindToStart();
                    }
                }
            }

            return(true);
        }