Use socket for IPC of focus APIs instead of the DBus
[platform/core/multimedia/libmm-sound.git] / include / mm_sound_focus_socket.h
1 /*
2  * libmm-sound
3  *
4  * Copyright (c) 2017 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_FOCUS_SOCKET_H__
23 #define __MM_SOUND_FOCUS_SOCKET_H__
24
25 #ifdef __cplusplus
26         extern "C" {
27 #endif
28
29 #include "include/mm_sound_common.h"
30 #include "include/mm_sound_focus.h"
31
32 #define FOCUS_SERVER_SOCK "/tmp/.focus_server.socket"
33 #define MAX_ERROR_LEN 64
34
35 typedef struct {
36         char func_name[MM_SOUND_NAME_NUM];
37         char stream_type[MM_SOUND_NAME_NUM];
38         int handle_id;
39         int handle_id_dst;
40         int pid;
41         mm_sound_focus_type_e focus_type;
42         int option;
43         char ext_info[MM_SOUND_NAME_NUM];
44         bool reacquisition;
45         bool is_in_thread;                 /* Called within focus callback thread */
46 } _mm_sound_focus_socket_param_t;
47
48 typedef struct {
49         int ret;
50         int handle_id;
51         int option;
52         char stream_type[MM_SOUND_NAME_NUM];
53         char ext_info[MM_SOUND_NAME_NUM];
54 } _mm_sound_focus_socket_result_t;
55
56 /* Function names */
57 #define FOCUS_FUNC_NAME_REGISTER          "RegisterFocus"
58 #define FOCUS_FUNC_NAME_UNREGISTER        "UnregisterFocus"
59 #define FOCUS_FUNC_NAME_ADD_WATCH         "AddWatchFocus"
60 #define FOCUS_FUNC_NAME_REMOVE_WATCH      "RemoveWatchFocus"
61 #define FOCUS_FUNC_NAME_ACQUIRE           "AcquireFocus"
62 #define FOCUS_FUNC_NAME_RELEASE           "ReleaseFocus"
63 #define FOCUS_FUNC_NAME_SET_REACQUISITON  "SetFocusReacquisition"
64 #define FOCUS_FUNC_NAME_DELIVER           "DeliverFocus"
65 #define FOCUS_FUNC_NAME_GET_ACQUIRED_INFO "GetAcquiredFocusInfo"
66
67 /* Error defines */
68 #define FOCUS_ERROR_NONE                 "error_none"
69 #define FOCUS_ERROR_INVALID_PARAMETER    "error_invalid_parameter"
70 #define FOCUS_ERROR_POLICY               "error_policy"
71 #define FOCUS_ERROR_INTERNAL             "error_internal"
72 #define FOCUS_ERROR_INVALID_STATE        "error_invalid_state"
73
74 int mm_sound_focus_socket_register(int pid, const char *stream_type, int *client_fd, int *server_fd);
75 int mm_sound_focus_socket_unregister(int pid, int client_fd, int server_fd);
76 int mm_sound_focus_socket_add_watch_cb(int pid, mm_sound_focus_type_e focus_type, int *client_fd, int *server_fd);
77 int mm_sound_focus_socket_remove_watch_cb(int pid, int client_fd, int server_fd);
78 int mm_sound_focus_socket_acquire(int pid, int client_fd, int server_fd, mm_sound_focus_type_e focus_type, int option, const char *ext_info, bool is_in_thread);
79 int mm_sound_focus_socket_release(int pid, int client_fd, int server_fd, mm_sound_focus_type_e focus_type, int option, const char *ext_info, bool is_in_thread);
80 int mm_sound_focus_socket_set_reacquisition(int pid, int client_fd, int server_fd, bool reacquisition);
81 int mm_sound_focus_socket_deliver(int pid, int src_client_fd, int src_server_fd, int dst_client_fd, int dst_server_fd, mm_sound_focus_type_e focus_type);
82 int mm_sound_focus_socket_get_acquired_focus_stream_type(mm_sound_focus_type_e focus_type, char **stream_type, int *option, char **ext_info);
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif  /* __MM_SOUND_FOCUS_SOCKET_H__ */
89