/*------------------------------------------------------------------------
 *
 *  File:	o1k_audio.h
 *  Revision:	1.8
 *  Last Mod:	17:36:51, 03/01/97
 *
 *  Description:
 *     Defines O1kAudio object.
 *       
 *----------------------------------------------------------------------*/
#pragma ident	"@(#)o1k_audio.h	1.8\t97/03/01  "

#ifndef _O1K_AUDIO_H
#define _O1K_AUDIO_H

#include "o1k_thread.h"

typedef enum _AudioType { G722, G728, ULAW, ALAW, PCM8, PCM16, AUD_NONE } AudioType;
typedef enum _AudioChannels { MONO, STEREO } AudioChannels;
typedef enum _AudioSampleRate { R8000, R11025, R16000, R22050, R32000} AudioSampleRate;
typedef enum _AudioPort { LINE_IN, MIC_IN } AudioPort;

typedef enum _AudioStatus { AS_BITRATE_T,   AS_BITRATE_R } AudioStatus;

extern char* AudioTypeStr[];
extern char* AudioChannelsStr[];
extern char* AudioSampleRateStr[];
extern char* AudioPortStr[];

/* audio device calls */

#define AUDIO_SEND    0x1
#define AUDIO_RECEIVE 0x2

/*------------------------------------------------------------------------
 *
 *  Class:  O1kAudio	
 *
 * Description:
 *     
 *     The O1kAudio object contains the state for the audio portion
 *     of the conference. This includes audio format, port, gains, 
 *     etc. It also contains two O1kThread thread objects which are
 *     used for audio transmit and receive.
 *     
 * Notes:
 *     
 *     Currently the audio object is not optimally setting the
 *     buffer size for the various audio formats. 
 *     
 *----------------------------------------------------------------------*/

class O1kAudio {

public:
  O1kAudio();
  ~O1kAudio();

private:
    
  /* audio codec params */
  AudioType       type;
  AudioChannels   channels;
  AudioSampleRate sample_rate;
  AudioPort       port;

  /* audio codec gains */
  unsigned int vol_output;
  unsigned int vol_input;
  unsigned int vol_monitor;

  /* audio codec misc */
  unsigned char   aes_on;
  unsigned char   enable_output;
  unsigned char   enable_input;
      
public:

  /* status variables */
  int bitrate_t;
  int bitrate_r;  
  
  /* audio codec file descs */  
  int Audio_fd;
  int Audioctl_fd;
  
  /* audio codec threads */
  O1kThread* thread_t;
  O1kThread* thread_r;
  
  void settings();

  void setFormat(AudioType value)           { type = value;          }
  void setChannels(AudioChannels value)     { channels = value;      }
  void setSampleRate(AudioSampleRate value) { sample_rate = value;   }
  void setAES(unsigned char value)          { aes_on = value;        }
  void setPort(AudioPort value)             { port = value;          }
  void setVolOutput(unsigned int value)     { vol_output = value;    }
  void setVolInput(unsigned int value)      { vol_input = value;     }
  void setVolMonitor(unsigned int value)    { vol_monitor = value;   }
  void setEnableOutput(unsigned char value) { enable_output = value; }
  void setEnableInput(unsigned char value)  { enable_input = value;  }

  
  AudioType       getFormat()       const { return type;          }
  AudioChannels   getChannels()     const { return channels;      }
  AudioSampleRate getSampleRate()   const { return sample_rate;   }
  unsigned char   getAES()          const { return aes_on;        }
  AudioPort       getPort()         const { return port;          }
  unsigned int    getVolOutput()    const { return vol_output;    }
  unsigned int    getVolInput()     const { return vol_input;     }
  unsigned int    getVolMonitor()   const { return vol_monitor;   }
  unsigned char   getEnableOutput() const { return enable_output; }
  unsigned char   getEnableInput()  const { return enable_input;  }

  char* getStatus(AudioStatus as);
  
  int start();
  int stop();



};

#endif
