~aleteoryx/muditaos

ref: fbb820c284d8aad7dcbc343def8aeea9a151d33d muditaos/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.hpp -rw-r--r-- 1.3 KiB
fbb820c2 — Artur Śleszyński [BH-357] Move protobuf to third-party dir 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <Audio/AudioDevice.hpp>
#include <Audio/AudioFormat.hpp>
#include <interface/profiles/A2DP/MediaContext.hpp>

namespace bluetooth
{

    class BluetoothAudioDevice : public audio::AudioDevice
    {
      public:
        BluetoothAudioDevice() = default;
        explicit BluetoothAudioDevice(MediaContext *mediaContext);
        virtual ~BluetoothAudioDevice();

        RetCode setOutputVolume(float vol) override;
        RetCode setInputGain(float gain) override;
        void setMediaContext(MediaContext *MediaContext);
        auto getTraits() const -> Traits override;
        auto getSupportedFormats() -> std::vector<audio::AudioFormat> override;
        auto getSourceFormat() -> audio::AudioFormat override;

        // Endpoint control methods
        void onDataSend() override;
        void onDataReceive() override;
        void enableInput() override;
        void enableOutput() override;
        void disableInput() override;
        void disableOutput() override;

      private:
        auto fillSbcAudioBuffer(MediaContext *context) -> int;

        MediaContext *ctx  = nullptr;
        bool outputEnabled = false;
        float outputVolume = 0.0;
    };

} // namespace bluetooth