Exemplo n.º 1
0
        //-------------------------------------------------------------------
        // Name: ProcessSamplesFromQueue
        // Description:
        //
        // Removes all of the samples and markers that are currently in the
        // queue and processes them.
        //
        // If bFlushData = DropSamples:
        //     For each marker, send an MEStreamSinkMarker event, with hr = E_ABORT.
        //     For each sample, drop the sample.
        //
        // If bFlushData = WriteSamples
        //     For each marker, send an MEStreamSinkMarker event, with hr = S_OK.
        //     For each sample, write the sample to the file.
        //
        // This method is called when we flush, stop, restart, receive a new
        // sample, or receive a marker.
        //-------------------------------------------------------------------
        void ProcessSamplesFromQueue(FlushState bFlushData)
        {
            // Enumerate all of the samples/markers in the queue.
            while (m_SampleQueue.Count > 0)
            {
                object pUnk = null;
                IMarker pMarker = null;
                IMFSample pSample = null;

                pUnk = m_SampleQueue.Dequeue();

                // Figure out if this is a marker or a sample.
                pMarker = pUnk as IMarker;

                if (pMarker == null)
                {
                    // If this is a sample, write it to the file.
                    pSample = (IMFSample)pUnk;
                }

                try
                {
                    // Now handle the sample/marker appropriately.
                    if (pMarker != null)
                    {
                        SendMarkerEvent(pMarker, bFlushData);
                    }
                    else
                    {
                        Debug.Assert(pSample != null);    // Not a marker, must be a sample
                        if (bFlushData == FlushState.WriteSamples)
                        {
                            WriteSampleToFile(pSample);
                        }
                    }
                }
                finally
                {
                    //SAFE_RELEASE(pUnk);
                    SafeRelease(pMarker);
                    SafeRelease(pSample);
                }
            }     // while loop
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------
        // Name: SendMarkerEvent
        // Description: Saned a marker event.
        //
        // pMarker: Pointer to our custom IMarker interface, which holds
        //          the marker information.
        //-------------------------------------------------------------------
        void SendMarkerEvent(IMarker pMarker, FlushState fs)
        {
            int hrStatus = 0;  // Status code for marker event.

            if (fs == FlushState.DropSamples)
            {
                hrStatus = E_Abort;
            }

            PropVariant var = new PropVariant();

            // Get the context data.
            pMarker.GetContext(var);

            QueueEvent(MediaEventType.MEStreamSinkMarker, Guid.Empty, hrStatus, var);

            var.Clear();
        }
Exemplo n.º 3
0
        private void InitFlushState(bool onlyDocStore)
        {
            lock (this)
            {
                InitSegmentName(onlyDocStore);

                if (flushState == null)
                {
                    flushState = new FlushState();
                    flushState.directory = directory;
                    flushState.docWriter = this;
                }

                flushState.docStoreSegmentName = docStoreSegment;
                flushState.segmentName = segment;
                flushState.numDocsInRAM = numDocsInRAM;
                flushState.numDocsInStore = numDocsInStore;
                flushState.flushedFiles = new System.Collections.Generic.Dictionary<string,string>();
            }
        }