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
4#include "qaudiobufferoutput_p.h"
5#include "qmediaplayer.h"
6#include "qaudiobuffer.h"
7
8QT_BEGIN_NAMESPACE
9
10/*!
11 \class QAudioBufferOutput
12 \inmodule QtMultimedia
13 \ingroup multimedia
14 \ingroup multimedia_audio
15 \since 6.8
16
17 \brief The QAudioBufferOutput class is used for capturing audio data provided by \l QMediaPlayer.
18
19 QAudioBufferOutput can be set to QMediaPlayer in order to receive audio buffers
20 decoded by the media player. The received audio data can be used for any
21 processing or visualization.
22
23 QAudioBufferOutput is only supported with the FFmpeg backend.
24
25 \sa QMediaPlayer, QMediaPlayer::setAudioBufferOutput, QAudioBuffer
26*/
27
28/*!
29 Constructs a new QAudioBufferOutput object with \a parent.
30
31 The audio format of output audio buffers will depend on
32 the source media file and the inner audio decoder in \l QMediaPlayer.
33*/
34QAudioBufferOutput::QAudioBufferOutput(QObject *parent)
35 : QObject(*new QAudioBufferOutputPrivate, parent)
36{
37}
38
39/*!
40 Constructs a new QAudioBufferOutput object with audio \a format and \a parent.
41
42 If the specified \a format is valid, it will be the format of output
43 audio buffers. Otherwise, the format of output audio buffers
44 will depend on the source media file and the inner audio decoder in \l QMediaPlayer.
45*/
46QAudioBufferOutput::QAudioBufferOutput(const QAudioFormat &format, QObject *parent)
47 : QObject(*new QAudioBufferOutputPrivate(format), parent)
48{
49}
50
51/*!
52 Destroys the audio buffer output object.
53*/
54QAudioBufferOutput::~QAudioBufferOutput()
55{
56 Q_D(QAudioBufferOutput);
57
58 if (d->mediaPlayer)
59 d->mediaPlayer->setAudioBufferOutput(nullptr);
60}
61
62/*!
63 Gets the audio format specified in the constructor.
64
65 If the format is valid, it specifies the format of output oudio buffers.
66*/
67QAudioFormat QAudioBufferOutput::format() const
68{
69 Q_D(const QAudioBufferOutput);
70 return d->format;
71}
72
73/*!
74 \fn void QAudioBufferOutput::audioBufferReceived(const QAudioBuffer &buffer)
75
76 Signals that a new audio \a buffer has been received from \l QMediaPlayer.
77*/
78
79QT_END_NAMESPACE
80
81#include "moc_qaudiobufferoutput.cpp"
82

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtmultimedia/src/multimedia/audio/qaudiobufferoutput.cpp