Improve focus auto reacquisition
[platform/core/multimedia/libmm-sound.git] / focus_server / include / mm_sound_mgr_focus.h
1 /*
2  * libmm-sound
3  *
4  * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Sangchul Lee <sc11.lee@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __MM_SOUND_MGR_FOCUS_H__
23 #define __MM_SOUND_MGR_FOCUS_H__
24
25 #include "../include/mm_sound.h"
26 #include "../include/mm_sound_focus.h"
27 #include "../include/mm_sound_stream.h"
28 #include "../include/mm_ipc.h"
29 #include "mm_sound_mgr_focus_ipc.h"
30
31 typedef enum
32 {
33         FOCUS_COMMAND_RELEASE,
34         FOCUS_COMMAND_ACQUIRE,
35 } focus_command_e;
36
37 typedef enum
38 {
39         FOCUS_TYPE_PLAYBACK = 1,
40         FOCUS_TYPE_CAPTURE,
41         FOCUS_TYPE_BOTH,
42 } focus_type_e;
43
44 typedef enum
45 {
46         FOCUS_STATUS_DEACTIVATED,
47         FOCUS_STATUS_ACTIVATED_PLAYBACK,
48         FOCUS_STATUS_ACTIVATED_CAPTURE,
49         FOCUS_STATUS_ACTIVATED_BOTH,
50 } focus_status_e;
51
52 typedef struct {
53         int pid;
54         int handle_id;
55         char stream_type[MAX_STREAM_TYPE_LEN];
56         char option[MM_SOUND_NAME_NUM];
57         focus_type_e request_type;
58         void *callback;
59         void *cbdata;
60         bool reacquisition;
61
62         bool is_for_session;    /* will be removed when the session concept is completely left out*/
63 } _mm_sound_mgr_focus_param_t;
64
65 typedef struct _taken_by_id
66 {
67         int pid;
68         int handle_id;
69         bool by_session;
70 } _focus_taken_by_id_t;
71
72 typedef struct {
73         int pid;
74         int handle_id;
75         int priority;
76         bool is_for_watch;
77         char stream_type[MAX_STREAM_TYPE_LEN];
78         focus_status_e status;
79         _focus_taken_by_id_t taken_by_id[NUM_OF_STREAM_IO_TYPE];
80         void *callback;
81         void *cbdata;
82         bool reacquisition;
83
84         bool is_for_session;    /* will be removed when the session concept is completely left out*/
85
86 #ifdef SUPPORT_CONTAINER
87         container_info_t container;
88 #endif
89 } focus_node_t;
90
91 int MMSoundMgrFocusInit(void);
92 int MMSoundMgrFocusFini(void);
93 int mm_sound_mgr_focus_create_node (const _mm_sound_mgr_focus_param_t *param);
94 int mm_sound_mgr_focus_destroy_node (const _mm_sound_mgr_focus_param_t *param);
95 int mm_sound_mgr_focus_set_reacquisition (const _mm_sound_mgr_focus_param_t *param);
96 int mm_sound_mgr_focus_request_acquire (const _mm_sound_mgr_focus_param_t *param);
97 int mm_sound_mgr_focus_request_release (const _mm_sound_mgr_focus_param_t *param);
98 int mm_sound_mgr_focus_set_watch_cb (const _mm_sound_mgr_focus_param_t *param);
99 int mm_sound_mgr_focus_unset_watch_cb (const _mm_sound_mgr_focus_param_t *param);
100 int mm_sound_mgr_focus_emergent_exit(const _mm_sound_mgr_focus_param_t *param);
101 #ifdef SUPPORT_CONTAINER
102 void mm_sound_mgr_focus_update_container_data(int pid,int handle, const char* container_name, int container_pid);
103 #endif
104
105
106 #endif /* __MM_SOUND_MGR_FOCUS_H__ */
107