Client::Client(QString server, quint16 port, QString inputDeviceName, QString outputDeviceName, QString userName, QWidget *parent) : QWidget(parent), ui(new Ui::Client) { ui->setupUi(this); ui->userList->setStyleSheet("background-color: white;" "background-image: url(:/logos/clientLogo.png);" "background-repeat: none;" "background-position: center;"); _server = server; _port = port; _connection = new ClientConnection(server, port, userName, this); _callEstablished = false; QObject::connect(_connection, SIGNAL(message(QString,ServerMessages::MessageTyp)), this, SLOT(showMessage(QString,ServerMessages::MessageTyp))); QObject::connect(_connection, SIGNAL(connectionEstablished()), this->parent(), SLOT(connectionEstablished())); QObject::connect(_connection, SIGNAL(userListRefresh()), this, SLOT(userListRefresh())); QObject::connect(_connection, SIGNAL(callOut(QString)), this->parent(), SLOT(callOut(QString))); QObject::connect(_connection, SIGNAL(callIn(QString)), this->parent(), SLOT(callIn(QString))); QObject::connect(_connection, SIGNAL(callDenied(QString)), this->parent(), SLOT(callDenied(QString))); QObject::connect(_connection, SIGNAL(callTerminated()), this->parent(), SLOT(callTerminated())); QObject::connect(_connection, SIGNAL(callEstablished()), this, SLOT(callEstablished())); QObject::connect(_connection, SIGNAL(callTerminated()), this, SLOT(callTerminated())); QObject::connect(_connection, SIGNAL(callEstablished()), this->parent(), SLOT(callEstablished())); QObject::connect(_connection, SIGNAL(receivedSoundData(QByteArray)), this, SLOT(receivedSoundData(QByteArray))); QObject::connect(_connection, SIGNAL(dataTransferred()), this, SLOT(dataTransferred())); _format.setFrequency(8000); _format.setChannels(1); _format.setSampleSize(16); _format.setCodec("audio/pcm"); _format.setByteOrder(QAudioFormat::LittleEndian); _format.setSampleType(QAudioFormat::SignedInt); _audioInputList = new QList<QByteArray>(); _audioOutputList = new QList<QByteArray>(); _audioInput = new AudioInput ( _format, audioDeviceByName(inputDeviceName, QAudio::AudioInput ), _audioInputList); _audioOutput = new AudioOutput( _format, audioDeviceByName(outputDeviceName, QAudio::AudioOutput ), _audioOutputList); }
void Client::showMessage(QString text, ServerMessages::MessageTyp typ) { switch(typ) { case ServerMessages::INFORMATION: { QMessageBox::information(this, tr("Information"), text); break; } case ServerMessages::ERRORMESSAGE: { callTerminated(); QMessageBox::critical(this, tr("Error"), text); emit serverError(); break; } case ServerMessages::WARNING: { QMessageBox::warning(this, tr("Warning"), text); break; } default: { } } }
Client::~Client() { callTerminated(); delete _audioInputList; delete _audioOutputList; delete _audioInput; delete _audioOutput; delete _connection; delete ui; }
MainWindow::MainWindow( QWidget *parent) : QMainWindow(parent), preferencesForm(0), videoMonitorForm(0), documentationForm(0), aboutForm(0), myGst(0), myDBus(0), // myUrlDialog(0), lastActiveStatus(Playing_Status), // this is a hack audioChoice(Microphone_Audio), videoChoice(No_Video), elapsedTime(0), ui(new Ui::MainWindow) { ui->setupUi(this); ui->pauseButton->setEnabled(false); ui->stopButton->setEnabled(false); updateStatus(Idle_Status); setAttribute(Qt::WA_Maemo5StackedWindow); preferencesForm = new OrePreferencesForm(this); videoMonitorForm = new OreVideoMonitorForm(this); myGst = new OreGst(this, videoMonitorForm->getWindowId()); myDBus = new OreDBus(); // myUrlDialog = new OreMJpegDialog(this); connect( myDBus, SIGNAL(callStarted()), this, SLOT(startRecordingCall())); connect( myDBus, SIGNAL(callTerminated()), this, SLOT(stopRecordingCall())); connect( myDBus, SIGNAL(playingAllowed()), this, SLOT(startPlaying())); connect( myDBus, SIGNAL(playingDenied()), this, SLOT(stopPlaying())); connect( preferencesForm, SIGNAL(encodingChanged(AudioEncoding)), myGst, SLOT(setAudioEncoding(AudioEncoding))); secondTimer.setInterval(1000); connect( &secondTimer, SIGNAL(timeout()), this, SLOT(updateStatusTime())); // Set up the combo boxes: QSettings settings("pietrzak.org", "Orecchiette"); if (settings.contains("AudioSourceChoice")) { QString asc = settings.value("AudioSourceChoice").toString(); if (asc == "Microphone_Audio") { ui->audioComboBox->setCurrentIndex(1); } else if (asc == "Speaker_Audio") { ui->audioComboBox->setCurrentIndex(2); } else if (asc == "MicrophoneAndSpeaker_Audio") { ui->audioComboBox->setCurrentIndex(3); } else { ui->audioComboBox->setCurrentIndex(0); } } if (settings.contains("VideoSourceChoice")) { QString vsc = settings.value("VideoSourceChoice").toString(); if (vsc == "Screen_Video") { ui->videoComboBox->setCurrentIndex(1); } else if (vsc == "BackCamera_Video") { ui->videoComboBox->setCurrentIndex(2); } else if (vsc == "FrontCamera_Video") { ui->videoComboBox->setCurrentIndex(3); } /* else if (vsc == "MJpegStream_Video") { ui->videoComboBox->setCurrentIndex(4); } */ else { ui->videoComboBox->setCurrentIndex(0); } } if (preferencesForm) { /* switch (preferencesForm->source) { case OrePreferencesForm::Microphone: ui->inputButton->click(); break; case OrePreferencesForm::Speaker: ui->outputButton->click(); break; case OrePreferencesForm::Both: default: ui->bothButton->click(); break; } */ if (preferencesForm->recordOnStartUp()) { // Act like the Record button's been pressed immediately after initialization ui->recordButton->click(); } } }