~aleteoryx/muditaos

ref: 0823d82e5141f44812c54debf07245d0ca746124 muditaos/module-services/service-audio/api/AudioServiceAPI.hpp -rw-r--r-- 6.3 KiB
0823d82e — Radoslaw Wicik [EGD-3743] Update copyrights in fies - add empty line after license 5 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#pragma once

#include "../messages/AudioMessage.hpp"
#include "Audio/decoder/decoder.hpp"

#include <optional>

class Service;

/**
 * Audio service API.
 */
namespace AudioServiceAPI
{
    /**
     * @brief Starts playback operation. Asynchronous call.
     *
     * @param serv Requesting service.
     * @param playbackType Type of playback.
     * @param fileName Name of the file.
     * @return True if request has been sent successfully, false otherwise
     *  Response will come as message AudioStartPlaybackResponse
     */
    bool PlaybackStart(sys::Service *serv, const audio::PlaybackType &playbackType, const std::string &fileName);

    /**
     * @brief Starts recording. Asynchronous call.
     *
     * @param serv Requesting service.
     * @param fileName Path to file where recording is to be saved.
     * @return True if request has been sent successfully, false otherwise
     *  Response will come as message AudioStartRecordingResponse
     */
    bool RecordingStart(sys::Service *serv, const std::string &fileName);
    /**
     * @brief Starts routing. Asynchronous call.
     *
     * @param serv Requesting service.
     * @return True if request has been sent successfully, false otherwise
     *  Response will come as message AudioStartRoutingResponse
     */
    bool RoutingStart(sys::Service *serv);
    /**
     * @brief Stops playback operations by type. Asynchronous call.
     *
     * @param serv Requesting service
     * @param stopVec Playback types to be stopped.
     *  When stop vector is passed it stops current operation only if it's type is contained in the vector.
     *  Otherwise does not have effect.
     * @return True if request has been sent successfully, false otherwise
     *  Response will come as message AudioStopResponse for all stopped inputs
     */
    bool Stop(sys::Service *serv, const std::vector<audio::PlaybackType> &stopVec);
    /**
     * @brief Stops playback operation.
     *
     * @param serv Requesting service
     * @param token Identifier of related operation
     * @return True if request has been sent successfully, false otherwise
     *  Response will come as message AudioStopResponse for all stopped inputs
     */
    bool Stop(sys::Service *serv, const audio::Token &token);
    /**
     * @brief Stops all active playback operation. Stopped operations cannot be resumed. Asynchronous call.
     *
     * @param serv Requesting service
     * @return True if request has been sent successfully, false otherwise
     *  Response will come as message AudioStopResponse for all stopped inputs
     */
    bool StopAll(sys::Service *serv);
    /**
     * @brief Pauses playback operation. Can be resumed by Resume(). Asynchronous call.
     *
     * @param serv Requesting service
     * @param token Identifier of related operation
     * @return True if request has been sent successfully, false otherwise
     *  Response will come as message AudioPauseResponse
     */
    bool Pause(sys::Service *serv, const audio::Token &token);
    /**
     * @brief Resumes paused operation. Asynchronous call.
     *
     * @param serv Requesting service
     * @param token Identifier of related operation
     * @return True if request has been sent successfully, false otherwise
     *  Response will come as message AudioResumeResponse
     */
    bool Resume(sys::Service *serv, const audio::Token &token);
    /**
     * @brief Sends audio event
     * @param serv Requesting service.
     * @param evt Event to be sent.
     * @return True is request has been sent successfully, false otherwise
     *   Response will come as message AudioSendEventResponse
     */
    bool SendEvent(sys::Service *serv, std::shared_ptr<audio::Event> evt);
    /**
     * @brief Sends audio event
     * @param serv Requesting service.
     * @param evt Event to be sent.
     *  @return True is request has been sent successfully, false otherwise
     *   Response will come as message AudioSendEventResponse
     */
    bool SendEvent(sys::Service *serv, audio::EventType evt);
    /**
     * @brief Attempts to parse audio file for metatags.
     *
     * @param serv Requesting service.
     * @param fileName Path to file to be parsed.
     * @return audio::Tags on success, std::nullopt on failure
     */
    std::optional<audio::Tags> GetFileTags(sys::Service *serv, const std::string &fileName);
    /** @brief Gets settings. Current profile is taken by default.
     *
     * @param serv - requesting service.
     * @param setting - setting to be set eg. Gain, volume etc.
     * @param value - requested value.
     * @param profileType - selected profile type.
     * @param playbackType -  type of playback. Not used when profileType is different than playback.
     * @return Standard service-api return code. Success if suitable.
     */
    template <typename T>
    audio::RetCode GetSetting(sys::Service *serv,
                              const audio::Setting &setting,
                              T &value,
                              const audio::PlaybackType &playbackType = audio::PlaybackType::None,
                              const audio::Profile::Type &profileType = audio::Profile::Type::Idle);
    /** @brief Sets settings. Current profile is taken by default.
     *
     * @param serv - requesting service.
     * @param setting - setting to be set eg. Gain, volume etc.
     * @param value - value to be set.
     * @param profileType - selected profile type.
     * @param playbackType -  type of playback. Not used when profileType is different than playback.
     * @return Standard service-api return code. Success if suitable.
     */
    template <typename T>
    audio::RetCode SetSetting(sys::Service *serv,
                              const audio::Setting &setting,
                              const T value,
                              const audio::PlaybackType &playbackType = audio::PlaybackType::None,
                              const audio::Profile::Type &profileType = audio::Profile::Type::Idle);
    /** @brief Key pressed handler.
     *
     * @param serv - requesting service.
     * @param step - step that will be added to current volume.
     * @return True if request has been sent successfully, false otherwise
     *  Response will come as message AudioKeyPressedResponse
     */
    bool KeyPressed(sys::Service *serv, const int step);
}; // namespace AudioServiceAPI