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 <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
AudioDecoder::AudioDecoder(bool isPlayback, bool isDelete)
|
||||
: m_cout(stdout, QIODevice::WriteOnly)
|
||||
|
||||
@@ -41,16 +41,16 @@
|
||||
#ifndef AUDIODECODER_H
|
||||
#define AUDIODECODER_H
|
||||
|
||||
#include <qaudiodecoder.h>
|
||||
#include "wavefilewriter.h"
|
||||
|
||||
#include <QAudioDecoder>
|
||||
#include <QSoundEffect>
|
||||
#include <QTextStream>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class AudioDecoder : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioDecoder(bool isPlayback, bool isDelete);
|
||||
~AudioDecoder() { }
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
|
||||
void setTargetFilename(const QString &fileName);
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void done();
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -38,14 +38,15 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QTextStream>
|
||||
#include <iostream>
|
||||
|
||||
#include <qfileinfo.h>
|
||||
#include <qdir.h>
|
||||
#include "audiodecoder.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
@@ -90,4 +91,4 @@ int main(int argc, char *argv[])
|
||||
decoder.start();
|
||||
|
||||
return app.exec();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,13 +41,14 @@
|
||||
#ifndef WAVEFILEWRITER_H
|
||||
#define WAVEFILEWRITER_H
|
||||
|
||||
#include <QAudioBuffer>
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
#include <qfile.h>
|
||||
#include <qaudiobuffer.h>
|
||||
|
||||
class WaveFileWriter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WaveFileWriter(QObject *parent = 0);
|
||||
~WaveFileWriter();
|
||||
|
||||
@@ -38,14 +38,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <qaudiodeviceinfo.h>
|
||||
|
||||
#include "audiodevices.h"
|
||||
|
||||
// Utility functions for converting QAudioFormat fields into text
|
||||
|
||||
QString toString(QAudioFormat::SampleType sampleType)
|
||||
static QString toString(QAudioFormat::SampleType sampleType)
|
||||
{
|
||||
QString result("Unknown");
|
||||
switch (sampleType) {
|
||||
@@ -64,7 +61,7 @@ QString toString(QAudioFormat::SampleType sampleType)
|
||||
return result;
|
||||
}
|
||||
|
||||
QString toString(QAudioFormat::Endian endian)
|
||||
static QString toString(QAudioFormat::Endian endian)
|
||||
{
|
||||
QString result("Unknown");
|
||||
switch (endian) {
|
||||
@@ -79,8 +76,8 @@ QString toString(QAudioFormat::Endian endian)
|
||||
}
|
||||
|
||||
|
||||
AudioDevicesBase::AudioDevicesBase(QWidget *parent, Qt::WindowFlags f)
|
||||
: QMainWindow(parent, f)
|
||||
AudioDevicesBase::AudioDevicesBase(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
@@ -88,8 +85,8 @@ AudioDevicesBase::AudioDevicesBase(QWidget *parent, Qt::WindowFlags f)
|
||||
AudioDevicesBase::~AudioDevicesBase() {}
|
||||
|
||||
|
||||
AudioTest::AudioTest(QWidget *parent, Qt::WindowFlags f)
|
||||
: AudioDevicesBase(parent, f)
|
||||
AudioTest::AudioTest(QWidget *parent)
|
||||
: AudioDevicesBase(parent)
|
||||
{
|
||||
mode = QAudio::AudioOutput;
|
||||
|
||||
@@ -186,11 +183,11 @@ void AudioTest::deviceChanged(int idx)
|
||||
settings.setChannelCount(chz.at(0));
|
||||
|
||||
codecsBox->clear();
|
||||
QStringList codecz = deviceInfo.supportedCodecs();
|
||||
for (int i = 0; i < codecz.size(); ++i)
|
||||
codecsBox->addItem(QString("%1").arg(codecz.at(i)));
|
||||
if (codecz.size())
|
||||
settings.setCodec(codecz.at(0));
|
||||
QStringList codecs = deviceInfo.supportedCodecs();
|
||||
for (int i = 0; i < codecs.size(); ++i)
|
||||
codecsBox->addItem(QString("%1").arg(codecs.at(i)));
|
||||
if (codecs.size())
|
||||
settings.setCodec(codecs.at(0));
|
||||
// Add false to create failed condition!
|
||||
codecsBox->addItem("audio/test");
|
||||
|
||||
|
||||
@@ -41,24 +41,25 @@
|
||||
#ifndef AUDIODEVICES_H
|
||||
#define AUDIODEVICES_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QMainWindow>
|
||||
#include <qaudiodeviceinfo.h>
|
||||
#include <QObject>
|
||||
|
||||
#include "ui_audiodevicesbase.h"
|
||||
|
||||
class AudioDevicesBase : public QMainWindow, public Ui::AudioDevicesBase
|
||||
{
|
||||
public:
|
||||
AudioDevicesBase(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
AudioDevicesBase(QWidget *parent = 0);
|
||||
virtual ~AudioDevicesBase();
|
||||
};
|
||||
|
||||
class AudioTest : public AudioDevicesBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioTest(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
AudioTest(QWidget *parent = 0);
|
||||
virtual ~AudioTest();
|
||||
|
||||
QAudioDeviceInfo deviceInfo;
|
||||
|
||||
@@ -42,15 +42,12 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <qaudiodeviceinfo.h>
|
||||
#include <qaudioinput.h>
|
||||
|
||||
#include <QtCore/qendian.h>
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QAudioInput>
|
||||
#include <qendian.h>
|
||||
|
||||
#include "audioinput.h"
|
||||
|
||||
@@ -337,10 +334,9 @@ void InputTest::readMore()
|
||||
if (len > BufferSize)
|
||||
len = BufferSize;
|
||||
qint64 l = m_input->read(m_buffer.data(), len);
|
||||
if(l > 0) {
|
||||
if (l > 0)
|
||||
m_audioInfo->write(m_buffer.constData(), l);
|
||||
}
|
||||
}
|
||||
|
||||
void InputTest::toggleMode()
|
||||
{
|
||||
|
||||
@@ -41,20 +41,20 @@
|
||||
#ifndef AUDIOINPUT_H
|
||||
#define AUDIOINPUT_H
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
#include <QMainWindow>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
#include <QAudioInput>
|
||||
#include <QByteArray>
|
||||
#include <QComboBox>
|
||||
#include <QMainWindow>
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QPushButton>
|
||||
#include <QSlider>
|
||||
|
||||
#include <qaudioinput.h>
|
||||
#include <QWidget>
|
||||
|
||||
class AudioInfo : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioInfo(const QAudioFormat &format, QObject *parent);
|
||||
~AudioInfo();
|
||||
@@ -94,9 +94,11 @@ private:
|
||||
QPixmap m_pixmap;
|
||||
};
|
||||
|
||||
|
||||
class InputTest : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputTest();
|
||||
~InputTest();
|
||||
@@ -133,5 +135,4 @@ private:
|
||||
QByteArray m_buffer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // AUDIOINPUT_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
TEMPLATE = app
|
||||
TARGET = audioinput
|
||||
|
||||
QT += multimedia
|
||||
QT += multimedia widgets
|
||||
|
||||
HEADERS = audioinput.h
|
||||
|
||||
@@ -13,5 +13,3 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
|
||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audioinput
|
||||
|
||||
INSTALLS += target sources
|
||||
|
||||
QT+=widgets
|
||||
|
||||
@@ -38,13 +38,13 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QAudioOutput>
|
||||
#include <QDebug>
|
||||
#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"
|
||||
|
||||
#define PUSH_MODE_LABEL "Enable push mode"
|
||||
|
||||
@@ -43,21 +43,21 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QMainWindow>
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include <QIODevice>
|
||||
#include <QTimer>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
#include <QAudioOutput>
|
||||
#include <QByteArray>
|
||||
|
||||
#include <qaudiooutput.h>
|
||||
#include <QComboBox>
|
||||
#include <QIODevice>
|
||||
#include <QLabel>
|
||||
#include <QMainWindow>
|
||||
#include <QObject>
|
||||
#include <QPushButton>
|
||||
#include <QSlider>
|
||||
#include <QTimer>
|
||||
|
||||
class Generator : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Generator(const QAudioFormat &format, qint64 durationUs, int sampleRate, QObject *parent);
|
||||
~Generator();
|
||||
@@ -80,6 +80,7 @@ private:
|
||||
class AudioTest : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioTest();
|
||||
~AudioTest();
|
||||
@@ -107,6 +108,7 @@ private:
|
||||
|
||||
bool m_pullMode;
|
||||
QByteArray m_buffer;
|
||||
|
||||
private slots:
|
||||
void notified();
|
||||
void pullTimerExpired();
|
||||
@@ -117,5 +119,4 @@ private slots:
|
||||
void volumeChanged(int);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // AUDIOOUTPUT_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
TEMPLATE = app
|
||||
TARGET = audiooutput
|
||||
|
||||
QT += multimedia
|
||||
QT += multimedia widgets
|
||||
|
||||
HEADERS = audiooutput.h
|
||||
|
||||
@@ -13,5 +13,3 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
|
||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/audiooutput
|
||||
|
||||
INSTALLS += target sources
|
||||
|
||||
QT+=widgets
|
||||
|
||||
@@ -38,14 +38,13 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QApplication>
|
||||
|
||||
#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");
|
||||
|
||||
AudioTest audio;
|
||||
|
||||
@@ -38,12 +38,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qdir.h>
|
||||
#include <QtWidgets/qfiledialog.h>
|
||||
|
||||
#include <qaudiorecorder.h>
|
||||
#include <qmediarecorder.h>
|
||||
#include <qaudioprobe.h>
|
||||
#include <QAudioProbe>
|
||||
#include <QAudioRecorder>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QMediaRecorder>
|
||||
|
||||
#include "audiorecorder.h"
|
||||
|
||||
@@ -53,8 +52,13 @@
|
||||
#include "ui_audiorecorder.h"
|
||||
#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),
|
||||
ui(new Ui::AudioRecorder),
|
||||
outputLocationSet(false)
|
||||
@@ -63,7 +67,7 @@ AudioRecorder::AudioRecorder(QWidget *parent)
|
||||
|
||||
audioRecorder = new QAudioRecorder(this);
|
||||
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);
|
||||
|
||||
//audio devices
|
||||
@@ -216,19 +220,20 @@ QUrl AudioRecorder::generateAudioFilePath()
|
||||
|
||||
int lastImage = 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();
|
||||
lastImage = qMax(lastImage, imgNumber);
|
||||
if (outputDir.exists(fileName))
|
||||
fileCount += 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
// 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
|
||||
if (!format.isValid())
|
||||
@@ -247,9 +252,9 @@ qreal AudioRecorder::GetPeakValue(const QAudioFormat& format)
|
||||
case QAudioFormat::SignedInt:
|
||||
if (format.sampleSize() == 32)
|
||||
return 2147483648.0;
|
||||
else if (format.sampleSize() == 16)
|
||||
if (format.sampleSize() == 16)
|
||||
return 32768.0;
|
||||
else if (format.sampleSize() == 8)
|
||||
if (format.sampleSize() == 8)
|
||||
return 128.0;
|
||||
break;
|
||||
case QAudioFormat::UnSignedInt:
|
||||
@@ -260,7 +265,7 @@ qreal AudioRecorder::GetPeakValue(const QAudioFormat& format)
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
qreal AudioRecorder::GetBufferLevel(const QAudioBuffer& buffer)
|
||||
qreal getBufferLevel(const QAudioBuffer& buffer)
|
||||
{
|
||||
if (!buffer.format().isValid() || buffer.format().byteOrder() != QAudioFormat::LittleEndian)
|
||||
return 0.0;
|
||||
@@ -268,7 +273,7 @@ qreal AudioRecorder::GetBufferLevel(const QAudioBuffer& buffer)
|
||||
if (buffer.format().codec() != "audio/pcm")
|
||||
return 0.0;
|
||||
|
||||
qreal peak_value = GetPeakValue(buffer.format());
|
||||
qreal peak_value = getPeakValue(buffer.format());
|
||||
if (qFuzzyCompare(peak_value, 0.0))
|
||||
return 0.0;
|
||||
|
||||
@@ -278,15 +283,15 @@ qreal AudioRecorder::GetBufferLevel(const QAudioBuffer& buffer)
|
||||
break;
|
||||
case QAudioFormat::Float:
|
||||
if (buffer.format().sampleSize() == 32)
|
||||
return GetBufferLevel(buffer.constData<float>(), buffer.sampleCount()) / peak_value;
|
||||
return getBufferLevel(buffer.constData<float>(), buffer.sampleCount()) / peak_value;
|
||||
break;
|
||||
case QAudioFormat::SignedInt:
|
||||
if (buffer.format().sampleSize() == 32)
|
||||
return GetBufferLevel(buffer.constData<long int>(), buffer.sampleCount()) / peak_value;
|
||||
else if (buffer.format().sampleSize() == 16)
|
||||
return GetBufferLevel(buffer.constData<short int>(), buffer.sampleCount()) / peak_value;
|
||||
else if (buffer.format().sampleSize() == 8)
|
||||
return GetBufferLevel(buffer.constData<signed char>(), buffer.sampleCount()) / peak_value;
|
||||
return getBufferLevel(buffer.constData<long int>(), buffer.sampleCount()) / peak_value;
|
||||
if (buffer.format().sampleSize() == 16)
|
||||
return getBufferLevel(buffer.constData<short int>(), buffer.sampleCount()) / peak_value;
|
||||
if (buffer.format().sampleSize() == 8)
|
||||
return getBufferLevel(buffer.constData<signed char>(), buffer.sampleCount()) / peak_value;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -294,12 +299,12 @@ qreal AudioRecorder::GetBufferLevel(const QAudioBuffer& buffer)
|
||||
}
|
||||
|
||||
template <class T>
|
||||
qreal AudioRecorder::GetBufferLevel(const T* buffer, int samples)
|
||||
qreal getBufferLevel(const T *buffer, int samples)
|
||||
{
|
||||
qreal max_value = 0.0;
|
||||
|
||||
for (int i = 0; i < samples; i++) {
|
||||
qreal value = qAbs((qreal)buffer[i]);
|
||||
for (int i = 0; i < samples; ++i) {
|
||||
qreal value = qAbs(qreal(buffer[i]));
|
||||
if (value > max_value)
|
||||
max_value = value;
|
||||
}
|
||||
@@ -309,6 +314,6 @@ qreal AudioRecorder::GetBufferLevel(const T* buffer, int samples)
|
||||
|
||||
void AudioRecorder::processBuffer(const QAudioBuffer& buffer)
|
||||
{
|
||||
qreal level = GetBufferLevel(buffer);
|
||||
qreal level = getBufferLevel(buffer);
|
||||
ui->audioLevel->setLevel(level);
|
||||
}
|
||||
|
||||
@@ -41,28 +41,21 @@
|
||||
#ifndef AUDIORECORDER_H
|
||||
#define AUDIORECORDER_H
|
||||
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtWidgets/qmainwindow.h>
|
||||
|
||||
#include <qmediarecorder.h>
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMediaRecorder>
|
||||
#include <QUrl>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace Ui {
|
||||
class AudioRecorder;
|
||||
}
|
||||
|
||||
namespace Ui { class AudioRecorder; }
|
||||
class QAudioRecorder;
|
||||
class QAudioProbe;
|
||||
class QAudioBuffer;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class AudioRecorder : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioRecorder(QWidget *parent = 0);
|
||||
~AudioRecorder();
|
||||
@@ -81,12 +74,6 @@ private slots:
|
||||
QUrl generateAudioFilePath();
|
||||
|
||||
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;
|
||||
|
||||
QAudioRecorder *audioRecorder;
|
||||
@@ -95,4 +82,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // AUDIORECORDER_H
|
||||
|
||||
@@ -50,4 +50,4 @@ int main(int argc, char *argv[])
|
||||
recorder.show();
|
||||
|
||||
return app.exec();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class QAudioLevel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
TEMPLATE = app
|
||||
TARGET = customvideoitem
|
||||
|
||||
QT += multimedia multimediawidgets
|
||||
QT += multimedia multimediawidgets widgets
|
||||
|
||||
contains(QT_CONFIG, opengl): QT += opengl
|
||||
|
||||
@@ -17,5 +17,3 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
|
||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/customvideoitem
|
||||
|
||||
INSTALLS += target sources
|
||||
|
||||
QT+=widgets
|
||||
|
||||
@@ -40,9 +40,9 @@
|
||||
|
||||
#include "videoplayer.h"
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
|
||||
@@ -40,8 +40,9 @@
|
||||
|
||||
#include "videoitem.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <qvideosurfaceformat.h>
|
||||
#include <QPainter>
|
||||
#include <QTransform>
|
||||
#include <QVideoSurfaceFormat>
|
||||
|
||||
VideoItem::VideoItem(QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
#ifndef VIDEOITEM_H
|
||||
#define VIDEOITEM_H
|
||||
|
||||
#include <qabstractvideosurface.h>
|
||||
#include <QtWidgets/QGraphicsItem>
|
||||
#include <QAbstractVideoSurface>
|
||||
#include <QGraphicsItem>
|
||||
|
||||
class VideoItem
|
||||
: public QAbstractVideoSurface,
|
||||
@@ -50,13 +50,13 @@ class VideoItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
|
||||
public:
|
||||
explicit VideoItem(QGraphicsItem *parentItem = 0);
|
||||
~VideoItem();
|
||||
|
||||
QRectF boundingRect() const;
|
||||
void paint(
|
||||
QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
//video surface
|
||||
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||
@@ -74,5 +74,5 @@ private:
|
||||
bool framePainted;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // VIDEOITEM_H
|
||||
|
||||
|
||||
@@ -42,14 +42,14 @@
|
||||
#include "videoitem.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <qvideosurfaceformat.h>
|
||||
#include <QVideoSurfaceFormat>
|
||||
|
||||
#if !defined(QT_NO_OPENGL)
|
||||
# include <QtOpenGL/QGLWidget>
|
||||
# include <QGLWidget>
|
||||
#endif
|
||||
|
||||
VideoPlayer::VideoPlayer(QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
VideoPlayer::VideoPlayer(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, mediaPlayer(0, QMediaPlayer::VideoSurface)
|
||||
, videoItem(0)
|
||||
, playButton(0)
|
||||
|
||||
@@ -41,24 +41,23 @@
|
||||
#ifndef VIDEOPLAYER_H
|
||||
#define VIDEOPLAYER_H
|
||||
|
||||
#include <qmediaplayer.h>
|
||||
|
||||
#include <QtGui/QMovie>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMovie>
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractButton;
|
||||
class QSlider;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
class VideoItem;
|
||||
|
||||
class VideoPlayer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoPlayer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
VideoPlayer(QWidget *parent = 0);
|
||||
~VideoPlayer();
|
||||
|
||||
QSize sizeHint() const { return QSize(800, 600); }
|
||||
@@ -81,5 +80,5 @@ private:
|
||||
QSlider *positionSlider;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // VIDEOPLAYER_H
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
TEMPLATE = app
|
||||
TARGET = customvideowidget
|
||||
|
||||
QT += multimedia multimediawidgets
|
||||
QT += multimedia multimediawidgets widgets
|
||||
|
||||
HEADERS = \
|
||||
videoplayer.h \
|
||||
@@ -19,5 +19,3 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
|
||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/customvideowidget
|
||||
|
||||
INSTALLS += target sources
|
||||
|
||||
QT+=widgets
|
||||
|
||||
@@ -41,10 +41,9 @@
|
||||
#ifndef VIDEOPLAYER_H
|
||||
#define VIDEOPLAYER_H
|
||||
|
||||
#include <qmediaplayer.h>
|
||||
|
||||
#include <QtGui/QMovie>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMovie>
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractButton;
|
||||
@@ -54,6 +53,7 @@ QT_END_NAMESPACE
|
||||
class VideoPlayer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoPlayer(QWidget *parent = 0);
|
||||
~VideoPlayer();
|
||||
@@ -74,4 +74,4 @@ private:
|
||||
QSlider *positionSlider;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // VIDEOPLAYER_H
|
||||
|
||||
@@ -43,18 +43,13 @@
|
||||
|
||||
#include "videowidgetsurface.h"
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractVideoSurface;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class VideoWidgetSurface;
|
||||
#include <QWidget>
|
||||
|
||||
//! [0]
|
||||
class VideoWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoWidget(QWidget *parent = 0);
|
||||
~VideoWidget();
|
||||
@@ -72,4 +67,4 @@ private:
|
||||
};
|
||||
//! [0]
|
||||
|
||||
#endif
|
||||
#endif // VIDEOWIDGET_H
|
||||
|
||||
@@ -41,15 +41,16 @@
|
||||
#ifndef VIDEOWIDGETSURFACE_H
|
||||
#define VIDEOWIDGETSURFACE_H
|
||||
|
||||
#include <QtCore/QRect>
|
||||
#include <QtGui/QImage>
|
||||
#include <qabstractvideosurface.h>
|
||||
#include <qvideoframe.h>
|
||||
#include <QAbstractVideoSurface>
|
||||
#include <QImage>
|
||||
#include <QRect>
|
||||
#include <QVideoFrame>
|
||||
|
||||
//! [0]
|
||||
class VideoWidgetSurface : public QAbstractVideoSurface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoWidgetSurface(QWidget *widget, QObject *parent = 0);
|
||||
|
||||
|
||||
@@ -41,13 +41,12 @@
|
||||
#ifndef HISTOGRAMWIDGET_H
|
||||
#define HISTOGRAMWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <qvideoframe.h>
|
||||
#include <QThread>
|
||||
#include <QVideoFrame>
|
||||
#include <QWidget>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class FrameProcessor: public QObject {
|
||||
class FrameProcessor: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
@@ -60,6 +59,7 @@ signals:
|
||||
class HistogramWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HistogramWidget(QWidget *parent = 0);
|
||||
~HistogramWidget();
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#include "player.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -53,18 +53,10 @@ int main(int argc, char *argv[])
|
||||
Player player;
|
||||
|
||||
#if defined(Q_WS_SIMULATOR)
|
||||
# if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 2))
|
||||
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();
|
||||
#else
|
||||
player.show();
|
||||
#endif
|
||||
return app.exec();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,10 +44,9 @@
|
||||
#include "playlistmodel.h"
|
||||
#include "histogramwidget.h"
|
||||
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediaplaylist.h>
|
||||
#include <qvideoprobe.h>
|
||||
|
||||
#include <QMediaService>
|
||||
#include <QMediaPlaylist>
|
||||
#include <QVideoProbe>
|
||||
#include <QtWidgets>
|
||||
|
||||
|
||||
@@ -427,4 +426,3 @@ void Player::showColorDialog()
|
||||
colorDialog->show();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -41,38 +41,35 @@
|
||||
#ifndef PLAYER_H
|
||||
#define PLAYER_H
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
#include <qmediaplayer.h>
|
||||
#include <qmediaplaylist.h>
|
||||
#include "videowidget.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMediaPlaylist>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractItemView;
|
||||
class QLabel;
|
||||
class QModelIndex;
|
||||
class QSlider;
|
||||
class QPushButton;
|
||||
class QVideoProbe;
|
||||
|
||||
class QMediaPlayer;
|
||||
class QModelIndex;
|
||||
class QPushButton;
|
||||
class QSlider;
|
||||
class QVideoProbe;
|
||||
class QVideoWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class PlaylistModel;
|
||||
class HistogramWidget;
|
||||
|
||||
class Player : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Player(QWidget *parent = 0);
|
||||
~Player();
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void fullScreenChanged(bool fullScreen);
|
||||
|
||||
private slots:
|
||||
@@ -127,4 +124,4 @@ private:
|
||||
qint64 duration;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // PLAYER_H
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
TEMPLATE = app
|
||||
TARGET = player
|
||||
|
||||
CONFIG += qt warn_on
|
||||
|
||||
QT += network \
|
||||
xml \
|
||||
multimedia \
|
||||
multimediawidgets
|
||||
multimediawidgets \
|
||||
widgets
|
||||
|
||||
HEADERS = \
|
||||
player.h \
|
||||
@@ -25,10 +24,7 @@ maemo* {
|
||||
DEFINES += PLAYER_NO_COLOROPTIONS
|
||||
}
|
||||
|
||||
#install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/player
|
||||
sources.files = $$SOURCES $HEADERS $$RESOURCES $$FORMS *.pro
|
||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/player
|
||||
INSTALLS += target sources
|
||||
|
||||
QT+=widgets
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
|
||||
#include "playercontrols.h"
|
||||
|
||||
#include <QtWidgets/qboxlayout.h>
|
||||
#include <QtWidgets/qslider.h>
|
||||
#include <QtWidgets/qstyle.h>
|
||||
#include <QtWidgets/qtoolbutton.h>
|
||||
#include <QtWidgets/qcombobox.h>
|
||||
#include <QBoxLayout>
|
||||
#include <QSlider>
|
||||
#include <QStyle>
|
||||
#include <QToolButton>
|
||||
#include <QComboBox>
|
||||
|
||||
PlayerControls::PlayerControls(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@@ -89,7 +89,6 @@ PlayerControls::PlayerControls(QWidget *parent)
|
||||
|
||||
connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SIGNAL(changeVolume(int)));
|
||||
|
||||
|
||||
rateBox = new QComboBox(this);
|
||||
rateBox->addItem("0.5x", QVariant(0.5));
|
||||
rateBox->addItem("1.0x", QVariant(1.0));
|
||||
@@ -105,10 +104,7 @@ PlayerControls::PlayerControls(QWidget *parent)
|
||||
layout->addWidget(playButton);
|
||||
layout->addWidget(nextButton);
|
||||
layout->addWidget(muteButton);
|
||||
if (volumeSlider)
|
||||
layout->addWidget(volumeSlider);
|
||||
|
||||
if (rateBox)
|
||||
layout->addWidget(rateBox);
|
||||
setLayout(layout);
|
||||
}
|
||||
@@ -192,7 +188,7 @@ qreal PlayerControls::playbackRate() const
|
||||
|
||||
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()))) {
|
||||
rateBox->setCurrentIndex(i);
|
||||
return;
|
||||
|
||||
@@ -41,9 +41,8 @@
|
||||
#ifndef PLAYERCONTROLS_H
|
||||
#define PLAYERCONTROLS_H
|
||||
|
||||
#include <qmediaplayer.h>
|
||||
|
||||
#include <QtWidgets/qwidget.h>
|
||||
#include <QMediaPlayer>
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractButton;
|
||||
@@ -51,16 +50,14 @@ class QAbstractSlider;
|
||||
class QComboBox;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class PlayerControls : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlayerControls(QWidget *parent = 0);
|
||||
|
||||
QMediaPlayer::State state() const;
|
||||
|
||||
int volume() const;
|
||||
bool isMuted() const;
|
||||
qreal playbackRate() const;
|
||||
@@ -98,4 +95,4 @@ private:
|
||||
QComboBox *rateBox;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // PLAYERCONTROLS_H
|
||||
|
||||
@@ -40,10 +40,9 @@
|
||||
|
||||
#include "playlistmodel.h"
|
||||
|
||||
#include <QtCore/qfileinfo.h>
|
||||
#include <QtCore/qurl.h>
|
||||
|
||||
#include <qmediaplaylist.h>
|
||||
#include <QFileInfo>
|
||||
#include <QUrl>
|
||||
#include <QMediaPlaylist>
|
||||
|
||||
PlaylistModel::PlaylistModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
@@ -155,5 +154,3 @@ void PlaylistModel::changeItems(int start, int end)
|
||||
m_data.clear();
|
||||
emit dataChanged(index(start,0), index(end,ColumnCount));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,18 +41,16 @@
|
||||
#ifndef PLAYLISTMODEL_H
|
||||
#define PLAYLISTMODEL_H
|
||||
|
||||
#include <qtmultimediadefs.h>
|
||||
#include <QtCore/qabstractitemmodel.h>
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMediaPlaylist;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class PlaylistModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Column
|
||||
{
|
||||
@@ -87,4 +85,4 @@ private:
|
||||
QMap<QModelIndex, QVariant> m_data;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // PLAYLISTMODEL_H
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
|
||||
#include "videowidget.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
|
||||
VideoWidget::VideoWidget(QWidget *parent)
|
||||
: QVideoWidget(parent)
|
||||
@@ -58,11 +59,9 @@ void VideoWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Escape && isFullScreen()) {
|
||||
setFullScreen(false);
|
||||
|
||||
event->accept();
|
||||
} else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
|
||||
setFullScreen(!isFullScreen());
|
||||
|
||||
event->accept();
|
||||
} else {
|
||||
QVideoWidget::keyPressEvent(event);
|
||||
@@ -72,7 +71,6 @@ void VideoWidget::keyPressEvent(QKeyEvent *event)
|
||||
void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
setFullScreen(!isFullScreen());
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,16 +37,16 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef VIDEOWIDGET_H
|
||||
#define VIDEOWIDGET_H
|
||||
|
||||
#include <qvideowidget.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
#include <QVideoWidget>
|
||||
|
||||
class VideoWidget : public QVideoWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoWidget(QWidget *parent = 0);
|
||||
|
||||
@@ -56,4 +56,4 @@ protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // VIDEOWIDGET_H
|
||||
|
||||
@@ -40,8 +40,6 @@
|
||||
|
||||
#include "radio.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
Radio::Radio()
|
||||
{
|
||||
radio = new QRadioTuner;
|
||||
@@ -60,7 +58,7 @@ Radio::Radio()
|
||||
freq = new QLabel;
|
||||
freq->setText(QString("%1 kHz").arg(radio->frequency()/1000));
|
||||
topBar->addWidget(freq);
|
||||
connect(radio,SIGNAL(frequencyChanged(int)),this,SLOT(freqChanged(int)));
|
||||
connect(radio, SIGNAL(frequencyChanged(int)), SLOT(freqChanged(int)));
|
||||
|
||||
signal = new QLabel;
|
||||
if (radio->isAvailable())
|
||||
@@ -68,12 +66,12 @@ Radio::Radio()
|
||||
else
|
||||
signal->setText(tr("No radio found"));
|
||||
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->setRange(0, 100);
|
||||
volumeSlider->setValue(50);
|
||||
connect(volumeSlider,SIGNAL(valueChanged(int)),this,SLOT(updateVolume(int)));
|
||||
connect(volumeSlider, SIGNAL(valueChanged(int)), SLOT(updateVolume(int)));
|
||||
topBar->addWidget(volumeSlider);
|
||||
|
||||
layout->addLayout(buttonBar);
|
||||
@@ -112,14 +110,14 @@ Radio::~Radio()
|
||||
void Radio::freqUp()
|
||||
{
|
||||
int f = radio->frequency();
|
||||
f = f + radio->frequencyStep(QRadioTuner::FM);
|
||||
f += radio->frequencyStep(QRadioTuner::FM);
|
||||
radio->setFrequency(f);
|
||||
}
|
||||
|
||||
void Radio::freqDown()
|
||||
{
|
||||
int f = radio->frequency();
|
||||
f = f - radio->frequencyStep(QRadioTuner::FM);
|
||||
f -= radio->frequencyStep(QRadioTuner::FM);
|
||||
radio->setFrequency(f);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,16 +42,7 @@
|
||||
#define RADIO_H
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include <qradiotuner.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class QSlider;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
#include <QRadioTuner>
|
||||
|
||||
class Radio : public QMainWindow
|
||||
{
|
||||
@@ -81,4 +72,4 @@ private:
|
||||
QRadioTuner *radio;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // RADIO_H
|
||||
|
||||
@@ -6,7 +6,7 @@ TEMPLATE = app
|
||||
|
||||
TARGET = spectrum
|
||||
|
||||
QT += multimedia
|
||||
QT += multimedia widgets
|
||||
|
||||
SOURCES += main.cpp \
|
||||
engine.cpp \
|
||||
@@ -89,6 +89,3 @@ macx {
|
||||
QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QT+=widgets
|
||||
|
||||
@@ -44,14 +44,14 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <QAudioInput>
|
||||
#include <QAudioOutput>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QMetaObject>
|
||||
#include <QSet>
|
||||
#include <QtMultimedia/QAudioInput>
|
||||
#include <QtMultimedia/QAudioOutput>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
#include <QFile>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constants
|
||||
|
||||
@@ -45,12 +45,13 @@
|
||||
#include "spectrumanalyser.h"
|
||||
#include "wavfile.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QAudioFormat>
|
||||
#include <QBuffer>
|
||||
#include <QByteArray>
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <QtMultimedia/QAudioDeviceInfo>
|
||||
#include <QtMultimedia/QAudioFormat>
|
||||
|
||||
#ifdef DUMP_CAPTURED_AUDIO
|
||||
#define DUMP_DATA
|
||||
@@ -60,14 +61,11 @@
|
||||
#define DUMP_DATA
|
||||
#endif
|
||||
|
||||
#ifdef DUMP_DATA
|
||||
#include <QDir>
|
||||
#endif
|
||||
|
||||
class FrequencySpectrum;
|
||||
QT_FORWARD_DECLARE_CLASS(QAudioInput)
|
||||
QT_FORWARD_DECLARE_CLASS(QAudioOutput)
|
||||
QT_FORWARD_DECLARE_CLASS(QFile)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAudioInput;
|
||||
class QAudioOutput;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
* This class interfaces with the QtMultimedia audio classes, and also with
|
||||
@@ -75,10 +73,12 @@ QT_FORWARD_DECLARE_CLASS(QFile)
|
||||
* of audio data, meanwhile performing real-time analysis of the audio level
|
||||
* and frequency spectrum.
|
||||
*/
|
||||
class Engine : public QObject {
|
||||
class Engine : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Engine(QObject *parent = 0);
|
||||
explicit Engine(QObject *parent = 0);
|
||||
~Engine();
|
||||
|
||||
const QList<QAudioDeviceInfo> &availableAudioInputDevices() const
|
||||
|
||||
@@ -49,10 +49,12 @@
|
||||
* RMS and peak levels of the window of audio samples most recently analyzed
|
||||
* by the Engine.
|
||||
*/
|
||||
class LevelMeter : public QWidget {
|
||||
class LevelMeter : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LevelMeter(QWidget *parent = 0);
|
||||
explicit LevelMeter(QWidget *parent = 0);
|
||||
~LevelMeter();
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
@@ -38,15 +38,15 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include "mainwidget.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("QtMultimedia spectrum analyzer");
|
||||
MainWidget w;
|
||||
|
||||
MainWidget w;
|
||||
w.show();
|
||||
|
||||
return app.exec();
|
||||
|
||||
@@ -445,4 +445,3 @@ void MainWidget::updateModeMenu()
|
||||
m_generateToneAction->setChecked(GenerateToneMode == m_mode);
|
||||
m_recordAction->setChecked(RecordMode == m_mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,33 +41,37 @@
|
||||
#ifndef MAINWIDGET_H
|
||||
#define MAINWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QAudio>
|
||||
#include <QIcon>
|
||||
#include <QtMultimedia/qaudio.h>
|
||||
#include <QWidget>
|
||||
|
||||
class Engine;
|
||||
class FrequencySpectrum;
|
||||
class ProgressBar;
|
||||
class Spectrograph;
|
||||
class Waveform;
|
||||
class LevelMeter;
|
||||
class ProgressBar;
|
||||
class SettingsDialog;
|
||||
class Spectrograph;
|
||||
class ToneGeneratorDialog;
|
||||
class Waveform;
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QAudioFormat)
|
||||
QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QAudioFormat;
|
||||
class QLabel;
|
||||
class QMenu;
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
* Main application widget, responsible for connecting the various UI
|
||||
* elements to the Engine.
|
||||
*/
|
||||
class MainWidget : public QWidget {
|
||||
class MainWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWidget(QWidget *parent = 0);
|
||||
explicit MainWidget(QWidget *parent = 0);
|
||||
~MainWidget();
|
||||
|
||||
// QObject
|
||||
@@ -138,7 +142,6 @@ private:
|
||||
QAction* m_loadFileAction;
|
||||
QAction* m_generateToneAction;
|
||||
QAction* m_recordAction;
|
||||
|
||||
};
|
||||
|
||||
#endif // MAINWIDGET_H
|
||||
|
||||
@@ -47,10 +47,12 @@
|
||||
* Widget which displays a the current fill state of the Engine's internal
|
||||
* buffer, and the current play/record position within that buffer.
|
||||
*/
|
||||
class ProgressBar : public QWidget {
|
||||
class ProgressBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ProgressBar(QWidget *parent = 0);
|
||||
explicit ProgressBar(QWidget *parent = 0);
|
||||
~ProgressBar();
|
||||
|
||||
void reset();
|
||||
@@ -68,7 +70,6 @@ private:
|
||||
qint64 m_playPosition;
|
||||
qint64 m_windowPosition;
|
||||
qint64 m_windowLength;
|
||||
|
||||
};
|
||||
|
||||
#endif // PROGRESSBAR_H
|
||||
|
||||
@@ -39,14 +39,14 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "settingsdialog.h"
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QSlider>
|
||||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
SettingsDialog::SettingsDialog(
|
||||
const QList<QAudioDeviceInfo> &availableInputDevices,
|
||||
|
||||
@@ -43,20 +43,24 @@
|
||||
|
||||
#include "spectrum.h"
|
||||
#include <QDialog>
|
||||
#include <QtMultimedia/QAudioDeviceInfo>
|
||||
#include <QAudioDeviceInfo>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QComboBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QSlider)
|
||||
QT_FORWARD_DECLARE_CLASS(QSpinBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QGridLayout)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
class QSlider;
|
||||
class QSpinBox;
|
||||
class QGridLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
* Dialog used to control settings such as the audio input / output device
|
||||
* and the windowing function.
|
||||
*/
|
||||
class SettingsDialog : public QDialog {
|
||||
class SettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SettingsDialog(const QList<QAudioDeviceInfo> &availableInputDevices,
|
||||
const QList<QAudioDeviceInfo> &availableOutputDevices,
|
||||
@@ -79,9 +83,7 @@ private:
|
||||
|
||||
QComboBox *m_inputDeviceComboBox;
|
||||
QComboBox *m_outputDeviceComboBox;
|
||||
|
||||
QComboBox *m_windowFunctionComboBox;
|
||||
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "spectrograph.h"
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QTimerEvent>
|
||||
|
||||
const int NullTimerId = -1;
|
||||
|
||||
@@ -41,19 +41,20 @@
|
||||
#ifndef SPECTROGRAPH_H
|
||||
#define SPECTROGRAPH_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "frequencyspectrum.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QMouseEvent)
|
||||
#include <QWidget>
|
||||
|
||||
/**
|
||||
* Widget which displays a spectrograph showing the frequency spectrum
|
||||
* of the window of audio samples most recently analyzed by the Engine.
|
||||
*/
|
||||
class Spectrograph : public QWidget {
|
||||
class Spectrograph : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Spectrograph(QWidget *parent = 0);
|
||||
explicit Spectrograph(QWidget *parent = 0);
|
||||
~Spectrograph();
|
||||
|
||||
void setParams(int numBars, qreal lowFreq, qreal highFreq);
|
||||
@@ -92,8 +93,6 @@ private:
|
||||
qreal m_lowFreq;
|
||||
qreal m_highFreq;
|
||||
FrequencySpectrum m_spectrum;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SPECTROGRAPH_H
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#ifndef SPECTRUM_H
|
||||
#define SPECTRUM_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <qglobal.h>
|
||||
#include "utils.h"
|
||||
#include "fftreal_wrapper.h" // For FFTLengthPowerOfTwo
|
||||
|
||||
@@ -89,7 +89,8 @@ enum WindowFunction {
|
||||
|
||||
const WindowFunction DefaultWindowFunction = HannWindow;
|
||||
|
||||
struct Tone {
|
||||
struct Tone
|
||||
{
|
||||
Tone(qreal freq = 0.0, qreal amp = 0.0)
|
||||
: frequency(freq), amplitude(amp)
|
||||
{ }
|
||||
@@ -101,7 +102,8 @@ struct Tone {
|
||||
qreal amplitude;
|
||||
};
|
||||
|
||||
struct SweptTone {
|
||||
struct SweptTone
|
||||
{
|
||||
SweptTone(qreal start = 0.0, qreal end = 0.0, qreal amp = 0.0)
|
||||
: startFreq(start), endFreq(end), amplitude(amp)
|
||||
{ Q_ASSERT(end >= start); }
|
||||
|
||||
@@ -40,14 +40,13 @@
|
||||
|
||||
#include "spectrumanalyser.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QtCore/qmath.h>
|
||||
#include <QtCore/qmetatype.h>
|
||||
#include <QtMultimedia/QAudioFormat>
|
||||
#include <QThread>
|
||||
|
||||
#include "fftreal_wrapper.h"
|
||||
|
||||
#include <qmath.h>
|
||||
#include <qmetatype.h>
|
||||
#include <QAudioFormat>
|
||||
#include <QThread>
|
||||
|
||||
SpectrumAnalyserThread::SpectrumAnalyserThread(QObject *parent)
|
||||
: QObject(parent)
|
||||
#ifndef DISABLE_FFT
|
||||
@@ -275,7 +274,3 @@ void SpectrumAnalyser::calculationComplete(const FrequencySpectrum &spectrum)
|
||||
emit spectrumChanged(spectrum);
|
||||
m_state = Idle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ class SpectrumAnalyserThreadPrivate;
|
||||
class SpectrumAnalyserThread : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpectrumAnalyserThread(QObject *parent);
|
||||
~SpectrumAnalyserThread();
|
||||
@@ -121,6 +122,7 @@ private:
|
||||
class SpectrumAnalyser : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpectrumAnalyser(QObject *parent = 0);
|
||||
~SpectrumAnalyser();
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
#include "spectrum.h"
|
||||
#include "utils.h"
|
||||
#include <QByteArray>
|
||||
#include <QtMultimedia/QAudioFormat>
|
||||
#include <QtCore/qmath.h>
|
||||
#include <QtCore/qendian.h>
|
||||
#include <QAudioFormat>
|
||||
#include <qmath.h>
|
||||
#include <qendian.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,13 @@
|
||||
#ifndef TONEGENERATOR_H
|
||||
#define TONEGENERATOR_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <qglobal.h>
|
||||
#include "spectrum.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QAudioFormat)
|
||||
QT_FORWARD_DECLARE_CLASS(QByteArray)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAudioFormat;
|
||||
class QByteArray;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
* Generate a sine wave
|
||||
|
||||
@@ -77,26 +77,23 @@ ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent)
|
||||
m_amplitudeSlider->setValue(ToneGeneratorAmplitudeDefault);
|
||||
|
||||
// Add widgets to layout
|
||||
|
||||
QScopedPointer<QGridLayout> frequencyControlLayout(new QGridLayout);
|
||||
QGridLayout *frequencyControlLayout = new QGridLayout;
|
||||
QLabel *frequencyLabel = new QLabel(tr("Frequency (Hz)"), this);
|
||||
frequencyControlLayout->addWidget(frequencyLabel, 0, 0, 2, 1);
|
||||
frequencyControlLayout->addWidget(m_frequencySlider, 0, 1);
|
||||
frequencyControlLayout->addWidget(m_frequencySpinBox, 1, 1);
|
||||
m_toneGeneratorFrequencyControl->setLayout(frequencyControlLayout.data());
|
||||
frequencyControlLayout.take(); // ownership transferred to m_toneGeneratorFrequencyControl
|
||||
m_toneGeneratorFrequencyControl->setLayout(frequencyControlLayout);
|
||||
m_toneGeneratorFrequencyControl->setEnabled(false);
|
||||
|
||||
QScopedPointer<QGridLayout> toneGeneratorLayout(new QGridLayout);
|
||||
QGridLayout *toneGeneratorLayout = new QGridLayout;
|
||||
QLabel *amplitudeLabel = new QLabel(tr("Amplitude"), this);
|
||||
toneGeneratorLayout->addWidget(m_toneGeneratorSweepCheckBox, 0, 1);
|
||||
toneGeneratorLayout->addWidget(m_toneGeneratorFrequencyControl, 1, 0, 1, 2);
|
||||
toneGeneratorLayout->addWidget(amplitudeLabel, 2, 0);
|
||||
toneGeneratorLayout->addWidget(m_amplitudeSlider, 2, 1);
|
||||
m_toneGeneratorControl->setLayout(toneGeneratorLayout.data());
|
||||
m_toneGeneratorControl->setLayout(toneGeneratorLayout);
|
||||
m_toneGeneratorControl->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
dialogLayout->addWidget(m_toneGeneratorControl);
|
||||
toneGeneratorLayout.take(); // ownership transferred
|
||||
|
||||
// Connect
|
||||
CHECKED_CONNECT(m_toneGeneratorSweepCheckBox, SIGNAL(toggled(bool)),
|
||||
|
||||
@@ -42,21 +42,25 @@
|
||||
#define TONEGENERATORDIALOG_H
|
||||
|
||||
#include "spectrum.h"
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QDialog>
|
||||
#include <QtMultimedia/QAudioDeviceInfo>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QSlider)
|
||||
QT_FORWARD_DECLARE_CLASS(QSpinBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QGridLayout)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
class QSlider;
|
||||
class QSpinBox;
|
||||
class QGridLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
* Dialog which controls the parameters of the tone generator.
|
||||
*/
|
||||
class ToneGeneratorDialog : public QDialog {
|
||||
class ToneGeneratorDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ToneGeneratorDialog(QWidget *parent = 0);
|
||||
explicit ToneGeneratorDialog(QWidget *parent = 0);
|
||||
~ToneGeneratorDialog();
|
||||
|
||||
bool isFrequencySweepEnabled() const;
|
||||
@@ -75,7 +79,6 @@ private:
|
||||
QSpinBox *m_frequencySpinBox;
|
||||
qreal m_frequency;
|
||||
QSlider *m_amplitudeSlider;
|
||||
|
||||
};
|
||||
|
||||
#endif // TONEGENERATORDIALOG_H
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtMultimedia/QAudioFormat>
|
||||
#include <QAudioFormat>
|
||||
#include "utils.h"
|
||||
|
||||
qint64 audioDuration(const QAudioFormat &format, qint64 bytes)
|
||||
@@ -119,10 +119,10 @@ bool isPCM(const QAudioFormat &format)
|
||||
|
||||
bool isPCMS16LE(const QAudioFormat &format)
|
||||
{
|
||||
return (isPCM(format) &&
|
||||
return isPCM(format) &&
|
||||
format.sampleType() == QAudioFormat::SignedInt &&
|
||||
format.sampleSize() == 16 &&
|
||||
format.byteOrder() == QAudioFormat::LittleEndian);
|
||||
format.byteOrder() == QAudioFormat::LittleEndian;
|
||||
}
|
||||
|
||||
const qint16 PCMS16MaxValue = 32767;
|
||||
|
||||
@@ -41,12 +41,10 @@
|
||||
#ifndef WAVEFORM_H
|
||||
#define WAVEFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QtMultimedia/QAudioFormat>
|
||||
#include <QAudioFormat>
|
||||
#include <QPixmap>
|
||||
#include <QScopedPointer>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QByteArray)
|
||||
#include <QWidget>
|
||||
|
||||
/**
|
||||
* 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
|
||||
* painted with the next section of the waveform.
|
||||
*/
|
||||
class Waveform : public QWidget {
|
||||
class Waveform : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Waveform(QWidget *parent = 0);
|
||||
explicit Waveform(QWidget *parent = 0);
|
||||
~Waveform();
|
||||
|
||||
// QWidget
|
||||
@@ -197,7 +197,6 @@ private:
|
||||
|
||||
qint64 m_windowPosition;
|
||||
qint64 m_windowLength;
|
||||
|
||||
};
|
||||
|
||||
#endif // WAVEFORM_H
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qendian.h>
|
||||
#include <qendian.h>
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
#include "utils.h"
|
||||
|
||||
@@ -38,13 +38,12 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef WAVFILE_H
|
||||
#define WAVFILE_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qfile.h>
|
||||
#include <QtMultimedia/qaudioformat.h>
|
||||
#include <QObject>
|
||||
#include <QFile>
|
||||
#include <QAudioFormat>
|
||||
|
||||
class WavFile : public QFile
|
||||
{
|
||||
@@ -62,8 +61,6 @@ private:
|
||||
private:
|
||||
QAudioFormat m_fileFormat;
|
||||
qint64 m_headerLength;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // WAVFILE_H
|
||||
|
||||
@@ -4,11 +4,9 @@ TEMPLATE = subdirs
|
||||
|
||||
# Ensure that library is built before application
|
||||
CONFIG += ordered
|
||||
QT += widgets
|
||||
|
||||
!contains(DEFINES, DISABLE_FFT) {
|
||||
SUBDIRS += 3rdparty/fftreal
|
||||
}
|
||||
|
||||
!contains(DEFINES, DISABLE_FFT): SUBDIRS += 3rdparty/fftreal
|
||||
SUBDIRS += app
|
||||
|
||||
TARGET = spectrum
|
||||
@@ -16,5 +14,3 @@ TARGET = spectrum
|
||||
sources.files = README.txt spectrum.pri spectrum.pro TODO.txt
|
||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/spectrum
|
||||
INSTALLS += sources
|
||||
|
||||
QT+=widgets
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#include "videoplayer.h"
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
@@ -41,11 +41,11 @@
|
||||
#include "videoplayer.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <qvideosurfaceformat.h>
|
||||
#include <qgraphicsvideoitem.h>
|
||||
#include <QVideoSurfaceFormat>
|
||||
#include <QGraphicsVideoItem>
|
||||
|
||||
VideoPlayer::VideoPlayer(QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
VideoPlayer::VideoPlayer(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, mediaPlayer(0, QMediaPlayer::VideoSurface)
|
||||
, videoItem(0)
|
||||
, playButton(0)
|
||||
|
||||
@@ -41,10 +41,9 @@
|
||||
#ifndef VIDEOPLAYER_H
|
||||
#define VIDEOPLAYER_H
|
||||
|
||||
#include <qmediaplayer.h>
|
||||
|
||||
#include <QtGui/QMovie>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMovie>
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractButton;
|
||||
@@ -55,8 +54,9 @@ QT_END_NAMESPACE
|
||||
class VideoPlayer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoPlayer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
VideoPlayer(QWidget *parent = 0);
|
||||
~VideoPlayer();
|
||||
|
||||
QSize sizeHint() const { return QSize(800, 600); }
|
||||
|
||||
Reference in New Issue
Block a user