From ef3f840a4dfa76f16dd009c536782a8b28fec6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Smoczy=C5=84ski?= Date: Thu, 29 Apr 2021 11:53:51 +0200 Subject: [PATCH] [EGD-6049] Add voice call over HSP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for voice calls over HSP. Signed-off-by: Marcin SmoczyƄski --- module-audio/Audio/AudioDevice.hpp | 3 +- .../Profiles/ProfilePlaybackBluetoothA2DP.hpp | 2 +- .../Profiles/ProfileRecordingBluetoothHSP.hpp | 2 +- .../Profiles/ProfileRoutingBluetoothHSP.hpp | 2 +- .../Audio/transcode/InputTranscodeProxy.cpp | 5 + .../Audio/transcode/InputTranscodeProxy.hpp | 1 + .../board/rt1051/RT1051DeviceFactory.cpp | 8 +- .../Bluetooth/audio/BluetoothAudioDevice.cpp | 179 ++++++++++++++++-- .../Bluetooth/audio/BluetoothAudioDevice.hpp | 84 ++++++-- .../interface/profiles/A2DP/A2DP.cpp | 2 +- .../interface/profiles/A2DP/A2DPImpl.hpp | 1 - .../interface/profiles/AudioProfile.hpp | 15 ++ .../Bluetooth/interface/profiles/HSP/HSP.cpp | 20 +- .../Bluetooth/interface/profiles/HSP/HSP.hpp | 3 +- .../interface/profiles/HSP/HSPImpl.hpp | 4 +- .../Bluetooth/interface/profiles/HSP/SCO.cpp | 1 - .../Bluetooth/interface/profiles/HSP/SCO.hpp | 4 +- .../interface/profiles/ProfileManager.cpp | 10 +- .../interface/profiles/ProfileManager.hpp | 9 +- .../service-audio/ServiceAudio.cpp | 44 +++-- .../service-audio/ServiceAudio.hpp | 3 +- 21 files changed, 327 insertions(+), 75 deletions(-) create mode 100644 module-bluetooth/Bluetooth/interface/profiles/AudioProfile.hpp diff --git a/module-audio/Audio/AudioDevice.hpp b/module-audio/Audio/AudioDevice.hpp index f27d38b5414ce423bc0bffd8ffc1b18ad747b90f..3dd991753a51249b1e9d5c130a94270fad3ec1da 100644 --- a/module-audio/Audio/AudioDevice.hpp +++ b/module-audio/Audio/AudioDevice.hpp @@ -27,7 +27,8 @@ namespace audio None, Audiocodec, Cellular, - Bluetooth + BluetoothA2DP, + BluetoothHSP }; virtual ~AudioDevice() = default; diff --git a/module-audio/Audio/Profiles/ProfilePlaybackBluetoothA2DP.hpp b/module-audio/Audio/Profiles/ProfilePlaybackBluetoothA2DP.hpp index 9b5e01700082f74897e0ebf336026c2883ac32b9..546199c3d562bddbdb9d5aa661542a39fa87df60 100644 --- a/module-audio/Audio/Profiles/ProfilePlaybackBluetoothA2DP.hpp +++ b/module-audio/Audio/Profiles/ProfilePlaybackBluetoothA2DP.hpp @@ -21,7 +21,7 @@ namespace audio .inputGain = 0, .inputPath = audio::codec::InputPath::None, .outputPath = audio::codec::OutputPath::None}, - AudioDevice::Type::Bluetooth) + AudioDevice::Type::BluetoothA2DP) {} }; diff --git a/module-audio/Audio/Profiles/ProfileRecordingBluetoothHSP.hpp b/module-audio/Audio/Profiles/ProfileRecordingBluetoothHSP.hpp index 7850fdc9584e58aad22aeb5ab4fa31ef46f82f1f..4234ac8ea5c4e8ce864e6124c53e81d11b0365f2 100644 --- a/module-audio/Audio/Profiles/ProfileRecordingBluetoothHSP.hpp +++ b/module-audio/Audio/Profiles/ProfileRecordingBluetoothHSP.hpp @@ -23,7 +23,7 @@ namespace audio .inputGain = static_cast(gain), .inputPath = audio::codec::InputPath::None, .outputPath = audio::codec::OutputPath::None}, - AudioDevice::Type::Bluetooth) + AudioDevice::Type::BluetoothHSP) {} }; diff --git a/module-audio/Audio/Profiles/ProfileRoutingBluetoothHSP.hpp b/module-audio/Audio/Profiles/ProfileRoutingBluetoothHSP.hpp index d48f57aa0c740ff2b04480067abde66d3d159265..f70e847efcbc6ccd7d3dff330f50720c17dad067 100644 --- a/module-audio/Audio/Profiles/ProfileRoutingBluetoothHSP.hpp +++ b/module-audio/Audio/Profiles/ProfileRoutingBluetoothHSP.hpp @@ -23,7 +23,7 @@ namespace audio .inputGain = static_cast(gain), .inputPath = audio::codec::InputPath::None, .outputPath = audio::codec::OutputPath::None}, - AudioDevice::Type::Bluetooth) + AudioDevice::Type::BluetoothHSP) {} }; diff --git a/module-audio/Audio/transcode/InputTranscodeProxy.cpp b/module-audio/Audio/transcode/InputTranscodeProxy.cpp index 36f181c7afcf2f8f2fd83bb70e93d324b6e47fc0..1d88525a88e6cf6c605ada2f0cf12e7cc132fc39 100644 --- a/module-audio/Audio/transcode/InputTranscodeProxy.cpp +++ b/module-audio/Audio/transcode/InputTranscodeProxy.cpp @@ -23,6 +23,11 @@ bool InputTranscodeProxy::push(const Span &span) return getWrappedStream().push(transform->transform(span, transcodingSpaceSpan)); } +bool InputTranscodeProxy::push(void *data, std::size_t dataSize) +{ + return push(Span{.data = reinterpret_cast(data), .dataSize = dataSize}); +} + void InputTranscodeProxy::commit() { if (isReserved) { diff --git a/module-audio/Audio/transcode/InputTranscodeProxy.hpp b/module-audio/Audio/transcode/InputTranscodeProxy.hpp index dfb2d23c41ed02e393db6c4ea3ddbaf9d1132a58..46903418f82a08b097f79fe912a0ac155d8be6c6 100644 --- a/module-audio/Audio/transcode/InputTranscodeProxy.hpp +++ b/module-audio/Audio/transcode/InputTranscodeProxy.hpp @@ -27,6 +27,7 @@ namespace audio::transcode std::shared_ptr transform) noexcept; bool push(const Span &span) override; + bool push(void *data, std::size_t dataSize); void commit() override; bool reserve(Span &span) override; [[nodiscard]] auto getInputTraits() const noexcept -> Traits override; diff --git a/module-audio/board/rt1051/RT1051DeviceFactory.cpp b/module-audio/board/rt1051/RT1051DeviceFactory.cpp index a3b29a0202f9d4502d9e015b4b82fa597e79c1be..b7baa642b38df4f8f822e6982d04a69d0f59a21a 100644 --- a/module-audio/board/rt1051/RT1051DeviceFactory.cpp +++ b/module-audio/board/rt1051/RT1051DeviceFactory.cpp @@ -21,8 +21,12 @@ std::shared_ptr RT1051DeviceFactory::getDevice(const audio::Profile device = std::make_shared(profile.GetAudioConfiguration()); } break; - case AudioDevice::Type::Bluetooth: { - device = std::make_shared(); + case AudioDevice::Type::BluetoothA2DP: { + device = std::make_shared(); + } break; + + case AudioDevice::Type::BluetoothHSP: { + device = std::make_shared(); } break; case AudioDevice::Type::Cellular: { diff --git a/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.cpp b/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.cpp index aca60e2e5df1f97b6d0acaa9212b2dae4ff61e5f..e386a28ec071d0a584cec8bdaa7527ebf0497109 100644 --- a/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.cpp +++ b/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.cpp @@ -3,42 +3,46 @@ #include "BluetoothAudioDevice.hpp" -#include