Change source file permissions to 0644
[platform/core/uifw/inputdelegator.git] / inc / MicEffector.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics 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 #pragma once
18
19 #include <vector>
20 #include <efl_extension.h>
21
22
23 #define SAMPLE_COUNT 59
24
25 namespace is {  /** name space input selector */
26 namespace ui {  /** name space ui */
27
28 /**
29  * Interface for external controller
30  *
31  */
32 class IMicEffector
33 {
34         public :
35                 virtual ~IMicEffector() = 0;
36                 virtual std::vector<int> GetVolume() = 0;
37                 virtual void ProcessingAnimationStart() = 0;
38                 virtual void ProcessingAnimationStop() = 0;
39 };
40 inline IMicEffector::~IMicEffector() { };
41
42 /**
43  * Effect & Effect Controller
44  *
45  */
46 class MicEffector
47 {
48         public :
49                 MicEffector(Evas_Object *canvas, Evas_Object *layout, IMicEffector& effect);
50                 ~MicEffector();
51
52                 /**
53                  * Start Effect.
54                  *
55                  * It support signaling to edje and start animation.
56                  *
57                  */
58                 void Start();
59
60                 /**
61                  * Equalizer Effect animation.
62                  *
63                  * @param volumes sampled volume values.
64                  * @param fake default false. if it set as true, it works using fixed volume values.
65                  *
66                  */
67                 void Effect(bool fake = false);
68
69                 /**
70                  * Stop Effect.
71                  *
72                  * It support signaling to edje and stop animation.
73                  *
74                  * @param forced default false. if it set as true, it should go idle state without processing.
75                  *
76                  */
77                 void Stop(bool forced = false);
78
79                 /**
80                  * Get volumes via ieffect and refresh equalizer effect.
81                  *
82                  * @param fake default false. if it set as true, it works using fixed volume values.
83                  *
84                  */
85                 void VolumeCheck(bool fake = false);
86
87                 /**
88                  * Draw image to show que animation.
89                  *
90                  * @param idx frame index value
91                  *
92                  */
93                 void DrawQue(int idx, bool is_start = true);
94
95                 /**
96                  * Draw image to show que animation.
97                  *
98                  * @param idx frame index value
99                  * @param amount current volume amount
100                  * @param prev_amount previous volume amount
101                  * @param opacity opacity value for effect
102                  * @param is_lastcmd
103                  *
104                  */
105                 void DrawWave(unsigned int idx, int amount, int prev_amount, double opacity = 1.0f, bool is_lastcmd = false);
106
107                 /**
108                  * Get ratio for tuned volume value.
109                  *
110                  * @param idx volume stick index
111                  * @return ratio for each volume stick
112                  *
113                  */
114                 float GetAmplifyValue(unsigned int idx);
115
116         private :
117                 /**
118                  * Support idle state actions.
119                  *
120                  */
121                 void Idle();
122
123                 /**
124                  * Support listening state actions.
125                  *
126                  */
127                 void Listening();
128
129                 /**
130                  * Support processing state actions.
131                  *
132                  */
133                 void Processing();
134
135                 /**
136                  * Draw dummy frame to avoid broken frame showing.
137                  * It have to be call one time internally.
138                  *
139                  */
140                 void DrawDummyFrame();
141
142                 /**
143                  * Volume values.
144                  *
145                  */
146                 std::vector<int> prev;
147                 std::vector<int> current;
148
149         public :
150                 int drawcount;
151                 bool forcestop;
152                 bool started;
153                 bool fake;
154
155                 Evas_Object *vg;
156                 Efl_VG *root;
157                 Efl_VG *shape;
158
159                 /**
160                  * timer handle
161                  *
162                  */
163                 Ecore_Timer *timer;
164
165                 /**
166                  * mic widget layout
167                  *
168                  */
169                 Evas_Object *layout;
170
171                 /**
172                  * interface with app
173                  *
174                  */
175                 IMicEffector& ieffect;
176 };
177
178 }} /** end of is::ui */
179