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
QtAudioDeviceManager.java
Go to the documentation of this file.
1// Copyright (C) 2021 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
4package org.qtproject.qt.android.multimedia;
5
6import java.util.ArrayList;
7import java.util.Arrays;
8import java.util.Comparator;
9import java.util.HashMap;
10import java.util.List;
11import java.util.concurrent.CountDownLatch;
12import java.util.concurrent.atomic.AtomicInteger;
13import android.content.Context;
14import android.media.AudioDeviceCallback;
15import android.media.AudioDeviceInfo;
16import android.media.AudioFormat;
17import android.media.AudioManager;
18import android.media.AudioRecord;
19import android.media.AudioTrack;
20import android.media.MediaRecorder;
21import android.os.Build;
22import android.os.Handler;
23import android.os.HandlerThread;
24import android.util.Log;
25
26import org.qtproject.qt.android.UsedFromNativeCode;
27
28class QtAudioDeviceManager
29{
30 private static final String TAG = "QtAudioDeviceManager";
31
32 static private AudioManager m_audioManager = null;
33 static private final AudioDevicesReceiver m_audioDevicesReceiver = new AudioDevicesReceiver();
34 static private HandlerThread m_handlerThread = null;
35 static private Handler m_handler = null;
36 static private AudioRecord m_recorder = null;
37 static private AudioTrack m_streamPlayer = null;
38 static private Thread m_streamingThread = null;
39 static private boolean m_isStreaming = false;
40 static private boolean m_useSpeaker = false;
41 static private final int m_sampleRate = 8000;
42 static private final int m_channels = AudioFormat.CHANNEL_CONFIGURATION_MONO;
43 static private final int m_audioFormat = AudioFormat.ENCODING_PCM_16BIT;
44 static private final int m_bufferSize = AudioRecord.getMinBufferSize(m_sampleRate, m_channels, m_audioFormat);
45 static private int m_currentOutputId = -1;
46 static private AtomicInteger m_scoCounter = new AtomicInteger();
47 static private AtomicInteger m_communicationDeviceCounter = new AtomicInteger();
48 static private AtomicInteger m_speakerphoneCounter = new AtomicInteger();
49 static private int m_currentCommunicationDeviceId = -1;
50
51 // Holds the pointer to the QAndroidAudioDevices instance.
52 //
53 // This is always assigned with callbacks registered, from a
54 // C++ thread. Assignment only happens when QAndroidAudioDevices
55 // is constructed. It is always cleared from the Handler thread, using
56 // blocking job from the C++ thread.
57 static private long m_qAudioDevicesNativePtr = 0;
58
59 static native void onAudioInputDevicesUpdated(long qAudioDeviceNativePtr);
60 static native void onAudioOutputDevicesUpdated(long qAudioDeviceNativePtr);
61
62 static private void updateDeviceList() {
63 assert(m_handler.getLooper().isCurrentThread());
64 // Make sure we never get a callback when we are unregistered.
65 assert(m_qAudioDevicesNativePtr != 0);
66
67 if (m_currentOutputId != -1)
68 prepareAudioOutput(m_currentOutputId);
69 onAudioInputDevicesUpdated(m_qAudioDevicesNativePtr);
70 onAudioOutputDevicesUpdated(m_qAudioDevicesNativePtr);
71 }
72
73 private static class AudioDevicesReceiver extends AudioDeviceCallback {
75 public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
76 assert(m_handler.getLooper().isCurrentThread());
77 updateDeviceList();
78 }
79
81 public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
82 assert(m_handler.getLooper().isCurrentThread());
83 updateDeviceList();
84 }
85 }
86
87 @UsedFromNativeCode
88 static void qAndroidAudioDevicesConstructed(long nativePtr)
89 {
90 assert(nativePtr != 0);
91 assert(m_handlerThread == null);
92 m_qAudioDevicesNativePtr = nativePtr;
93 m_handlerThread = new HandlerThread("QtAudioDeviceCallbacks");
94 m_handlerThread.start();
95 m_handler = new Handler(m_handlerThread.getLooper());
96 m_audioManager.registerAudioDeviceCallback(m_audioDevicesReceiver, m_handler);
97 }
98
99 @UsedFromNativeCode
100 static void qAndroidAudioDevicesDestroyed()
101 {
102 assert(!m_handler.getLooper().isCurrentThread());
103
104 // Perform cleanup on the same thread that we receive callbacks, then wait for cleanup job
105 // to finish. No need for locks.
106 final CountDownLatch latch = new CountDownLatch(1);
107 final boolean postSuccess = m_handler.post(() -> {
108 m_audioManager.unregisterAudioDeviceCallback(m_audioDevicesReceiver);
109 assert(m_qAudioDevicesNativePtr != 0);
110 m_qAudioDevicesNativePtr = 0;
111 latch.countDown(); // Signal that the task is done
112 });
113
114 if (!postSuccess) {
115 Log.w(
116 TAG,
117 "Unable to post cleanup job to corresponding thread during " +
118 "QAndroidAudioDevices cleanup.");
119 return;
120 }
121
122 try {
123 latch.await();
124 } catch (Exception e) {
125 Log.w(
126 TAG,
127 "Unable to wait for cleanup job to finish on corresponding thread during" +
128 "QAndroidAudioDevices cleanup.");
129 }
130
131 m_handlerThread.quitSafely();
132 m_handlerThread = null;
133 m_handler = null;
134 }
135
136 static void setContext(Context context)
137 {
138 m_audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
139 }
140
141 static AudioDeviceInfo[] getAudioOutputDevices()
142 {
143 return getAudioDevices(AudioManager.GET_DEVICES_OUTPUTS);
144 }
145
146 static AudioDeviceInfo[] getAudioInputDevices()
147 {
148 return getAudioDevices(AudioManager.GET_DEVICES_INPUTS);
149 }
150
151 @UsedFromNativeCode
152 static AudioDeviceInfo getAudioInputDeviceInfo(int id)
153 {
154 final AudioDeviceInfo[] audioDevices = m_audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS);
155
156 for (AudioDeviceInfo deviceInfo : audioDevices) {
157 if (deviceInfo.getId() == id)
158 return deviceInfo;
159 }
160
161 return null;
162 }
163
164 @UsedFromNativeCode
165 static int getDefaultSampleRate()
166 {
167 String sampleRate = m_audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
168 return Integer.parseInt(sampleRate);
169 }
170
171 @UsedFromNativeCode
172 static boolean isBluetoothDevice(AudioDeviceInfo deviceInfo)
173 {
174 switch (deviceInfo.getType()) {
175 case AudioDeviceInfo.TYPE_BLUETOOTH_A2DP:
176 case AudioDeviceInfo.TYPE_BLUETOOTH_SCO:
177 return true;
178 default:
179 return false;
180 }
181 }
182
183 @UsedFromNativeCode
184 static boolean prepareAudioInput(int id)
185 {
186 final AudioDeviceInfo[] audioDevices =
187 m_audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS);
188 for (AudioDeviceInfo deviceInfo : audioDevices) {
189 if (deviceInfo.getId() == id) {
190 switch (deviceInfo.getType())
191 {
192 case AudioDeviceInfo.TYPE_BLUETOOTH_A2DP:
193 case AudioDeviceInfo.TYPE_BLUETOOTH_SCO:
194 case AudioDeviceInfo.TYPE_WIRED_HEADSET:
195 case AudioDeviceInfo.TYPE_USB_HEADSET:
196 case AudioDeviceInfo.TYPE_BUILTIN_MIC:
197 return prepareAudioDevice(deviceInfo, AudioManager.MODE_NORMAL);
198 default:
199 return true;
200 }
201 }
202 }
203 return false;
204 }
205
206 private static void setInputMuted(boolean mute)
207 {
208 // This method mutes the microphone across the entire platform
209 m_audioManager.setMicrophoneMute(mute);
210 }
211
212 private static boolean isMicrophoneMute()
213 {
214 return m_audioManager.isMicrophoneMute();
215 }
216
217 private static String audioDeviceTypeToString(int type)
218 {
219 // API <= 23 types
220 switch (type)
221 {
222 case AudioDeviceInfo.TYPE_AUX_LINE:
223 return "AUX Line";
224 case AudioDeviceInfo.TYPE_BLUETOOTH_A2DP:
225 case AudioDeviceInfo.TYPE_BLUETOOTH_SCO:
226 return "Bluetooth";
227 case AudioDeviceInfo.TYPE_BUILTIN_EARPIECE:
228 return "Built in earpiece";
229 case AudioDeviceInfo.TYPE_BUILTIN_MIC:
230 return "Built in microphone";
231 case AudioDeviceInfo.TYPE_BUILTIN_SPEAKER:
232 return "Built in speaker";
233 case AudioDeviceInfo.TYPE_DOCK:
234 return "Dock";
235 case AudioDeviceInfo.TYPE_FM:
236 return "FM";
237 case AudioDeviceInfo.TYPE_FM_TUNER:
238 return "FM TUNER";
239 case AudioDeviceInfo.TYPE_HDMI:
240 return "HDMI";
241 case AudioDeviceInfo.TYPE_HDMI_ARC:
242 return "HDMI ARC";
243 case AudioDeviceInfo.TYPE_IP:
244 return "IP";
245 case AudioDeviceInfo.TYPE_LINE_ANALOG:
246 return "Line analog";
247 case AudioDeviceInfo.TYPE_LINE_DIGITAL:
248 return "Line digital";
249 case AudioDeviceInfo.TYPE_TV_TUNER:
250 return "TV tuner";
251 case AudioDeviceInfo.TYPE_USB_ACCESSORY:
252 return "USB accessory";
253 case AudioDeviceInfo.TYPE_WIRED_HEADPHONES:
254 return "Wired headphones";
255 case AudioDeviceInfo.TYPE_WIRED_HEADSET:
256 return "Wired headset";
257 }
258
259 // API 24
260 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
261 if (type == AudioDeviceInfo.TYPE_BUS)
262 return "Bus";
263 }
264
265 return "Unknown-Type";
266
267 }
268
269 private static final HashMap<Integer, Integer> priorityMap = new HashMap<Integer, Integer>() {{
270 put(AudioDeviceInfo.TYPE_WIRED_HEADSET, 1);
271 put(AudioDeviceInfo.TYPE_WIRED_HEADPHONES, 1);
272 put(AudioDeviceInfo.TYPE_BLUETOOTH_A2DP, 2);
273 put(AudioDeviceInfo.TYPE_BLUETOOTH_SCO, 2);
274 put(AudioDeviceInfo.TYPE_BUILTIN_SPEAKER, 3);
275 }};
276 private static final int DEFAULT_PRIORITY = 4;
277
278 private static void sortAudioDevices(AudioDeviceInfo[] devices) {
279 Comparator<AudioDeviceInfo> deviceTypeComparator = new Comparator<AudioDeviceInfo>() {
280 @Override
281 public int compare(AudioDeviceInfo device1, AudioDeviceInfo device2) {
282 return getPriority(device1) - getPriority(device2);
283 }
284
285 private int getPriority(AudioDeviceInfo device) {
286 return priorityMap.getOrDefault(device.getType(), DEFAULT_PRIORITY);
287 }
288 };
289
290 Arrays.sort(devices, deviceTypeComparator);
291 }
292
293 private static AudioDeviceInfo[] getAudioDevices(int type)
294 {
295 ArrayList<AudioDeviceInfo> filteredDevices = new ArrayList<>();
296
297 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
298 boolean builtInMicAdded = false;
299 boolean bluetoothDeviceAdded = false;
300 AudioDeviceInfo[] audioDevices = m_audioManager.getDevices(type);
301 sortAudioDevices(audioDevices);
302
303 for (AudioDeviceInfo deviceInfo : audioDevices) {
304 String deviceType = audioDeviceTypeToString(deviceInfo.getType());
305
306 if (deviceType.equals(audioDeviceTypeToString(AudioDeviceInfo.TYPE_UNKNOWN))) {
307 // Not supported device type
308 continue;
309 } else if (deviceType.equals(audioDeviceTypeToString(AudioDeviceInfo.TYPE_BUILTIN_MIC))) {
310 if (builtInMicAdded) {
311 // Built in mic already added. Second built in mic is CAMCORDER, but there
312 // is no reliable way of selecting it. AudioSource.MIC usually means the
313 // primary mic. AudioSource.CAMCORDER source might mean the secondary mic,
314 // but there's no guarantee. It depends e.g. on the physical placement
315 // of the mics. That's why we will not add built in microphone twice.
316 // Should we?
317 continue;
318 }
319 builtInMicAdded = true;
320 } else if (isBluetoothDevice(deviceInfo)) {
321 if (bluetoothDeviceAdded) {
322 // Bluetooth device already added. Second device is just a different
323 // technology profille (like A2DP or SCO). We should not add the same
324 // device twice. Should we?
325 continue;
326 }
327 bluetoothDeviceAdded = true;
328 }
329
330 filteredDevices.add(deviceInfo);
331 }
332 }
333
334 return filteredDevices.toArray(new AudioDeviceInfo[filteredDevices.size()]);
335 }
336
337 final private static int [] bluetoothTypes = {
338 AudioDeviceInfo.TYPE_BLUETOOTH_A2DP,
339 AudioDeviceInfo.TYPE_BLUETOOTH_SCO
340 };
341 final private static int [] wiredTypes = {
342 AudioDeviceInfo.TYPE_WIRED_HEADSET,
343 AudioDeviceInfo.TYPE_WIRED_HEADPHONES
344 };
345
346 private static boolean containsAnyOfType(AudioDeviceInfo[] devices, int[]... types) {
347
348 return Arrays.stream(devices)
349 .anyMatch(device -> Arrays.stream(types)
350 .flatMapToInt(Arrays::stream)
351 .anyMatch(type -> device.getType() == type));
352 }
353
354 private static int getCorrectModeIfContainsAnyOfType(AudioDeviceInfo[] devices, int[]... types) {
355 return containsAnyOfType(devices, types) ?
356 AudioManager.MODE_IN_COMMUNICATION : AudioManager.MODE_NORMAL;
357 }
358
359 private static int getModeForWired(AudioDeviceInfo[] audioDevices)
360 {
361 return getCorrectModeIfContainsAnyOfType(audioDevices, bluetoothTypes);
362 }
363
364 private static int getModeForBluetooth(AudioDeviceInfo[] audioDevices)
365 {
366 return getCorrectModeIfContainsAnyOfType(audioDevices, wiredTypes);
367 }
368
369 private static int getModeForSpeaker(AudioDeviceInfo[] audioDevices)
370 {
371 return getCorrectModeIfContainsAnyOfType(audioDevices, bluetoothTypes, wiredTypes);
372 }
373
374 private static boolean prepareAudioOutput(int id)
375 {
376 final AudioDeviceInfo[] audioDevices =
377 m_audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
378 for (AudioDeviceInfo deviceInfo : audioDevices) {
379 if (deviceInfo.getId() == id) {
380 switch (deviceInfo.getType())
381 {
382 case AudioDeviceInfo.TYPE_BLUETOOTH_A2DP:
383 case AudioDeviceInfo.TYPE_BLUETOOTH_SCO:
384 return prepareAudioDevice(deviceInfo, getModeForBluetooth(audioDevices));
385 case AudioDeviceInfo.TYPE_BUILTIN_SPEAKER:
386 return prepareAudioDevice(deviceInfo, getModeForSpeaker(audioDevices));
387 case AudioDeviceInfo.TYPE_WIRED_HEADSET:
388 case AudioDeviceInfo.TYPE_WIRED_HEADPHONES:
389 return prepareAudioDevice(deviceInfo, getModeForWired(audioDevices));
390 case AudioDeviceInfo.TYPE_BUILTIN_EARPIECE:
391 // It doesn't work when WIRED HEADPHONES are connected
392 // Earpiece has the lowest priority and setWiredHeadsetOn(boolean)
393 // method to force it is deprecated
394 Log.w(TAG, "Built in Earpiece may not work when "
395 + "Wired Headphones are connected");
396 return prepareAudioDevice(deviceInfo, AudioManager.MODE_IN_CALL);
397 case AudioDeviceInfo.TYPE_HDMI:
398 case AudioDeviceInfo.TYPE_HDMI_ARC:
399 case AudioDeviceInfo.TYPE_HDMI_EARC:
400 return prepareAudioDevice(deviceInfo, AudioManager.MODE_NORMAL);
401 default:
402 return false;
403 }
404 }
405 }
406 return false;
407 }
408
413 private static AudioDeviceInfo getValidCommunicationDevice(AudioDeviceInfo device) {
414 if (device.isSink())
415 return device;
416
417 if (isBluetoothDevice(device)) {
418 // For Bluetooth sources, get output device with the same type and address
419 List<AudioDeviceInfo> communicationDevices = m_audioManager.getAvailableCommunicationDevices();
420 for (AudioDeviceInfo communicationDevice : communicationDevices) {
421 boolean isSameType = communicationDevice.getType() == device.getType();
422 boolean isSameAddress = communicationDevice.getAddress().equals(device.getAddress());
423 if (isSameType && isSameAddress)
424 return communicationDevice;
425 }
426
427 Log.w(TAG, "No matching bluetooth output device found for " + device);
428 }
429
430 return null;
431 }
432
433 private static boolean deviceIsCurrentCommunicationDevice(AudioDeviceInfo device) {
434 if (m_currentCommunicationDeviceId == -1 || device == null) {
435 return false;
436 }
437
438 return m_currentCommunicationDeviceId == device.getId();
439 }
440
441 @UsedFromNativeCode
442 static void releaseAudioDevice(int id) {
443 final AudioDeviceInfo[] devices = m_audioManager.getDevices(AudioManager.GET_DEVICES_ALL);
445 if (device.getId() == id)
446 releaseAudioDevice(device);
447 }
448 }
449
453 private static void releaseAudioDevice(AudioDeviceInfo deviceInfo) {
454 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
455 // If device was used as the communication device, it should be cleared
456 AudioDeviceInfo communicationDevice = getValidCommunicationDevice(deviceInfo);
457 if (!deviceIsCurrentCommunicationDevice(communicationDevice))
458 return;
459
460 if (m_communicationDeviceCounter.decrementAndGet() == 0) {
461 m_audioManager.clearCommunicationDevice();
462 m_currentCommunicationDeviceId = -1;
463 }
464 } else if (isBluetoothDevice(deviceInfo) && m_audioManager.isBluetoothScoOn()
465 && m_scoCounter.decrementAndGet() == 0) {
466 m_audioManager.stopBluetoothSco();
467 m_audioManager.setBluetoothScoOn(false);
468 } else if (deviceInfo.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER
469 && m_speakerphoneCounter.decrementAndGet() == 0) {
470 m_audioManager.setSpeakerphoneOn(false);
471 }
472 }
473
474 private static boolean prepareAudioDevice(AudioDeviceInfo deviceInfo, int mode)
475 {
476 if (deviceInfo == null)
477 return false;
478
479 m_audioManager.setMode(mode);
480
481 boolean isSink = deviceInfo.isSink();
482 if (isSink)
483 m_currentOutputId = deviceInfo.getId();
484
485 boolean isBluetoothDevice = isBluetoothDevice(deviceInfo);
486 boolean isBluetoothSource = isBluetoothDevice && !isSink;
487 boolean isCommunicationMode = (mode == AudioManager.MODE_IN_CALL
488 || mode == AudioManager.MODE_IN_COMMUNICATION);
489
490 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
491 if (!isBluetoothSource && !isCommunicationMode)
492 return true;
493
494 // For communication modes and Bluetooth sources, it's required to set a communication device
495 AudioDeviceInfo communicationDevice = getValidCommunicationDevice(deviceInfo);
496 if (communicationDevice == null) {
497 Log.w(TAG, "No suitable communication device to set to enable communication via "
498 + deviceInfo.getId());
499 return false;
500 }
501
502 if (deviceIsCurrentCommunicationDevice(communicationDevice)) {
503 m_communicationDeviceCounter.incrementAndGet();
504 return true;
505 } else if (m_audioManager.setCommunicationDevice(communicationDevice)) {
506 // NOTE: Keep track of communication devices we set, as it takes time for it to be
507 // fully operational.
508 // TODO: Other applications can set a different communication device, in which case
509 // we should probably register a listener and clear our tracking when the
510 // communication device unexpectedly changes
511 m_currentCommunicationDeviceId = communicationDevice.getId();
512 m_communicationDeviceCounter.set(1);
513 return true;
514 }
515
516 return false;
517 }
518
519 boolean isSpeakerphoneDevice = deviceInfo.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER;
520
521 if (isBluetoothSource && m_scoCounter.getAndIncrement() == 0) {
522 m_audioManager.startBluetoothSco();
523 m_audioManager.setBluetoothScoOn(true);
524 } else if (isSpeakerphoneDevice
525 && m_speakerphoneCounter.getAndIncrement() == 0) {
526 // TODO: Check if setting speakerphone is actually required for anything, it's not
527 // recommended in Android docs.
528 m_audioManager.setSpeakerphoneOn(true);
529 }
530
531 return true;
532 }
533
534 private static void streamSound()
535 {
536 byte data[] = new byte[m_bufferSize];
537 while (m_isStreaming) {
538 m_recorder.read(data, 0, m_bufferSize);
539 m_streamPlayer.play();
540 m_streamPlayer.write(data, 0, m_bufferSize);
541 m_streamPlayer.stop();
542 }
543 }
544
545 private static void startSoundStreaming(int inputId, int outputId)
546 {
547 if (m_isStreaming)
548 stopSoundStreaming();
549
550 m_recorder = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, m_sampleRate, m_channels,
551 m_audioFormat, m_bufferSize);
552 m_streamPlayer = new AudioTrack(AudioManager.STREAM_MUSIC, m_sampleRate, m_channels,
553 m_audioFormat, m_bufferSize, AudioTrack.MODE_STREAM);
554
555 final AudioDeviceInfo[] devices = m_audioManager.getDevices(AudioManager.GET_DEVICES_ALL);
556 for (AudioDeviceInfo deviceInfo : devices) {
557 if (deviceInfo.getId() == outputId) {
558 m_streamPlayer.setPreferredDevice(deviceInfo);
559 } else if (deviceInfo.getId() == inputId) {
560 m_recorder.setPreferredDevice(deviceInfo);
561 }
562 }
563
564 m_recorder.startRecording();
565 m_isStreaming = true;
566
567 m_streamingThread = new Thread(new Runnable() {
568 @Override
569 public void run() {
570 streamSound();
571 }
572 });
573
574 m_streamingThread.start();
575 }
576
577 private static void stopSoundStreaming()
578 {
579 if (!m_isStreaming)
580 return;
581
582 m_isStreaming = false;
583 try {
584 m_streamingThread.join();
585 m_streamingThread = null;
586 } catch (InterruptedException e) {
587 e.printStackTrace();
588 }
589 m_recorder.stop();
590 m_recorder.release();
591 m_streamPlayer.release();
592 m_streamPlayer = null;
593 m_recorder = null;
594 }
595}
void AudioDeviceInfo()
[Audio callback capture setup peak meter]
Definition audio.cpp:278
IOBluetoothDevice * device
QPainter Context
static const QString context()
Definition java.cpp:396
QTCONCURRENT_RUN_NODISCARD auto run(QThreadPool *pool, Function &&f, Args &&...args)
#define assert
EGLDeviceEXT * devices
GLenum mode
GLsizei GLenum GLenum * types
GLenum type
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
[0]
@ Handler
static int compare(quint64 a, quint64 b)
static QInputDevice::DeviceType deviceType(const UINT cursorType)
manager put(request, myData, this, [this](QRestReply &reply) { if(reply.isSuccess()) })
[5]