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
qohaudiostream_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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 QOHAUDIOSTREAM_P_H
5#define QOHAUDIOSTREAM_P_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 <QtMultimedia/qaudioformat.h>
19
20#include <QtCore/qloggingcategory.h>
21
22#include <ohaudio/native_audiocapturer.h>
23#include <ohaudio/native_audiorenderer.h>
24#include <ohaudio/native_audiostream_base.h>
25#include <ohaudio/native_audiostreambuilder.h>
26
27QT_BEGIN_NAMESPACE
28
29namespace QtOHAudio {
30
31Q_DECLARE_LOGGING_CATEGORY(qLcOHAudioStream)
32
33struct StreamBuilder;
34
35struct Stream
36{
37 explicit Stream(StreamBuilder &builder);
38 ~Stream();
39
41
42 bool start();
43 void stop();
44 void pause();
45 void flush();
46
47 bool isOpen() const;
49
50 OH_AudioRenderer *renderer() const noexcept { return m_renderer; }
51 OH_AudioCapturer *capturer() const noexcept { return m_capturer; }
52
53private:
54 void close();
55
56 OH_AudioStream_Type m_streamType{ AUDIOSTREAM_TYPE_RENDERER };
57 OH_AudioRenderer *m_renderer{ nullptr };
58 OH_AudioCapturer *m_capturer{ nullptr };
59 bool m_areStreamParametersRespected{ false };
60};
61
69
71{
72 friend Stream;
73
74 explicit StreamBuilder(QAudioFormat format, OH_AudioStream_Type direction);
76
78
81 int32_t (*readCallback)(OH_AudioCapturer *capturer, void *userData, void *buffer,
82 int32_t length){ nullptr };
83 void *userData{ nullptr };
86
87 void setupBuilder();
88
89private:
90 OH_AudioStreamBuilder *m_builder{ nullptr };
91};
92
93OH_AudioStream_SampleFormat toOHSampleFormat(QAudioFormat::SampleFormat fmt);
94QAudioFormat::SampleFormat fromOHSampleFormat(OH_AudioStream_SampleFormat fmt);
95QAudioFormat::SampleFormat preferredCompatibleSampleFormat(QAudioFormat::SampleFormat requested);
96
97} // namespace QtOHAudio
98
99QT_END_NAMESPACE
100
101#endif // QOHAUDIOSTREAM_P_H
Combined button and popup list for selecting options.
QAudioFormat::SampleFormat fromOHSampleFormat(OH_AudioStream_SampleFormat fmt)
OH_AudioStream_SampleFormat toOHSampleFormat(QAudioFormat::SampleFormat fmt)
QAudioFormat::SampleFormat preferredCompatibleSampleFormat(QAudioFormat::SampleFormat requested)
QT_MM_DEFINE_QDEBUG_ENUM(OH_AudioStream_Result)
StreamParameterSet params
StreamBuilder(QAudioFormat format, OH_AudioStream_Type direction)
OH_AudioRenderer_OnWriteDataCallback writeCallback
int32_t(* readCallback)(OH_AudioCapturer *capturer, void *userData, void *buffer, int32_t length)
OH_AudioStream_Usage outputUsage
OH_AudioStream_SourceType inputSourceType
OH_AudioStream_LatencyMode latencyMode
bool areStreamParametersRespected() const
OH_AudioRenderer * renderer() const noexcept
OH_AudioCapturer * capturer() const noexcept
Stream(StreamBuilder &builder)