Пример #1
0
        public int AudioDec(byte[] inData, ref byte[] outData)
        {
            //lock (this) {

            if (_isReleased)
            {
                return(0);
            }

            // var size = System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64;

            BFrame bframe = new BFrame();
            //bframe.Buff = FunctionEx.BytesToIntPtr(inData);
            //bframe.Size = inData.Length;
            // IntPtr pbframe = FunctionEx.StructToIntPtr(bframe);
            IntPtr pbframe = IntPtr.Zero;

            var decSize = ffimp_audio_decode(pAVObj, inData, inData.Length, ref pbframe);

            bframe  = FunctionEx.IntPtrToStruct <BFrame>(pbframe, 0, Marshal.SizeOf(bframe));
            outData = FunctionEx.IntPtrToBytes(bframe.Buff, 0, bframe.Size);

            return(bframe.Size);
            //}
        }
Пример #2
0
        public int AudioEnc(byte[] inData, ref byte[] outData)
        {
            lock (this) {
                if (_isReleased)
                {
                    return(0);
                }
                var pInData = FunctionEx.BytesToIntPtr(inData);

                BFrame bframe = new BFrame();
                bframe.Buff = FunctionEx.BytesToIntPtr(inData);
                bframe.Size = inData.Length;
                IntPtr pbframe         = FunctionEx.StructToIntPtr(bframe);
                var    encFrameBuffLen = 192000;
                var    encFrameBuff    = Marshal.AllocHGlobal(encFrameBuffLen);

                var encSize = ffimp_audio_encode(pAVObj, encFrameBuff, encFrameBuffLen, pbframe);
                if (encSize == -1)
                {
                    return(encSize);
                }
                outData = FunctionEx.IntPtrToBytes(encFrameBuff, 0, encSize);

                Marshal.FreeHGlobal(pInData);
                Marshal.FreeHGlobal(encFrameBuff);
                return(encSize);
            }
        }