import { ITokenizer } from 'strtok3/lib/core' ; import * as initDebug from 'debug' ; import { IPageHeader } from '../Ogg' ; import { VorbisParser } from '../vorbis/VorbisParser' ; import { IOptions } from '../../type' ; import { INativeMetadataCollector } from '../../common/MetadataCollector' ; import * as Speex from './Speex' ; const debug = initDebug ( 'music-metadata:parser:ogg:speex' ) ; /**
 * Speex, RFC 5574
 * Ref:
 *   https://www.speex.org/docs/manual/speex-manual/
 *   https://tools.ietf.org/html/rfc5574
 */ export class SpeexParser extends VorbisParser { constructor ( metadata , options , private tokenizer ) { super ( metadata , options ) ; } param { IPageHeader } header param { Buffer } pageData protected parseFirstPage ( header , pageData ) { debug ( 'First Ogg/Speex page' ) ; const speexHeader = Speex . Header . get ( pageData , 0 ) ; this . metadata . setFormat ( 'codec' , `Speex ${ speexHeader . version }` ) ; this . metadata . setFormat ( 'numberOfChannels' , speexHeader . nb_channels ) ; this . metadata . setFormat ( 'sampleRate' , speexHeader . rate ) ; if ( speexHeader . bitrate !== - 1 ) { this . metadata . setFormat ( 'bitrate' , speexHeader . bitrate ) ; } } }