Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
            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);
            }
Ejemplo n.º 3
0
 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);
Ejemplo n.º 4
0
 public static extern void opus_decoder_destroy([NativeTypeName("OpusDecoder *")] OpusDecoder *st);
Ejemplo n.º 5
0
 public static extern int opus_decoder_ctl([NativeTypeName("OpusDecoder *")] OpusDecoder *st, int request);
Ejemplo n.º 6
0
 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);
Ejemplo n.º 7
0
 public static extern int opus_decoder_init([NativeTypeName("OpusDecoder *")] OpusDecoder *st, [NativeTypeName("opus_int32")] int Fs, int channels);