示例#1
0
        private void TestProcess()
        {
            const int iSize = 44100;

            int         hr;
            int         iCurSize;
            IntPtr      ip;
            AMMediaType pmt = new AMMediaType();

            DMOOutputDataBuffer [] pOutBuf = new DMOOutputDataBuffer[1];

            hr = m_imo.GetInputType(0, 0, pmt);
            hr = m_imo.SetInputType(0, pmt, DMOSetType.None);

            hr = m_imo.GetOutputType(0, 0, pmt);
            hr = m_imo.SetOutputType(0, pmt, DMOSetType.None);

            hr = m_imo.AllocateStreamingResources();
            DMOError.ThrowExceptionForHR(hr);

            DoBuff d = new DoBuff(iSize);

            d.SetLength(iSize);
            d.GetBufferAndLength(out ip, out iCurSize);

            hr = m_imoip.Process(iSize, ip, 0, DMOInplaceProcess.Normal);
            DMOError.ThrowExceptionForHR(hr);
        }
示例#2
0
        /// <summary>
        /// Processes a block of data.
        /// The application supplies a pointer to a block of input data. The DMO processes the data in place.
        /// </summary>
        /// <param name="size">Size of the data, in bytes.</param>
        /// <param name="offset">offset into buffer</param>
        /// <param name="data">In/Out Data Buffer</param>
        /// <param name="timeStart">Start time of the data.</param>
        /// <param name="inPlaceFlag">DmoInplaceProcessFlags</param>
        /// <returns>Return value when Process is executed with IMediaObjectInPlace</returns>
        public DmoInPlaceProcessReturn Process(int size, int offset, byte[] data, long timeStart, DmoInPlaceProcessFlags inPlaceFlag)
        {
            var pointer = Marshal.AllocHGlobal(size);

            Marshal.Copy(data, offset, pointer, size);

            var result = mediaObjectInPlace.Process(size, pointer, timeStart, inPlaceFlag);

            Marshal.ThrowExceptionForHR(result);

            Marshal.Copy(pointer, data, offset, size);
            Marshal.FreeHGlobal(pointer);

            return((DmoInPlaceProcessReturn)result);
        }