📄 options.cxx
字号:
//// 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.cxx,v $ * Revision 1.4 2003/04/04 04:37:49 dereksmithies * Major upgrade. * Ixj & microtelco support added. Fix threading issues. * * Revision 1.3 2002/11/27 23:52:48 dereksmithies * Changes to make compatible with current openh323 library code. * * Revision 1.2 2002/07/31 22:14:52 dereksmithies * Minor tweaks. * * Revision 1.1.1.1 2002/05/12 22:55:03 dereksmithies * Initial release. * * * * */#include <ptlib.h>#include "main.h"#include "keys.h"#include "options.h"#include "cpendpoint.h"#include "mainwindowSub.h"#include "qtvid.h"AudioOptions::AudioOptions(){ encodingChannel = NULL; receiveChannel = NULL;}AudioOptions::~AudioOptions(){}BOOL AudioOptions::Initialise(){ PConfig *config = new PConfig(AUDIO_CONFIG); disableSilence = config->GetBoolean(CHECKBOXDISABLESILENCEDETECTION_KEY, FALSE); jitterBufferSize = config->GetInteger(SLIDERJITTERBUFFERSIZE_KEY, 150); volumeMicrophone = config->GetInteger(SLIDERMICROPHONE_KEY, 80); volumeSpeaker = config->GetInteger(SLIDERSPEAKER_KEY, 80); buffers = config->GetInteger(SPINBOXNUMBERSOUNDBUFFERS_KEY, 2); audioDevice = config->GetString(COMBOBOXAUDIODEVICE_KEY, ""); echoCancellation = config->GetString(COMBOBOXECHOCANCELLATION_KEY, CPhone::GetUi().GetAvailableEchoCancNames()[5]); delete config; return TRUE;}BOOL AudioOptions::SaveSettings(){ PConfig *config = new PConfig(AUDIO_CONFIG); config->SetBoolean(CHECKBOXDISABLESILENCEDETECTION_KEY, disableSilence); config->SetInteger(SLIDERJITTERBUFFERSIZE_KEY, jitterBufferSize); config->SetInteger(SLIDERMICROPHONE_KEY, volumeMicrophone); config->SetInteger(SLIDERSPEAKER_KEY, volumeSpeaker); config->SetInteger(SPINBOXNUMBERSOUNDBUFFERS_KEY, buffers); config->SetString(COMBOBOXAUDIODEVICE_KEY, audioDevice); config->SetString(COMBOBOXECHOCANCELLATION_KEY, echoCancellation); delete config; return TRUE;}void AudioOptions::PrintOn(ostream & strm) const{ strm << "-------------------------------------------------------" << endl << "Disable Silence detection is " << disableSilence << endl << "Echo cancellation is " << echoCancellation << endl << "Buffers is " << buffers << endl << "Jitter buffer size is " << jitterBufferSize << " ms" << endl << "Microphone volume is " << volumeMicrophone << endl << "Speaker volume is " << volumeSpeaker << endl << "Audio device is " << audioDevice << endl << "-------------------------------------------------------" << endl;}void AudioOptions::AttachAudioChannel(BOOL isEncoding, PChannel *newChannel){ if (isEncoding) { encodingChannel = (PSoundChannel *)newChannel; EchoCancellationChange(); VolumeMicrophoneChange(); } else { receiveChannel = (PSoundChannel *)newChannel; VolumeSpeakerChange(); }}BOOL AudioOptions::DisableSilenceChange(){ return CPhone::GetUi().SetDisableSilenceDetection(disableSilence);}BOOL AudioOptions::DisableSilenceChange(BOOL newDisableSilence){ disableSilence = newDisableSilence; return DisableSilenceChange();}BOOL AudioOptions::EchoCancellationChange(){ return CPhone::GetUi().SetEchoCancellation((const char *)echoCancellation);} BOOL AudioOptions::EchoCancellationChange(QString newEchoCancellation){ echoCancellation = newEchoCancellation; return EchoCancellationChange();}BOOL AudioOptions::BuffersChange(){ CPhone::GetUi().SetSoundChannelBufferDepth(buffers); return TRUE;}BOOL AudioOptions::BuffersChange(int newBuffers){ buffers = newBuffers; return BuffersChange();}BOOL AudioOptions::JitterBufferSizeChange(){ CPhone::GetUi().SetAudioJitterDelay(0, (unsigned) jitterBufferSize); return TRUE;}BOOL AudioOptions::JitterBufferSizeChange(int newJitterBufferSize){ jitterBufferSize = newJitterBufferSize; return JitterBufferSizeChange();}BOOL AudioOptions::VolumeMicrophoneChange(){ if (encodingChannel != NULL) if (encodingChannel->IsClass("PSoundChannel")) { int newVol = volumeMicrophone | (volumeMicrophone << 8); return encodingChannel->SetVolume(newVol); }#if HAS_IXJ return CPhone::GetUi().lidThread.SetRecordVolume(volumeMicrophone);#endif return FALSE;}BOOL AudioOptions::VolumeMicrophoneChange(int newVolumeMicrophone){ volumeMicrophone = newVolumeMicrophone; return VolumeMicrophoneChange();}BOOL AudioOptions::VolumeSpeakerChange(){ if (receiveChannel != NULL) if (receiveChannel->IsClass("PSoundChannel")) { int newVol = volumeSpeaker | (volumeSpeaker << 8); return receiveChannel->SetVolume(newVol); }#ifdef HAS_IXJ return CPhone::GetUi().lidThread.SetPlayVolume(volumeSpeaker);#endif return FALSE;}BOOL AudioOptions::VolumeSpeakerChange(int newVolumeSpeaker){ volumeSpeaker = newVolumeSpeaker; return VolumeSpeakerChange();}BOOL AudioOptions::AudioDeviceChange(){ BOOL success = FALSE;#ifdef HAS_IXJ if (CPhone::GetUi().GetAvailableIxjDeviceNames().GetStringsIndex(audioDevice) != P_MAX_INDEX){ success = CPhone::GetUi().lidThread.SetPhoneDevice(audioDevice); if (success) goto end_AudioDeviceChange; }#endif success = CPhone::GetUi().SetSoundChannelRecordDevice(audioDevice); if (success) success = CPhone::GetUi().SetSoundChannelPlayDevice(audioDevice); end_AudioDeviceChange: CPhone::GetUi().RebuildCapabilityTable(); return success;}BOOL AudioOptions::AudioDeviceChange(PString newAudioDevice){ audioDevice = newAudioDevice; return AudioDeviceChange();}///////////////////BOOL AudioOptions::GetDisableSilence(){ return disableSilence;}PString AudioOptions::GetEchoCancellation(){ return echoCancellation;}int AudioOptions::GetBuffers(){ return buffers;}int AudioOptions::GetJitterBufferSize(){ return jitterBufferSize;}int AudioOptions::GetVolumeMicrophone(){ return volumeMicrophone;}int AudioOptions::GetVolumeSpeaker(){ return volumeSpeaker;}PString AudioOptions::GetAudioDevice(){ return audioDevice;}/////////////////////////////////////////////////////////VideoOptions::VideoOptions(){ codec = NULL; txChannel = NULL; rxChannel = NULL;}VideoOptions::~VideoOptions(){}BOOL VideoOptions::Initialise(){ PConfig *config = new PConfig(VIDEO_CONFIG); // get default display options brightness = config->GetInteger(SLIDERBRIGHTNESS_KEY, 50); colour = config->GetInteger(SLIDERCOLOUR_KEY, 50); contrast = config->GetInteger(SLIDERCONTRAST_KEY, 50); hue = config->GetInteger(SLIDERHUE_KEY, 50); whiteness = config->GetInteger(SLIDERWHITENESS_KEY, 50); inputChannel = config->GetInteger(SPINBOXVIDEOINPUTCHANNEL_KEY, -1); receiveQuality = config->GetInteger(SPINBOXVIDEORECEIVEQUALITY_KEY, -1); palFormat = config->GetBoolean(RADIOBUTTONPALVIDEOFORMAT_KEY, TRUE); ntscFormat = config->GetBoolean(RADIOBUTTONNTSCVIDEOFORMAT_KEY, FALSE); transmitQuality= config->GetInteger(SPINBOXVIDEOTRANSMITQUALITY_KEY, -1); useLargeSize = config->GetBoolean(CHECKBOXLARGESIZE_KEY, FALSE); displayLocal = config->GetBoolean(CHECKBOXDISPLAYLOCALVIDEO_KEY, TRUE); flipLocal = config->GetBoolean(CHECKBOXFLIPLOCALVIDEO_KEY, FALSE); flipReceived = config->GetBoolean(CHECKBOXFLIPRECEIVEDVIDEO_KEY, FALSE); receiveQuality = config->GetInteger(SPINBOXVIDEORECEIVEQUALITY_KEY, 10); transmitQuality = config->GetInteger(SPINBOXVIDEOTRANSMITQUALITY_KEY, 10); videoDevice = config->GetString(COMBOBOXVIDEOINPUTDEVICE_KEY, "fake"); delete config; // PFakeVideoInputDevice *vFake = new PFakeVideoInputDevice(); fakeVideoDevices = PFakeVideoInputDevice::GetInputDeviceNames(); // delete vFake; //PVideoInputDevice *vReal = new PVideoInputDevice(); realVideoDevices = PVideoInputDevice::GetInputDeviceNames(); //delete vReal; return TRUE;}BOOL VideoOptions::SaveSettings(){ PConfig *config = new PConfig(VIDEO_CONFIG); config->SetInteger(SLIDERBRIGHTNESS_KEY, brightness); config->SetInteger(SLIDERCOLOUR_KEY, colour); config->SetInteger(SLIDERCONTRAST_KEY, contrast); config->SetInteger(SLIDERHUE_KEY, hue); config->SetInteger(SLIDERWHITENESS_KEY, whiteness); config->SetInteger(SPINBOXVIDEOINPUTCHANNEL_KEY, inputChannel); config->SetInteger(SPINBOXVIDEORECEIVEQUALITY_KEY, receiveQuality); config->SetInteger(SPINBOXVIDEOTRANSMITQUALITY_KEY,transmitQuality); config->SetBoolean(RADIOBUTTONPALVIDEOFORMAT_KEY, palFormat); config->SetBoolean(RADIOBUTTONNTSCVIDEOFORMAT_KEY, ntscFormat); config->SetBoolean(CHECKBOXLARGESIZE_KEY, useLargeSize); config->SetBoolean(CHECKBOXDISPLAYLOCALVIDEO_KEY, displayLocal); config->SetBoolean(CHECKBOXFLIPLOCALVIDEO_KEY, flipLocal); config->SetBoolean(CHECKBOXFLIPRECEIVEDVIDEO_KEY, flipReceived); config->SetInteger(SPINBOXVIDEORECEIVEQUALITY_KEY, receiveQuality); config->SetInteger(SPINBOXVIDEOTRANSMITQUALITY_KEY, transmitQuality); config->SetString(COMBOBOXVIDEOINPUTDEVICE_KEY, videoDevice); delete config; return TRUE;}void VideoOptions::GetVideoFrameSizeSetting(unsigned &newFrameWidth, unsigned &newFrameHeight){ if (useLargeSize ) { newFrameWidth = 352; newFrameHeight = 288; } else { newFrameWidth = 176; newFrameHeight = 144; }}void VideoOptions::AttachVideoChannels(CpVideoChannel *newRxChannel, CpVideoChannel *newTxChannel){ rxChannel = newRxChannel; txChannel = newTxChannel;}BOOL VideoOptions::DeviceChange(PString newDevice){ videoDevice = newDevice; return DeviceChange();}BOOL VideoOptions::DeviceChange(){ int returnVal = TRUE; txChannel->RestrictAccess(); txChannel->AttachVideoReader(NULL, FALSE); //delete attached grabber. txChannel->AttachVideoReader(GetNewVideoGrabber(), FALSE); txChannel->EnableAccess(); BrightnessChange(); ColourChange(); ContrastChange(); HueChange(); WhitenessChange(); TransmitQualityChange(); DisplayLocalChange(); return returnVal;}BOOL VideoOptions::FormatChange(BOOL usePalFormat){ palFormat = usePalFormat; ntscFormat = !usePalFormat; return FormatChange();}BOOL VideoOptions::FormatChange(){ int returnVal = TRUE; txChannel->RestrictAccess(); PVideoInputDevice * grabber = txChannel->GetVideoReader(); if (grabber == NULL) { txChannel->EnableAccess(); return FALSE; } returnVal = grabber->SetVideoFormat(palFormat ? PVideoDevice::PAL : PVideoDevice::NTSC); txChannel->EnableAccess(); return returnVal;}BOOL VideoOptions::ChannelChange(int newChannel){ inputChannel = newChannel; return DeviceChange(); //A channel change requires complete //reinitialization of the device.}BOOL VideoOptions::ChannelChange(){ int returnVal = TRUE; txChannel->RestrictAccess(); PVideoInputDevice * grabber = txChannel->GetVideoReader(); if (grabber == NULL) { txChannel->EnableAccess(); return FALSE; } returnVal = grabber->SetChannel(inputChannel); txChannel->EnableAccess(); return returnVal;}BOOL VideoOptions::ColourFormatChange(PString newColourFormat){ ColourFormatChange(); return TRUE;}BOOL VideoOptions::ColourFormatChange(){ int returnVal = TRUE; txChannel->RestrictAccess(); PVideoInputDevice * grabber = txChannel->GetVideoReader(); if (grabber == NULL) { txChannel->EnableAccess(); return FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -