Exemplo n.º 1
0
        private void _buffer(Stream input)
        {
            Console.WriteLine("[Initial buffering] Meta interval: {0}", this.StationInformation.ContainsKey("icy-metaint") ? long.Parse(this.StationInformation["icy-metaint"]) : -1);

            // Auto-fix the stream and auto-parse metadata
            stream =
                new FixedBufferedStream(
                    input,
                    this.StationInformation.ContainsKey("icy-metaint") ? long.Parse(this.StationInformation["icy-metaint"]) : -1
                    );

            // Read first frame
            this.Status = StreamStatus.Buffering;
            switch (Codec)
            {
            case StreamCodec.MP3:
                // Make a decoder which can decode that (and sequentially following) frames
                // The decoder will decode to 16-bit samples
                frame       = Mp3Frame.LoadFromStream(stream);
                _decoderMp3 = new AcmMp3FrameDecompressor(new Mp3WaveFormat(frame.SampleRate, frame.ChannelMode == ChannelMode.Mono ? 1 : 2, frame.FrameLength, frame.BitRate));
                Console.WriteLine("[Initial buffering] MP3 decoder will encode to {0}-encoded wave format.", _decoderMp3.OutputFormat.Encoding);
                break;

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 2
0
        private void _buffer(Stream input)
        {
            Console.WriteLine("[Initial buffering] Meta interval: {0}", this.StationInformation.ContainsKey("icy-metaint") ? long.Parse(this.StationInformation["icy-metaint"]) : -1);

            // Auto-fix the stream and auto-parse metadata
            stream =
                new FixedBufferedStream(
                    input,
                    this.StationInformation.ContainsKey("icy-metaint") ? long.Parse(this.StationInformation["icy-metaint"]) : -1
                );

            // Read first frame
            this.Status = StreamStatus.Buffering;
            switch (Codec)
            {
                case StreamCodec.MP3:
                    // Make a decoder which can decode that (and sequentially following) frames
                    // The decoder will decode to 16-bit samples
                    frame = Mp3Frame.LoadFromStream(stream);
                    _decoderMp3 = new AcmMp3FrameDecompressor(new Mp3WaveFormat(frame.SampleRate, frame.ChannelMode == ChannelMode.Mono ? 1 : 2, frame.FrameLength, frame.BitRate));
                    Console.WriteLine("[Initial buffering] MP3 decoder will encode to {0}-encoded wave format.", _decoderMp3.OutputFormat.Encoding);
                    break;
                default:
                    throw new NotSupportedException();
            }
        }