|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "mcemicsource.h" |
|
22 #include "mcecommicsource.h" |
|
23 #include "mcesession.h" |
|
24 #include "mcemediastream.h" |
|
25 #include "mceitcsender.h" |
|
26 #include "mceclilogs.h" |
|
27 #include "mcemanager.h" |
|
28 |
|
29 #define _FLAT_DATA static_cast<CMceComMicSource*>( iFlatData ) |
|
30 #define FLAT_DATA( data ) _FLAT_DATA->data |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CMceMicSource::NewL |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 EXPORT_C CMceMicSource* CMceMicSource::NewL() |
|
40 { |
|
41 |
|
42 CMceMicSource* self = NewLC(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CMceMicSource::NewLC |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CMceMicSource* CMceMicSource::NewLC() |
|
53 { |
|
54 |
|
55 CMceMicSource* self = new (ELeave) CMceMicSource(); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 return self; |
|
59 |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CMceMicSource::~CMceMicSource |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C CMceMicSource::~CMceMicSource() |
|
67 { |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CMceMicSource::EnableL |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 EXPORT_C void CMceMicSource::EnableL() |
|
75 { |
|
76 MCECLI_DEBUG("CMceMicSource::EnableL, Entry"); |
|
77 |
|
78 CMceMediaSource::DoEnableL(); |
|
79 |
|
80 MCECLI_DEBUG("CMceMicSource::EnableL, Exit"); |
|
81 |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CMceMicSource::Disable |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C void CMceMicSource::DisableL() |
|
89 { |
|
90 MCECLI_DEBUG("CMceMicSource::DisableL, Entry"); |
|
91 |
|
92 CMceMediaSource::DoDisableL(); |
|
93 |
|
94 MCECLI_DEBUG("CMceMicSource::DisableL, Exit"); |
|
95 |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CMceMicSource::SetGainL |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C void CMceMicSource::SetGainL( TInt aGain ) |
|
103 { |
|
104 MCECLI_DEBUG("CMceMicSource::SetGainL, Entry"); |
|
105 MCECLI_DEBUG_DVALUE("gain", aGain); |
|
106 |
|
107 if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) |
|
108 { |
|
109 CMceSession* session = iStream->Session(); |
|
110 |
|
111 TMceIds ids; |
|
112 session->PrepareForITC( ids ); |
|
113 ids.iMediaID = iStream->Id(); |
|
114 ids.iSourceID = Id(); |
|
115 |
|
116 TMceItcArgTInt gain( aGain ); |
|
117 session->ITCSender().WriteL( ids, EMceItcSetGain, gain ); |
|
118 } |
|
119 |
|
120 FLAT_DATA( iGain ) = aGain; |
|
121 |
|
122 MCECLI_DEBUG("CMceMicSource::SetGainL, Exit"); |
|
123 |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CMceMicSource::GainL |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 EXPORT_C TInt CMceMicSource::GainL() const |
|
131 { |
|
132 MCECLI_DEBUG("CMceMicSource::GainL, Entry"); |
|
133 |
|
134 TInt gain( 0 ); |
|
135 |
|
136 if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) |
|
137 { |
|
138 CMceSession* session = iStream->Session(); |
|
139 |
|
140 TMceIds ids; |
|
141 session->PrepareForITC( ids ); |
|
142 ids.iMediaID = iStream->Id(); |
|
143 ids.iSourceID = Id(); |
|
144 |
|
145 TMceItcArgTInt gainArg; |
|
146 |
|
147 session->ITCSender().ReadL( ids, EMceItcGain, gainArg ); |
|
148 |
|
149 gain = gainArg(); |
|
150 } |
|
151 else |
|
152 { |
|
153 gain = FLAT_DATA( iGain ); |
|
154 } |
|
155 |
|
156 MCECLI_DEBUG("CMceMicSource::GainL, Exit"); |
|
157 |
|
158 return gain; |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CMceMicSource::MaxGainL |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C TInt CMceMicSource::MaxGainL() const |
|
166 { |
|
167 MCECLI_DEBUG("CMceMicSource::MaxGainL"); |
|
168 |
|
169 TMceItcArgTInt maxGain; |
|
170 |
|
171 if ( iStream && iStream->Session() && &iStream->Session()->Manager() ) |
|
172 { |
|
173 CMceManager& manager = iStream->Session()->Manager(); |
|
174 TMceIds ids; |
|
175 ids.iAppUID = manager.AppUid().iUid; |
|
176 _FLAT_DATA->SenderL( |
|
177 manager.ServerSession() ).ReadL( ids, EMceItcMaxGain, maxGain ); |
|
178 } |
|
179 else |
|
180 { |
|
181 MCECLI_DEBUG("CMceMicSource::MaxGainL, not ready"); |
|
182 User::Leave( KErrNotReady ); |
|
183 } |
|
184 |
|
185 // If gain is not set, set it to half of the max gain |
|
186 if ( FLAT_DATA( iGain ) == KMceNotAssignedInt ) |
|
187 { |
|
188 const TInt KMceGainDivider = 2; |
|
189 FLAT_DATA( iGain ) = ( maxGain() / KMceGainDivider ); |
|
190 } |
|
191 |
|
192 return maxGain(); |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CMceMicSource::CMceMicSource |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 CMceMicSource::CMceMicSource() |
|
200 : CMceMediaSource() |
|
201 { |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CMceMicSource::ConstructL |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CMceMicSource::ConstructL() |
|
209 { |
|
210 CMceComMicSource* mic = CMceComMicSource::NewLC(); |
|
211 CMceMediaSource::ConstructL( mic ); |
|
212 CleanupStack::Pop( mic ); |
|
213 } |
|
214 |
|
215 |