|
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 "mcespeakersink.h" |
|
22 #include "mcecomspeakersink.h" |
|
23 #include "mceevents.h" |
|
24 #include "mcecomavsink.h" |
|
25 |
|
26 |
|
27 #ifdef MCE_COMMON_SERVER_SIDE |
|
28 |
|
29 #include <mmccinterface.h> |
|
30 #include "mcesdpsession.h" |
|
31 #include "mcemediamanager.h" |
|
32 |
|
33 #endif//MCE_COMMON_SERVER_SIDE |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CMceComSpeakerSink::NewL |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CMceComSpeakerSink* CMceComSpeakerSink::NewL() |
|
44 { |
|
45 CMceComSpeakerSink* self = NewLC(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMceComSpeakerSink::NewLC |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CMceComSpeakerSink* CMceComSpeakerSink::NewLC() |
|
55 { |
|
56 CMceComSpeakerSink* self = new (ELeave) CMceComSpeakerSink(); |
|
57 CleanupStack::PushL( self ); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMceComSpeakerSink::~CMceComSpeakerSink |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CMceComSpeakerSink::~CMceComSpeakerSink() |
|
66 { |
|
67 if ( iEndpointProxy ) |
|
68 { |
|
69 CMceComAvSink* endpointProxy = static_cast<CMceComAvSink*>( iEndpointProxy ); |
|
70 endpointProxy->RemoveProxyClient( *this ); |
|
71 if ( endpointProxy->ReferenceCount() == 0 ) |
|
72 { |
|
73 delete endpointProxy; |
|
74 } |
|
75 iEndpointProxy = NULL; |
|
76 } |
|
77 |
|
78 } |
|
79 |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CMceComSpeakerSink::CMceComSpeakerSink |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CMceComSpeakerSink::CMceComSpeakerSink() |
|
86 : CMceComMediaSink( KMceSpeakerSink ), |
|
87 iAudioRoute( 0 ), |
|
88 iVolume( KMceNotAssignedInt ) |
|
89 { |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CMceComSpeakerSink::CloneL |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 CMceComMediaSink* CMceComSpeakerSink::CloneL() |
|
97 { |
|
98 CMceComSpeakerSink* copy = new (ELeave) CMceComSpeakerSink(); |
|
99 Mem::Copy( copy, this, sizeof(CMceComSpeakerSink) ); |
|
100 copy->Zero(); |
|
101 return copy; |
|
102 |
|
103 } |
|
104 |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CMceComSpeakerSink::InternalizeFlatL |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CMceComSpeakerSink::InternalizeFlatL( RReadStream& aReadStream ) |
|
111 { |
|
112 CMceComMediaSink::InternalizeFlatL( aReadStream ); |
|
113 |
|
114 iAudioRoute = aReadStream.ReadInt32L(); |
|
115 iVolume = aReadStream.ReadInt32L(); |
|
116 } |
|
117 |
|
118 |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CMceComSpeakerSink::ExternalizeFlatL |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void CMceComSpeakerSink::ExternalizeFlatL( RWriteStream& aWriteStream ) |
|
125 { |
|
126 CMceComMediaSink::ExternalizeFlatL( aWriteStream ); |
|
127 |
|
128 aWriteStream.WriteInt32L( iAudioRoute ); |
|
129 aWriteStream.WriteInt32L( iVolume ); |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CMceComSpeakerSink::UsesEndpointProxy() |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 TBool CMceComSpeakerSink::UsesEndpointProxy() const |
|
137 { |
|
138 return ETrue; |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CMceComSpeakerSink::CreateEndpointProxyL() |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 MMceComEndPointProxy* CMceComSpeakerSink::CreateEndpointProxyL() const |
|
146 { |
|
147 return CMceComAvSink::NewL(); |
|
148 } |
|
149 |
|
150 |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CMceComSpeakerSink::EventReceivedL |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 TInt CMceComSpeakerSink::EventReceivedL( TMceComEvent& aEvent ) |
|
157 { |
|
158 TInt status = CMceComMediaSink::EventReceivedL( aEvent ); |
|
159 if ( status != KMceEventNotConsumed ) |
|
160 { |
|
161 return status; |
|
162 } |
|
163 |
|
164 if ( aEvent.Id().IsSinkId() ) |
|
165 { |
|
166 status = aEvent.Handler().HandleL( *this, aEvent ); |
|
167 } |
|
168 else |
|
169 { |
|
170 status = KMceEventNotConsumed; |
|
171 } |
|
172 |
|
173 return status; |
|
174 |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CMceComSpeakerSink::UpdateL |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CMceComSpeakerSink::UpdateL( CMceComMediaSink& aUpdate ) |
|
182 { |
|
183 CMceComMediaSink::UpdateL( aUpdate ); |
|
184 |
|
185 iAudioRoute = static_cast<CMceComSpeakerSink&>( aUpdate ).iAudioRoute; |
|
186 iVolume = static_cast<CMceComSpeakerSink&>( aUpdate ).iVolume; |
|
187 |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CMceComSpeakerSink::Reusable |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 TBool CMceComSpeakerSink::Reusable( const CMceComMediaStream& /*aParent*/ ) const |
|
195 { |
|
196 if ( EndpointProxy() ) |
|
197 { |
|
198 // If speaker is in bundled stream, sharing is allowed as speaker is |
|
199 // actually replaced with display |
|
200 return ETrue; |
|
201 } |
|
202 return EFalse; |
|
203 } |
|
204 |
|
205 #ifdef MCE_COMMON_SERVER_SIDE |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CMceComSpeakerSink::InitParamL |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 const TDesC8& CMceComSpeakerSink::InitParamL( const CMceComCodec& aCodec ) |
|
212 { |
|
213 if ( EndpointProxy() ) |
|
214 { |
|
215 CMceComAvSink* endpointProxy = static_cast<CMceComAvSink*>( EndpointProxy() ); |
|
216 return endpointProxy->InitParamL( aCodec ); |
|
217 } |
|
218 |
|
219 return CMceComMediaSink::InitParamL( aCodec ); |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CMceComSpeakerSink::PrepareL |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CMceComSpeakerSink::PrepareL() |
|
227 { |
|
228 if ( EndpointProxy() ) |
|
229 { |
|
230 CMceComAvSink* endpointProxy = static_cast<CMceComAvSink*>( EndpointProxy() ); |
|
231 endpointProxy->PrepareL(); |
|
232 } |
|
233 else |
|
234 { |
|
235 if ( MediaStream() && MediaStream()->Session() ) |
|
236 { |
|
237 CMceMediaManager& mediaManager = MediaStream()->Session()->SdpSession().Manager(); |
|
238 if ( iAudioRoute ) |
|
239 { |
|
240 mediaManager.SetAudioRoutingL( *this, iAudioRoute ); |
|
241 } |
|
242 |
|
243 if ( iVolume != KMceNotAssignedInt ) |
|
244 { |
|
245 mediaManager.SetVolumeL( *this, iVolume ); |
|
246 } |
|
247 } |
|
248 } |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // CMceComSpeakerSink::MccType |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 const TUid CMceComSpeakerSink::MccType() |
|
256 { |
|
257 TUid id = KUidMmfAudioOutput; |
|
258 if ( EndpointProxy() ) |
|
259 { |
|
260 CMceComAvSink* endpointProxy = static_cast<CMceComAvSink*>( EndpointProxy() ); |
|
261 id = endpointProxy->MccType(); |
|
262 } |
|
263 return id; |
|
264 } |
|
265 |
|
266 #endif//MCE_COMMON_SERVER_SIDE |
|
267 |
|
268 |