Class speex

java.lang.Object
javaforce.voip.codec.speex
All Implemented Interfaces:
RTPAudioCoder

public class speex extends Object implements RTPAudioCoder
Encodes/decodes speex packets. RFC 5574
  • Constructor Details

    • speex

      public speex()
  • Method Details

    • getInstance

      public static speex getInstance()
    • setup

      public speex setup(RTP rtp, int rate)
    • setid

      public void setid(int id)
      Description copied from interface: RTPAudioCoder
      Sets RTP payload ID. This value is exchanged in SDP packets. For most audio codecs this value is fixed and ignored.
      Specified by:
      setid in interface RTPAudioCoder
    • getPacketSize

      public int getPacketSize()
      Description copied from interface: RTPAudioCoder
      Returns encoded packet size (excluding RTP header) -1 = variable sized
      Specified by:
      getPacketSize in interface RTPAudioCoder
    • setQuality

      public speex setQuality(int value)
      Set encoder quality (0-10) Default = 5. Affects only new speex instances.
    • setEnhancedMode

      public speex setEnhancedMode(boolean mode)
      Set decoder enhanced mode. Default = false Affects only new speex instances.
    • encode

      public byte[] encode(short[] samples)
      Description copied from interface: RTPAudioCoder
      Encodes audio samples into RTP packet.
      Specified by:
      encode in interface RTPAudioCoder
    • decode

      public short[] decode(byte[] encoded, int off, int length)
      Description copied from interface: RTPAudioCoder
      Decodes RTP packet into audio samples.
      Specified by:
      decode in interface RTPAudioCoder
    • getSampleRate

      public int getSampleRate()
      Description copied from interface: RTPAudioCoder
      Returns sample rate.
      Specified by:
      getSampleRate in interface RTPAudioCoder
    • speex_dsp_init

      public long speex_dsp_init(int sample_rate)
      Allocate speex DSP context. Audio buffers should be 160 samples. NOTE : speex SDP functions do NOT require the use of speex codec.
      Parameters:
      sample_rate - = sample rate
      Returns:
      ctx
    • speex_dsp_init

      public long speex_dsp_init(int sample_rate, int echo_buffers)
      Allocate speex DSP context. Audio buffers should be 160 samples (50 per second, 20ms each). NOTE : speex SDP functions do NOT require the use of speex codec.
      Parameters:
      sample_rate - = sample rate
      echo_buffers - = # of buffers to allocate for echo cancellation (-1=default of 10)
      Returns:
      ctx
    • speex_dsp_uninit

      public void speex_dsp_uninit(long ctx)
      Free speex DSP context
      Parameters:
      ctx - = speex context
    • speex_dsp_denoise

      public void speex_dsp_denoise(long ctx, short[] audio)
      Performs denoise function.
      Parameters:
      ctx - = speex context
      audio - = audio samples
    • speex_dsp_echo

      public void speex_dsp_echo(long ctx, short[] audio_mic, short[] audio_spk, short[] audio_out)
      Performs echo cancellation. All 3 arrays must be same length.
      Parameters:
      ctx - = speex context
      audio_mic - = mic audio (not modified)
      audio_spk - = speaker audio (not modified)
      audio_out - = outbound audio (modified)
    • main

      public static void main(String[] args)
    • close

      public void close()
      Description copied from interface: RTPAudioCoder
      Free any resources.
      Specified by:
      close in interface RTPAudioCoder