Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qgstreameraudiosource_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of other Qt classes. This header file may change from version to
10// version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QAUDIOINPUTGSTREAMER_H
16#define QAUDIOINPUTGSTREAMER_H
17
18#include <QtCore/qfile.h>
19#include <QtCore/qtimer.h>
20#include <QtCore/qstring.h>
21#include <QtCore/qstringlist.h>
22#include <QtCore/qelapsedtimer.h>
23#include <QtCore/qiodevice.h>
24#include <QtCore/qmutex.h>
25#include <QtCore/qatomic.h>
26#include <QtCore/private/qringbuffer_p.h>
27
28#include "qaudio.h"
29#include "qaudiodevice.h"
30#include <private/qaudiosystem_p.h>
31
32#include <qgstutils_p.h>
33#include <qgstpipeline_p.h>
34#include <gst/app/gstappsink.h>
35
37
39
42{
45public:
48
49 void start(QIODevice *device) override;
50 QIODevice *start() override;
51 void stop() override;
52 void reset() override;
53 void suspend() override;
54 void resume() override;
55 qsizetype bytesReady() const override;
56 void setBufferSize(qsizetype value) override;
57 qsizetype bufferSize() const override;
58 qint64 processedUSecs() const override;
59 QAudio::Error error() const override;
60 QAudio::State state() const override;
61 void setFormat(const QAudioFormat &format) override;
62 QAudioFormat format() const override;
63
64 void setVolume(qreal volume) override;
65 qreal volume() const override;
66
67private Q_SLOTS:
68 void newDataAvailable(GstSample *sample);
69
70private:
71 void setState(QAudio::State state);
73
74 QGstElement createAppSink();
75 static GstFlowReturn new_sample(GstAppSink *, gpointer user_data);
76 static void eos(GstAppSink *, gpointer user_data);
77
78 bool open();
79 void close();
80
81 static gboolean busMessage(GstBus *bus, GstMessage *msg, gpointer user_data);
82
83 QAudioDevice m_info;
84 qint64 m_bytesWritten = 0;
85 QIODevice *m_audioSink = nullptr;
86 QAudioFormat m_format;
87 QAudio::Error m_errorState = QAudio::NoError;
88 QAudio::State m_deviceState = QAudio::StoppedState;
89 qreal m_volume = 1.;
90
91 QRingBuffer m_buffer;
92 QAtomicInteger<bool> m_pullMode = true;
93 bool m_opened = false;
94 int m_bufferSize = 0;
95 qint64 m_elapsedTimeOffset = 0;
96 QElapsedTimer m_timeStamp;
97 QByteArray m_device;
98 QByteArray m_tempBuffer;
99
100 QGstElement gstInput;
101 QGstPipeline gstPipeline;
102 QGstElement gstVolume;
103 QGstElement gstAppSink;
104};
105
107{
109public:
112
113 qint64 readData(char *data, qint64 len) override;
114 qint64 writeData(const char *data, qint64 len) override;
115 qint64 bytesAvailable() const override;
116 bool isSequential() const override { return true; }
117private:
118 QGStreamerAudioSource *m_audioDevice;
119};
120
122
123#endif
IOBluetoothDevice * device
qint64 bytesAvailable() const override
Returns the number of bytes that are available for reading.
qint64 writeData(const char *data, qint64 len) override
Writes up to maxSize bytes from data to the device.
bool isSequential() const override
Returns true if this device is sequential; otherwise returns false.
\inmodule QtCore
Definition qatomic.h:18
The QAudioDevice class provides an information about audio devices and their functionality.
The QAudioFormat class stores audio stream parameter information.
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
qsizetype bufferSize() const override
void setFormat(const QAudioFormat &format) override
void setBufferSize(qsizetype value) override
qsizetype bytesReady() const override
QAudioFormat format() const override
qreal volume() const override
qint64 processedUSecs() const override
void setVolume(qreal volume) override
QAudio::State state() const override
QIODevice * start() override
QAudio::Error error() const override
\inmodule QtCore \reentrant
Definition qiodevice.h:34
\inmodule QtCore
Definition qobject.h:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
State
\value ActiveState Audio data is being processed, this state is set after start() is called and while...
Definition qaudio.h:25
@ StoppedState
Definition qaudio.h:25
Error
\value NoError No errors have occurred \value OpenError An error occurred opening the audio device \v...
Definition qaudio.h:24
@ NoError
Definition qaudio.h:24
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void * user_data
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLenum GLsizei len
static void setError(QJsonObject *response, const QString &msg)
#define Q_OBJECT
#define Q_SLOTS
ptrdiff_t qsizetype
Definition qtypes.h:70
long long qint64
Definition qtypes.h:55
double qreal
Definition qtypes.h:92
file open(QIODevice::ReadOnly)
QByteArray readData()