예제 #1
0
 private static void CheckError(OpusError error)
 {
     if (error < 0)
     {
         throw new Exception($"Opus Error: {error}");
     }
 }
예제 #2
0
 protected static void CheckError(OpusError error)
 {
     if ((int)error < 0)
     {
         throw new Exception($"Opus Error: {error}");
     }
 }
예제 #3
0
 protected void CheckError(OpusError error)
 {
     if (error < OpusError.OK)
     {
         throw new OpusException(error);
     }
 }
예제 #4
0
파일: OpusCodec.cs 프로젝트: Kriste00/k
 private void CheckForError(OpusError err)
 {
     if (err < 0)
     {
         throw new Exception(string.Concat("Opus returned an error: ", err.ToString()));
     }
 }
예제 #5
0
        private static string GetMessage(OpusError error)
        {
            switch (error)
            {
            case OpusError.BadArg:
                return("One or more invalid/out of range arguments.");

            case OpusError.BufferTooSmall:
                return("Not enough bytes allocated in the buffer.");

            case OpusError.InternalError:
                return("An internal error was detected.");

            case OpusError.InvalidPacket:
                return("The compressed data passed is corrupted.");

            case OpusError.Unimplemented:
                return("Invalid/unsupported request number.");

            case OpusError.InvalidState:
                return("An encoder or decoder structure is invalid or already freed.");

            case OpusError.AllocFail:
                return("Memory allocation has failed.");

            default:
                return("An unknown error has occurred.");
            }
        }
예제 #6
0
        // Token: 0x0600015E RID: 350 RVA: 0x0000476C File Offset: 0x0000296C
        public unsafe static int OpusDecode(IntPtr decoder, int frameSize, Span <byte> pcm)
        {
            int num;

            fixed(byte *pinnableReference = pcm.GetPinnableReference())
            {
                byte *data = pinnableReference;

                num = Interop._OpusDecode(decoder, null, 0, data, frameSize, 1);
            }

            if (num < 0)
            {
                OpusError opusError = (OpusError)num;
                throw new Exception(string.Format("Could not decode PCM data from Opus: {0} ({1}).", opusError, (int)opusError));
            }
            return(num);
        }
예제 #7
0
        // Token: 0x0600015D RID: 349 RVA: 0x000046FC File Offset: 0x000028FC
        public unsafe static int OpusDecode(IntPtr decoder, ReadOnlySpan <byte> opus, int frameSize, Span <byte> pcm, bool useFec)
        {
            int num;

            fixed(byte *pinnableReference = opus.GetPinnableReference())
            {
                byte *opusData = pinnableReference;

                fixed(byte *pinnableReference2 = pcm.GetPinnableReference())
                {
                    byte *data = pinnableReference2;

                    num = Interop._OpusDecode(decoder, opusData, opus.Length, data, frameSize, useFec ? 1 : 0);
                }
            }

            if (num < 0)
            {
                OpusError opusError = (OpusError)num;
                throw new Exception(string.Format("Could not decode PCM data from Opus: {0} ({1}).", opusError, (int)opusError));
            }
            return(num);
        }
예제 #8
0
        // Token: 0x0600015B RID: 347 RVA: 0x00004648 File Offset: 0x00002848
        public unsafe static void OpusEncode(IntPtr encoder, ReadOnlySpan <byte> pcm, int frameSize, ref Span <byte> opus)
        {
            int num;

            fixed(byte *pinnableReference = pcm.GetPinnableReference())
            {
                byte *pcmData = pinnableReference;

                fixed(byte *pinnableReference2 = opus.GetPinnableReference())
                {
                    byte *data = pinnableReference2;

                    num = Interop._OpusEncode(encoder, pcmData, frameSize, data, opus.Length);
                }
            }

            if (num < 0)
            {
                OpusError opusError = (OpusError)num;
                throw new Exception(string.Format("Could not encode PCM data to Opus: {0} ({1}).", opusError, (int)opusError));
            }
            opus = opus.Slice(0, num);
        }
예제 #9
0
 public static extern IntPtr CreateEncoder(int Fs, int channels, int application, out OpusError error);
예제 #10
0
 public static extern IntPtr CreateDecoder(int Fs, int channels, out OpusError error);
예제 #11
0
 private static extern IntPtr _OpusCreateDecoder(int sampleRate, int channels, out OpusError error);
예제 #12
0
 IntPtr IOpusConverter.CreateDecoder(int Fs, int channels, out OpusError error)
 {
     return(CreateDecoder(Fs, channels, out error));
 }
예제 #13
0
 IntPtr IOpusConverter.CreateEncoder(int Fs, int channels, int application, out OpusError error)
 {
     return(CreateEncoder(Fs, channels, application, out error));
 }
예제 #14
0
 static extern IntPtr op_open_callbacks(IntPtr source, ref _OpusFileCallbacks cb, IntPtr initial_data, IntPtr initial_bytes, out OpusError error);
예제 #15
0
 private static extern IntPtr CreateEncoder(int Fs, int channels, int application, out OpusError error);
예제 #16
0
 public OpusException(OpusError error) : base(error.ToString())
 {
 }
예제 #17
0
 public static extern IntPtr CreateDecoder(int Fs, int channels, out OpusError error);
예제 #18
0
 public OpusException(OpusError error)
     : base(error.ToString())
 {
 }
예제 #19
0
파일: OpusInterop.cs 프로젝트: Vysn/Voice
 internal static extern IntPtr opus_encoder_create(int sampleRate, int channels, int application,
                                                   out OpusError error);
예제 #20
0
 static extern IntPtr op_open_callbacks(IntPtr source, ref _OpusFileCallbacks cb, IntPtr initial_data, IntPtr initial_bytes, out OpusError error);
예제 #21
0
 private static extern IntPtr OpusCreateEncoder(int sampleRate, int channels, int application,
                                                out OpusError error);
예제 #22
0
파일: OpusInterop.cs 프로젝트: Vysn/Voice
 internal static extern IntPtr opus_decoder_create(int sampleRate, int channels, out OpusError error);