|
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 #ifdef MCE_COMMON_SERVER_SIDE |
|
22 |
|
23 #include <mmccinterface.h> |
|
24 |
|
25 #endif//MCE_COMMON_SERVER_SIDE |
|
26 |
|
27 #include "mcecomstreambundle.h" |
|
28 #include "mcecomsession.h" |
|
29 #include "mcestreambundle.h" |
|
30 #include "mcecomfactory.h" |
|
31 #include "mceserial.h" |
|
32 #include "mceevents.h" |
|
33 #include "mcecommediasink.h" |
|
34 #include "mcecommediasource.h" |
|
35 #include "mcecomendpointproxy.h" |
|
36 |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CMceComStreamBundle::NewL |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CMceComStreamBundle* CMceComStreamBundle::NewL( CMceStreamBundle::TMceStreamBundleType aType ) |
|
45 { |
|
46 CMceComStreamBundle* self = NewLC( aType ); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CMceComStreamBundle::NewLC |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CMceComStreamBundle* CMceComStreamBundle::NewLC( CMceStreamBundle::TMceStreamBundleType aType ) |
|
57 { |
|
58 CMceComStreamBundle* self = new (ELeave) CMceComStreamBundle( aType ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CMceComStreamBundle::~CMceComStreamBundle |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CMceComStreamBundle::~CMceComStreamBundle() |
|
69 { |
|
70 iStreams.Close(); |
|
71 } |
|
72 |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CMceComStreamBundle::Type |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CMceStreamBundle::TMceStreamBundleType CMceComStreamBundle::Type() const |
|
79 { |
|
80 return iBundleType; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CMceComStreamBundle::AddStreamL |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CMceComStreamBundle::AddStreamL( CMceComMediaStream& aStream ) |
|
88 { |
|
89 iStreams.AppendL( &aStream ); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CMceComStreamBundle::RemoveStreamL |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CMceComStreamBundle::RemoveStreamL( CMceComMediaStream& aStream ) |
|
97 { |
|
98 TInt index = iStreams.Find( &aStream ); |
|
99 User::LeaveIfError( index ); |
|
100 iStreams.Remove( index ); |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CMceComStreamBundle::Streams |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 const RPointerArray< CMceComMediaStream >& CMceComStreamBundle::Streams() const |
|
108 { |
|
109 return iStreams; |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CMceComStreamBundle::InternalizeFlatL |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CMceComStreamBundle::InternalizeFlatL( RReadStream& aReadStream ) |
|
118 { |
|
119 iBundleType = static_cast<CMceStreamBundle::TMceStreamBundleType>( aReadStream.ReadUint8L() ); |
|
120 //iID |
|
121 MceSerial::DecodeL( iID, aReadStream ); |
|
122 |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CMceComStreamBundle::ExternalizeFlatL |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CMceComStreamBundle::ExternalizeFlatL( RWriteStream& aWriteStream ) |
|
130 { |
|
131 aWriteStream.WriteUint8L( iBundleType ); |
|
132 //iID |
|
133 MceSerial::EncodeL( iID, aWriteStream ); |
|
134 } |
|
135 |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CMceComStreamBundle::CloneL |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 CMceComStreamBundle* CMceComStreamBundle::CloneL() |
|
142 { |
|
143 CMceComStreamBundle* copy = new (ELeave) CMceComStreamBundle( iBundleType ); |
|
144 Mem::Copy( copy, this, sizeof(CMceComStreamBundle) ); |
|
145 copy->Zero(); |
|
146 return copy; |
|
147 |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CMceComStreamBundle::Zero |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void CMceComStreamBundle::Zero() |
|
155 { |
|
156 iStreams = RPointerArray<CMceComMediaStream>( KMceArrayGranularity ); |
|
157 iSession = NULL; |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CMceComStreamBundle::CloneL |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 CMceComStreamBundle* CMceComStreamBundle::CloneL( |
|
165 const RPointerArray<CMceComMediaStream>& aStreams ) |
|
166 { |
|
167 CMceComStreamBundle* copy = static_cast<CMceComStreamBundle*>( CloneL() ); |
|
168 CleanupStack::PushL( copy ); |
|
169 |
|
170 for( TInt i = 0; i< aStreams.Count();i++ ) |
|
171 { |
|
172 CMceComMediaStream* bundleStream = aStreams[ i ]; |
|
173 CMceComMediaStream* stream = NULL; |
|
174 TInt index = 0; |
|
175 while( !stream && index < iStreams.Count() ) |
|
176 { |
|
177 stream = iStreams[ index++ ]; |
|
178 stream = stream->Id() == bundleStream->Id() ? bundleStream : NULL; |
|
179 } |
|
180 if ( stream ) |
|
181 { |
|
182 copy->AddStreamL( *bundleStream ); |
|
183 } |
|
184 } |
|
185 |
|
186 CleanupStack::Pop( copy ); |
|
187 return copy; |
|
188 |
|
189 } |
|
190 |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CMceComStreamBundle::UpdateL |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 void CMceComStreamBundle::UpdateL( CMceComStreamBundle& /*aUpdate*/ ) |
|
197 { |
|
198 //NOP |
|
199 } |
|
200 |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CMceComStreamBundle::SerializationId |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 TUint64 CMceComStreamBundle::SerializationId() const |
|
207 { |
|
208 return iID.Uint64(); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CMceComStreamBundle::InternalizeL |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void CMceComStreamBundle::InternalizeL( MMceComSerializationContext& aSerCtx ) |
|
216 { |
|
217 __ASSERT_ALWAYS( iSession, User::Leave( KErrArgument ) ); |
|
218 |
|
219 RReadStream& readStream = aSerCtx.ReadStream(); |
|
220 |
|
221 CMceComStreamBundle::InternalizeFlatL( readStream ); |
|
222 |
|
223 TUint32 i = 0; |
|
224 TInt j = 0; |
|
225 TMceMediaId streamId; |
|
226 |
|
227 TUint32 streamCount = readStream.ReadUint32L(); |
|
228 for( i = 0; i<streamCount; i++) |
|
229 { |
|
230 MceSerial::DecodeL( streamId, readStream ); |
|
231 for( j = 0; j < iSession->Streams().Count();j++ ) |
|
232 { |
|
233 CMceComMediaStream* stream = iSession->Streams()[ j ]; |
|
234 if ( stream->Id() == streamId ) |
|
235 { |
|
236 AddStreamL( *stream ); |
|
237 } |
|
238 } |
|
239 } |
|
240 |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CMceComStreamBundle::ExternalizeL |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 void CMceComStreamBundle::ExternalizeL( MMceComSerializationContext& aSerCtx ) |
|
248 { |
|
249 RWriteStream& writeStream = aSerCtx.WriteStream(); |
|
250 |
|
251 CMceComStreamBundle::ExternalizeFlatL( writeStream ); |
|
252 |
|
253 writeStream.WriteUint32L( iStreams.Count() ); |
|
254 for( TInt i = 0;i<iStreams.Count();i++) |
|
255 { |
|
256 MceSerial::EncodeL( iStreams[ i ]->Id(), writeStream ); |
|
257 } |
|
258 |
|
259 } |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // CMceComStreamBundle::InitializeL |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void CMceComStreamBundle::InitializeL( CMceComSession& aParent ) |
|
266 { |
|
267 iSession = &aParent; |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CMceComStreamBundle::CMceComStreamBundle |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 CMceComStreamBundle::CMceComStreamBundle( CMceStreamBundle::TMceStreamBundleType aType ) |
|
275 : iBundleType( aType ), |
|
276 iID( TMceMediaId( (TUint32)&iID ) ) |
|
277 { |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CMceComStreamBundle::ConstructL |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void CMceComStreamBundle::ConstructL() |
|
285 { |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // CMceComStreamBundle::AddedL |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 void CMceComStreamBundle::AddedL() |
|
293 { |
|
294 MMceComEndPointProxy* proxy = NULL; |
|
295 CMceComEndpoint* endpoint = NULL; |
|
296 TInt i = 0; |
|
297 |
|
298 //sinks |
|
299 for( i = 0; i< iStreams.Count(); i++ ) |
|
300 { |
|
301 |
|
302 CMceComMediaStream* stream = iStreams[ i ]; |
|
303 AddedSinkL( *stream, endpoint, proxy ); |
|
304 if ( stream->BoundStream() ) |
|
305 { |
|
306 AddedSinkL( stream->BoundStreamL(), endpoint, proxy ); |
|
307 } |
|
308 } |
|
309 |
|
310 //sources |
|
311 endpoint = NULL; |
|
312 proxy = NULL; |
|
313 for( i = 0;i<iStreams.Count();i++ ) |
|
314 { |
|
315 CMceComMediaStream* stream = iStreams[ i ]; |
|
316 AddedSourceL( *stream, endpoint, proxy ); |
|
317 if ( stream->BoundStream() ) |
|
318 { |
|
319 AddedSourceL( stream->BoundStreamL(), endpoint, proxy ); |
|
320 } |
|
321 } |
|
322 } |
|
323 |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // CMceComStreamBundle::AddedSinkL |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 void CMceComStreamBundle::AddedSinkL( CMceComMediaStream& aStream, |
|
330 CMceComEndpoint*& aCurrentSink, |
|
331 MMceComEndPointProxy*& aProxy ) |
|
332 |
|
333 { |
|
334 |
|
335 for( TInt j=0; j < aStream.Sinks().Count(); j++ ) |
|
336 { |
|
337 aProxy = aCurrentSink ? aCurrentSink->EndpointProxy() : aProxy; |
|
338 aCurrentSink = aStream.Sinks()[ j ]; |
|
339 aCurrentSink->SetupEndpointProxyL( aProxy ); |
|
340 } |
|
341 } |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // CMceComStreamBundle::AddedSourceL |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 void CMceComStreamBundle::AddedSourceL( CMceComMediaStream& aStream, |
|
348 CMceComEndpoint*& aCurrentSource, |
|
349 MMceComEndPointProxy*& aProxy ) |
|
350 |
|
351 { |
|
352 aProxy = aCurrentSource ? aCurrentSource->EndpointProxy() : aProxy; |
|
353 aCurrentSource = aStream.Source(); |
|
354 aCurrentSource->SetupEndpointProxyL( aProxy ); |
|
355 |
|
356 } |
|
357 |
|
358 |