1 /*--------------------------------------------------------------------------
2 Copyright (c) 2010, The Linux Foundation. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6     * Redistributions of source code must retain the above copyright
7       notice, this list of conditions and the following disclaimer.
8     * Redistributions in binary form must reproduce the above copyright
9       notice, this list of conditions and the following disclaimer in the
10       documentation and/or other materials provided with the distribution.
11     * Neither the name of The Linux Foundation nor
12       the names of its contributors may be used to endorse or promote
13       products derived from this software without specific prior written
14       permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 --------------------------------------------------------------------------*/
28 #ifndef AENC_SVR_H
29 #define AENC_SVR_H
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 #include <pthread.h>
35 #include <sched.h>
36 #include <utils/Log.h>
37 
38 #ifdef _ANDROID_
39 #define LOG_TAG "QC_AACENC"
40 #endif
41 
42 #ifndef LOGE
43 #define LOGE ALOGE
44 #endif
45 
46 #ifndef LOGW
47 #define LOGW ALOGW
48 #endif
49 
50 #ifndef LOGD
51 #define LOGD ALOGD
52 #endif
53 
54 #ifndef LOGV
55 #define LOGV ALOGV
56 #endif
57 
58 #ifndef LOGI
59 #define LOGI ALOGI
60 #endif
61 
62 #define DEBUG_PRINT_ERROR LOGE
63 #define DEBUG_PRINT       LOGV
64 #define DEBUG_DETAIL      LOGV
65 
66 typedef void (*message_func)(void* client_data, unsigned char id);
67 
68 /**
69  @brief audio encoder ipc info structure
70 
71  */
72 struct aac_ipc_info
73 {
74     pthread_t thr;
75     int pipe_in;
76     int pipe_out;
77     int dead;
78     message_func process_msg_cb;
79     void         *client_data;
80     char         thread_name[128];
81 };
82 
83 /**
84  @brief This function starts command server
85 
86  @param cb pointer to callback function from the client
87  @param client_data reference client wants to get back
88   through callback
89  @return handle to command server
90  */
91 struct aac_ipc_info *omx_aac_thread_create(message_func cb,
92     void* client_data,
93     char *th_name);
94 
95 struct aac_ipc_info *omx_aac_event_thread_create(message_func cb,
96     void* client_data,
97     char *th_name);
98 /**
99  @brief This function stop command server
100 
101  @param svr handle to command server
102  @return none
103  */
104 void omx_aac_thread_stop(struct aac_ipc_info *aac_ipc);
105 
106 
107 /**
108  @brief This function post message in the command server
109 
110  @param svr handle to command server
111  @return none
112  */
113 void omx_aac_post_msg(struct aac_ipc_info *aac_ipc,
114                           unsigned char id);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* AENC_SVR */
121