Beispiel #1
0
        /// <summary>
        /// Accept the input buffers to be processed.  You'll want to read
        /// the MSDN docs on this one.  One point worth noting is that DMO
        /// doesn't require that one complete block be passed at a time.
        /// Picture a case where raw data is being read from a file, and your
        /// DMO is the first to process it.  The chunk of data you receive
        /// might represent one image, 5 images, half an image, etc.  Likewise,
        /// your input could contain both video and audio that you are splitting
        /// into two output streams.
        /// That helps explain some of the parameters you see here and in
        /// InternalProcessOutput.
        /// Note that while DMO doesn't insist on it, for this sample, we
        /// specifically request that only complete buffers be provided.
        /// </summary>
        /// <param name="inputStreamIndex">Stream Index</param>
        /// <param name="mediaBuffer">Interface that holds the input data</param>
        /// <param name="flags">Flags to control input processing</param>
        /// <param name="timestamp">Timestamp of the sample</param>
        /// <param name="timelength">Duration of the sample</param>
        /// <returns>S_FALSE if there is no output, S_OK otherwise</returns>
        protected override int InternalProcessInput(
            int inputStreamIndex,
            [In] IMediaBuffer mediaBuffer,
            DMOInputDataBuffer flags,
            long timestamp,
            long timelength)
        {
            // Check state - if we already have a buffer, we shouldn't be getting another
            Debug.Assert(this.inputStreams[inputStreamIndex].Buffer == null, "We already have a buffer, we shouldn't be getting another");

            IntPtr bufferPointer;
            int    bufferByteCount;

            int hr = mediaBuffer.GetBufferAndLength(out bufferPointer, out bufferByteCount);

            this.inputStreams[inputStreamIndex].BufferPointer   = bufferPointer;
            this.inputStreams[inputStreamIndex].BufferByteCount = bufferByteCount;

            if (hr >= 0)
            {
                // Ignore zero length buffers
                if (this.inputStreams[inputStreamIndex].BufferByteCount > 0)
                {
                    this.inputStreams[inputStreamIndex].Buffer = mediaBuffer;

                    // Cast the input flags to become output flags
                    this.bufferFlags = (DMOOutputDataBufferFlags)flags;

                    // If there is a time, store it
                    if (0 == (flags & DMOInputDataBuffer.Time))
                    {
                        this.inputStreams[inputStreamIndex].BufferTimeStamp = MaxTime;
                    }
                    else
                    {
                        this.inputStreams[inputStreamIndex].BufferTimeStamp = timestamp;
                    }

                    // If there is a TimeLength, store it
                    if (0 == (flags & DMOInputDataBuffer.TimeLength))
                    {
                        this.inputStreams[inputStreamIndex].BufferTimeLength = -1;
                    }
                    else
                    {
                        this.inputStreams[inputStreamIndex].BufferTimeLength = timelength;
                    }

                    hr = SOK;
                }
                else
                {
                    this.ReleaseInputBuffs(inputStreamIndex);
                    hr = SFALSE;
                }
            }

            return(hr);
        }
Beispiel #2
0
        /// <summary>
        /// Accept the input buffers to be processed.  You'll want to read
        /// the MSDN docs on this one.  One point worth noting is that DMO
        /// doesn't require that one complete block be passed at a time.
        /// Picture a case where raw data is being read from a file, and your
        /// DMO is the first to process it.  The chunk of data you receive
        /// might represent one image, 5 images, half an image, etc.  Likewise,
        /// your input could contain both video and audio that you are splitting
        /// into two output streams.
        /// That helps explain some of the parameters you see here and in
        /// InternalProcessOutput.
        /// Note that while DMO doesn't insist on it, for this sample, we
        /// specifically request that only complete buffers be provided.
        /// </summary>
        /// <param name="dwInputStreamIndex">Stream Index</param>
        /// <param name="pBuffer">Interface that holds the input data</param>
        /// <param name="dwFlags">Flags to control input processing</param>
        /// <param name="rtTimestamp">Timestamp of the sample</param>
        /// <param name="rtTimelength">Duration of the sample</param>
        /// <returns>S_FALSE if there is no output, S_OK otherwise</returns>
        override protected int InternalProcessInput(
            int dwInputStreamIndex,
            [In] IMediaBuffer pBuffer,
            DMOInputDataBuffer dwFlags,
            long rtTimestamp,
            long rtTimelength)
        {
            //  Check state - if we already have a buffer, we shouldn't be getting another
            Debug.Assert(m_pBuffer == null);

            int cbData;

            int hr = pBuffer.GetBufferAndLength(out m_InBuffer, out m_cbInData);

            if (hr >= 0)
            {
                // Ignore zero length buffers
                if (m_cbInData > 0)
                {
                    m_pBuffer = pBuffer;

                    // Cast the input flags to become output flags
                    m_Flags = (DMOOutputDataBufferFlags)dwFlags;

                    // If there is a time, store it
                    if (0 == (dwFlags & DMOInputDataBuffer.Time))
                    {
                        m_TimeStamp = MAX_TIME;
                    }
                    else
                    {
                        m_TimeStamp = rtTimestamp;
                    }


                    // If there is a TimeLength, store it
                    if (0 == (dwFlags & DMOInputDataBuffer.TimeLength))
                    {
                        m_TimeLength = -1;
                    }
                    else
                    {
                        m_TimeLength = rtTimelength;
                    }
                    hr = S_OK;
                }
                else
                {
                    ReleaseInputBuffs();
                    hr = S_FALSE;
                }
            }

            return(hr);
        }