Multimedia: examples coding style unification
Change-Id: Iffae3a276bb2b01f871aee76dc069ce006d69fce Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "audiodecoder.h"
|
#include "audiodecoder.h"
|
||||||
#include <iostream>
|
#include <stdio.h>
|
||||||
|
|
||||||
AudioDecoder::AudioDecoder(bool isPlayback, bool isDelete)
|
AudioDecoder::AudioDecoder(bool isPlayback, bool isDelete)
|
||||||
: m_cout(stdout, QIODevice::WriteOnly)
|
: m_cout(stdout, QIODevice::WriteOnly)
|
||||||
|
|||||||
@@ -41,16 +41,16 @@
|
|||||||
#ifndef AUDIODECODER_H
|
#ifndef AUDIODECODER_H
|
||||||
#define AUDIODECODER_H
|
#define AUDIODECODER_H
|
||||||
|
|
||||||
#include <qaudiodecoder.h>
|
|
||||||
#include "wavefilewriter.h"
|
#include "wavefilewriter.h"
|
||||||
|
|
||||||
|
#include <QAudioDecoder>
|
||||||
#include <QSoundEffect>
|
#include <QSoundEffect>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class AudioDecoder : public QObject
|
class AudioDecoder : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AudioDecoder(bool isPlayback, bool isDelete);
|
AudioDecoder(bool isPlayback, bool isDelete);
|
||||||
~AudioDecoder() { }
|
~AudioDecoder() { }
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
|
|
||||||
void setTargetFilename(const QString &fileName);
|
void setTargetFilename(const QString &fileName);
|
||||||
|
|
||||||
Q_SIGNALS:
|
signals:
|
||||||
void done();
|
void done();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
@@ -38,14 +38,15 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
|
||||||
#include <QTextStream>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <qfileinfo.h>
|
|
||||||
#include <qdir.h>
|
|
||||||
#include "audiodecoder.h"
|
#include "audiodecoder.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
@@ -90,4 +91,4 @@ int main(int argc, char *argv[])
|
|||||||
decoder.start();
|
decoder.start();
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -107,12 +107,12 @@ bool WaveFileWriter::open(const QString& fileName, const QAudioFormat& format)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaveFileWriter::write(const QAudioBuffer& buffer)
|
bool WaveFileWriter::write(const QAudioBuffer &buffer)
|
||||||
{
|
{
|
||||||
if (buffer.format() != m_format)
|
if (buffer.format() != m_format)
|
||||||
return false; // buffer format has changed
|
return false; // buffer format has changed
|
||||||
|
|
||||||
qint64 written = file.write((const char*)buffer.constData(), buffer.byteCount());
|
qint64 written = file.write((const char *)buffer.constData(), buffer.byteCount());
|
||||||
m_dataLength += written;
|
m_dataLength += written;
|
||||||
return written == buffer.byteCount();
|
return written == buffer.byteCount();
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ bool WaveFileWriter::close()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaveFileWriter::writeHeader(const QAudioFormat& format)
|
bool WaveFileWriter::writeHeader(const QAudioFormat &format)
|
||||||
{
|
{
|
||||||
// check if format is supported
|
// check if format is supported
|
||||||
if (format.byteOrder() == QAudioFormat::BigEndian || format.sampleType() != QAudioFormat::SignedInt)
|
if (format.byteOrder() == QAudioFormat::BigEndian || format.sampleType() != QAudioFormat::SignedInt)
|
||||||
|
|||||||
@@ -41,24 +41,25 @@
|
|||||||
#ifndef WAVEFILEWRITER_H
|
#ifndef WAVEFILEWRITER_H
|
||||||
#define WAVEFILEWRITER_H
|
#define WAVEFILEWRITER_H
|
||||||
|
|
||||||
|
#include <QAudioBuffer>
|
||||||
|
#include <QFile>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <qfile.h>
|
|
||||||
#include <qaudiobuffer.h>
|
|
||||||
|
|
||||||
class WaveFileWriter : public QObject
|
class WaveFileWriter : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WaveFileWriter(QObject *parent = 0);
|
explicit WaveFileWriter(QObject *parent = 0);
|
||||||
~WaveFileWriter();
|
~WaveFileWriter();
|
||||||
|
|
||||||
bool open(const QString& fileName, const QAudioFormat& format);
|
bool open(const QString &fileName, const QAudioFormat &format);
|
||||||
bool write(const QAudioBuffer& buffer);
|
bool write(const QAudioBuffer &buffer);
|
||||||
bool close();
|
bool close();
|
||||||
bool isOpen() const { return file.isOpen(); }
|
bool isOpen() const { return file.isOpen(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool writeHeader(const QAudioFormat& format);
|
bool writeHeader(const QAudioFormat &format);
|
||||||
bool writeDataLength();
|
bool writeDataLength();
|
||||||
|
|
||||||
QFile file;
|
QFile file;
|
||||||
|
|||||||
@@ -38,14 +38,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include <qaudiodeviceinfo.h>
|
|
||||||
|
|
||||||
#include "audiodevices.h"
|
#include "audiodevices.h"
|
||||||
|
|
||||||
// Utility functions for converting QAudioFormat fields into text
|
// Utility functions for converting QAudioFormat fields into text
|
||||||
|
|
||||||
QString toString(QAudioFormat::SampleType sampleType)
|
static QString toString(QAudioFormat::SampleType sampleType)
|
||||||
{
|
{
|
||||||
QString result("Unknown");
|
QString result("Unknown");
|
||||||
switch (sampleType) {
|
switch (sampleType) {
|
||||||
@@ -64,7 +61,7 @@ QString toString(QAudioFormat::SampleType sampleType)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString toString(QAudioFormat::Endian endian)
|
static QString toString(QAudioFormat::Endian endian)
|
||||||
{
|
{
|
||||||
QString result("Unknown");
|
QString result("Unknown");
|
||||||
switch (endian) {
|
switch (endian) {
|
||||||
@@ -79,8 +76,8 @@ QString toString(QAudioFormat::Endian endian)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AudioDevicesBase::AudioDevicesBase(QWidget *parent, Qt::WindowFlags f)
|
AudioDevicesBase::AudioDevicesBase(QWidget *parent)
|
||||||
: QMainWindow(parent, f)
|
: QMainWindow(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
}
|
}
|
||||||
@@ -88,8 +85,8 @@ AudioDevicesBase::AudioDevicesBase(QWidget *parent, Qt::WindowFlags f)
|
|||||||
AudioDevicesBase::~AudioDevicesBase() {}
|
AudioDevicesBase::~AudioDevicesBase() {}
|
||||||
|
|
||||||
|
|
||||||
AudioTest::AudioTest(QWidget *parent, Qt::WindowFlags f)
|
AudioTest::AudioTest(QWidget *parent)
|
||||||
: AudioDevicesBase(parent, f)
|
: AudioDevicesBase(parent)
|
||||||
{
|
{
|
||||||
mode = QAudio::AudioOutput;
|
mode = QAudio::AudioOutput;
|
||||||
|
|
||||||
@@ -186,11 +183,11 @@ void AudioTest::deviceChanged(int idx)
|
|||||||
settings.setChannelCount(chz.at(0));
|
settings.setChannelCount(chz.at(0));
|
||||||
|
|
||||||
codecsBox->clear();
|
codecsBox->clear();
|
||||||
QStringList codecz = deviceInfo.supportedCodecs();
|
QStringList codecs = deviceInfo.supportedCodecs();
|
||||||
for (int i = 0; i < codecz.size(); ++i)
|
for (int i = 0; i < codecs.size(); ++i)
|
||||||
codecsBox->addItem(QString("%1").arg(codecz.at(i)));
|
codecsBox->addItem(QString("%1").arg(codecs.at(i)));
|
||||||
if (codecz.size())
|
if (codecs.size())
|
||||||
settings.setCodec(codecz.at(0));
|
settings.setCodec(codecs.at(0));
|
||||||
// Add false to create failed condition!
|
// Add false to create failed condition!
|
||||||
codecsBox->addItem("audio/test");
|
codecsBox->addItem("audio/test");
|
||||||
|
|
||||||
|
|||||||
@@ -41,24 +41,25 @@
|
|||||||
#ifndef AUDIODEVICES_H
|
#ifndef AUDIODEVICES_H
|
||||||
#define AUDIODEVICES_H
|
#define AUDIODEVICES_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QAudioDeviceInfo>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <qaudiodeviceinfo.h>
|
#include <QObject>
|
||||||
|
|
||||||
#include "ui_audiodevicesbase.h"
|
#include "ui_audiodevicesbase.h"
|
||||||
|
|
||||||
class AudioDevicesBase : public QMainWindow, public Ui::AudioDevicesBase
|
class AudioDevicesBase : public QMainWindow, public Ui::AudioDevicesBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioDevicesBase(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
AudioDevicesBase(QWidget *parent = 0);
|
||||||
virtual ~AudioDevicesBase();
|
virtual ~AudioDevicesBase();
|
||||||
};
|
};
|
||||||
|
|
||||||
class AudioTest : public AudioDevicesBase
|
class AudioTest : public AudioDevicesBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AudioTest(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
AudioTest(QWidget *parent = 0);
|
||||||
virtual ~AudioTest();
|
virtual ~AudioTest();
|
||||||
|
|
||||||
QAudioDeviceInfo deviceInfo;
|
QAudioDeviceInfo deviceInfo;
|
||||||
|
|||||||
@@ -42,15 +42,12 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QAudioDeviceInfo>
|
||||||
#include <qaudiodeviceinfo.h>
|
#include <QAudioInput>
|
||||||
#include <qaudioinput.h>
|
#include <qendian.h>
|
||||||
|
|
||||||
#include <QtCore/qendian.h>
|
|
||||||
|
|
||||||
#include "audioinput.h"
|
#include "audioinput.h"
|
||||||
|
|
||||||
@@ -331,15 +328,14 @@ void InputTest::notified()
|
|||||||
|
|
||||||
void InputTest::readMore()
|
void InputTest::readMore()
|
||||||
{
|
{
|
||||||
if(!m_audioInput)
|
if (!m_audioInput)
|
||||||
return;
|
return;
|
||||||
qint64 len = m_audioInput->bytesReady();
|
qint64 len = m_audioInput->bytesReady();
|
||||||
if(len > BufferSize)
|
if (len > BufferSize)
|
||||||
len = BufferSize;
|
len = BufferSize;
|
||||||
qint64 l = m_input->read(m_buffer.data(), len);
|
qint64 l = m_input->read(m_buffer.data(), len);
|
||||||
if(l > 0) {
|
if (l > 0)
|
||||||
m_audioInfo->write(m_buffer.constData(), l);
|
m_audioInfo->write(m_buffer.constData(), l);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputTest::toggleMode()
|
void InputTest::toggleMode()
|
||||||
@@ -364,7 +360,7 @@ void InputTest::toggleMode()
|
|||||||
void InputTest::toggleSuspend()
|
void InputTest::toggleSuspend()
|
||||||
{
|
{
|
||||||
// toggle suspend/resume
|
// toggle suspend/resume
|
||||||
if(m_audioInput->state() == QAudio::SuspendedState) {
|
if (m_audioInput->state() == QAudio::SuspendedState) {
|
||||||
qWarning() << "status: Suspended, resume()";
|
qWarning() << "status: Suspended, resume()";
|
||||||
m_audioInput->resume();
|
m_audioInput->resume();
|
||||||
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
|
|||||||
@@ -41,20 +41,20 @@
|
|||||||
#ifndef AUDIOINPUT_H
|
#ifndef AUDIOINPUT_H
|
||||||
#define AUDIOINPUT_H
|
#define AUDIOINPUT_H
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QAudioInput>
|
||||||
#include <QWidget>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
|
#include <QWidget>
|
||||||
#include <qaudioinput.h>
|
|
||||||
|
|
||||||
class AudioInfo : public QIODevice
|
class AudioInfo : public QIODevice
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AudioInfo(const QAudioFormat &format, QObject *parent);
|
AudioInfo(const QAudioFormat &format, QObject *parent);
|
||||||
~AudioInfo();
|
~AudioInfo();
|
||||||
@@ -94,9 +94,11 @@ private:
|
|||||||
QPixmap m_pixmap;
|
QPixmap m_pixmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class InputTest : public QMainWindow
|
class InputTest : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InputTest();
|
InputTest();
|
||||||
~InputTest();
|
~InputTest();
|
||||||
@@ -133,5 +135,4 @@ private:
|
|||||||
QByteArray m_buffer;
|
QByteArray m_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // AUDIOINPUT_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
TARGET = audioinput
|
TARGET = audioinput
|
||||||
|
|
||||||
QT += multimedia
|
QT += multimedia widgets
|
||||||
|
|
||||||
HEADERS = audioinput.h
|
HEADERS = audioinput.h
|
||||||
|
|
||||||
@@ -13,5 +13,3 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
|
|||||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audioinput
|
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audioinput
|
||||||
|
|
||||||
INSTALLS += target sources
|
INSTALLS += target sources
|
||||||
|
|
||||||
QT+=widgets
|
|
||||||
|
|||||||
@@ -38,13 +38,13 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <QAudioDeviceInfo>
|
||||||
|
#include <QAudioOutput>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <qmath.h>
|
||||||
|
#include <qendian.h>
|
||||||
|
|
||||||
#include <qaudiooutput.h>
|
|
||||||
#include <qaudiodeviceinfo.h>
|
|
||||||
#include <QtCore/qmath.h>
|
|
||||||
#include <QtCore/qendian.h>
|
|
||||||
#include "audiooutput.h"
|
#include "audiooutput.h"
|
||||||
|
|
||||||
#define PUSH_MODE_LABEL "Enable push mode"
|
#define PUSH_MODE_LABEL "Enable push mode"
|
||||||
|
|||||||
@@ -43,21 +43,21 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QAudioOutput>
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QSlider>
|
|
||||||
#include <QIODevice>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QComboBox>
|
||||||
#include <qaudiooutput.h>
|
#include <QIODevice>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QSlider>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
class Generator : public QIODevice
|
class Generator : public QIODevice
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Generator(const QAudioFormat &format, qint64 durationUs, int sampleRate, QObject *parent);
|
Generator(const QAudioFormat &format, qint64 durationUs, int sampleRate, QObject *parent);
|
||||||
~Generator();
|
~Generator();
|
||||||
@@ -80,6 +80,7 @@ private:
|
|||||||
class AudioTest : public QMainWindow
|
class AudioTest : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AudioTest();
|
AudioTest();
|
||||||
~AudioTest();
|
~AudioTest();
|
||||||
@@ -90,23 +91,24 @@ private:
|
|||||||
void createAudioOutput();
|
void createAudioOutput();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer* m_pullTimer;
|
QTimer *m_pullTimer;
|
||||||
|
|
||||||
// Owned by layout
|
// Owned by layout
|
||||||
QPushButton* m_modeButton;
|
QPushButton *m_modeButton;
|
||||||
QPushButton* m_suspendResumeButton;
|
QPushButton *m_suspendResumeButton;
|
||||||
QComboBox* m_deviceBox;
|
QComboBox *m_deviceBox;
|
||||||
QLabel* m_volumeLabel;
|
QLabel *m_volumeLabel;
|
||||||
QSlider* m_volumeSlider;
|
QSlider *m_volumeSlider;
|
||||||
|
|
||||||
QAudioDeviceInfo m_device;
|
QAudioDeviceInfo m_device;
|
||||||
Generator* m_generator;
|
Generator *m_generator;
|
||||||
QAudioOutput* m_audioOutput;
|
QAudioOutput *m_audioOutput;
|
||||||
QIODevice* m_output; // not owned
|
QIODevice *m_output; // not owned
|
||||||
QAudioFormat m_format;
|
QAudioFormat m_format;
|
||||||
|
|
||||||
|
bool m_pullMode;
|
||||||
|
QByteArray m_buffer;
|
||||||
|
|
||||||
bool m_pullMode;
|
|
||||||
QByteArray m_buffer;
|
|
||||||
private slots:
|
private slots:
|
||||||
void notified();
|
void notified();
|
||||||
void pullTimerExpired();
|
void pullTimerExpired();
|
||||||
@@ -117,5 +119,4 @@ private slots:
|
|||||||
void volumeChanged(int);
|
void volumeChanged(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // AUDIOOUTPUT_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
TARGET = audiooutput
|
TARGET = audiooutput
|
||||||
|
|
||||||
QT += multimedia
|
QT += multimedia widgets
|
||||||
|
|
||||||
HEADERS = audiooutput.h
|
HEADERS = audiooutput.h
|
||||||
|
|
||||||
@@ -13,5 +13,3 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
|
|||||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audiooutput
|
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audiooutput
|
||||||
|
|
||||||
INSTALLS += target sources
|
INSTALLS += target sources
|
||||||
|
|
||||||
QT+=widgets
|
|
||||||
|
|||||||
@@ -38,14 +38,13 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "audiooutput.h"
|
#include "audiooutput.h"
|
||||||
|
|
||||||
int main(int argv, char **args)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argv, args);
|
QApplication app(argc, argv);
|
||||||
app.setApplicationName("Audio Output Test");
|
app.setApplicationName("Audio Output Test");
|
||||||
|
|
||||||
AudioTest audio;
|
AudioTest audio;
|
||||||
|
|||||||
@@ -38,12 +38,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtCore/qdir.h>
|
#include <QAudioProbe>
|
||||||
#include <QtWidgets/qfiledialog.h>
|
#include <QAudioRecorder>
|
||||||
|
#include <QDir>
|
||||||
#include <qaudiorecorder.h>
|
#include <QFileDialog>
|
||||||
#include <qmediarecorder.h>
|
#include <QMediaRecorder>
|
||||||
#include <qaudioprobe.h>
|
|
||||||
|
|
||||||
#include "audiorecorder.h"
|
#include "audiorecorder.h"
|
||||||
|
|
||||||
@@ -53,8 +52,13 @@
|
|||||||
#include "ui_audiorecorder.h"
|
#include "ui_audiorecorder.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AudioRecorder::AudioRecorder(QWidget *parent)
|
static qreal getPeakValue(const QAudioFormat &format);
|
||||||
:
|
static qreal getBufferLevel(const QAudioBuffer &buffer);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
static qreal getBufferLevel(const T *buffer, int samples);
|
||||||
|
|
||||||
|
AudioRecorder::AudioRecorder(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::AudioRecorder),
|
ui(new Ui::AudioRecorder),
|
||||||
outputLocationSet(false)
|
outputLocationSet(false)
|
||||||
@@ -63,7 +67,7 @@ AudioRecorder::AudioRecorder(QWidget *parent)
|
|||||||
|
|
||||||
audioRecorder = new QAudioRecorder(this);
|
audioRecorder = new QAudioRecorder(this);
|
||||||
probe = new QAudioProbe;
|
probe = new QAudioProbe;
|
||||||
connect(probe, SIGNAL(audioBufferProbed(const QAudioBuffer&)), this, SLOT(processBuffer(QAudioBuffer)));
|
connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)), this, SLOT(processBuffer(QAudioBuffer)));
|
||||||
probe->setSource(audioRecorder);
|
probe->setSource(audioRecorder);
|
||||||
|
|
||||||
//audio devices
|
//audio devices
|
||||||
@@ -216,19 +220,20 @@ QUrl AudioRecorder::generateAudioFilePath()
|
|||||||
|
|
||||||
int lastImage = 0;
|
int lastImage = 0;
|
||||||
int fileCount = 0;
|
int fileCount = 0;
|
||||||
foreach(QString fileName, outputDir.entryList(QStringList() << "testclip_*")) {
|
foreach (const QString &fileName, outputDir.entryList(QStringList(QString("testclip_*")))) {
|
||||||
int imgNumber = fileName.mid(5, fileName.size() - 9).toInt();
|
int imgNumber = fileName.mid(5, fileName.size() - 9).toInt();
|
||||||
lastImage = qMax(lastImage, imgNumber);
|
lastImage = qMax(lastImage, imgNumber);
|
||||||
if (outputDir.exists(fileName))
|
if (outputDir.exists(fileName))
|
||||||
fileCount += 1;
|
fileCount += 1;
|
||||||
}
|
}
|
||||||
lastImage += fileCount;
|
lastImage += fileCount;
|
||||||
QUrl location(QDir::toNativeSeparators(outputDir.canonicalPath() + QString("/testclip_%1").arg(lastImage + 1, 4, 10, QLatin1Char('0'))));
|
QUrl location(QDir::toNativeSeparators(outputDir.canonicalPath()
|
||||||
|
+ QString("/testclip_%1").arg(lastImage + 1, 4, 10, QLatin1Char('0'))));
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function returns the maximum possible sample value for a given audio format
|
// This function returns the maximum possible sample value for a given audio format
|
||||||
qreal AudioRecorder::GetPeakValue(const QAudioFormat& format)
|
qreal getPeakValue(const QAudioFormat& format)
|
||||||
{
|
{
|
||||||
// Note: Only the most common sample formats are supported
|
// Note: Only the most common sample formats are supported
|
||||||
if (!format.isValid())
|
if (!format.isValid())
|
||||||
@@ -247,9 +252,9 @@ qreal AudioRecorder::GetPeakValue(const QAudioFormat& format)
|
|||||||
case QAudioFormat::SignedInt:
|
case QAudioFormat::SignedInt:
|
||||||
if (format.sampleSize() == 32)
|
if (format.sampleSize() == 32)
|
||||||
return 2147483648.0;
|
return 2147483648.0;
|
||||||
else if (format.sampleSize() == 16)
|
if (format.sampleSize() == 16)
|
||||||
return 32768.0;
|
return 32768.0;
|
||||||
else if (format.sampleSize() == 8)
|
if (format.sampleSize() == 8)
|
||||||
return 128.0;
|
return 128.0;
|
||||||
break;
|
break;
|
||||||
case QAudioFormat::UnSignedInt:
|
case QAudioFormat::UnSignedInt:
|
||||||
@@ -260,7 +265,7 @@ qreal AudioRecorder::GetPeakValue(const QAudioFormat& format)
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal AudioRecorder::GetBufferLevel(const QAudioBuffer& buffer)
|
qreal getBufferLevel(const QAudioBuffer& buffer)
|
||||||
{
|
{
|
||||||
if (!buffer.format().isValid() || buffer.format().byteOrder() != QAudioFormat::LittleEndian)
|
if (!buffer.format().isValid() || buffer.format().byteOrder() != QAudioFormat::LittleEndian)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
@@ -268,7 +273,7 @@ qreal AudioRecorder::GetBufferLevel(const QAudioBuffer& buffer)
|
|||||||
if (buffer.format().codec() != "audio/pcm")
|
if (buffer.format().codec() != "audio/pcm")
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
qreal peak_value = GetPeakValue(buffer.format());
|
qreal peak_value = getPeakValue(buffer.format());
|
||||||
if (qFuzzyCompare(peak_value, 0.0))
|
if (qFuzzyCompare(peak_value, 0.0))
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
@@ -278,15 +283,15 @@ qreal AudioRecorder::GetBufferLevel(const QAudioBuffer& buffer)
|
|||||||
break;
|
break;
|
||||||
case QAudioFormat::Float:
|
case QAudioFormat::Float:
|
||||||
if (buffer.format().sampleSize() == 32)
|
if (buffer.format().sampleSize() == 32)
|
||||||
return GetBufferLevel(buffer.constData<float>(), buffer.sampleCount()) / peak_value;
|
return getBufferLevel(buffer.constData<float>(), buffer.sampleCount()) / peak_value;
|
||||||
break;
|
break;
|
||||||
case QAudioFormat::SignedInt:
|
case QAudioFormat::SignedInt:
|
||||||
if (buffer.format().sampleSize() == 32)
|
if (buffer.format().sampleSize() == 32)
|
||||||
return GetBufferLevel(buffer.constData<long int>(), buffer.sampleCount()) / peak_value;
|
return getBufferLevel(buffer.constData<long int>(), buffer.sampleCount()) / peak_value;
|
||||||
else if (buffer.format().sampleSize() == 16)
|
if (buffer.format().sampleSize() == 16)
|
||||||
return GetBufferLevel(buffer.constData<short int>(), buffer.sampleCount()) / peak_value;
|
return getBufferLevel(buffer.constData<short int>(), buffer.sampleCount()) / peak_value;
|
||||||
else if (buffer.format().sampleSize() == 8)
|
if (buffer.format().sampleSize() == 8)
|
||||||
return GetBufferLevel(buffer.constData<signed char>(), buffer.sampleCount()) / peak_value;
|
return getBufferLevel(buffer.constData<signed char>(), buffer.sampleCount()) / peak_value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,12 +299,12 @@ qreal AudioRecorder::GetBufferLevel(const QAudioBuffer& buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
qreal AudioRecorder::GetBufferLevel(const T* buffer, int samples)
|
qreal getBufferLevel(const T *buffer, int samples)
|
||||||
{
|
{
|
||||||
qreal max_value = 0.0;
|
qreal max_value = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < samples; i++) {
|
for (int i = 0; i < samples; ++i) {
|
||||||
qreal value = qAbs((qreal)buffer[i]);
|
qreal value = qAbs(qreal(buffer[i]));
|
||||||
if (value > max_value)
|
if (value > max_value)
|
||||||
max_value = value;
|
max_value = value;
|
||||||
}
|
}
|
||||||
@@ -309,6 +314,6 @@ qreal AudioRecorder::GetBufferLevel(const T* buffer, int samples)
|
|||||||
|
|
||||||
void AudioRecorder::processBuffer(const QAudioBuffer& buffer)
|
void AudioRecorder::processBuffer(const QAudioBuffer& buffer)
|
||||||
{
|
{
|
||||||
qreal level = GetBufferLevel(buffer);
|
qreal level = getBufferLevel(buffer);
|
||||||
ui->audioLevel->setLevel(level);
|
ui->audioLevel->setLevel(level);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,28 +41,21 @@
|
|||||||
#ifndef AUDIORECORDER_H
|
#ifndef AUDIORECORDER_H
|
||||||
#define AUDIORECORDER_H
|
#define AUDIORECORDER_H
|
||||||
|
|
||||||
#include <QtCore/qurl.h>
|
#include <QMainWindow>
|
||||||
#include <QtWidgets/qmainwindow.h>
|
#include <QMediaRecorder>
|
||||||
|
#include <QUrl>
|
||||||
#include <qmediarecorder.h>
|
|
||||||
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
namespace Ui { class AudioRecorder; }
|
||||||
namespace Ui {
|
|
||||||
class AudioRecorder;
|
|
||||||
}
|
|
||||||
|
|
||||||
class QAudioRecorder;
|
class QAudioRecorder;
|
||||||
class QAudioProbe;
|
class QAudioProbe;
|
||||||
class QAudioBuffer;
|
class QAudioBuffer;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class AudioRecorder : public QMainWindow
|
class AudioRecorder : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AudioRecorder(QWidget *parent = 0);
|
AudioRecorder(QWidget *parent = 0);
|
||||||
~AudioRecorder();
|
~AudioRecorder();
|
||||||
@@ -81,18 +74,12 @@ private slots:
|
|||||||
QUrl generateAudioFilePath();
|
QUrl generateAudioFilePath();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static qreal GetPeakValue(const QAudioFormat& format);
|
|
||||||
static qreal GetBufferLevel(const QAudioBuffer& buffer);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
static qreal GetBufferLevel(const T* buffer, int samples);
|
|
||||||
|
|
||||||
Ui::AudioRecorder *ui;
|
Ui::AudioRecorder *ui;
|
||||||
|
|
||||||
QAudioRecorder* audioRecorder;
|
QAudioRecorder *audioRecorder;
|
||||||
QAudioProbe* probe;
|
QAudioProbe *probe;
|
||||||
bool outputLocationSet;
|
bool outputLocationSet;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // AUDIORECORDER_H
|
||||||
|
|||||||
@@ -50,4 +50,4 @@ int main(int argc, char *argv[])
|
|||||||
recorder.show();
|
recorder.show();
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -43,8 +43,6 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class QAudioLevel : public QWidget
|
class QAudioLevel : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
TARGET = customvideoitem
|
TARGET = customvideoitem
|
||||||
|
|
||||||
QT += multimedia multimediawidgets
|
QT += multimedia multimediawidgets widgets
|
||||||
|
|
||||||
contains(QT_CONFIG, opengl): QT += opengl
|
contains(QT_CONFIG, opengl): QT += opengl
|
||||||
|
|
||||||
@@ -17,5 +17,3 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
|
|||||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/customvideoitem
|
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/customvideoitem
|
||||||
|
|
||||||
INSTALLS += target sources
|
INSTALLS += target sources
|
||||||
|
|
||||||
QT+=widgets
|
|
||||||
|
|||||||
@@ -40,9 +40,9 @@
|
|||||||
|
|
||||||
#include "videoplayer.h"
|
#include "videoplayer.h"
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,9 @@
|
|||||||
|
|
||||||
#include "videoitem.h"
|
#include "videoitem.h"
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QPainter>
|
||||||
#include <qvideosurfaceformat.h>
|
#include <QTransform>
|
||||||
|
#include <QVideoSurfaceFormat>
|
||||||
|
|
||||||
VideoItem::VideoItem(QGraphicsItem *parent)
|
VideoItem::VideoItem(QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent)
|
: QGraphicsItem(parent)
|
||||||
|
|||||||
@@ -41,8 +41,8 @@
|
|||||||
#ifndef VIDEOITEM_H
|
#ifndef VIDEOITEM_H
|
||||||
#define VIDEOITEM_H
|
#define VIDEOITEM_H
|
||||||
|
|
||||||
#include <qabstractvideosurface.h>
|
#include <QAbstractVideoSurface>
|
||||||
#include <QtWidgets/QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
|
||||||
class VideoItem
|
class VideoItem
|
||||||
: public QAbstractVideoSurface,
|
: public QAbstractVideoSurface,
|
||||||
@@ -50,13 +50,13 @@ class VideoItem
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(QGraphicsItem)
|
Q_INTERFACES(QGraphicsItem)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VideoItem(QGraphicsItem *parentItem = 0);
|
explicit VideoItem(QGraphicsItem *parentItem = 0);
|
||||||
~VideoItem();
|
~VideoItem();
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||||
QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
|
||||||
|
|
||||||
//video surface
|
//video surface
|
||||||
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||||
@@ -74,5 +74,5 @@ private:
|
|||||||
bool framePainted;
|
bool framePainted;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // VIDEOITEM_H
|
||||||
|
|
||||||
|
|||||||
@@ -42,14 +42,14 @@
|
|||||||
#include "videoitem.h"
|
#include "videoitem.h"
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#include <qvideosurfaceformat.h>
|
#include <QVideoSurfaceFormat>
|
||||||
|
|
||||||
#if !defined(QT_NO_OPENGL)
|
#if !defined(QT_NO_OPENGL)
|
||||||
# include <QtOpenGL/QGLWidget>
|
# include <QGLWidget>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VideoPlayer::VideoPlayer(QWidget *parent, Qt::WindowFlags flags)
|
VideoPlayer::VideoPlayer(QWidget *parent)
|
||||||
: QWidget(parent, flags)
|
: QWidget(parent)
|
||||||
, mediaPlayer(0, QMediaPlayer::VideoSurface)
|
, mediaPlayer(0, QMediaPlayer::VideoSurface)
|
||||||
, videoItem(0)
|
, videoItem(0)
|
||||||
, playButton(0)
|
, playButton(0)
|
||||||
|
|||||||
@@ -41,24 +41,23 @@
|
|||||||
#ifndef VIDEOPLAYER_H
|
#ifndef VIDEOPLAYER_H
|
||||||
#define VIDEOPLAYER_H
|
#define VIDEOPLAYER_H
|
||||||
|
|
||||||
#include <qmediaplayer.h>
|
#include <QMediaPlayer>
|
||||||
|
#include <QMovie>
|
||||||
#include <QtGui/QMovie>
|
#include <QWidget>
|
||||||
#include <QtWidgets/QWidget>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAbstractButton;
|
class QAbstractButton;
|
||||||
class QSlider;
|
class QSlider;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
class VideoItem;
|
class VideoItem;
|
||||||
|
|
||||||
class VideoPlayer : public QWidget
|
class VideoPlayer : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoPlayer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
VideoPlayer(QWidget *parent = 0);
|
||||||
~VideoPlayer();
|
~VideoPlayer();
|
||||||
|
|
||||||
QSize sizeHint() const { return QSize(800, 600); }
|
QSize sizeHint() const { return QSize(800, 600); }
|
||||||
@@ -81,5 +80,5 @@ private:
|
|||||||
QSlider *positionSlider;
|
QSlider *positionSlider;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // VIDEOPLAYER_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
TARGET = customvideowidget
|
TARGET = customvideowidget
|
||||||
|
|
||||||
QT += multimedia multimediawidgets
|
QT += multimedia multimediawidgets widgets
|
||||||
|
|
||||||
HEADERS = \
|
HEADERS = \
|
||||||
videoplayer.h \
|
videoplayer.h \
|
||||||
@@ -19,5 +19,3 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
|
|||||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/customvideowidget
|
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/customvideowidget
|
||||||
|
|
||||||
INSTALLS += target sources
|
INSTALLS += target sources
|
||||||
|
|
||||||
QT+=widgets
|
|
||||||
|
|||||||
@@ -41,10 +41,9 @@
|
|||||||
#ifndef VIDEOPLAYER_H
|
#ifndef VIDEOPLAYER_H
|
||||||
#define VIDEOPLAYER_H
|
#define VIDEOPLAYER_H
|
||||||
|
|
||||||
#include <qmediaplayer.h>
|
#include <QMediaPlayer>
|
||||||
|
#include <QMovie>
|
||||||
#include <QtGui/QMovie>
|
#include <QWidget>
|
||||||
#include <QtWidgets/QWidget>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAbstractButton;
|
class QAbstractButton;
|
||||||
@@ -54,6 +53,7 @@ QT_END_NAMESPACE
|
|||||||
class VideoPlayer : public QWidget
|
class VideoPlayer : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoPlayer(QWidget *parent = 0);
|
VideoPlayer(QWidget *parent = 0);
|
||||||
~VideoPlayer();
|
~VideoPlayer();
|
||||||
@@ -74,4 +74,4 @@ private:
|
|||||||
QSlider *positionSlider;
|
QSlider *positionSlider;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // VIDEOPLAYER_H
|
||||||
|
|||||||
@@ -43,18 +43,13 @@
|
|||||||
|
|
||||||
#include "videowidgetsurface.h"
|
#include "videowidgetsurface.h"
|
||||||
|
|
||||||
#include <QtWidgets/QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QAbstractVideoSurface;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
class VideoWidgetSurface;
|
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
class VideoWidget : public QWidget
|
class VideoWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoWidget(QWidget *parent = 0);
|
VideoWidget(QWidget *parent = 0);
|
||||||
~VideoWidget();
|
~VideoWidget();
|
||||||
@@ -72,4 +67,4 @@ private:
|
|||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
#endif
|
#endif // VIDEOWIDGET_H
|
||||||
|
|||||||
@@ -41,15 +41,16 @@
|
|||||||
#ifndef VIDEOWIDGETSURFACE_H
|
#ifndef VIDEOWIDGETSURFACE_H
|
||||||
#define VIDEOWIDGETSURFACE_H
|
#define VIDEOWIDGETSURFACE_H
|
||||||
|
|
||||||
#include <QtCore/QRect>
|
#include <QAbstractVideoSurface>
|
||||||
#include <QtGui/QImage>
|
#include <QImage>
|
||||||
#include <qabstractvideosurface.h>
|
#include <QRect>
|
||||||
#include <qvideoframe.h>
|
#include <QVideoFrame>
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
class VideoWidgetSurface : public QAbstractVideoSurface
|
class VideoWidgetSurface : public QAbstractVideoSurface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoWidgetSurface(QWidget *widget, QObject *parent = 0);
|
VideoWidgetSurface(QWidget *widget, QObject *parent = 0);
|
||||||
|
|
||||||
|
|||||||
@@ -41,13 +41,12 @@
|
|||||||
#ifndef HISTOGRAMWIDGET_H
|
#ifndef HISTOGRAMWIDGET_H
|
||||||
#define HISTOGRAMWIDGET_H
|
#define HISTOGRAMWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <qvideoframe.h>
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QVideoFrame>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
class FrameProcessor: public QObject
|
||||||
|
{
|
||||||
class FrameProcessor: public QObject {
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -60,6 +59,7 @@ signals:
|
|||||||
class HistogramWidget : public QWidget
|
class HistogramWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit HistogramWidget(QWidget *parent = 0);
|
explicit HistogramWidget(QWidget *parent = 0);
|
||||||
~HistogramWidget();
|
~HistogramWidget();
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -53,18 +53,10 @@ int main(int argc, char *argv[])
|
|||||||
Player player;
|
Player player;
|
||||||
|
|
||||||
#if defined(Q_WS_SIMULATOR)
|
#if defined(Q_WS_SIMULATOR)
|
||||||
# if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 2))
|
|
||||||
player.setAttribute(Qt::WA_LockLandscapeOrientation);
|
player.setAttribute(Qt::WA_LockLandscapeOrientation);
|
||||||
# else
|
|
||||||
// lock screen orientation
|
|
||||||
CAknAppUi* appUi = dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
|
|
||||||
if(appUi){
|
|
||||||
QT_TRAP_THROWING(appUi ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape));
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
player.showMaximized();
|
player.showMaximized();
|
||||||
#else
|
#else
|
||||||
player.show();
|
player.show();
|
||||||
#endif
|
#endif
|
||||||
return app.exec();
|
return app.exec();
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -44,10 +44,9 @@
|
|||||||
#include "playlistmodel.h"
|
#include "playlistmodel.h"
|
||||||
#include "histogramwidget.h"
|
#include "histogramwidget.h"
|
||||||
|
|
||||||
#include <qmediaservice.h>
|
#include <QMediaService>
|
||||||
#include <qmediaplaylist.h>
|
#include <QMediaPlaylist>
|
||||||
#include <qvideoprobe.h>
|
#include <QVideoProbe>
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
|
|
||||||
@@ -308,7 +307,7 @@ void Player::statusChanged(QMediaPlayer::MediaStatus status)
|
|||||||
void Player::handleCursor(QMediaPlayer::MediaStatus status)
|
void Player::handleCursor(QMediaPlayer::MediaStatus status)
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
if( status == QMediaPlayer::LoadingMedia ||
|
if (status == QMediaPlayer::LoadingMedia ||
|
||||||
status == QMediaPlayer::BufferingMedia ||
|
status == QMediaPlayer::BufferingMedia ||
|
||||||
status == QMediaPlayer::StalledMedia)
|
status == QMediaPlayer::StalledMedia)
|
||||||
setCursor(QCursor(Qt::BusyCursor));
|
setCursor(QCursor(Qt::BusyCursor));
|
||||||
@@ -427,4 +426,3 @@ void Player::showColorDialog()
|
|||||||
colorDialog->show();
|
colorDialog->show();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -41,38 +41,35 @@
|
|||||||
#ifndef PLAYER_H
|
#ifndef PLAYER_H
|
||||||
#define PLAYER_H
|
#define PLAYER_H
|
||||||
|
|
||||||
#include <QtWidgets/QWidget>
|
|
||||||
|
|
||||||
#include <qmediaplayer.h>
|
|
||||||
#include <qmediaplaylist.h>
|
|
||||||
#include "videowidget.h"
|
#include "videowidget.h"
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QMediaPlayer>
|
||||||
|
#include <QMediaPlaylist>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAbstractItemView;
|
class QAbstractItemView;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QModelIndex;
|
|
||||||
class QSlider;
|
|
||||||
class QPushButton;
|
|
||||||
class QVideoProbe;
|
|
||||||
|
|
||||||
class QMediaPlayer;
|
class QMediaPlayer;
|
||||||
|
class QModelIndex;
|
||||||
|
class QPushButton;
|
||||||
|
class QSlider;
|
||||||
|
class QVideoProbe;
|
||||||
class QVideoWidget;
|
class QVideoWidget;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class PlaylistModel;
|
class PlaylistModel;
|
||||||
class HistogramWidget;
|
class HistogramWidget;
|
||||||
|
|
||||||
class Player : public QWidget
|
class Player : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Player(QWidget *parent = 0);
|
Player(QWidget *parent = 0);
|
||||||
~Player();
|
~Player();
|
||||||
|
|
||||||
Q_SIGNALS:
|
signals:
|
||||||
void fullScreenChanged(bool fullScreen);
|
void fullScreenChanged(bool fullScreen);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@@ -96,7 +93,7 @@ private slots:
|
|||||||
#ifndef PLAYER_NO_COLOROPTIONS
|
#ifndef PLAYER_NO_COLOROPTIONS
|
||||||
void showColorDialog();
|
void showColorDialog();
|
||||||
#endif
|
#endif
|
||||||
void addToPlaylist(const QStringList& fileNames);
|
void addToPlaylist(const QStringList &fileNames);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setTrackInfo(const QString &info);
|
void setTrackInfo(const QString &info);
|
||||||
@@ -127,4 +124,4 @@ private:
|
|||||||
qint64 duration;
|
qint64 duration;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // PLAYER_H
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
TARGET = player
|
TARGET = player
|
||||||
|
|
||||||
CONFIG += qt warn_on
|
|
||||||
|
|
||||||
QT += network \
|
QT += network \
|
||||||
xml \
|
xml \
|
||||||
multimedia \
|
multimedia \
|
||||||
multimediawidgets
|
multimediawidgets \
|
||||||
|
widgets
|
||||||
|
|
||||||
HEADERS = \
|
HEADERS = \
|
||||||
player.h \
|
player.h \
|
||||||
@@ -25,10 +24,7 @@ maemo* {
|
|||||||
DEFINES += PLAYER_NO_COLOROPTIONS
|
DEFINES += PLAYER_NO_COLOROPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
#install
|
|
||||||
target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/player
|
target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/player
|
||||||
sources.files = $$SOURCES $HEADERS $$RESOURCES $$FORMS *.pro
|
sources.files = $$SOURCES $HEADERS $$RESOURCES $$FORMS *.pro
|
||||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/player
|
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/player
|
||||||
INSTALLS += target sources
|
INSTALLS += target sources
|
||||||
|
|
||||||
QT+=widgets
|
|
||||||
|
|||||||
@@ -40,11 +40,11 @@
|
|||||||
|
|
||||||
#include "playercontrols.h"
|
#include "playercontrols.h"
|
||||||
|
|
||||||
#include <QtWidgets/qboxlayout.h>
|
#include <QBoxLayout>
|
||||||
#include <QtWidgets/qslider.h>
|
#include <QSlider>
|
||||||
#include <QtWidgets/qstyle.h>
|
#include <QStyle>
|
||||||
#include <QtWidgets/qtoolbutton.h>
|
#include <QToolButton>
|
||||||
#include <QtWidgets/qcombobox.h>
|
#include <QComboBox>
|
||||||
|
|
||||||
PlayerControls::PlayerControls(QWidget *parent)
|
PlayerControls::PlayerControls(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
@@ -89,7 +89,6 @@ PlayerControls::PlayerControls(QWidget *parent)
|
|||||||
|
|
||||||
connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SIGNAL(changeVolume(int)));
|
connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SIGNAL(changeVolume(int)));
|
||||||
|
|
||||||
|
|
||||||
rateBox = new QComboBox(this);
|
rateBox = new QComboBox(this);
|
||||||
rateBox->addItem("0.5x", QVariant(0.5));
|
rateBox->addItem("0.5x", QVariant(0.5));
|
||||||
rateBox->addItem("1.0x", QVariant(1.0));
|
rateBox->addItem("1.0x", QVariant(1.0));
|
||||||
@@ -105,11 +104,8 @@ PlayerControls::PlayerControls(QWidget *parent)
|
|||||||
layout->addWidget(playButton);
|
layout->addWidget(playButton);
|
||||||
layout->addWidget(nextButton);
|
layout->addWidget(nextButton);
|
||||||
layout->addWidget(muteButton);
|
layout->addWidget(muteButton);
|
||||||
if (volumeSlider)
|
layout->addWidget(volumeSlider);
|
||||||
layout->addWidget(volumeSlider);
|
layout->addWidget(rateBox);
|
||||||
|
|
||||||
if (rateBox)
|
|
||||||
layout->addWidget(rateBox);
|
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,15 +188,15 @@ qreal PlayerControls::playbackRate() const
|
|||||||
|
|
||||||
void PlayerControls::setPlaybackRate(float rate)
|
void PlayerControls::setPlaybackRate(float rate)
|
||||||
{
|
{
|
||||||
for (int i=0; i<rateBox->count(); i++) {
|
for (int i = 0; i < rateBox->count(); ++i) {
|
||||||
if (qFuzzyCompare(rate, float(rateBox->itemData(i).toDouble()))) {
|
if (qFuzzyCompare(rate, float(rateBox->itemData(i).toDouble()))) {
|
||||||
rateBox->setCurrentIndex(i);
|
rateBox->setCurrentIndex(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rateBox->addItem( QString("%1x").arg(rate), QVariant(rate));
|
rateBox->addItem(QString("%1x").arg(rate), QVariant(rate));
|
||||||
rateBox->setCurrentIndex(rateBox->count()-1);
|
rateBox->setCurrentIndex(rateBox->count() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerControls::updateRate()
|
void PlayerControls::updateRate()
|
||||||
|
|||||||
@@ -41,9 +41,8 @@
|
|||||||
#ifndef PLAYERCONTROLS_H
|
#ifndef PLAYERCONTROLS_H
|
||||||
#define PLAYERCONTROLS_H
|
#define PLAYERCONTROLS_H
|
||||||
|
|
||||||
#include <qmediaplayer.h>
|
#include <QMediaPlayer>
|
||||||
|
#include <QWidget>
|
||||||
#include <QtWidgets/qwidget.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAbstractButton;
|
class QAbstractButton;
|
||||||
@@ -51,16 +50,14 @@ class QAbstractSlider;
|
|||||||
class QComboBox;
|
class QComboBox;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class PlayerControls : public QWidget
|
class PlayerControls : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlayerControls(QWidget *parent = 0);
|
PlayerControls(QWidget *parent = 0);
|
||||||
|
|
||||||
QMediaPlayer::State state() const;
|
QMediaPlayer::State state() const;
|
||||||
|
|
||||||
int volume() const;
|
int volume() const;
|
||||||
bool isMuted() const;
|
bool isMuted() const;
|
||||||
qreal playbackRate() const;
|
qreal playbackRate() const;
|
||||||
@@ -98,4 +95,4 @@ private:
|
|||||||
QComboBox *rateBox;
|
QComboBox *rateBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // PLAYERCONTROLS_H
|
||||||
|
|||||||
@@ -40,10 +40,9 @@
|
|||||||
|
|
||||||
#include "playlistmodel.h"
|
#include "playlistmodel.h"
|
||||||
|
|
||||||
#include <QtCore/qfileinfo.h>
|
#include <QFileInfo>
|
||||||
#include <QtCore/qurl.h>
|
#include <QUrl>
|
||||||
|
#include <QMediaPlaylist>
|
||||||
#include <qmediaplaylist.h>
|
|
||||||
|
|
||||||
PlaylistModel::PlaylistModel(QObject *parent)
|
PlaylistModel::PlaylistModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
@@ -155,5 +154,3 @@ void PlaylistModel::changeItems(int start, int end)
|
|||||||
m_data.clear();
|
m_data.clear();
|
||||||
emit dataChanged(index(start,0), index(end,ColumnCount));
|
emit dataChanged(index(start,0), index(end,ColumnCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,18 +41,16 @@
|
|||||||
#ifndef PLAYLISTMODEL_H
|
#ifndef PLAYLISTMODEL_H
|
||||||
#define PLAYLISTMODEL_H
|
#define PLAYLISTMODEL_H
|
||||||
|
|
||||||
#include <qtmultimediadefs.h>
|
#include <QAbstractItemModel>
|
||||||
#include <QtCore/qabstractitemmodel.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QMediaPlaylist;
|
class QMediaPlaylist;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class PlaylistModel : public QAbstractItemModel
|
class PlaylistModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Column
|
enum Column
|
||||||
{
|
{
|
||||||
@@ -87,4 +85,4 @@ private:
|
|||||||
QMap<QModelIndex, QVariant> m_data;
|
QMap<QModelIndex, QVariant> m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // PLAYLISTMODEL_H
|
||||||
|
|||||||
@@ -40,7 +40,8 @@
|
|||||||
|
|
||||||
#include "videowidget.h"
|
#include "videowidget.h"
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QKeyEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
VideoWidget::VideoWidget(QWidget *parent)
|
VideoWidget::VideoWidget(QWidget *parent)
|
||||||
: QVideoWidget(parent)
|
: QVideoWidget(parent)
|
||||||
@@ -58,11 +59,9 @@ void VideoWidget::keyPressEvent(QKeyEvent *event)
|
|||||||
{
|
{
|
||||||
if (event->key() == Qt::Key_Escape && isFullScreen()) {
|
if (event->key() == Qt::Key_Escape && isFullScreen()) {
|
||||||
setFullScreen(false);
|
setFullScreen(false);
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
} else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
|
} else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
|
||||||
setFullScreen(!isFullScreen());
|
setFullScreen(!isFullScreen());
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
} else {
|
} else {
|
||||||
QVideoWidget::keyPressEvent(event);
|
QVideoWidget::keyPressEvent(event);
|
||||||
@@ -72,7 +71,6 @@ void VideoWidget::keyPressEvent(QKeyEvent *event)
|
|||||||
void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
setFullScreen(!isFullScreen());
|
setFullScreen(!isFullScreen());
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,16 +37,16 @@
|
|||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef VIDEOWIDGET_H
|
#ifndef VIDEOWIDGET_H
|
||||||
#define VIDEOWIDGET_H
|
#define VIDEOWIDGET_H
|
||||||
|
|
||||||
#include <qvideowidget.h>
|
#include <QVideoWidget>
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class VideoWidget : public QVideoWidget
|
class VideoWidget : public QVideoWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoWidget(QWidget *parent = 0);
|
VideoWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
@@ -56,4 +56,4 @@ protected:
|
|||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // VIDEOWIDGET_H
|
||||||
|
|||||||
@@ -40,27 +40,25 @@
|
|||||||
|
|
||||||
#include "radio.h"
|
#include "radio.h"
|
||||||
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
Radio::Radio()
|
Radio::Radio()
|
||||||
{
|
{
|
||||||
radio = new QRadioTuner;
|
radio = new QRadioTuner;
|
||||||
connect(radio, SIGNAL(error(QRadioTuner::Error)), this, SLOT(error(QRadioTuner::Error)));
|
connect(radio, SIGNAL(error(QRadioTuner::Error)), this, SLOT(error(QRadioTuner::Error)));
|
||||||
|
|
||||||
if(radio->isBandSupported(QRadioTuner::FM))
|
if (radio->isBandSupported(QRadioTuner::FM))
|
||||||
radio->setBand(QRadioTuner::FM);
|
radio->setBand(QRadioTuner::FM);
|
||||||
|
|
||||||
QWidget *window = new QWidget;
|
QWidget *window = new QWidget;
|
||||||
QVBoxLayout* layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
QHBoxLayout* buttonBar = new QHBoxLayout;
|
QHBoxLayout *buttonBar = new QHBoxLayout;
|
||||||
QHBoxLayout* topBar = new QHBoxLayout;
|
QHBoxLayout *topBar = new QHBoxLayout;
|
||||||
|
|
||||||
layout->addLayout(topBar);
|
layout->addLayout(topBar);
|
||||||
|
|
||||||
freq = new QLabel;
|
freq = new QLabel;
|
||||||
freq->setText(QString("%1 kHz").arg(radio->frequency()/1000));
|
freq->setText(QString("%1 kHz").arg(radio->frequency()/1000));
|
||||||
topBar->addWidget(freq);
|
topBar->addWidget(freq);
|
||||||
connect(radio,SIGNAL(frequencyChanged(int)),this,SLOT(freqChanged(int)));
|
connect(radio, SIGNAL(frequencyChanged(int)), SLOT(freqChanged(int)));
|
||||||
|
|
||||||
signal = new QLabel;
|
signal = new QLabel;
|
||||||
if (radio->isAvailable())
|
if (radio->isAvailable())
|
||||||
@@ -68,34 +66,34 @@ Radio::Radio()
|
|||||||
else
|
else
|
||||||
signal->setText(tr("No radio found"));
|
signal->setText(tr("No radio found"));
|
||||||
topBar->addWidget(signal);
|
topBar->addWidget(signal);
|
||||||
connect(radio,SIGNAL(signalStrengthChanged(int)),this,SLOT(signalChanged(int)));
|
connect(radio, SIGNAL(signalStrengthChanged(int)), SLOT(signalChanged(int)));
|
||||||
|
|
||||||
volumeSlider = new QSlider(Qt::Vertical,this);
|
volumeSlider = new QSlider(Qt::Vertical,this);
|
||||||
volumeSlider->setRange(0,100);
|
volumeSlider->setRange(0, 100);
|
||||||
volumeSlider->setValue(50);
|
volumeSlider->setValue(50);
|
||||||
connect(volumeSlider,SIGNAL(valueChanged(int)),this,SLOT(updateVolume(int)));
|
connect(volumeSlider, SIGNAL(valueChanged(int)), SLOT(updateVolume(int)));
|
||||||
topBar->addWidget(volumeSlider);
|
topBar->addWidget(volumeSlider);
|
||||||
|
|
||||||
layout->addLayout(buttonBar);
|
layout->addLayout(buttonBar);
|
||||||
|
|
||||||
searchLeft = new QPushButton;
|
searchLeft = new QPushButton;
|
||||||
searchLeft->setText(tr("scan Down"));
|
searchLeft->setText(tr("scan Down"));
|
||||||
connect(searchLeft,SIGNAL(clicked()),SLOT(searchDown()));
|
connect(searchLeft, SIGNAL(clicked()), SLOT(searchDown()));
|
||||||
buttonBar->addWidget(searchLeft);
|
buttonBar->addWidget(searchLeft);
|
||||||
|
|
||||||
left = new QPushButton;
|
left = new QPushButton;
|
||||||
left->setText(tr("Freq Down"));
|
left->setText(tr("Freq Down"));
|
||||||
connect(left,SIGNAL(clicked()),SLOT(freqDown()));
|
connect(left, SIGNAL(clicked()), SLOT(freqDown()));
|
||||||
buttonBar->addWidget(left);
|
buttonBar->addWidget(left);
|
||||||
|
|
||||||
right = new QPushButton;
|
right = new QPushButton;
|
||||||
connect(right,SIGNAL(clicked()),SLOT(freqUp()));
|
connect(right, SIGNAL(clicked()), SLOT(freqUp()));
|
||||||
right->setText(tr("Freq Up"));
|
right->setText(tr("Freq Up"));
|
||||||
buttonBar->addWidget(right);
|
buttonBar->addWidget(right);
|
||||||
|
|
||||||
searchRight = new QPushButton;
|
searchRight = new QPushButton;
|
||||||
searchRight->setText(tr("scan Up"));
|
searchRight->setText(tr("scan Up"));
|
||||||
connect(searchRight,SIGNAL(clicked()),SLOT(searchUp()));
|
connect(searchRight, SIGNAL(clicked()), SLOT(searchUp()));
|
||||||
buttonBar->addWidget(searchRight);
|
buttonBar->addWidget(searchRight);
|
||||||
|
|
||||||
window->setLayout(layout);
|
window->setLayout(layout);
|
||||||
@@ -112,14 +110,14 @@ Radio::~Radio()
|
|||||||
void Radio::freqUp()
|
void Radio::freqUp()
|
||||||
{
|
{
|
||||||
int f = radio->frequency();
|
int f = radio->frequency();
|
||||||
f = f + radio->frequencyStep(QRadioTuner::FM);
|
f += radio->frequencyStep(QRadioTuner::FM);
|
||||||
radio->setFrequency(f);
|
radio->setFrequency(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Radio::freqDown()
|
void Radio::freqDown()
|
||||||
{
|
{
|
||||||
int f = radio->frequency();
|
int f = radio->frequency();
|
||||||
f = f - radio->frequencyStep(QRadioTuner::FM);
|
f -= radio->frequencyStep(QRadioTuner::FM);
|
||||||
radio->setFrequency(f);
|
radio->setFrequency(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +151,7 @@ void Radio::updateVolume(int v)
|
|||||||
|
|
||||||
void Radio::error(QRadioTuner::Error error)
|
void Radio::error(QRadioTuner::Error error)
|
||||||
{
|
{
|
||||||
const QMetaObject* metaObj = radio->metaObject();
|
const QMetaObject *metaObj = radio->metaObject();
|
||||||
QMetaEnum errorEnum = metaObj->enumerator(metaObj->indexOfEnumerator("Error"));
|
QMetaEnum errorEnum = metaObj->enumerator(metaObj->indexOfEnumerator("Error"));
|
||||||
qWarning().nospace() << "Warning: Example application received error QRadioTuner::" << errorEnum.valueToKey(error);
|
qWarning().nospace() << "Warning: Example application received error QRadioTuner::" << errorEnum.valueToKey(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,16 +42,7 @@
|
|||||||
#define RADIO_H
|
#define RADIO_H
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
#include <QRadioTuner>
|
||||||
#include <qradiotuner.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QLabel;
|
|
||||||
class QPushButton;
|
|
||||||
class QSlider;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
|
||||||
|
|
||||||
class Radio : public QMainWindow
|
class Radio : public QMainWindow
|
||||||
{
|
{
|
||||||
@@ -71,14 +62,14 @@ public slots:
|
|||||||
void error(QRadioTuner::Error error);
|
void error(QRadioTuner::Error error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel* freq;
|
QLabel *freq;
|
||||||
QLabel* signal;
|
QLabel *signal;
|
||||||
QPushButton* left;
|
QPushButton *left;
|
||||||
QPushButton* right;
|
QPushButton *right;
|
||||||
QPushButton* searchLeft;
|
QPushButton *searchLeft;
|
||||||
QPushButton* searchRight;
|
QPushButton *searchRight;
|
||||||
QSlider* volumeSlider;
|
QSlider *volumeSlider;
|
||||||
QRadioTuner* radio;
|
QRadioTuner *radio;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // RADIO_H
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ TEMPLATE = app
|
|||||||
|
|
||||||
TARGET = spectrum
|
TARGET = spectrum
|
||||||
|
|
||||||
QT += multimedia
|
QT += multimedia widgets
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
engine.cpp \
|
engine.cpp \
|
||||||
@@ -89,6 +89,3 @@ macx {
|
|||||||
QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN
|
QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QT+=widgets
|
|
||||||
|
|||||||
@@ -44,14 +44,14 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <QAudioInput>
|
||||||
|
#include <QAudioOutput>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFile>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QtMultimedia/QAudioInput>
|
|
||||||
#include <QtMultimedia/QAudioOutput>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QFile>
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Constants
|
// Constants
|
||||||
|
|||||||
@@ -45,12 +45,13 @@
|
|||||||
#include "spectrumanalyser.h"
|
#include "spectrumanalyser.h"
|
||||||
#include "wavfile.h"
|
#include "wavfile.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QAudioDeviceInfo>
|
||||||
#include <QByteArray>
|
#include <QAudioFormat>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QObject>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QtMultimedia/QAudioDeviceInfo>
|
|
||||||
#include <QtMultimedia/QAudioFormat>
|
|
||||||
|
|
||||||
#ifdef DUMP_CAPTURED_AUDIO
|
#ifdef DUMP_CAPTURED_AUDIO
|
||||||
#define DUMP_DATA
|
#define DUMP_DATA
|
||||||
@@ -60,14 +61,11 @@
|
|||||||
#define DUMP_DATA
|
#define DUMP_DATA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DUMP_DATA
|
|
||||||
#include <QDir>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class FrequencySpectrum;
|
class FrequencySpectrum;
|
||||||
QT_FORWARD_DECLARE_CLASS(QAudioInput)
|
QT_BEGIN_NAMESPACE
|
||||||
QT_FORWARD_DECLARE_CLASS(QAudioOutput)
|
class QAudioInput;
|
||||||
QT_FORWARD_DECLARE_CLASS(QFile)
|
class QAudioOutput;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class interfaces with the QtMultimedia audio classes, and also with
|
* This class interfaces with the QtMultimedia audio classes, and also with
|
||||||
@@ -75,26 +73,28 @@ QT_FORWARD_DECLARE_CLASS(QFile)
|
|||||||
* of audio data, meanwhile performing real-time analysis of the audio level
|
* of audio data, meanwhile performing real-time analysis of the audio level
|
||||||
* and frequency spectrum.
|
* and frequency spectrum.
|
||||||
*/
|
*/
|
||||||
class Engine : public QObject {
|
class Engine : public QObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Engine(QObject *parent = 0);
|
explicit Engine(QObject *parent = 0);
|
||||||
~Engine();
|
~Engine();
|
||||||
|
|
||||||
const QList<QAudioDeviceInfo>& availableAudioInputDevices() const
|
const QList<QAudioDeviceInfo> &availableAudioInputDevices() const
|
||||||
{ return m_availableAudioInputDevices; }
|
{ return m_availableAudioInputDevices; }
|
||||||
|
|
||||||
const QList<QAudioDeviceInfo>& availableAudioOutputDevices() const
|
const QList<QAudioDeviceInfo> &availableAudioOutputDevices() const
|
||||||
{ return m_availableAudioOutputDevices; }
|
{ return m_availableAudioOutputDevices; }
|
||||||
|
|
||||||
QAudio::Mode mode() const { return m_mode; }
|
QAudio::Mode mode() const { return m_mode; }
|
||||||
QAudio::State state() const { return m_state; }
|
QAudio::State state() const { return m_state; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \return Current audio format
|
* \return Current audio format
|
||||||
* \note May be QAudioFormat() if engine is not initialized
|
* \note May be QAudioFormat() if engine is not initialized
|
||||||
*/
|
*/
|
||||||
const QAudioFormat& format() const { return m_format; }
|
const QAudioFormat& format() const { return m_format; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop any ongoing recording or playback, and reset to ground state.
|
* Stop any ongoing recording or playback, and reset to ground state.
|
||||||
@@ -125,25 +125,25 @@ public:
|
|||||||
* Position of the audio input device.
|
* Position of the audio input device.
|
||||||
* \return Position in bytes.
|
* \return Position in bytes.
|
||||||
*/
|
*/
|
||||||
qint64 recordPosition() const { return m_recordPosition; }
|
qint64 recordPosition() const { return m_recordPosition; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RMS level of the most recently processed set of audio samples.
|
* RMS level of the most recently processed set of audio samples.
|
||||||
* \return Level in range (0.0, 1.0)
|
* \return Level in range (0.0, 1.0)
|
||||||
*/
|
*/
|
||||||
qreal rmsLevel() const { return m_rmsLevel; }
|
qreal rmsLevel() const { return m_rmsLevel; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Peak level of the most recently processed set of audio samples.
|
* Peak level of the most recently processed set of audio samples.
|
||||||
* \return Level in range (0.0, 1.0)
|
* \return Level in range (0.0, 1.0)
|
||||||
*/
|
*/
|
||||||
qreal peakLevel() const { return m_peakLevel; }
|
qreal peakLevel() const { return m_peakLevel; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Position of the audio output device.
|
* Position of the audio output device.
|
||||||
* \return Position in bytes.
|
* \return Position in bytes.
|
||||||
*/
|
*/
|
||||||
qint64 playPosition() const { return m_playPosition; }
|
qint64 playPosition() const { return m_playPosition; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Length of the internal engine buffer.
|
* Length of the internal engine buffer.
|
||||||
@@ -155,7 +155,7 @@ public:
|
|||||||
* Amount of data held in the buffer.
|
* Amount of data held in the buffer.
|
||||||
* \return Data length in bytes.
|
* \return Data length in bytes.
|
||||||
*/
|
*/
|
||||||
qint64 dataLength() const { return m_dataLength; }
|
qint64 dataLength() const { return m_dataLength; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set window function applied to audio data before spectral analysis.
|
* Set window function applied to audio data before spectral analysis.
|
||||||
|
|||||||
@@ -58,12 +58,12 @@ int FrequencySpectrum::count() const
|
|||||||
return m_elements.count();
|
return m_elements.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
FrequencySpectrum::Element& FrequencySpectrum::operator[](int index)
|
FrequencySpectrum::Element &FrequencySpectrum::operator[](int index)
|
||||||
{
|
{
|
||||||
return m_elements[index];
|
return m_elements[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
const FrequencySpectrum::Element& FrequencySpectrum::operator[](int index) const
|
const FrequencySpectrum::Element &FrequencySpectrum::operator[](int index) const
|
||||||
{
|
{
|
||||||
return m_elements[index];
|
return m_elements[index];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,10 +49,12 @@
|
|||||||
* RMS and peak levels of the window of audio samples most recently analyzed
|
* RMS and peak levels of the window of audio samples most recently analyzed
|
||||||
* by the Engine.
|
* by the Engine.
|
||||||
*/
|
*/
|
||||||
class LevelMeter : public QWidget {
|
class LevelMeter : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LevelMeter(QWidget *parent = 0);
|
explicit LevelMeter(QWidget *parent = 0);
|
||||||
~LevelMeter();
|
~LevelMeter();
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|||||||
@@ -38,15 +38,15 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
app.setApplicationName("QtMultimedia spectrum analyzer");
|
app.setApplicationName("QtMultimedia spectrum analyzer");
|
||||||
MainWidget w;
|
|
||||||
|
|
||||||
|
MainWidget w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|||||||
@@ -445,4 +445,3 @@ void MainWidget::updateModeMenu()
|
|||||||
m_generateToneAction->setChecked(GenerateToneMode == m_mode);
|
m_generateToneAction->setChecked(GenerateToneMode == m_mode);
|
||||||
m_recordAction->setChecked(RecordMode == m_mode);
|
m_recordAction->setChecked(RecordMode == m_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,33 +41,37 @@
|
|||||||
#ifndef MAINWIDGET_H
|
#ifndef MAINWIDGET_H
|
||||||
#define MAINWIDGET_H
|
#define MAINWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QAudio>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QtMultimedia/qaudio.h>
|
#include <QWidget>
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
class FrequencySpectrum;
|
class FrequencySpectrum;
|
||||||
class ProgressBar;
|
|
||||||
class Spectrograph;
|
|
||||||
class Waveform;
|
|
||||||
class LevelMeter;
|
class LevelMeter;
|
||||||
|
class ProgressBar;
|
||||||
class SettingsDialog;
|
class SettingsDialog;
|
||||||
|
class Spectrograph;
|
||||||
class ToneGeneratorDialog;
|
class ToneGeneratorDialog;
|
||||||
|
class Waveform;
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QAudioFormat)
|
QT_BEGIN_NAMESPACE
|
||||||
QT_FORWARD_DECLARE_CLASS(QLabel)
|
class QAction;
|
||||||
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
class QAudioFormat;
|
||||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
class QLabel;
|
||||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
class QMenu;
|
||||||
|
class QPushButton;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main application widget, responsible for connecting the various UI
|
* Main application widget, responsible for connecting the various UI
|
||||||
* elements to the Engine.
|
* elements to the Engine.
|
||||||
*/
|
*/
|
||||||
class MainWidget : public QWidget {
|
class MainWidget : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWidget(QWidget *parent = 0);
|
explicit MainWidget(QWidget *parent = 0);
|
||||||
~MainWidget();
|
~MainWidget();
|
||||||
|
|
||||||
// QObject
|
// QObject
|
||||||
@@ -138,7 +142,6 @@ private:
|
|||||||
QAction* m_loadFileAction;
|
QAction* m_loadFileAction;
|
||||||
QAction* m_generateToneAction;
|
QAction* m_generateToneAction;
|
||||||
QAction* m_recordAction;
|
QAction* m_recordAction;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWIDGET_H
|
#endif // MAINWIDGET_H
|
||||||
|
|||||||
@@ -47,10 +47,12 @@
|
|||||||
* Widget which displays a the current fill state of the Engine's internal
|
* Widget which displays a the current fill state of the Engine's internal
|
||||||
* buffer, and the current play/record position within that buffer.
|
* buffer, and the current play/record position within that buffer.
|
||||||
*/
|
*/
|
||||||
class ProgressBar : public QWidget {
|
class ProgressBar : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProgressBar(QWidget *parent = 0);
|
explicit ProgressBar(QWidget *parent = 0);
|
||||||
~ProgressBar();
|
~ProgressBar();
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
@@ -68,7 +70,6 @@ private:
|
|||||||
qint64 m_playPosition;
|
qint64 m_playPosition;
|
||||||
qint64 m_windowPosition;
|
qint64 m_windowPosition;
|
||||||
qint64 m_windowLength;
|
qint64 m_windowLength;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROGRESSBAR_H
|
#endif // PROGRESSBAR_H
|
||||||
|
|||||||
@@ -39,14 +39,14 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog(
|
SettingsDialog::SettingsDialog(
|
||||||
const QList<QAudioDeviceInfo> &availableInputDevices,
|
const QList<QAudioDeviceInfo> &availableInputDevices,
|
||||||
|
|||||||
@@ -43,29 +43,33 @@
|
|||||||
|
|
||||||
#include "spectrum.h"
|
#include "spectrum.h"
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QtMultimedia/QAudioDeviceInfo>
|
#include <QAudioDeviceInfo>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QComboBox)
|
QT_BEGIN_NAMESPACE
|
||||||
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
class QComboBox;
|
||||||
QT_FORWARD_DECLARE_CLASS(QSlider)
|
class QCheckBox;
|
||||||
QT_FORWARD_DECLARE_CLASS(QSpinBox)
|
class QSlider;
|
||||||
QT_FORWARD_DECLARE_CLASS(QGridLayout)
|
class QSpinBox;
|
||||||
|
class QGridLayout;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog used to control settings such as the audio input / output device
|
* Dialog used to control settings such as the audio input / output device
|
||||||
* and the windowing function.
|
* and the windowing function.
|
||||||
*/
|
*/
|
||||||
class SettingsDialog : public QDialog {
|
class SettingsDialog : public QDialog
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SettingsDialog(const QList<QAudioDeviceInfo> &availableInputDevices,
|
SettingsDialog(const QList<QAudioDeviceInfo> &availableInputDevices,
|
||||||
const QList<QAudioDeviceInfo> &availableOutputDevices,
|
const QList<QAudioDeviceInfo> &availableOutputDevices,
|
||||||
QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
~SettingsDialog();
|
~SettingsDialog();
|
||||||
|
|
||||||
WindowFunction windowFunction() const { return m_windowFunction; }
|
WindowFunction windowFunction() const { return m_windowFunction; }
|
||||||
const QAudioDeviceInfo& inputDevice() const { return m_inputDevice; }
|
const QAudioDeviceInfo &inputDevice() const { return m_inputDevice; }
|
||||||
const QAudioDeviceInfo& outputDevice() const { return m_outputDevice; }
|
const QAudioDeviceInfo &outputDevice() const { return m_outputDevice; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void windowFunctionChanged(int index);
|
void windowFunctionChanged(int index);
|
||||||
@@ -77,11 +81,9 @@ private:
|
|||||||
QAudioDeviceInfo m_inputDevice;
|
QAudioDeviceInfo m_inputDevice;
|
||||||
QAudioDeviceInfo m_outputDevice;
|
QAudioDeviceInfo m_outputDevice;
|
||||||
|
|
||||||
QComboBox* m_inputDeviceComboBox;
|
QComboBox *m_inputDeviceComboBox;
|
||||||
QComboBox* m_outputDeviceComboBox;
|
QComboBox *m_outputDeviceComboBox;
|
||||||
|
QComboBox *m_windowFunctionComboBox;
|
||||||
QComboBox* m_windowFunctionComboBox;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGSDIALOG_H
|
#endif // SETTINGSDIALOG_H
|
||||||
|
|||||||
@@ -39,9 +39,9 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "spectrograph.h"
|
#include "spectrograph.h"
|
||||||
#include <QPainter>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QPainter>
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
|
|
||||||
const int NullTimerId = -1;
|
const int NullTimerId = -1;
|
||||||
|
|||||||
@@ -41,19 +41,20 @@
|
|||||||
#ifndef SPECTROGRAPH_H
|
#ifndef SPECTROGRAPH_H
|
||||||
#define SPECTROGRAPH_H
|
#define SPECTROGRAPH_H
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include "frequencyspectrum.h"
|
#include "frequencyspectrum.h"
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QMouseEvent)
|
#include <QWidget>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Widget which displays a spectrograph showing the frequency spectrum
|
* Widget which displays a spectrograph showing the frequency spectrum
|
||||||
* of the window of audio samples most recently analyzed by the Engine.
|
* of the window of audio samples most recently analyzed by the Engine.
|
||||||
*/
|
*/
|
||||||
class Spectrograph : public QWidget {
|
class Spectrograph : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Spectrograph(QWidget *parent = 0);
|
explicit Spectrograph(QWidget *parent = 0);
|
||||||
~Spectrograph();
|
~Spectrograph();
|
||||||
|
|
||||||
void setParams(int numBars, qreal lowFreq, qreal highFreq);
|
void setParams(int numBars, qreal lowFreq, qreal highFreq);
|
||||||
@@ -92,8 +93,6 @@ private:
|
|||||||
qreal m_lowFreq;
|
qreal m_lowFreq;
|
||||||
qreal m_highFreq;
|
qreal m_highFreq;
|
||||||
FrequencySpectrum m_spectrum;
|
FrequencySpectrum m_spectrum;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SPECTROGRAPH_H
|
#endif // SPECTROGRAPH_H
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
#ifndef SPECTRUM_H
|
#ifndef SPECTRUM_H
|
||||||
#define SPECTRUM_H
|
#define SPECTRUM_H
|
||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <qglobal.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "fftreal_wrapper.h" // For FFTLengthPowerOfTwo
|
#include "fftreal_wrapper.h" // For FFTLengthPowerOfTwo
|
||||||
|
|
||||||
@@ -89,7 +89,8 @@ enum WindowFunction {
|
|||||||
|
|
||||||
const WindowFunction DefaultWindowFunction = HannWindow;
|
const WindowFunction DefaultWindowFunction = HannWindow;
|
||||||
|
|
||||||
struct Tone {
|
struct Tone
|
||||||
|
{
|
||||||
Tone(qreal freq = 0.0, qreal amp = 0.0)
|
Tone(qreal freq = 0.0, qreal amp = 0.0)
|
||||||
: frequency(freq), amplitude(amp)
|
: frequency(freq), amplitude(amp)
|
||||||
{ }
|
{ }
|
||||||
@@ -101,7 +102,8 @@ struct Tone {
|
|||||||
qreal amplitude;
|
qreal amplitude;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SweptTone {
|
struct SweptTone
|
||||||
|
{
|
||||||
SweptTone(qreal start = 0.0, qreal end = 0.0, qreal amp = 0.0)
|
SweptTone(qreal start = 0.0, qreal end = 0.0, qreal amp = 0.0)
|
||||||
: startFreq(start), endFreq(end), amplitude(amp)
|
: startFreq(start), endFreq(end), amplitude(amp)
|
||||||
{ Q_ASSERT(end >= start); }
|
{ Q_ASSERT(end >= start); }
|
||||||
|
|||||||
@@ -40,14 +40,13 @@
|
|||||||
|
|
||||||
#include "spectrumanalyser.h"
|
#include "spectrumanalyser.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <QtCore/qmath.h>
|
|
||||||
#include <QtCore/qmetatype.h>
|
|
||||||
#include <QtMultimedia/QAudioFormat>
|
|
||||||
#include <QThread>
|
|
||||||
|
|
||||||
#include "fftreal_wrapper.h"
|
#include "fftreal_wrapper.h"
|
||||||
|
|
||||||
|
#include <qmath.h>
|
||||||
|
#include <qmetatype.h>
|
||||||
|
#include <QAudioFormat>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
SpectrumAnalyserThread::SpectrumAnalyserThread(QObject *parent)
|
SpectrumAnalyserThread::SpectrumAnalyserThread(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
#ifndef DISABLE_FFT
|
#ifndef DISABLE_FFT
|
||||||
@@ -275,7 +274,3 @@ void SpectrumAnalyser::calculationComplete(const FrequencySpectrum &spectrum)
|
|||||||
emit spectrumChanged(spectrum);
|
emit spectrumChanged(spectrum);
|
||||||
m_state = Idle;
|
m_state = Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class SpectrumAnalyserThreadPrivate;
|
|||||||
class SpectrumAnalyserThread : public QObject
|
class SpectrumAnalyserThread : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpectrumAnalyserThread(QObject *parent);
|
SpectrumAnalyserThread(QObject *parent);
|
||||||
~SpectrumAnalyserThread();
|
~SpectrumAnalyserThread();
|
||||||
@@ -121,6 +122,7 @@ private:
|
|||||||
class SpectrumAnalyser : public QObject
|
class SpectrumAnalyser : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpectrumAnalyser(QObject *parent = 0);
|
SpectrumAnalyser(QObject *parent = 0);
|
||||||
~SpectrumAnalyser();
|
~SpectrumAnalyser();
|
||||||
|
|||||||
@@ -41,9 +41,9 @@
|
|||||||
#include "spectrum.h"
|
#include "spectrum.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QtMultimedia/QAudioFormat>
|
#include <QAudioFormat>
|
||||||
#include <QtCore/qmath.h>
|
#include <qmath.h>
|
||||||
#include <QtCore/qendian.h>
|
#include <qendian.h>
|
||||||
|
|
||||||
void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer)
|
void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer)
|
||||||
{
|
{
|
||||||
@@ -88,4 +88,3 @@ void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray
|
|||||||
phaseStep += phaseStepStep;
|
phaseStep += phaseStepStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,11 +41,13 @@
|
|||||||
#ifndef TONEGENERATOR_H
|
#ifndef TONEGENERATOR_H
|
||||||
#define TONEGENERATOR_H
|
#define TONEGENERATOR_H
|
||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <qglobal.h>
|
||||||
#include "spectrum.h"
|
#include "spectrum.h"
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QAudioFormat)
|
QT_BEGIN_NAMESPACE
|
||||||
QT_FORWARD_DECLARE_CLASS(QByteArray)
|
class QAudioFormat;
|
||||||
|
class QByteArray;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a sine wave
|
* Generate a sine wave
|
||||||
|
|||||||
@@ -77,26 +77,23 @@ ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent)
|
|||||||
m_amplitudeSlider->setValue(ToneGeneratorAmplitudeDefault);
|
m_amplitudeSlider->setValue(ToneGeneratorAmplitudeDefault);
|
||||||
|
|
||||||
// Add widgets to layout
|
// Add widgets to layout
|
||||||
|
QGridLayout *frequencyControlLayout = new QGridLayout;
|
||||||
QScopedPointer<QGridLayout> frequencyControlLayout(new QGridLayout);
|
|
||||||
QLabel *frequencyLabel = new QLabel(tr("Frequency (Hz)"), this);
|
QLabel *frequencyLabel = new QLabel(tr("Frequency (Hz)"), this);
|
||||||
frequencyControlLayout->addWidget(frequencyLabel, 0, 0, 2, 1);
|
frequencyControlLayout->addWidget(frequencyLabel, 0, 0, 2, 1);
|
||||||
frequencyControlLayout->addWidget(m_frequencySlider, 0, 1);
|
frequencyControlLayout->addWidget(m_frequencySlider, 0, 1);
|
||||||
frequencyControlLayout->addWidget(m_frequencySpinBox, 1, 1);
|
frequencyControlLayout->addWidget(m_frequencySpinBox, 1, 1);
|
||||||
m_toneGeneratorFrequencyControl->setLayout(frequencyControlLayout.data());
|
m_toneGeneratorFrequencyControl->setLayout(frequencyControlLayout);
|
||||||
frequencyControlLayout.take(); // ownership transferred to m_toneGeneratorFrequencyControl
|
|
||||||
m_toneGeneratorFrequencyControl->setEnabled(false);
|
m_toneGeneratorFrequencyControl->setEnabled(false);
|
||||||
|
|
||||||
QScopedPointer<QGridLayout> toneGeneratorLayout(new QGridLayout);
|
QGridLayout *toneGeneratorLayout = new QGridLayout;
|
||||||
QLabel *amplitudeLabel = new QLabel(tr("Amplitude"), this);
|
QLabel *amplitudeLabel = new QLabel(tr("Amplitude"), this);
|
||||||
toneGeneratorLayout->addWidget(m_toneGeneratorSweepCheckBox, 0, 1);
|
toneGeneratorLayout->addWidget(m_toneGeneratorSweepCheckBox, 0, 1);
|
||||||
toneGeneratorLayout->addWidget(m_toneGeneratorFrequencyControl, 1, 0, 1, 2);
|
toneGeneratorLayout->addWidget(m_toneGeneratorFrequencyControl, 1, 0, 1, 2);
|
||||||
toneGeneratorLayout->addWidget(amplitudeLabel, 2, 0);
|
toneGeneratorLayout->addWidget(amplitudeLabel, 2, 0);
|
||||||
toneGeneratorLayout->addWidget(m_amplitudeSlider, 2, 1);
|
toneGeneratorLayout->addWidget(m_amplitudeSlider, 2, 1);
|
||||||
m_toneGeneratorControl->setLayout(toneGeneratorLayout.data());
|
m_toneGeneratorControl->setLayout(toneGeneratorLayout);
|
||||||
m_toneGeneratorControl->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
m_toneGeneratorControl->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||||
dialogLayout->addWidget(m_toneGeneratorControl);
|
dialogLayout->addWidget(m_toneGeneratorControl);
|
||||||
toneGeneratorLayout.take(); // ownership transferred
|
|
||||||
|
|
||||||
// Connect
|
// Connect
|
||||||
CHECKED_CONNECT(m_toneGeneratorSweepCheckBox, SIGNAL(toggled(bool)),
|
CHECKED_CONNECT(m_toneGeneratorSweepCheckBox, SIGNAL(toggled(bool)),
|
||||||
|
|||||||
@@ -42,21 +42,25 @@
|
|||||||
#define TONEGENERATORDIALOG_H
|
#define TONEGENERATORDIALOG_H
|
||||||
|
|
||||||
#include "spectrum.h"
|
#include "spectrum.h"
|
||||||
|
#include <QAudioDeviceInfo>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QtMultimedia/QAudioDeviceInfo>
|
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
QT_BEGIN_NAMESPACE
|
||||||
QT_FORWARD_DECLARE_CLASS(QSlider)
|
class QCheckBox;
|
||||||
QT_FORWARD_DECLARE_CLASS(QSpinBox)
|
class QSlider;
|
||||||
QT_FORWARD_DECLARE_CLASS(QGridLayout)
|
class QSpinBox;
|
||||||
|
class QGridLayout;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog which controls the parameters of the tone generator.
|
* Dialog which controls the parameters of the tone generator.
|
||||||
*/
|
*/
|
||||||
class ToneGeneratorDialog : public QDialog {
|
class ToneGeneratorDialog : public QDialog
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ToneGeneratorDialog(QWidget *parent = 0);
|
explicit ToneGeneratorDialog(QWidget *parent = 0);
|
||||||
~ToneGeneratorDialog();
|
~ToneGeneratorDialog();
|
||||||
|
|
||||||
bool isFrequencySweepEnabled() const;
|
bool isFrequencySweepEnabled() const;
|
||||||
@@ -67,15 +71,14 @@ private slots:
|
|||||||
void frequencySweepEnabled(bool enabled);
|
void frequencySweepEnabled(bool enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QCheckBox* m_toneGeneratorSweepCheckBox;
|
QCheckBox *m_toneGeneratorSweepCheckBox;
|
||||||
bool m_frequencySweepEnabled;
|
bool m_frequencySweepEnabled;
|
||||||
QWidget* m_toneGeneratorControl;
|
QWidget *m_toneGeneratorControl;
|
||||||
QWidget* m_toneGeneratorFrequencyControl;
|
QWidget *m_toneGeneratorFrequencyControl;
|
||||||
QSlider* m_frequencySlider;
|
QSlider *m_frequencySlider;
|
||||||
QSpinBox* m_frequencySpinBox;
|
QSpinBox *m_frequencySpinBox;
|
||||||
qreal m_frequency;
|
qreal m_frequency;
|
||||||
QSlider* m_amplitudeSlider;
|
QSlider *m_amplitudeSlider;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TONEGENERATORDIALOG_H
|
#endif // TONEGENERATORDIALOG_H
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtMultimedia/QAudioFormat>
|
#include <QAudioFormat>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
qint64 audioDuration(const QAudioFormat &format, qint64 bytes)
|
qint64 audioDuration(const QAudioFormat &format, qint64 bytes)
|
||||||
@@ -119,10 +119,10 @@ bool isPCM(const QAudioFormat &format)
|
|||||||
|
|
||||||
bool isPCMS16LE(const QAudioFormat &format)
|
bool isPCMS16LE(const QAudioFormat &format)
|
||||||
{
|
{
|
||||||
return (isPCM(format) &&
|
return isPCM(format) &&
|
||||||
format.sampleType() == QAudioFormat::SignedInt &&
|
format.sampleType() == QAudioFormat::SignedInt &&
|
||||||
format.sampleSize() == 16 &&
|
format.sampleSize() == 16 &&
|
||||||
format.byteOrder() == QAudioFormat::LittleEndian);
|
format.byteOrder() == QAudioFormat::LittleEndian;
|
||||||
}
|
}
|
||||||
|
|
||||||
const qint16 PCMS16MaxValue = 32767;
|
const qint16 PCMS16MaxValue = 32767;
|
||||||
|
|||||||
@@ -41,12 +41,10 @@
|
|||||||
#ifndef WAVEFORM_H
|
#ifndef WAVEFORM_H
|
||||||
#define WAVEFORM_H
|
#define WAVEFORM_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QAudioFormat>
|
||||||
#include <QtMultimedia/QAudioFormat>
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
#include <QWidget>
|
||||||
QT_FORWARD_DECLARE_CLASS(QByteArray)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Widget which displays a section of the audio waveform.
|
* Widget which displays a section of the audio waveform.
|
||||||
@@ -57,10 +55,12 @@ QT_FORWARD_DECLARE_CLASS(QByteArray)
|
|||||||
* outside the widget, it is moved to the right end of the tile array and
|
* outside the widget, it is moved to the right end of the tile array and
|
||||||
* painted with the next section of the waveform.
|
* painted with the next section of the waveform.
|
||||||
*/
|
*/
|
||||||
class Waveform : public QWidget {
|
class Waveform : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Waveform(QWidget *parent = 0);
|
explicit Waveform(QWidget *parent = 0);
|
||||||
~Waveform();
|
~Waveform();
|
||||||
|
|
||||||
// QWidget
|
// QWidget
|
||||||
@@ -197,7 +197,6 @@ private:
|
|||||||
|
|
||||||
qint64 m_windowPosition;
|
qint64 m_windowPosition;
|
||||||
qint64 m_windowLength;
|
qint64 m_windowLength;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WAVEFORM_H
|
#endif // WAVEFORM_H
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtCore/qendian.h>
|
#include <qendian.h>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|||||||
@@ -38,13 +38,12 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef WAVFILE_H
|
#ifndef WAVFILE_H
|
||||||
#define WAVFILE_H
|
#define WAVFILE_H
|
||||||
|
|
||||||
#include <QtCore/qobject.h>
|
#include <QObject>
|
||||||
#include <QtCore/qfile.h>
|
#include <QFile>
|
||||||
#include <QtMultimedia/qaudioformat.h>
|
#include <QAudioFormat>
|
||||||
|
|
||||||
class WavFile : public QFile
|
class WavFile : public QFile
|
||||||
{
|
{
|
||||||
@@ -62,8 +61,6 @@ private:
|
|||||||
private:
|
private:
|
||||||
QAudioFormat m_fileFormat;
|
QAudioFormat m_fileFormat;
|
||||||
qint64 m_headerLength;
|
qint64 m_headerLength;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // WAVFILE_H
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ TEMPLATE = subdirs
|
|||||||
|
|
||||||
# Ensure that library is built before application
|
# Ensure that library is built before application
|
||||||
CONFIG += ordered
|
CONFIG += ordered
|
||||||
|
QT += widgets
|
||||||
|
|
||||||
!contains(DEFINES, DISABLE_FFT) {
|
!contains(DEFINES, DISABLE_FFT): SUBDIRS += 3rdparty/fftreal
|
||||||
SUBDIRS += 3rdparty/fftreal
|
|
||||||
}
|
|
||||||
|
|
||||||
SUBDIRS += app
|
SUBDIRS += app
|
||||||
|
|
||||||
TARGET = spectrum
|
TARGET = spectrum
|
||||||
@@ -16,5 +14,3 @@ TARGET = spectrum
|
|||||||
sources.files = README.txt spectrum.pri spectrum.pro TODO.txt
|
sources.files = README.txt spectrum.pri spectrum.pro TODO.txt
|
||||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/spectrum
|
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/spectrum
|
||||||
INSTALLS += sources
|
INSTALLS += sources
|
||||||
|
|
||||||
QT+=widgets
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
#include "videoplayer.h"
|
#include "videoplayer.h"
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,11 +41,11 @@
|
|||||||
#include "videoplayer.h"
|
#include "videoplayer.h"
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#include <qvideosurfaceformat.h>
|
#include <QVideoSurfaceFormat>
|
||||||
#include <qgraphicsvideoitem.h>
|
#include <QGraphicsVideoItem>
|
||||||
|
|
||||||
VideoPlayer::VideoPlayer(QWidget *parent, Qt::WindowFlags flags)
|
VideoPlayer::VideoPlayer(QWidget *parent)
|
||||||
: QWidget(parent, flags)
|
: QWidget(parent)
|
||||||
, mediaPlayer(0, QMediaPlayer::VideoSurface)
|
, mediaPlayer(0, QMediaPlayer::VideoSurface)
|
||||||
, videoItem(0)
|
, videoItem(0)
|
||||||
, playButton(0)
|
, playButton(0)
|
||||||
|
|||||||
@@ -41,10 +41,9 @@
|
|||||||
#ifndef VIDEOPLAYER_H
|
#ifndef VIDEOPLAYER_H
|
||||||
#define VIDEOPLAYER_H
|
#define VIDEOPLAYER_H
|
||||||
|
|
||||||
#include <qmediaplayer.h>
|
#include <QMediaPlayer>
|
||||||
|
#include <QMovie>
|
||||||
#include <QtGui/QMovie>
|
#include <QWidget>
|
||||||
#include <QtWidgets/QWidget>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAbstractButton;
|
class QAbstractButton;
|
||||||
@@ -55,8 +54,9 @@ QT_END_NAMESPACE
|
|||||||
class VideoPlayer : public QWidget
|
class VideoPlayer : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoPlayer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
VideoPlayer(QWidget *parent = 0);
|
||||||
~VideoPlayer();
|
~VideoPlayer();
|
||||||
|
|
||||||
QSize sizeHint() const { return QSize(800, 600); }
|
QSize sizeHint() const { return QSize(800, 600); }
|
||||||
|
|||||||
Reference in New Issue
Block a user