Bug fix TIVI-839 ,change the design and permit operation of the music player while...
[profile/ivi/ico-uxf-homescreen.git] / include / ico_apf_resource_control.h
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9 /**
10  * @brief   header file of Apprication Framework (Resource Control)
11  *
12  * @date    Feb-28-2013
13  */
14
15 #include    "ico_uxf_sysdef.h"
16
17 #ifndef __ICO_APF_RESOURCE_CONTROL_H__
18 #define __ICO_APF_RESOURCE_CONTROL_H__
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 /*
25  *  id of resource
26  */
27 typedef enum _resid {
28     ICO_APF_RESID_BASIC_SCREEN  = 1, /* basic screen */
29     ICO_APF_RESID_INT_SCREEN    = 2, /* interrupt screen */
30     ICO_APF_RESID_ON_SCREEN     = 3, /* onscreeen */
31     ICO_APF_RESID_BASIC_SOUND   = 4, /* basic sound */
32     ICO_APF_RESID_INT_SOUND     = 5, /* interrupt sound */
33     ICO_APF_RESID_INPUT_DEV     = 6, /* input device */
34 } ico_apf_resid_e;
35 #define ICO_APF_RESOURCE_RESID_MIN      ((int)(ICO_APF_RESID_BASIC_SCREEN))
36 #define ICO_APF_RESOURCE_RESID_MAX      ((int)(ICO_APF_RESID_INPUT_DEV))
37
38 /*
39  *  state of resource
40  */
41 typedef enum _resource_state {
42     ICO_APF_RESOURCE_STATE_ACQUIRED     = 1,    /* acquired         */
43     ICO_APF_RESOURCE_STATE_DEPRIVED     = 2,    /* deprived         */
44     ICO_APF_RESOURCE_STATE_WAITTING     = 3,    /* waitting         */
45     ICO_APF_RESOURCE_STATE_RELEASED     = 4,    /* released         */
46
47     ICO_APF_RESOURCE_COMMAND_GET        = 5,    /* get command      */
48     ICO_APF_RESOURCE_COMMAND_RELEASE    = 6,    /* release command  */
49     ICO_APF_RESOURCE_COMMAND_ADD        = 7,    /* add command      */
50     ICO_APF_RESOURCE_COMMAND_CHANGE     = 8,    /* change command   */
51     ICO_APF_RESOURCE_COMMAND_DELETE     = 9,    /* delete command   */
52
53     ICO_APF_RESOURCE_REPLY_OK           = 10,   /* OK reply         */
54     ICO_APF_RESOURCE_REPLY_NG           = 11,   /* NG reply         */
55     ICO_APF_RESOURCE_STATE_CONNECTED    = 12,   /* connected        */
56     ICO_APF_RESOURCE_STATE_DISCONNECTED = 13,   /* disconnected     */
57 } ico_apf_resource_state_e;
58 #define ICO_APF_RESOURCE_COMMAND_MIN    ((int)(ICO_APF_RESOURCE_STATE_ACQUIRED))
59 #define ICO_APF_RESOURCE_COMMAND_MAX    ((int)(ICO_APF_RESOURCE_STATE_DISCONNECTED))
60
61 /*
62  *  sound control
63  */
64 typedef enum _sound_resource {
65     ICO_APF_SOUND_COMMAND_MUTEON        = 21,   /* mute on          */
66     ICO_APF_SOUND_COMMAND_MUTEOFF       = 22,   /* mute off         */
67     ICO_APF_SOUND_COMMAND_CANCEL        = 23,   /* cancel           */
68     ICO_APF_SOUND_COMMAND_GETLIST       = 24,   /* get stream list  */
69     ICO_APF_SOUND_COMMAND_FRESH         = 25,   /* fresh            */
70     ICO_APF_SOUND_COMMAND_ALLMUTEON     = 26,   /* mute on all streams*/
71     ICO_APF_SOUND_COMMAND_ALLMUTEOFF    = 27,   /* mute off all streams*/
72
73     ICO_APF_SOUND_EVENT_NEW             = 28,   /* created new stream*/
74     ICO_APF_SOUND_EVENT_FREE            = 29,   /* destoryed stream */
75
76     ICO_APF_SOUND_REPLY_LIST            = 30    /* reply on stream list*/
77 } ico_apf_sound_state_e;
78 #define ICO_APF_SOUND_COMMAND_MIN       ((int)(ICO_APF_SOUND_COMMAND_MUTEON))
79 #define ICO_APF_SOUND_COMMAND_CMD       ((int)(ICO_APF_SOUND_COMMAND_ALLMUTEOFF))
80 #define ICO_APF_SOUND_COMMAND_MAX       ((int)(ICO_APF_SOUND_REPLY_LIST))
81
82 /*
83  *  notify callback information
84  */
85 typedef struct _resmgr_notify_info {
86     ico_apf_resid_e resid;
87     int             id;
88     int             bid;
89     int             pid;
90     char            appid[ICO_UXF_MAX_PROCESS_NAME+1];
91     ico_apf_resource_state_e state;
92     char            device[ICO_UXF_MAX_DEVICE_NAME+1];
93 } ico_apf_resource_notify_info_t;
94
95 typedef void (*ico_apf_resource_notify_cb_t)(ico_apf_resource_notify_info_t* info,
96                                              void *user_data);
97
98 /*--------------------------------------------------------------------------*/
99 /**
100  *  @brief  Initialize resouce manager component for client Application
101  *
102  *  @param[in]  uri         server URI
103  *  @return result status
104  *  @retval ICO_APF_RESOURCE_E_NONE                 success
105  *  @retval ICO_APF_RESOURCE_E_INIT_COM_FAILD       can not create connection
106  *  @retval ICO_APF_RESOURCE_E_INIT_COMMUNICATION   initialize communication error
107  */
108 /*--------------------------------------------------------------------------*/
109 int ico_apf_resource_init_client(const char *uri);
110
111 /*--------------------------------------------------------------------------*/
112 /**
113  *  @brief  Terminame resouce manager component
114  *
115  *  @param      none
116  *  @return     none
117  */
118 /*--------------------------------------------------------------------------*/
119 void ico_apf_resource_term_client(void);
120
121 /*--------------------------------------------------------------------------*/
122 /**
123  *  @brief  Initialize resouce manager component for sever(AppsController)
124  *
125  *  @param[in]  uri         my URI
126  *  @return result status
127  *  @retval ICO_APF_RESOURCE_E_NONE                 success
128  *  @retval ICO_APF_RESOURCE_E_INIT_COM_FAILD       can not create connection
129  *  @retval ICO_APF_RESOURCE_E_INIT_COMMUNICATION   initialize communication error
130  *  @retval ICO_APF_RESOURCE_E_INVALID_PARAMETER    appid is null
131  */
132 /*--------------------------------------------------------------------------*/
133 int ico_apf_resource_init_server(const char *uri);
134
135 /*--------------------------------------------------------------------------*/
136 /**
137  *  @brief  Terminame resouce manager component for server(AppsController)
138  *
139  *  @param      none
140  *  @return     none
141  */
142 /*--------------------------------------------------------------------------*/
143 void ico_apf_resource_term_server(void);
144
145 /*--------------------------------------------------------------------------*/
146 /**
147  *  @brief  Set event callback function
148  *
149  *  @param[in]  callbacks   callback functions
150  *  @param[in]  user_data   passed data on called callback function
151  *  @return     result status
152  *  @retval     ICO_APF_RESOURCE_E_NONE     success
153  *  @retval     ICO_APF_RESOURCE_E_INVAL    callbacks is null
154  */
155 /*--------------------------------------------------------------------------*/
156 int ico_apf_resource_set_event_cb(ico_apf_resource_notify_cb_t callbacks,
157                                   void *user_data);
158
159 /*--------------------------------------------------------------------------*/
160 /**
161  *  @brief  Unset event callback function
162  *
163  *  @param      none
164  *  @return     result status
165  *  @retval     ICO_APF_RESOURCE_E_NONE     success(At present, always give back this)
166  */
167 /*--------------------------------------------------------------------------*/
168 int ico_apf_resource_unset_event_cb(void);
169
170 /*--------------------------------------------------------------------------*/
171 /**
172  *  @brief  Get the rights of basic screen
173  *
174  *  @param[in]  disp_dev    display device uri
175  *  @param[in]  src_id      id of basic screen
176  *  @return     result status
177  *  @retval     ICO_APF_RESOURCE_E_NONE               success
178  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
179  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
180  */
181 /*--------------------------------------------------------------------------*/
182 int ico_apf_resource_get_screen_mode(const char* disp_dev, int scr_id);
183
184 /*--------------------------------------------------------------------------*/
185 /**
186  *  @brief  Release the rights of basic screen
187  *
188  *  @param[in]  disp_dev    display device uri
189  *  @param[in]  src_id      id of basic screen
190  *  @return     result status
191  *  @retval     ICO_APF_RESOURCE_E_NONE               success
192  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
193  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
194  */
195 /*--------------------------------------------------------------------------*/
196 int ico_apf_resource_release_screen_mode(const char* disp_dev, int scr_id);
197
198 /*--------------------------------------------------------------------------*/
199 /**
200  *  @brief  Reply the basic screen status change event
201  *
202  *  @param[in]  disp_dev    display device uri
203  *  @param[in]  src_id      id of basic screen
204  *  @param[in]  ok          OK(1) or NG(0)
205  *  @return     result status
206  *  @retval     ICO_APF_RESOURCE_E_NONE               success
207  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
208  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
209  */
210 /*--------------------------------------------------------------------------*/
211 int ico_apf_resource_reply_screen_mode(const char* disp_dev, int scr_id, const int ok);
212
213 /*--------------------------------------------------------------------------*/
214 /**
215  *  @brief  Release the rights of interrupt screen
216  *
217  *  @param[in]  disp_dev    display device uri
218  *  @param[in]  src_id      id of basic screen
219  *  @param[in]  int_src_id  id of interrupt screen
220  *  @return     result status
221  *  @retval     ICO_APF_RESOURCE_E_NONE               success
222  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
223  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
224  */
225 /*--------------------------------------------------------------------------*/
226 int ico_apf_resource_get_int_screen_mode(const char* disp_dev,
227                                          int scr_id, int int_scr_id);
228
229 /*--------------------------------------------------------------------------*/
230 /**
231  *  @brief  Release the rights of interrupt screen on basic screen
232  *
233  *  @param[in]  disp_dev    display device uri
234  *  @param[in]  src_id      id of basic screen
235  *  @param[in]  int_scr_id  id of interrupt screen
236  *  @return     result status
237  *  @retval     ICO_APF_RESOURCE_E_NONE               success
238  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
239  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
240  */
241 /*--------------------------------------------------------------------------*/
242 int ico_apf_resource_release_int_screen_mode(const char* disp_dev,
243                                              int scr_id, int int_scr_id);
244
245 /*--------------------------------------------------------------------------*/
246 /**
247  *  @brief  Reply the rights of interrupt screen on basic screen
248  *
249  *  @param[in]  disp_dev    display device uri
250  *  @param[in]  src_id      id of basic screen
251  *  @param[in]  int_src_id  id of interrupt screen
252  *  @param[in]  ok          OK(1) or NG(0)
253  *  @return     result status
254  *  @retval     ICO_APF_RESOURCE_E_NONE               success
255  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
256  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
257  */
258 /*--------------------------------------------------------------------------*/
259 int ico_apf_resource_reply_int_screen_mode(const char* disp_dev,
260                                            int scr_id, int int_scr_id, const int ok);
261
262 /*--------------------------------------------------------------------------*/
263 /**
264  *  @brief  Get the rights of interrupt screen on display
265  *
266  *  @param[in]  disp_dev    display device uri
267  *  @param[in]  int_scr_id  id of interrupt screen
268  *  @return     result status
269  *  @retval     ICO_APF_RESOURCE_E_NONE               success
270  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
271  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
272  */
273 /*--------------------------------------------------------------------------*/
274 int ico_apf_resource_get_int_screen_mode_disp(const char* disp_dev,
275                                               int int_scr_id);
276
277 /*--------------------------------------------------------------------------*/
278 /**
279  *  @brief  Release the rights of interrupt screen on display
280  *
281  *  @param[in]  disp_dev    display device uri
282  *  @param[in]  int_scr_id  id of interrupt screen
283  *  @return     result status
284  *  @retval     ICO_APF_RESOURCE_E_NONE               success
285  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
286  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
287  */
288 /*--------------------------------------------------------------------------*/
289 int ico_apf_resource_release_int_screen_mode_disp(const char* disp_dev,
290                                                   int int_scr_id);
291
292 /*--------------------------------------------------------------------------*/
293 /**
294  *  @brief  Reply the rights of interrupt screen on display
295  *
296  *  @param[in]  disp_dev    display device uri
297  *  @param[in]  int_scr_id  id of interrupt screen
298  *  @param[in]  ok          OK(1) or NG(0)
299  *  @return     result status
300  *  @retval     ICO_APF_RESOURCE_E_NONE               success
301  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
302  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
303  */
304 /*--------------------------------------------------------------------------*/
305 int ico_apf_resource_reply_int_screen_mode_disp(const char* disp_dev,
306                                                 int int_scr_id, const int ok);
307
308 /*--------------------------------------------------------------------------*/
309 /**
310  *  @brief  Get the rights of basic sound on zone
311  *
312  *  @param[in]  zone        sound device uri
313  *  @param[in]  snd_id      id of basic sound
314  *  @param[in]  adjust      adjust acction
315  *  @return     result status
316  *  @retval     ICO_APF_RESOURCE_E_NONE               success
317  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
318  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
319  */
320 /*--------------------------------------------------------------------------*/
321 int ico_apf_resource_get_sound_mode(const char* zone, int snd_id, int adjust);
322
323 /*--------------------------------------------------------------------------*/
324 /**
325  *  @brief  Release the rights of basic sound on zone
326  *
327  *  @param[in]  zone        sound device uri
328  *  @param[in]  snd_id      id of basic sound
329  *  @return     result status
330  *  @retval     ICO_APF_RESOURCE_E_NONE               success
331  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
332  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
333  */
334 /*--------------------------------------------------------------------------*/
335 int ico_apf_resource_release_sound_mode(const char* zone, int snd_id);
336
337 /*--------------------------------------------------------------------------*/
338 /**
339  *  @brief  Reply the rights of basic sound on zone
340  *
341  *  @param[in]  zone        sound device uri
342  *  @param[in]  snd_id      id of basic sound
343  *  @param[in]  ok          OK(1) or NG(0)
344  *  @return     result status
345  *  @retval     ICO_APF_RESOURCE_E_NONE               success
346  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
347  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
348  */
349 /*--------------------------------------------------------------------------*/
350 int ico_apf_resource_reply_sound_mode(const char* zone, int snd_id, const int ok);
351
352 /*--------------------------------------------------------------------------*/
353 /**
354  *  @brief  Get the rights of interrupt sound on zone
355  *
356  *  @param[in]  zone        sound device uri
357  *  @param[in]  int_snd_id  id of basic sound
358  *  @param[in]  adjust      adjust action
359  *  @return     result status
360  *  @retval     ICO_APF_RESOURCE_E_NONE               success
361  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
362  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
363  */
364 /*--------------------------------------------------------------------------*/
365 int ico_apf_resource_get_int_sound_mode(const char* zone,
366                                         int int_snd_id, int adjust);
367
368 /*--------------------------------------------------------------------------*/
369 /**
370  *  @brief  Release the rights of interrupt sound on zone
371  *
372  *  @param[in]  zone        sound device uri
373  *  @param[in]  int_snd_id  id of interrupt sound
374  *  @return     result status
375  *  @retval     ICO_APF_RESOURCE_E_NONE               success
376  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
377  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
378  */
379 /*--------------------------------------------------------------------------*/
380 int ico_apf_resource_release_int_sound_mode(const char* zone, int int_snd_id);
381
382 /*--------------------------------------------------------------------------*/
383 /**
384  *  @brief  Reply the rights of interrupt sound on zone
385  *
386  *  @param[in]  zone        sound device uri
387  *  @param[in]  int_snd_id  id of interrupt sound
388  *  @param[in]  ok          OK(1) or NG(0)
389  *  @return     result status
390  *  @retval     ICO_APF_RESOURCE_E_NONE               success
391  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
392  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
393  */
394 /*--------------------------------------------------------------------------*/
395 int ico_apf_resource_reply_int_sound_mode(const char* zone,
396                                           int int_snd_id, const int ok);
397
398 /*--------------------------------------------------------------------------*/
399 /**
400  *  @brief  Add the input event notification from input device
401  *
402  *  @param[in]  input_dev   input device uri
403  *  @param[in]  events      notify input events
404  *  @return     result status
405  *  @retval     ICO_APF_RESOURCE_E_NONE               success
406  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
407  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
408  */
409 /*--------------------------------------------------------------------------*/
410 int ico_apf_resource_add_input_event(const char* input_dev, int events);
411
412 /*--------------------------------------------------------------------------*/
413 /**
414  *  @brief  Change the input event notification from input device
415  *
416  *  @param[in]  input_dev   input device uri
417  *  @param[in]  events      notify input events
418  *  @return     result status
419  *  @retval     ICO_APF_RESOURCE_E_NONE               success
420  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
421  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
422  */
423 /*--------------------------------------------------------------------------*/
424 int ico_apf_resource_change_input_event(const char* input_dev, int events);
425
426 /*--------------------------------------------------------------------------*/
427 /**
428  *  @brief  Delete the input event notification from input device
429  *
430  *  @param[in]  input_dev   input device uri
431  *  @param[in]  events      notify input events
432  *  @return     result status
433  *  @retval     ICO_APF_RESOURCE_E_NONE               success
434  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED    not initialized
435  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION      communication error
436  */
437 /*--------------------------------------------------------------------------*/
438 int ico_apf_resource_delete_input_event(const char* input_dev, int events);
439
440 /*--------------------------------------------------------------------------*/
441 /**
442  *  @brief  Send responce form server(AppsController) to client application
443  *
444  *  @param[in]  appid       client application id
445  *  @param[in]  event       event
446  *  @param[in]  resource    target resource
447  *  @param[in]  device      display device / sound zone
448  *  @param[in]  id          application defined object id
449  *  @return     result status
450  *  @retval     ICO_APF_RESOURCE_E_NONE             success
451  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED  not initialized
452  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION    communication error
453  *  @retval     ICO_APF_RESOURCE_E_INVAL            illegal appid or event code
454  */
455 /*--------------------------------------------------------------------------*/
456 int ico_apf_resource_send_to_client(const char *appid, const int event,
457                                     const int resource, const char *device, const int id);
458
459 /*--------------------------------------------------------------------------*/
460 /**
461  *  @brief  Send request to Multi Input Manager
462  *
463  *  @param[in]  cmd         send command
464  *  @param[in]  pid         target pid
465  *  @return     result status
466  *  @retval     ICO_APF_RESOURCE_E_NONE             success
467  *  @retval     ICO_APF_RESOURCE_E_NOT_INITIALIZED  not initialized
468  *  @retval     ICO_APF_RESOURCE_E_COMMUNICATION    communication error
469  */
470 /*--------------------------------------------------------------------------*/
471 int ico_apf_resource_send_to_soundctl(const ico_apf_sound_state_e cmd, const int pid);
472
473 /*--------------------------------------------------------------------------*/
474 /**
475  *  @brief  Get aplication Id
476  *
477  *  @param[in]  pid         process id (if 0, current process id)
478  *  @param[out] appid       client application id
479  *  @return     result status
480  *  @retval     ICO_APP_CTL_E_NONE              success
481  *  @retval     ICO_APP_CTL_E_INVALID_PARAM     error(pid dose not exist)
482  */
483 /*--------------------------------------------------------------------------*/
484 /* Applicaton Manager                           */
485 int ico_apf_get_app_id(const int pid, char *appid);
486
487 #ifdef __cplusplus
488 }
489 #endif
490
491 #endif  /*__ICO_APF_RESOURCE_CONTROL_H__*/