private RTPFormat createAudioFormat ( int payload , Text description ) { Iterator < Text > it = description . split ( ' ' ) . iterator ( ) ; //encoding name Text token = it . next ( ) ; token . trim ( ) ; EncodingName name = new EncodingName ( token ) ; //clock rate //TODO : convert to sample rate token = it . next ( ) ; token . trim ( ) ; int clockRate = token . toInteger ( ) ; //channels int channels = 1 ; if ( it . hasNext ( ) ) { token = it . next ( ) ; token . trim ( ) ; channels = token . toInteger ( ) ; } RTPFormat rtpFormat = getFormat ( payload ) ; if ( rtpFormat == null ) { formats . add ( new RTPFormat ( payload , FormatFactory . createAudioFormat ( name , clockRate , - 1 , channels ) ) ) ; } else { //TODO: recreate format anyway. it is illegal to use clock rate as sample rate ( ( AudioFormat ) rtpFormat . getFormat ( ) ) . setName ( name ) ; ( ( AudioFormat ) rtpFormat . getFormat ( ) ) . setSampleRate ( clockRate ) ; ( ( AudioFormat ) rtpFormat . getFormat ( ) ) . setChannels ( channels ) ; } return rtpFormat ; }
Creates or updates audio format using payload number and text format description .