Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qgstreameraudiosink_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#ifndef QAUDIOOUTPUTGSTREAMER_H
5#define QAUDIOOUTPUTGSTREAMER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
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/private/qringbuffer_p.h>
25
26#include "qaudio.h"
27#include "qaudiodevice.h"
28#include <private/qaudiosystem_p.h>
29#include <private/qmultimediautils_p.h>
30
31#include <qgst_p.h>
32#include <qgstpipeline_p.h>
33
35
36class QGstAppSrc;
37
39 : public QPlatformAudioSink,
41{
44
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 bytesFree() 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 bytesProcessedByAppSrc(int bytes);
69 void needData();
70
71private:
72 QGStreamerAudioSink(const QAudioDevice &device, QGstAppSrc *appsrc, QGstElement audioconvert,
74
75 void setState(QAudio::State state);
76 void setError(QAudio::Error error);
77
78 bool processBusMessage(const QGstreamerMessage &message) override;
79
80 bool open();
81 void close();
82 qint64 write(const char *data, qint64 len);
83
84private:
85 QByteArray m_device;
86 QAudioFormat m_format;
87 QAudio::Error m_errorState = QAudio::NoError;
88 QAudio::State m_deviceState = QAudio::StoppedState;
89 QAudio::State m_suspendedInState = QAudio::SuspendedState;
90 bool m_pullMode = true;
91 bool m_opened = false;
92 QIODevice *m_audioSource = nullptr;
93 int m_bufferSize = 0;
94 qint64 m_bytesProcessed = 0;
95 QElapsedTimer m_timeStamp;
96 qreal m_volume = 1.;
97 QByteArray pushData;
98
99 QGstPipeline gstPipeline;
100 QGstElement gstOutput;
101 QGstElement gstVolume;
102 QGstElement gstAppSrc;
103 QGstAppSrc *m_appSrc = nullptr;
104};
105
107{
110
111public:
114
115protected:
116 qint64 readData(char *data, qint64 len) override;
117 qint64 writeData(const char *data, qint64 len) override;
118
119private:
120 QGStreamerAudioSink *m_audioDevice;
121};
122
124
125#endif
IOBluetoothDevice * device
qint64 writeData(const char *data, qint64 len) override
Writes up to maxSize bytes from data to the device.
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
void setFormat(const QAudioFormat &format) override
QIODevice * start() override
QAudioFormat format() const override
void setVolume(qreal volume) override
QAudio::State state() const override
bool processBusMessage(const QGstreamerMessage &message) override
qsizetype bufferSize() const override
qsizetype bytesFree() const override
qint64 processedUSecs() const override
qreal volume() const override
void setBufferSize(qsizetype value) 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
@ SuspendedState
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.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLenum GLsizei len
#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
QByteArray readData()
view create()