internal unsafe OpusDecodingTranscoder(PipeReader input, OpusAudioCodec codec) { _codec = codec; int status; _decoder = opus_decoder_create(codec.SamplingRate, codec.ChannelCount, &status); if (status < 0) { ThrowExternalException("Could not create Opus Decoder", status); } _input = input; _pipe = new Pipe(); }
static unsafe int WriteInternal(OpusDecoder *decoder, int channelCount, ReadOnlySpan <byte> frame, PipeWriter writer) { var block = writer.GetSpan(OutputBufferSize); int blockSize = block.Length / sizeof(short) / channelCount; int encoded; fixed(byte *opusData = frame) fixed(short *outputBlock = MemoryMarshal .Cast <byte, short>(block)) encoded = opus_decode(decoder, opusData, frame.Length, outputBlock + 1, blockSize, 1); return(encoded > 0 && !BinaryPrimitives.TryWriteInt16LittleEndian(block, (short)encoded) ? -1 : encoded); }
public static extern int opus_decoder_get_nb_samples([NativeTypeName("const OpusDecoder *")] OpusDecoder *dec, [NativeTypeName("const unsigned char []")] byte packet, [NativeTypeName("opus_int32")] int len);
public static extern void opus_decoder_destroy([NativeTypeName("OpusDecoder *")] OpusDecoder *st);
public static extern int opus_decoder_ctl([NativeTypeName("OpusDecoder *")] OpusDecoder *st, int request);
public static extern int opus_decode_float([NativeTypeName("OpusDecoder *")] OpusDecoder *st, [NativeTypeName("const unsigned char *")] byte *data, [NativeTypeName("opus_int32")] int len, [NativeTypeName("float *")] float *pcm, int frame_size, int decode_fec);
public static extern int opus_decoder_init([NativeTypeName("OpusDecoder *")] OpusDecoder *st, [NativeTypeName("opus_int32")] int Fs, int channels);