~aleteoryx/muditaos

muditaos/module-audio/Audio/test/TestEndpoint.hpp -rw-r--r-- 1.4 KiB
a405cad6Aleteoryx trim readme 8 days 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
44
45
46
47
48
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#pragma once

#include <Audio/Endpoint.hpp>
#include <Audio/AudioFormat.hpp>

#include <vector>

namespace audio::test
{
    constexpr inline auto testTraits = ::audio::Endpoint::Traits{};

    class TestSink : public audio::Sink
    {
      public:
        explicit TestSink(std::vector<AudioFormat> supportedFormats);

        void onDataSend() override;
        void enableOutput() override;
        void disableOutput() override;
        auto getSupportedFormats() -> std::vector<AudioFormat> override;
        auto getTraits() const -> ::audio::Endpoint::Traits override;

      private:
        std::vector<AudioFormat> formats;
    };

    class TestSource : public audio::Source
    {
      public:
        explicit TestSource(AudioFormat audioFormat);
        explicit TestSource(std::vector<AudioFormat> supportedFormats, AudioFormat sourceFormat);

        auto getSourceFormat() -> AudioFormat override;
        void onDataReceive() override;
        void enableInput() override;
        void disableInput() override;
        auto getSupportedFormats() -> std::vector<AudioFormat> override;
        auto getTraits() const -> ::audio::Endpoint::Traits override;

      private:
        std::vector<AudioFormat> formats;
        AudioFormat sourceFormat;
    };

} // namespace audio::test