//
//  The contents of this file are subject to the Mozilla Public License
//  Version 1.0 (the "License"); you may not use this file except in
//  compliance with the License. You may obtain a copy of the License at
//  http://www.mozilla.org/MPL/
// 
//  Software distributed under the License is distributed on an "AS IS"
//  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
//  the License for the specific language governing rights and limitations
//  under the License.
// 
//  The Original Code is CPhone, a cross platform voip gui.
//
//  The Initial Developer of the Original Code is Derek Smithies.
//
//  Copyright (C) 2002 Indranet Technologies Ltd, 
//                                  http://www.indranet-technologies.com
//  All Rights Reserved.
//
//  Contributor(s): _______________


/*
 *
 *  $Log: options.h,v $
 *  Revision 1.5  2004/01/02 04:06:24  dereksmithies
 *  Bring up to date with openh323 libraries. Get Plugins to work corectly.
 *
 *  Revision 1.4  2003/09/02 03:37:32  dereksmithies
 *  Add statistics, new icons, toolbuttons (icon + name)
 *
 *  Revision 1.3  2003/08/26 04:48:02  dereksmithies
 *  Fixes to get statistics working right, add icons, add ok,cancel,apply buttons
 *
 *  Revision 1.2  2003/04/04 04:37:49  dereksmithies
 *  Major upgrade.
 *  Ixj & microtelco support added. Fix threading issues.
 *
 *  Revision 1.1.1.1  2002/05/12 22:55:04  dereksmithies
 *  Initial release.
 *
 *
 *
 *
 */

#ifndef _CPhone_OPTIONS_H
#define _CPhone_OPTIONS_H

#include <ptlib.h>

class MainUserInterface;

class AudioOptions;
class VideoOptions;

class LocalVideoDisplayThread;
class CpEndPoint;
class H323VideoCodec;
class CpVideoChannel;

class AudioOptions : public PObject
{
  PCLASSINFO(AudioOptions, PObject);
  AudioOptions();
  ~AudioOptions();

 public:
  BOOL Initialise();
  BOOL SaveSettings();

  void PrintOn(ostream & str) const;

  BOOL DisableSilenceChange();
  BOOL DisableSilenceChange(BOOL newDisableSilence);
  BOOL EchoCancellationChange();
  BOOL EchoCancellationChange(QString newEchoCancellation);

  BOOL BuffersChange();
  BOOL BuffersChange(int newBuffers);
  BOOL JitterBufferSizeChange();
  BOOL JitterBufferSizeChange(int newJitterBufferSize);
  BOOL VolumeMicrophoneChange();
  BOOL VolumeMicrophoneChange(int newVolumeMicrophone);
  BOOL VolumeSpeakerChange();
  BOOL VolumeSpeakerChange(int newVolumeSpeaker);
  BOOL AudioDeviceChange();
  BOOL AudioDeviceChange(PString newAudioDevice);

  BOOL GetDisableSilence();

  int  GetBuffers();
  int  GetJitterBufferSize();
  int  GetVolumeMicrophone();
  int  GetVolumeSpeaker();

  PString GetAudioDevice();
  PString GetEchoCancellation();

  void AttachAudioChannel(BOOL isEncoding, PChannel *newChannel);

 protected:
  BOOL disableSilence;

  int  buffers;
  int  jitterBufferSize;
  int  volumeMicrophone;
  int  volumeSpeaker;


  PSoundChannel    *encodingChannel;
  PSoundChannel    *receiveChannel;

  PString audioDevice;
  PString echoCancellation;
};


///////////////////////////////////////////////////


class ConnectOptions : public PObject
{
  PCLASSINFO(ConnectOptions, PObject);

  ConnectOptions();
  ~ConnectOptions();

 public:

  BOOL Initialise();
  BOOL SaveSettings();

  void PrintOn(ostream & str) const;
  
  PString gatekeeperName;
  BOOL    searchForGatekeeper;

  PString externalNatAddress;
  PString microTelcoAccount;
  PString microTelcoPassword;

  BOOL    autoAnswer;
  BOOL    noFastStart;
  BOOL    noH245Tunnelling;
  BOOL    doNatTraversal;
  BOOL    doMicroTelco;

  BOOL    videoReceptionEnabled;
  BOOL    videoTransmissionEnabled;

  BOOL    useDefaultAudioBandwidth;
  BOOL    useDefaultVideoBandwidth;

  BOOL    doLogInternalActivity;
  int     logLevel;
  PString logFileName;    
  BOOL    logBlocks;
  BOOL    logDateTime;
  BOOL    logFileLine;
  BOOL    logLevelNumber;
  BOOL    logThreadAddress;
  BOOL    logThreadNames;
  BOOL    logTimestamp;
 
