Ejemplo n.º 1
0
 public void Destroy()
 {
     try
     {
         OpusLibrary.Java_aopus_OpusLibrary_decoderDestroy(JNIEnv.Handle, IntPtr.Zero, State);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Ejemplo n.º 2
0
 public Decoder(int clockRate, int channels, int packetTime)
 {
     try
     {
         State = OpusLibrary.Java_aopus_OpusLibrary_decoderCreate(JNIEnv.Handle, IntPtr.Zero, clockRate, channels, packetTime);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Ejemplo n.º 3
0
        public byte[] Encode(byte[] data, int index, int length)
        {
            IntPtr dataPtr = JNIEnv.NewArray(data);

            try
            {
                var result = OpusLibrary.Java_aopus_OpusLibrary_encoderEncode(JNIEnv.Handle, IntPtr.Zero, State, dataPtr, index, length);
                JniEnvironment.References.CreatedReference(new JniObjectReference(result, JniObjectReferenceType.Local));
                return((byte[])JNIEnv.GetArray(result, JniHandleOwnership.TransferLocalRef, typeof(byte)));
            }
            finally
            {
                JNIEnv.DeleteLocalRef(dataPtr);
            }
        }
Ejemplo n.º 4
0
        public byte[] Decode(byte[] encodedData, bool fec)
        {
            IntPtr encodedDataPtr = JNIEnv.NewArray(encodedData);

            try
            {
                var result   = OpusLibrary.Java_aopus_OpusLibrary_decoderDecode2(JNIEnv.Handle, IntPtr.Zero, State, encodedDataPtr, fec);
                var transfer = (encodedData == null);
                if (transfer)
                {
                    JniEnvironment.References.CreatedReference(new JniObjectReference(result, JniObjectReferenceType.Local));
                }
                return((byte[])JNIEnv.GetArray(result, (transfer ? JniHandleOwnership.TransferLocalRef : JniHandleOwnership.DoNotTransfer), typeof(byte)));
            }
            finally
            {
                JNIEnv.DeleteLocalRef(encodedDataPtr);
            }
        }
Ejemplo n.º 5
0
 public void DeactivateFEC()
 {
     OpusLibrary.Java_aopus_OpusLibrary_encoderDeactivateFEC(JNIEnv.Handle, IntPtr.Zero, State);
 }
Ejemplo n.º 6
0
 public void ActivateFEC(int packetLossPercent)
 {
     OpusLibrary.Java_aopus_OpusLibrary_encoderActivateFEC(JNIEnv.Handle, IntPtr.Zero, State, packetLossPercent);
 }