diff --git a/src/audiocapturedevice.h b/src/audiocapturedevice.h index 448a4c0b..6ea2456a 100644 --- a/src/audiocapturedevice.h +++ b/src/audiocapturedevice.h @@ -1,7 +1,7 @@ #pragma once -// This class has been modified from QT audio input example +// This class has been modified from QT audio input example #include diff --git a/src/audiocapturefilter.cpp b/src/audiocapturefilter.cpp index 4dcf7985..7d89737d 100644 --- a/src/audiocapturefilter.cpp +++ b/src/audiocapturefilter.cpp @@ -1,7 +1,6 @@ #include "audiocapturefilter.h" #include - #include @@ -12,9 +11,9 @@ const int AUDIO_BUFFER_SIZE = 65536; AudioCaptureFilter::AudioCaptureFilter(StatisticsInterface *stats) : Filter("Audio capture", stats, false, true), deviceInfo_(QAudioDeviceInfo::defaultInputDevice()), - device_(0), - audioInput_(0), - input_(0), + device_(NULL), + audioInput_(NULL), + input_(NULL), buffer_(AUDIO_BUFFER_SIZE, 0) {} @@ -39,7 +38,6 @@ void AudioCaptureFilter::initializeAudio(QAudioFormat format) if (device_) delete device_; device_ = new AudioCaptureDevice(format_, this); - // connect(device_, SIGNAL(update()), SLOT(refreshDisplay())); createAudioInput(); qDebug() << "Audio initializing completed"; @@ -49,7 +47,6 @@ void AudioCaptureFilter::createAudioInput() { qDebug() << "Creating audio input"; audioInput_ = new QAudioInput(deviceInfo_, format_, this); - //volumeSlider->setValue(audioInput->volume() * 100); device_->start(); @@ -78,7 +75,7 @@ void AudioCaptureFilter::readMore() Data* newSample = new Data; - // set time + // create audio data packet to be sent to filter graph timeval present_time; present_time.tv_sec = QDateTime::currentMSecsSinceEpoch()/1000; present_time.tv_usec = (QDateTime::currentMSecsSinceEpoch()%1000) * 1000; @@ -127,23 +124,6 @@ void AudioCaptureFilter::stop() qDebug() << "Audio input suspended."; } -void AudioCaptureFilter::toggleSuspend() -{ - // toggle suspend/resume - if (audioInput_->state() == QAudio::SuspendedState) { - audioInput_->resume(); - //suspendResumeButton_->setText(tr(SUSPEND_LABEL)); - } else if (audioInput_->state() == QAudio::ActiveState) { - audioInput_->suspend(); - //m_suspendResumeButton->setText(tr(RESUME_LABEL)); - } else if (audioInput_->state() == QAudio::StoppedState) { - audioInput_->resume(); - //m_suspendResumeButton->setText(tr(SUSPEND_LABEL)); - } else if (audioInput_->state() == QAudio::IdleState) { - // no-op - } -} - // changing of audio device mid stream. void AudioCaptureFilter::deviceChanged(int index) { @@ -152,7 +132,6 @@ void AudioCaptureFilter::deviceChanged(int index) audioInput_->disconnect(this); delete audioInput_; - //deviceInfo_ = m_deviceBox->itemData(index).value(); initializeAudio(format_); } @@ -165,6 +144,4 @@ void AudioCaptureFilter::volumeChanged(int value) } void AudioCaptureFilter::process() -{ - -} +{} diff --git a/src/audiocapturefilter.h b/src/audiocapturefilter.h index fa651855..caeab480 100644 --- a/src/audiocapturefilter.h +++ b/src/audiocapturefilter.h @@ -5,6 +5,7 @@ #include +//TODO: this class would not have to be a filter, just needs to send data to one class AudioCaptureFilter : public Filter { @@ -30,10 +31,7 @@ private slots: private: - void toggleMode(); - void toggleSuspend(); void deviceChanged(int index); - void createAudioInput(); QAudioDeviceInfo deviceInfo_; diff --git a/src/audiooutput.cpp b/src/audiooutput.cpp index 10f517f7..279c1948 100644 --- a/src/audiooutput.cpp +++ b/src/audiooutput.cpp @@ -24,9 +24,6 @@ AudioOutput::~AudioOutput() void AudioOutput::initializeAudio(QAudioFormat format) { - // connect(m_pushTimer, SIGNAL(timeout()), SLOT(pushTimerExpired())); - - QAudioDeviceInfo info(device_); if (!info.isFormatSupported(format)) { qWarning() << "Default format not supported - trying to use nearest"; @@ -57,13 +54,6 @@ void AudioOutput::createAudioOutput() source_->start(); // pull mode output_ = audioOutput_->start(); - - - // push mode - // audioOutput_->start(source_); - - - // m_volumeSlider->setValue(int(m_audioOutput->volume()*100.0f)); } void AudioOutput::deviceChanged(int index) @@ -98,18 +88,19 @@ void AudioOutput::receiveInput() } } -void AudioOutput::toggleSuspendResume() +void AudioOutput::start() { - if (audioOutput_->state() == QAudio::SuspendedState) { + if(audioOutput_->state() == QAudio::SuspendedState + || audioOutput_->state() == QAudio::StoppedState) + { audioOutput_->resume(); -// m_suspendResumeButton->setText(tr(SUSPEND_LABEL)); - } else if (audioOutput_->state() == QAudio::ActiveState) { + } +} + +void AudioOutput::stop() +{ + if(audioOutput_->state() == QAudio::ActiveState) + { audioOutput_->suspend(); -// m_suspendResumeButton->setText(tr(RESUME_LABEL)); - } else if (audioOutput_->state() == QAudio::StoppedState) { - audioOutput_->resume(); -// m_suspendResumeButton->setText(tr(SUSPEND_LABEL)); - } else if (audioOutput_->state() == QAudio::IdleState) { - // no-op } } diff --git a/src/audiooutput.h b/src/audiooutput.h index ead721fa..1bbe5774 100644 --- a/src/audiooutput.h +++ b/src/audiooutput.h @@ -20,6 +20,9 @@ class AudioOutput : public QObject return source_; } + void start(); + void stop(); + private: void createAudioOutput(); @@ -38,7 +41,6 @@ class AudioOutput : public QObject private slots: void receiveInput(); - void toggleSuspendResume(); void deviceChanged(int index); void volumeChanged(int); }; diff --git a/src/audiooutputdevice.h b/src/audiooutputdevice.h index 8253ab05..1ebe4b6f 100644 --- a/src/audiooutputdevice.h +++ b/src/audiooutputdevice.h @@ -16,10 +16,12 @@ class AudioOutputDevice : public QIODevice void start(); void stop(); + // read data from buffer qint64 readData(char *data, qint64 maxlen); - qint64 writeData(const char *data, qint64 len); + qint64 writeData(const char *data, qint64 len); // unused qint64 bytesAvailable() const; + // Receives input from filter graph and tells output that there is input available void takeInput(std::unique_ptr input); signals: diff --git a/src/cameraframegrabber.cpp b/src/cameraframegrabber.cpp index a65060c5..2599616b 100644 --- a/src/cameraframegrabber.cpp +++ b/src/cameraframegrabber.cpp @@ -4,9 +4,7 @@ CameraFrameGrabber::CameraFrameGrabber(QObject *parent) : QAbstractVideoSurface(parent) -{ - -} +{} bool CameraFrameGrabber::present(const QVideoFrame &frame) {