NUGU SDK Linux  1.7.6
playsync_manager_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_PLAYSYNC_MANAGER_INTERFACE_H__
18 #define __NUGU_PLAYSYNC_MANAGER_INTERFACE_H__
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 
24 #include <base/nugu_directive.h>
25 #include <nugu.h>
26 
27 namespace NuguClientKit {
28 
43 enum class PlaySyncState {
44  None,
45  Prepared,
46  Synced,
47  Released,
48  Appending
49 };
50 
54 enum class PlayStackActivity {
55  None,
56  Alert,
57  Call,
58  TTS,
59  Media
60 };
61 
66 class NUGU_API IPlaySyncManagerListener {
67 public:
68  virtual ~IPlaySyncManagerListener() = default;
69 
76  virtual void onSyncState(const std::string& ps_id, PlaySyncState state, void* extra_data);
77 
83  virtual void onDataChanged(const std::string& ps_id, std::pair<void*, void*> extra_datas);
84 
89  virtual void onStackChanged(const std::pair<std::string, std::string>& ps_ids);
90 };
91 
96 class NUGU_API IPlaySyncManager {
97 public:
98  using PlaySyncContainer = std::map<std::string, std::pair<PlaySyncState, void*>>;
99  using PlayStacks = std::map<std::string, PlaySyncContainer>;
100 
101 public:
102  virtual ~IPlaySyncManager() = default;
103 
108  virtual void registerCapabilityForSync(const std::string& capability_name) = 0;
109 
115  virtual void addListener(const std::string& requester, IPlaySyncManagerListener* listener) = 0;
116 
121  virtual void removeListener(const std::string& requester) = 0;
122 
128  virtual void prepareSync(const std::string& ps_id, NuguDirective* ndir) = 0;
129 
136  virtual void startSync(const std::string& ps_id, const std::string& requester, void* extra_data = nullptr) = 0;
137 
143  virtual void cancelSync(const std::string& ps_id, const std::string& requester) = 0;
144 
150  virtual void releaseSync(const std::string& ps_id, const std::string& requester) = 0;
151 
157  virtual void releaseSyncLater(const std::string& ps_id, const std::string& requester) = 0;
158 
164  virtual void releaseSyncImmediately(const std::string& ps_id, const std::string& requester) = 0;
165 
171  virtual void releaseSyncUnconditionally(const std::string& ps_id = "") = 0;
172 
176  virtual void postPoneRelease() = 0;
177 
181  virtual void continueRelease() = 0;
182 
186  virtual void stopHolding() = 0;
187 
191  virtual void resetHolding() = 0;
192 
196  virtual void clearHolding() = 0;
197 
201  virtual void restartHolding() = 0;
202 
206  virtual void clear() = 0;
207 
214  virtual bool isConditionToHandlePrevDialog(NuguDirective* prev_ndir, NuguDirective* cur_ndir) = 0;
215 
222  virtual bool hasActivity(const std::string& ps_id, PlayStackActivity activity) = 0;
223 
228  virtual bool hasNextPlayStack() = 0;
229 
234  virtual std::vector<std::string> getAllPlayStackItems() = 0;
235 
240  virtual void adjustPlayStackHoldTime(unsigned int time) = 0;
241 
246  virtual void setDefaultPlayStackHoldTime(unsigned int time) = 0;
247 
254  virtual void replacePlayStack(const std::string& prev_ps_id, const std::string& new_ps_id, std::pair<std::string, void*> extra_data = {}) = 0;
255 };
256 
261 } // NuguClientKit
262 
263 #endif /* __NUGU_PLAYSYNC_MANAGER_INTERFACE_H__ */
IPlaySyncManagerListener interface.
Definition: playsync_manager_interface.hh:66
virtual void onDataChanged(const std::string &ps_id, std::pair< void *, void * > extra_datas)
Receive callback when the extra data is changed.
virtual void onSyncState(const std::string &ps_id, PlaySyncState state, void *extra_data)
Receive callback when sync state is changed.
virtual void onStackChanged(const std::pair< std::string, std::string > &ps_ids)
Receive callback when the play stack is changed.
IPlaySyncManager interface.
Definition: playsync_manager_interface.hh:96
virtual void cancelSync(const std::string &ps_id, const std::string &requester)=0
Cancel sync specific capability agent which was synced.
virtual void clearHolding()=0
Clear timer for releasing sync.
virtual std::vector< std::string > getAllPlayStackItems()=0
Get all items which are stored in playstack.
virtual void restartHolding()=0
Restart timer for releasing sync.
virtual void setDefaultPlayStackHoldTime(unsigned int time)=0
Set default playstack hold time.
virtual void releaseSync(const std::string &ps_id, const std::string &requester)=0
Release sync all capability agents. (Actually, it release sync after context holding time....
virtual void continueRelease()=0
Continue pending release if exist.
virtual void releaseSyncUnconditionally(const std::string &ps_id="")=0
Release sync all capability agents unconditionally. If it's not specify the play service id,...
virtual void releaseSyncLater(const std::string &ps_id, const std::string &requester)=0
Release sync all capability agents after long time elapsed.
virtual void registerCapabilityForSync(const std::string &capability_name)=0
Register capability agent for sync (default:TTS, AudioPlayer, Display)
virtual bool hasNextPlayStack()=0
Check whether the next playstack to handle exists.
virtual void adjustPlayStackHoldTime(unsigned int time)=0
Adjust playstack hold time.
virtual void replacePlayStack(const std::string &prev_ps_id, const std::string &new_ps_id, std::pair< std::string, void * > extra_data={})=0
Replace current playstack to new one. (It only replace playstack not notifying related callbacks....
virtual void stopHolding()=0
Stop timer for releasing sync.
virtual void removeListener(const std::string &requester)=0
Remove IPlayStackManagerListener.
virtual void prepareSync(const std::string &ps_id, NuguDirective *ndir)=0
Prepare sync capability agents which are included in directive.
virtual bool isConditionToHandlePrevDialog(NuguDirective *prev_ndir, NuguDirective *cur_ndir)=0
Check whether the previous dialog has to be handled or not.
virtual void clear()=0
Clear all playstack info.
virtual void startSync(const std::string &ps_id, const std::string &requester, void *extra_data=nullptr)=0
Start sync specific capability agent which was prepared.
virtual void resetHolding()=0
Reset timer for releasing sync.
virtual void releaseSyncImmediately(const std::string &ps_id, const std::string &requester)=0
Release sync all capability agents immediately.
virtual bool hasActivity(const std::string &ps_id, PlayStackActivity activity)=0
Check whether the specific playstack activity exist.
virtual void postPoneRelease()=0
Postpone already started release if exist.
virtual void addListener(const std::string &requester, IPlaySyncManagerListener *listener)=0
Add IPlaySyncManagerListener.
struct _nugu_directive NuguDirective
Directive object.
Definition: nugu_directive.h:48
PlayStackActivity
PlayStack Activity Type.
Definition: playsync_manager_interface.hh:54
PlaySyncState
PlaySync State.
Definition: playsync_manager_interface.hh:43