Exemple #1
0
        void StartTest()
        {
            bool reading = true;

            while (reading)
            {
                // Read the next frame from our source video
                m_objRed.SourceFrameGet(-1, out MFORMATSLib.MFFrame sourceFrame, "");

                // Get the information about the frame and stop reading if we reached the last frame
                sourceFrame.MFAllGet(out MFORMATSLib.MF_FRAME_INFO frameInfo);
                if ((frameInfo.mTime.eFFlags & MFORMATSLib.eMFrameFlags.eMFF_Last) != 0)
                {
                    reading = false;
                }

                // Send the frame to the encoder
                m_objWriter.ReceiverFramePut(sourceFrame, -1, "");
                m_objPrev.ReceiverFramePut(sourceFrame, -1, "");

                // Release the source frame
                Marshal.ReleaseComObject(sourceFrame);
            }
            m_objRed.ReaderClose();
            m_objWriter.WriterClose(1);
        }
Exemple #2
0
        private void thread_DoWork(CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                if (start)
                {
                    count++;
                    if (count >= 0 && count <= 3000)
                    {
                        MFFrame frame;
                        m_objReader.SourceFrameGet(-1, out frame, "");
                        m_objPreview.ReceiverFramePut(frame, -1, "");
                        //m_objWriter.ReceiverFramePut(frame, -1, "");

                        Marshal.ReleaseComObject(frame);
                    }
                    if (count > 3000)
                    {
                        endTime = DateTime.Now;
                        //m_objWriter.WriterClose(0);
                        m_objReader.ReaderClose();

                        BeginInvoke(new InvokeDelegate(UpdateButton));
                        start = false;
                    }
                    BeginInvoke(new InvokeDelegate(UpdateLabel));
                }
            }
        }
Exemple #3
0
 private void stopPub_btn_Click(object sender, EventArgs e)
 {
     starFile = false;
     m_objReaderFile.ReaderClose();
     Marshal.ReleaseComObject(m_objReaderFile);
     openAndPublish_btn.BackColor = Color.Gray;
 }
Exemple #4
0
 private void stopRec_btn_Click(object sender, EventArgs e)
 {
     startStream = false;
     m_objReaderStream.ReaderClose();
     Marshal.ReleaseComObject(m_objReaderStream);
     GC.Collect();
     receiveStream_btn.BackColor = Color.Gray;
 }
        public void Dispose()
        {
            if (State == MediaPlayerState.Disposed)
            {
                return;
            }

            Stop();

            mfReader.ReaderClose();

            State = MediaPlayerState.Disposed;
        }
Exemple #6
0
        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            cancelSource.Cancel();
            // Release Reader (the worker could be in running state at this moment -> use lock)

            m_threadWorker.Join(1000);

            if (m_objMFReader != null)
            {
                m_objMFReader.ReaderClose();
                releaseComObj(m_objMFReader);
            }

            m_objMFSink.SinkClose();
        }
Exemple #7
0
        private void comboBoxExtSources_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxExtSources.SelectedIndex > 0)
            {
                comboBoxV.Enabled          = false;
                comboBoxVideoLine.Enabled  = false;
                comboBoxVF.Enabled         = false;
                comboBoxAudio.Enabled      = false;
                comboBoxAudioEx.Enabled    = false;
                buttonUpdateLineIn.Enabled = false;
                buttonInit.Enabled         = false;
                buttonCloseDev.Enabled     = false;
                livePropsList.Enabled      = false;

                try
                {
                    m_objReader.ReaderOpen("mp://" + comboBoxExtSources.SelectedItem, "");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed load a source.\n\n" + ex);
                    return;
                }

                m_bWork = true;
            }
            else
            {
                m_bWork = false;
                m_objReader.ReaderClose();

                comboBoxV.Enabled          = true;
                comboBoxVideoLine.Enabled  = true;
                comboBoxVF.Enabled         = true;
                comboBoxAudio.Enabled      = true;
                comboBoxAudioEx.Enabled    = true;
                buttonUpdateLineIn.Enabled = true;
                buttonInit.Enabled         = true;
                buttonCloseDev.Enabled     = true;
                livePropsList.Enabled      = true;
            }
        }
Exemple #8
0
        private void Button1_Click(object sender, EventArgs e)
        {
            reader.PropsSet("experimental.mfcodecs", "true");
            reader.PropsSet("experimental.out_video_packets", "true");
            reader.PropsSet("external_process", "false");
            reader.ReaderOpen(@"M:\TEST_VIDEOS\Moneyball.2011.720p.BluRay.x264-HiDt.mkv", "");

            writer.PropsSet("external_process", "false");
            writer.WriterSet(@"M:\TempVideo\mariovideo.mp4", 0, "format='mp4' video::codec='packets' audio::codec='audio_packets'");
            //writer.PropsSet("rate_control", "true");
            //writer.PropsSet("pull_mode", "false");


            var w = new Stopwatch();

            w.Start();

            DateTime start = DateTime.Now;

            while (count <= 2000)
            {
                count++;
                if (count >= 1000)
                {
                    MFFrame frame;
                    reader.SourceFrameGet(-1, out frame, "");
                    writer.ReceiverFramePut(frame, -1, "");
                    prev.ReceiverFramePut(frame, -1, "");
                    Marshal.ReleaseComObject(frame);

                    BeginInvoke(new InvokeDelegate(UpdateLabel));
                }
            }
            DateTime end = DateTime.Now;

            w.Stop();
            writer.WriterClose(0);
            reader.ReaderClose();
            int dif = (end.Millisecond + end.Second * 1000 + end.Minute * 60 * 1000) - (start.Millisecond + start.Second * 1000 + start.Minute * 60 * 1000);

            button1.Text = "END. Dif ==" + dif.ToString();
        }
Exemple #9
0
 private void Stop_btn_Click(object sender, EventArgs e)
 {
     start = false;
     m_objReader.ReaderClose();
     m_objWriter.WriterClose(0);
 }