NUGU SDK Linux  1.7.6
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 #include <nugu.h>
23 
24 namespace NuguCapability {
25 
26 using namespace NuguClientKit;
27 
39 #define NUGU_SPEAKER_NUGU_STRING "NUGU"
40 #define NUGU_SPEAKER_MUSIC_STRING NUGU_AUDIO_ATTRIBUTE_MUSIC_DEFAULT_STRING
41 #define NUGU_SPEAKER_RINGTONE_STRING NUGU_AUDIO_ATTRIBUTE_RINGTONE_DEFAULT_STRING
42 #define NUGU_SPEAKER_CALL_STRING NUGU_AUDIO_ATTRIBUTE_CALL_DEFAULT_STRING
43 #define NUGU_SPEAKER_NOTIFICATION_STRING NUGU_AUDIO_ATTRIBUTE_NOTIFICATION_DEFAULT_STRING
44 #define NUGU_SPEAKER_ALARM_STRING NUGU_AUDIO_ATTRIBUTE_ALARM_DEFAULT_STRING
45 #define NUGU_SPEAKER_VOICE_COMMAND_STRING NUGU_AUDIO_ATTRIBUTE_VOICE_COMMAND_DEFAULT_STRING
46 #define NUGU_SPEAKER_NAVIGATION_STRING NUGU_AUDIO_ATTRIBUTE_NAVIGATION_DEFAULT_STRING
47 #define NUGU_SPEAKER_SYSTEM_SOUND_STRING NUGU_AUDIO_ATTRIBUTE_SYSTEM_SOUND_DEFAULT_STRING
48 
49 #define NUGU_SPEAKER_MIN_VOLUME 0
50 #define NUGU_SPEAKER_MAX_VOLUME 100
51 #define NUGU_SPEAKER_DEFAULT_VOLUME 50
52 #define NUGU_SPEAKER_DEFAULT_STEP 10
53 #define NUGU_SPEAKER_UNABLE_CONTROL -1
58 enum class SpeakerType {
59  NUGU = 0,
69 };
70 
74 class NUGU_API SpeakerInfo {
75 public:
76  SpeakerInfo() = default;
77  ~SpeakerInfo() = default;
78 
80  std::string group;
81  int min = NUGU_SPEAKER_MIN_VOLUME;
82  int max = NUGU_SPEAKER_MAX_VOLUME;
83  int volume = NUGU_SPEAKER_DEFAULT_VOLUME;
84  int step = NUGU_SPEAKER_DEFAULT_STEP;
85  int level = NUGU_SPEAKER_DEFAULT_VOLUME;
86  int mute = NUGU_SPEAKER_UNABLE_CONTROL;
87  bool can_control = false;
88 };
89 
94 class NUGU_API ISpeakerListener : virtual public ICapabilityListener {
95 public:
96  virtual ~ISpeakerListener() = default;
97 
106  virtual void requestSetVolume(const std::string& ps_id, SpeakerType type, int volume, bool linear) = 0;
107 
115  virtual void requestSetMute(const std::string& ps_id, SpeakerType type, bool mute) = 0;
116 };
117 
122 class NUGU_API ISpeakerHandler : virtual public ICapabilityInterface {
123 public:
124  virtual ~ISpeakerHandler() = default;
125 
130  virtual void setSpeakerInfo(const std::map<SpeakerType, SpeakerInfo>& info) = 0;
136  virtual void informVolumeChanged(SpeakerType type, int volume) = 0;
142  virtual void informMuteChanged(SpeakerType type, bool mute) = 0;
148  virtual void sendEventVolumeChanged(const std::string& ps_id, bool result) = 0;
149 
155  virtual void sendEventMuteChanged(const std::string& ps_id, bool result) = 0;
156 
162  virtual std::string getSpeakerName(const SpeakerType& type) = 0;
163 
170  virtual bool getSpeakerType(const std::string& name, SpeakerType& type) = 0;
171 };
172 
177 } // NuguInterface
178 
179 #endif /* __NUGU_SPEAKER_INTERFACE_H__ */
speaker handler interface
Definition: speaker_interface.hh:122
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:94
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:74
std::string group
Definition: speaker_interface.hh:80
capability interface
Definition: capability_interface.hh:82
capability listener interface
Definition: capability_interface.hh:60
SpeakerType
SpeakerType.
Definition: speaker_interface.hh:58
@ NUGU_AUDIO_ATTRIBUTE_NAVIGATION
Definition: nugu_audio.h:84
@ NUGU_AUDIO_ATTRIBUTE_MUSIC
Definition: nugu_audio.h:76
@ NUGU_AUDIO_ATTRIBUTE_NOTIFICATION
Definition: nugu_audio.h:79
@ NUGU_AUDIO_ATTRIBUTE_CALL
Definition: nugu_audio.h:78
@ NUGU_AUDIO_ATTRIBUTE_RINGTONE
Definition: nugu_audio.h:77
@ NUGU_AUDIO_ATTRIBUTE_ALARM
Definition: nugu_audio.h:81
@ NUGU_AUDIO_ATTRIBUTE_SYSTEM_SOUND
Definition: nugu_audio.h:85
@ NUGU_AUDIO_ATTRIBUTE_VOICE_COMMAND
Definition: nugu_audio.h:82