/// Reads a StreamInfo block and populates the reader with stream information.
Reads a StreamInfo block and populates the reader with stream information.
Reads a StreamInfo block and populates the reader with stream information .
fn read_stream_info_block<B : ByteStream>(
    block_stream: &mut B,
    streams: &mut Vec<Stream>,
    parser: &mut PacketParser,
) -> Result<()> {
    // Only one StreamInfo block, and therefore ony one Stream, is allowed per media source stream.
    if streams.is_empty() {
        let info = StreamInfo::read(block_stream)?;
        info!("stream md5 = {:x?}", info.md5);
        // Populate the codec parameters with the parameters from the stream information block.
        let mut codec_params = CodecParameters::new();
        codec_params
            .for_codec(CODEC_TYPE_FLAC)
            .with_sample_rate(info.sample_rate)
            .with_bits_per_sample(info.bits_per_sample)
            .with_max_frames_per_packet(u64::from(info.block_len_max))
            .with_channels(info.channels)
            .with_packet_data_integrity(true);
        // Total samples (per channel) aka frames may or may not be stated in StreamInfo.
        if let Some(n_frames) = info.n_samples {
            codec_params.with_n_frames(n_frames);
        }
        // Reset the packet parser.
        parser.reset(info);
        // Add the stream.
        streams.push(Stream::new(0, codec_params));
    }
    else {
        return decode_error("found more than one stream info block");
    }
    Ok(())
}
fn read_stream_info_block < B : ByteStream > ( block_stream : & mut B , streams : & mut Vec < Stream > , parser : & mut PacketParser , ) -> Result < ( ) > { // Only one StreamInfo block, and therefore ony one Stream, is allowed per media source stream. if streams . is_empty ( ) { let info = StreamInfo :: read ( block_stream ) ? ; info ! ( " " info md5 ) ; // Populate the codec parameters with the parameters from the stream information block. let mut codec_params = CodecParameters :: new ( ) ; codec_params . for_codec ( CODEC_TYPE_FLAC ) . with_sample_rate ( info . sample_rate ) . with_bits_per_sample ( info . bits_per_sample ) . with_max_frames_per_packet ( u64 :: from ( info . block_len_max ) ) . with_channels ( info . channels ) . with_packet_data_integrity ( true ) ; // Total samples (per channel) aka frames may or may not be stated in StreamInfo. if let Some ( n_frames ) = info . n_samples { codec_params . with_n_frames ( n_frames ) ; } // Reset the packet parser. parser . reset ( info ) ; // Add the stream. streams . push ( Stream :: new ( 0 , codec_params ) ) ; } else { return decode_error ( " " ) ; } Ok ( ( ) ) }
Reads a StreamInfo block and populates the reader with stream information.
Reads a StreamInfo block and populates the reader with stream information .
block_stream
&mut B
streams
&mut Vec<Stream>
parser
&mut PacketParser