void AudioChatWidgetHolder::toggleAudioMuteCapture()
{
	std::cerr << "******** VOIPLugin: Toggling audio mute capture!" << std::endl;
    if (audioMuteCaptureToggleButton->isChecked()) {
        //activate audio output
        audioListenToggleButton->setChecked(true);
        audioMuteCaptureToggleButton->setToolTip(tr("Hold Call"));

        //activate audio input
        if (!inputProcessor) {
            inputProcessor = new QtSpeex::SpeexInputProcessor();
            if (outputProcessor) {
                connect(outputProcessor, SIGNAL(playingFrame(QByteArray*)), inputProcessor, SLOT(addEchoFrame(QByteArray*)));
            }
            inputProcessor->open(QIODevice::WriteOnly | QIODevice::Unbuffered);
        }
        if (!inputDevice) {
            inputDevice = AudioDeviceHelper::getPreferedInputDevice();
        }
        connect(inputProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData()));
        inputDevice->start(inputProcessor);
        
        if (mChatWidget) {
         mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("Outgoing Call is started..."), ChatWidget::MSGTYPE_SYSTEM);
        }
        
    } else {
        disconnect(inputProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData()));
        if (inputDevice) {
            inputDevice->stop();
        }
        audioMuteCaptureToggleButton->setToolTip(tr("Resume Call"));
    }
}
Beispiel #2
0
void Phone::processAudioSamples(float *samples, int nsample)
{
	recBuffer = samples;
	while (nsample > 0)
	{
		toRead = frame_size - ready;
		if (nsample < toRead)
		{
			memcpy(bufptr, recBuffer, nsample*sizeof(float));
			ready += nsample;
			bufptr += nsample;
			nsample = 0;
			break;
		}
		else
		if (nsample >= toRead)
		{
			memcpy(bufptr, recBuffer, toRead*sizeof(float));
			ready += toRead;
			bufptr += toRead;
			recBuffer += toRead;
			nsample -= toRead;
			if (ready == frame_size)
			{
				sendAudioData(buffer, frame_size);
				ready = 0;
				bufptr = buffer;
			}
		}
	}
}
void VOIPChatWidgetHolder::toggleAudioCapture()
{
    if (audioCaptureToggleButton->isChecked()) {
        //activate audio output
        audioListenToggleButton->setChecked(true);
        audioCaptureToggleButton->setToolTip(tr("Hold Call"));
        hangupButton->show();

        //activate audio input
        if (!inputAudioProcessor) {
            inputAudioProcessor = new QtSpeex::SpeexInputProcessor();
            if (outputAudioProcessor) {
                connect(outputAudioProcessor, SIGNAL(playingFrame(QByteArray*)), inputAudioProcessor, SLOT(addEchoFrame(QByteArray*)));
            }
            inputAudioProcessor->open(QIODevice::WriteOnly | QIODevice::Unbuffered);
        }
        if (!inputAudioDevice) {
            inputAudioDevice = AudioDeviceHelper::getPreferedInputDevice();
        }
        connect(inputAudioProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData()));
        inputAudioDevice->start(inputAudioProcessor);
        
        if (mChatWidget) {
         mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("Outgoing Call is started..."), ChatWidget::MSGTYPE_SYSTEM);
        }
        
        button_map::iterator it = buttonMapTakeVideo.begin();
        while (it != buttonMapTakeVideo.end()) {
        RSButtonOnText *button = it.value();
        delete button;
        it = buttonMapTakeVideo.erase(it);
        }
        
    } else {
        disconnect(inputAudioProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData()));
        if (inputAudioDevice) {
            inputAudioDevice->stop();
        }
        audioCaptureToggleButton->setToolTip(tr("Resume Call"));
        hangupButton->hide();
    }
}
void AudioChatWidgetHolder::hangupCall()
{
	std::cerr << "******** VOIPLugin: Hangup call!" << std::endl;

        disconnect(inputProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData()));
        if (inputDevice) {
            inputDevice->stop();
        }        
        if (outputDevice) {
            outputDevice->stop();
        }
        audioListenToggleButton->setChecked(false);
        audioMuteCaptureToggleButton->setChecked(false);
}
void VOIPChatWidgetHolder::hangupCall()
{
	disconnect(inputAudioProcessor, SIGNAL(networkPacketReady()), this, SLOT(sendAudioData()));
	if (inputAudioDevice) {
		inputAudioDevice->stop();
	}        
	if (outputAudioDevice) {
		outputAudioDevice->stop();
	}

	if (mChatWidget) {
		mChatWidget->addChatMsg(true, tr("VoIP Status"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("Outgoing Call stopped."), ChatWidget::MSGTYPE_SYSTEM);
	}
	
	audioListenToggleButton->setChecked(false);
	audioCaptureToggleButton->setChecked(false);
	hangupButton->hide();
}