NUGU SDK Linux  1.7.5
speaker_interface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 SK Telecom Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __NUGU_SPEAKER_INTERFACE_H__
18 #define __NUGU_SPEAKER_INTERFACE_H__
19 
20 #include <base/nugu_audio.h>
22 
23 namespace NuguCapability {
24 
25 using namespace NuguClientKit;
26 
38 #define NUGU_SPEAKER_NUGU_STRING "NUGU"
39 #define NUGU_SPEAKER_MUSIC_STRING NUGU_AUDIO_ATTRIBUTE_MUSIC_DEFAULT_STRING
40 #define NUGU_SPEAKER_RINGTONE_STRING NUGU_AUDIO_ATTRIBUTE_RINGTONE_DEFAULT_STRING
41 #define NUGU_SPEAKER_CALL_STRING NUGU_AUDIO_ATTRIBUTE_CALL_DEFAULT_STRING
42 #define NUGU_SPEAKER_NOTIFICATION_STRING NUGU_AUDIO_ATTRIBUTE_NOTIFICATION_DEFAULT_STRING
43 #define NUGU_SPEAKER_ALARM_STRING NUGU_AUDIO_ATTRIBUTE_ALARM_DEFAULT_STRING
44 #define NUGU_SPEAKER_VOICE_COMMAND_STRING NUGU_AUDIO_ATTRIBUTE_VOICE_COMMAND_DEFAULT_STRING
45 #define NUGU_SPEAKER_NAVIGATION_STRING NUGU_AUDIO_ATTRIBUTE_NAVIGATION_DEFAULT_STRING
46 #define NUGU_SPEAKER_SYSTEM_SOUND_STRING NUGU_AUDIO_ATTRIBUTE_SYSTEM_SOUND_DEFAULT_STRING
47 
48 #define NUGU_SPEAKER_MIN_VOLUME 0
49 #define NUGU_SPEAKER_MAX_VOLUME 100
50 #define NUGU_SPEAKER_DEFAULT_VOLUME 50
51 #define NUGU_SPEAKER_DEFAULT_STEP 10
52 #define NUGU_SPEAKER_UNABLE_CONTROL -1
57 enum class SpeakerType {
58  NUGU = 0,
68 };
69 
73 class SpeakerInfo {
74 public:
75  SpeakerInfo() = default;
76  ~SpeakerInfo() = default;
77 
79  std::string group;
80  int min = NUGU_SPEAKER_MIN_VOLUME;
81  int max = NUGU_SPEAKER_MAX_VOLUME;
82  int volume = NUGU_SPEAKER_DEFAULT_VOLUME;
83  int step = NUGU_SPEAKER_DEFAULT_STEP;
84  int level = NUGU_SPEAKER_DEFAULT_VOLUME;
85  int mute = NUGU_SPEAKER_UNABLE_CONTROL;
86  bool can_control = false;
87 };
88 
93 class ISpeakerListener : virtual public ICapabilityListener {
94 public:
95  virtual ~ISpeakerListener() = default;
96 
105  virtual void requestSetVolume(const std::string& ps_id, SpeakerType type, int volume, bool linear) = 0;
106 
114  virtual void requestSetMute(const std::string& ps_id, SpeakerType type, bool mute) = 0;
115 };
116 
121 class ISpeakerHandler : virtual public ICapabilityInterface {
122 public:
123  virtual ~ISpeakerHandler() = default;
124 
129  virtual void setSpeakerInfo(const std::map<SpeakerType, SpeakerInfo>& info) = 0;
135  virtual void informVolumeChanged(SpeakerType type, int volume) = 0;
141  virtual void informMuteChanged(SpeakerType type, bool mute) = 0;
147  virtual void sendEventVolumeChanged(const std::string& ps_id, bool result) = 0;
148 
154  virtual void sendEventMuteChanged(const std::string& ps_id, bool result) = 0;
155 
161  virtual std::string getSpeakerName(const SpeakerType& type) = 0;
162 
169  virtual bool getSpeakerType(const std::string& name, SpeakerType& type) = 0;
170 };
171 
176 } // NuguInterface
177 
178 #endif /* __NUGU_SPEAKER_INTERFACE_H__ */
speaker handler interface
Definition: speaker_interface.hh:121
virtual void sendEventMuteChanged(const std::string &ps_id, bool result)=0
Send event the result of request SetMute to the SDK.
virtual void informVolumeChanged(SpeakerType type, int volume)=0
Inform volume changed by application to the SDK.
virtual void sendEventVolumeChanged(const std::string &ps_id, bool result)=0
Send event the result of request SetVolume to the SDK.
virtual std::string getSpeakerName(const SpeakerType &type)=0
Get speaker's name.
virtual bool getSpeakerType(const std::string &name, SpeakerType &type)=0
Get speaker's type according speaker's name.
virtual void setSpeakerInfo(const std::map< SpeakerType, SpeakerInfo > &info)=0
Set speaker information in SDK to be controlled by application.
virtual void informMuteChanged(SpeakerType type, bool mute)=0
Inform mute changed by application to the SDK.
speaker listener interface
Definition: speaker_interface.hh:93
virtual void requestSetVolume(const std::string &ps_id, SpeakerType type, int volume, bool linear)=0
The SDK requests the volume setting received from the server.
virtual void requestSetMute(const std::string &ps_id, SpeakerType type, bool mute)=0
The SDK requests the mute setting received from the server.
SpeakerInfo.
Definition: speaker_interface.hh:73
int volume
Definition: speaker_interface.hh:82
int min
Definition: speaker_interface.hh:80
int step
Definition: speaker_interface.hh:83
int level
Definition: speaker_interface.hh:84
int max
Definition: speaker_interface.hh:81
int mute
Definition: speaker_interface.hh:85
bool can_control
Definition: speaker_interface.hh:86
SpeakerType type
Definition: speaker_interface.hh:78
std::string group
Definition: speaker_interface.hh:79
capability interface
Definition: capability_interface.hh:81
capability listener interface
Definition: capability_interface.hh:59
SpeakerType
SpeakerType.
Definition: speaker_interface.hh:57
@ NUGU_AUDIO_ATTRIBUTE_NAVIGATION
Definition: nugu_audio.h:82
@ NUGU_AUDIO_ATTRIBUTE_MUSIC
Definition: nugu_audio.h:74
@ NUGU_AUDIO_ATTRIBUTE_NOTIFICATION
Definition: nugu_audio.h:77
@ NUGU_AUDIO_ATTRIBUTE_CALL
Definition: nugu_audio.h:76
@ NUGU_AUDIO_ATTRIBUTE_RINGTONE
Definition: nugu_audio.h:75
@ NUGU_AUDIO_ATTRIBUTE_ALARM
Definition: nugu_audio.h:79
@ NUGU_AUDIO_ATTRIBUTE_SYSTEM_SOUND
Definition: nugu_audio.h:83
@ NUGU_AUDIO_ATTRIBUTE_VOICE_COMMAND
Definition: nugu_audio.h:80