Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 <common/qgstutils_p.h>
34
35#include <gst/app/gstappsink.h>
36
38
40
43{
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:
68 void setState(QAudio::State state);
70
71 QGstAppSink createAppSink();
72 static GstFlowReturn new_sample(GstAppSink *, gpointer user_data);
73 static void eos(GstAppSink *, gpointer user_data);
74
75 bool open();
76 void close();
77
78 static gboolean busMessage(GstBus *bus, GstMessage *msg, gpointer user_data);
79
80 void newDataAvailable(QGstSampleHandle sample);
81
82 QAudioDevice m_info;
83 qint64 m_bytesWritten = 0;
84 QIODevice *m_audioSink = nullptr;
85 QAudioFormat m_format;
86 QAudio::Error m_errorState = QAudio::NoError;
87 QAudio::State m_deviceState = QAudio::StoppedState;
88 qreal m_volume = 1.;
89
90 QRingBuffer m_buffer;
91 QAtomicInteger<bool> m_pullMode = true;
92 bool m_opened = false;
93 int m_bufferSize = 0;
94 qint64 m_elapsedTimeOffset = 0;
95 QElapsedTimer m_timeStamp;
96 QByteArray m_device;
97 QByteArray m_tempBuffer;
98
99 QGstElement gstInput;
100 QGstPipeline gstPipeline;
101 QGstElement gstVolume;
102 QGstAppSink gstAppSink;
103};
104
106{
107public:
109
110 qint64 readData(char *data, qint64 len) override;
111 qint64 writeData(const char *data, qint64 len) override;
112 qint64 bytesAvailable() const override;
113 bool isSequential() const override { return true; }
114private:
115 QGStreamerAudioSource *m_audioDevice;
116};
117
119
120#endif
IOBluetoothDevice * device
qint64 bytesAvailable() const override
Returns the number of bytes that are available for reading.
GStreamerInputPrivate(QGStreamerAudioSource *audio)
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.
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
QGStreamerAudioSource(const QAudioDevice &device, QObject *parent)
QAudio::Error error() const override
\inmodule QtCore \reentrant
Definition qiodevice.h:34
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
State
Definition qaudio.h:29
@ StoppedState
Definition qaudio.h:29
Error
Definition qaudio.h:28
@ NoError
Definition qaudio.h:28
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)
ptrdiff_t qsizetype
Definition qtypes.h:165
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
file open(QIODevice::ReadOnly)
QByteArray readData()