  int     audioBandwidth;
  int     videoBandwidth;
  
  int     packetUtilization;
  
  int     lowUdpPort;
  int     highUdpPort;

  BOOL    audioStats;
  BOOL    videoStats;
 
  PString userName;    

  PStringList GetAvailableCapabilities();
  PStringList GetDisabledCapabilities(); 
  PStringList GetEnabledCapabilities();
  
  void SetAvailableCapabilities(PStringList newCapabilities);
  void SetEnabledCapabilities(PStringList newCapabilities);  
  void LoadCapabilitiesFromDisk();

  void InstallLogging();
  void CloseCurrentTraceFile();
 
protected:

  void UpdateDisabledCapabilities();
  void InstallOneTraceOption(BOOL useOption, unsigned option);
 
  PMutex access;

  PStringList availableCapabilities;
  PStringList disabledCapabilities;
  PStringList enabledCapabilities;

  PTextFile *myTraceFile;
  PMutex    traceAccess;
};


///////////////////////////////////////////////////


class VideoOptions : public PObject
{
  PCLASSINFO(VideoOptions, PObject);
  VideoOptions();
  ~VideoOptions();

 public:
  void AttachVideoChannels(CpVideoChannel *newRxChannel,
			   CpVideoChannel *newTxChannel);

  BOOL Initialise();
  BOOL SaveSettings();

  void PrintOn(ostream & str) const;
  void AttachVideoCodec(H323VideoCodec *newCodec);

  BOOL DeviceChange();
  BOOL DeviceChange(PString newDevice);
  BOOL FormatChange();
  BOOL FormatChange(BOOL usePalFormat);
  BOOL ChannelChange();
  BOOL ChannelChange(int  newChannel);
  BOOL ColourFormatChange();
  BOOL ColourFormatChange(PString newColourFormat);
  BOOL FrameRateChange();
  BOOL FrameRateChange(int newFrameRate);
  BOOL FrameSizeChange();
  BOOL FrameSizeChange(BOOL newUseLargeSize);
  BOOL LocalVideoOrientationChange();
  BOOL LocalVideoOrientationChange(BOOL  newFlipLocal);
  BOOL ReceivedVideoOrientationChange();
  BOOL ReceivedVideoOrientationChange(BOOL newFlipReceived);
  BOOL BrightnessChange();
  BOOL BrightnessChange(int newBrightness);
  BOOL ColourChange();
  BOOL ColourChange(int newColour);
  BOOL ContrastChange();
  BOOL ContrastChange(int newContrast);
  BOOL HueChange();
  BOOL HueChange(int newHue);
  BOOL WhitenessChange();
  BOOL WhitenessChange(int newWhiteness);
  BOOL DisplayLocalChange();
  BOOL DisplayLocalChange(BOOL newDisplayLocal);
  BOOL TransmitQualityChange();
  BOOL TransmitQualityChange(int newTxQuality);
  BOOL ReceivedQualityChange();
  BOOL ReceivedQualityChange(int newRxQuality);
  
  PStringList GetAllVideoDevices();

  void GetVideoFrameSizeSetting
    (unsigned &newFrameWidth, unsigned &newFrameHeight);

  BOOL AttachPlayerReaderToVideoChannel(BOOL isEncoding);    

  PVideoInputDevice *GetNewVideoGrabber();
  
  int  GetBrightness();
  int  GetColour();
  int  GetContrast();
  int  GetHue();
  int  GetWhiteness();
  
  int  GetInputChannel();
  int  GetReceiveQuality();
  int  GetTransmitQuality();

  BOOL GetPalFormat();
  BOOL GetNtscFormat();
  
  BOOL GetUseLargeSize();
  
  BOOL GetDisplayLocal();
  BOOL GetFlipLocal();
  BOOL GetFlipReceived();

  PString GetVideoDevice();

 protected:
  // only used internally
  CpVideoChannel  *rxChannel;
  CpVideoChannel  *txChannel;
  
  int  brightness;
  int  colour;
  int  contrast;
  int  hue;
  int  whiteness;
  
  int  inputChannel;
  int  receiveQuality;
  int  transmitQuality;
  
  BOOL palFormat;
  BOOL ntscFormat;
  
  BOOL useLargeSize;
  
  BOOL displayLocal;
  BOOL flipLocal;
  BOOL flipReceived;
  
  PString videoDevice;
  
  H323VideoCodec    *codec;
};

#endif //_CPhone_OPTIONS_H


syntax highlighted by Code2HTML, v. 0.9.1