Пример #1
0
        private OpusDecoder(double frameSize, OpusSampleRate sampleRate, OpusAudioChannels audioChannels, bool frameSizeWasSpecified)
        {
            switch (frameSize)
            {
            case 2.5:
            case 5:
            case 10:
            case 20:
            case 40:
            case 60:
                break;

            default:
                throw new ArgumentException("Value must be one of the following: 2.5, 5, 10, 20, 40 or 60.", nameof(frameSize));
            }

            if (!Enum.IsDefined(typeof(OpusSampleRate), sampleRate))
            {
                throw new ArgumentException("Value is not defined in the enumeration.", nameof(sampleRate));
            }

            if (!Enum.IsDefined(typeof(OpusAudioCHannels), audioChannels))
            {
                throw new ArgumentException("Value is not defined in the enumeration.", nameof(audioChannels));
            }

            if (frameSizeWasSpecified)
            {
                FrameSize = frameSize;
            }

            SampleRate    = sampleRate;
            AudioChannels = audioChannels;

            _samples   = GetSampleCount(frameSize);
            _pcmLength = GetPCMLength(_samples);
            _handle    = FFI.opus_decoder_create((int)sampleRate, (int)audioChannels, out int error);

            ThrowIfError(error);
        }
Пример #2
0
 public static extern int opus_decode(SafeDecoderHandle st, IntPtr data, int len, IntPtr pcm, int frame_size, int decode_fec);