Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qaudiobufferoutput.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 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
5
6#include <QtMultimedia/qaudiobuffer.h>
7#include <QtMultimedia/qmediaplayer.h>
8
10
11/*!
12 \class QAudioBufferOutput
13 \inmodule QtMultimedia
14 \ingroup multimedia
15 \ingroup multimedia_audio
16 \since 6.8
17
18 \brief The QAudioBufferOutput class is used for capturing audio data provided by \l QMediaPlayer.
19
20 QAudioBufferOutput can be set to QMediaPlayer in order to receive audio buffers
21 decoded by the media player. The received audio data can be used for any
22 processing or visualization. An audio level meter implementation can be seen
23 in the widget based \l{Media Player Example}.
24
25 QAudioBufferOutput is only supported with the FFmpeg backend.
26
27 \sa QMediaPlayer, QMediaPlayer::setAudioBufferOutput, QAudioBuffer
28*/
29
30/*!
31 Constructs a new QAudioBufferOutput object with \a parent.
32
33 The audio format of output audio buffers will depend on
34 the source media file and the inner audio decoder in \l QMediaPlayer.
35*/
36QAudioBufferOutput::QAudioBufferOutput(QObject *parent)
37 : QObject(*new QAudioBufferOutputPrivate, parent)
38{
39}
40
41/*!
42 Constructs a new QAudioBufferOutput object with audio \a format and \a parent.
43
44 If the specified \a format is valid, it will be the format of output
45 audio buffers. Otherwise, the format of output audio buffers
46 will depend on the source media file and the inner audio decoder in \l QMediaPlayer.
47*/
48QAudioBufferOutput::QAudioBufferOutput(const QAudioFormat &format, QObject *parent)
49 : QObject(*new QAudioBufferOutputPrivate(format), parent)
50{
51}
52
53/*!
54 Destroys the audio buffer output object.
55*/
56QAudioBufferOutput::~QAudioBufferOutput()
57{
58 Q_D(QAudioBufferOutput);
59
60 if (d->mediaPlayer)
61 d->mediaPlayer->setAudioBufferOutput(nullptr);
62}
63
64/*!
65 Gets the audio format specified in the constructor.
66
67 If the format is valid, it specifies the format of output oudio buffers.
68*/
69QAudioFormat QAudioBufferOutput::format() const
70{
71 Q_D(const QAudioBufferOutput);
72 return d->format;
73}
74
75/*!
76 \fn void QAudioBufferOutput::audioBufferReceived(const QAudioBuffer &buffer)
77
78 Signals that a new audio \a buffer has been received from \l QMediaPlayer.
79*/
80
81QT_END_NAMESPACE
82
83#include "moc_qaudiobufferoutput.cpp"
Combined button and popup list for selecting options.