예제 #1
0
        StartCapture()
        {
            int hr;

            if (m_DeviceSelected)
            {
                if (m_strFile != null)
                {
                    // re-enable capture stream
                    IAMStreamControl pSC = (IAMStreamControl)m_pCapOutput;

                    // immediately!
                    pSC.StartAt(null, 0); // Ignore any error

                    // start capture graph
                    IMediaControl pMC = (IMediaControl)m_pCaptureGraph;
                    hr = pMC.Run();
                    DsError.ThrowExceptionForHR(hr);

                    hr = m_pBridge.BridgeGraphs(m_pSourceGraphSinkFilter, m_pCaptureGraphSourceFilter);
                    DsError.ThrowExceptionForHR(hr);

                    // If we make it here, we are capturing
                    m_Capturing = true;
                }
                else
                {
                    throw new Exception("File name not specified");
                }
            }
            else
            {
                throw new Exception("Device not selected");
            }
        }
예제 #2
0
 /// <summary>
 ///  stops any current recording and deletes the recording graph
 /// </summary>
 protected void StopAndDeleteRecordingGraph()
 {
     lock (instanceMutex)
     {
         if (_fileSinkMediaControl != null)
         {
             _fileSinkMediaControl.StopWhenReady();
         }
         if (_bridgeController != null)
         {
             _bridgeController.BridgeGraphs(null, null);
         }
         if (_bridgeSource != null)
         {
             Marshal.FinalReleaseComObject(_bridgeSource);
             _bridgeSource = null;
         }
         if (_muxer != null)
         {
             Marshal.FinalReleaseComObject(_muxer);
             _muxer = null;
         }
         if (_fileSink != null)
         {
             Marshal.FinalReleaseComObject(_fileSink);
             _fileSink = null;
         }
         if (_fileSinkGraphBuilder != null)
         {
             Marshal.FinalReleaseComObject(_fileSinkGraphBuilder);
             _fileSinkGraphBuilder = null;
         }
         if (_fileSinkCaptureGraphBuilder != null)
         {
             Marshal.FinalReleaseComObject(_fileSinkCaptureGraphBuilder);
             _fileSinkCaptureGraphBuilder = null;
         }
     }
 }
예제 #3
0
파일: ClipPlayer.cs 프로젝트: d3x0r/xperdex
        public void OnEndOfSegment1()
        {
            if (m_itCurrent == m_Clips.Count)
            {
                // ? already at the end
                return;
            }

            int itOld = m_itCurrent;

            // locate next graph
            if (m_pPlayNext < 0)
            {
                m_itCurrent++;

                if (m_itCurrent == m_Clips.Count)
                {
                    if (!m_bLoop)
                    {
                        // no more clips, so allow EOS to propagate through
                        // render graph. We will receive EC_COMPLETE eventually.
                        m_pController.NoMoreSegments();

                        // disconnect graphs -- but we cannot do that until NoMoreSegments has
                        // sent the EndOfStream through the bridge
                        m_pController.BridgeGraphs(null, null);
                        return;
                    }
                    else
                    {
                        m_pController.BridgeGraphs(null, null);
                        m_itCurrent = 0;
                    }
                }
            }
            else
            {
                m_itCurrent = m_pPlayNext;
                m_pPlayNext = -1;
            }

            // disconnect graphs before seeking the source graph
            m_tStartPosition = 0;

            ClipEntry ce = (ClipEntry)m_Clips[m_itCurrent];

            // looping to same graph? rewind now
            if (m_itCurrent == itOld)
            {
                ce.Prime(0);
            }
            else
            {
                // need to rewind clip for next time round
                // unless we are reusing it immediately (ie looping single clip)
                // it's better to do this when not in use
                ClipEntry ce3 = (ClipEntry)m_Clips[itOld];
                ce3.Prime(0);
            }

            // now we are about to connect it, so as soon as data is delivered out of the graph it
            // is no longer primed for re-use (it will need a new seek before using again)
            ce.InUse();

            // reconnect
            m_pController.BridgeGraphs(ce.SinkFilter(), m_pRenderGraphSourceFilter);
        }