|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "MCEConstants.h" |
|
21 #include "TCmdGetStreamInfo.h" |
|
22 #include "CTcMCEContext.h" |
|
23 #include <MCEAudioStream.h> |
|
24 #include <MCEVideoStream.h> |
|
25 #include <MCERTPSource.h> |
|
26 #include <MCEMicSource.h> |
|
27 #include <MCECameraSource.h> |
|
28 #include <MCERTPSink.h> |
|
29 #include <MCESpeakerSink.h> |
|
30 #include <MCEDisplaySink.h> |
|
31 #include <mcefilesink.h> |
|
32 #include <MCEAudioCodec.h> |
|
33 #include <badesca.h> |
|
34 |
|
35 #include "mcefilesource.h" |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // TCmdGetStreamInfo::ExecuteL |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 void TCmdGetStreamInfo::ExecuteL() |
|
42 { |
|
43 // ---------- Setup -------------------------------------------------------- |
|
44 |
|
45 // Get stream |
|
46 CMceSession* session= |
|
47 reinterpret_cast<CMceSession*>(GetObjectForIdL(KSessionId, ETrue)); |
|
48 CDesC8Array* mediaStreams = new(ELeave)CDesC8ArraySeg(1); |
|
49 CleanupStack::PushL( mediaStreams ); |
|
50 const RPointerArray<CMceMediaStream>& streamPtrs = session->Streams(); |
|
51 |
|
52 for (TInt streamIndex=0; streamIndex < streamPtrs.Count(); streamIndex++) |
|
53 { |
|
54 // Add to registry by reference and fetch name |
|
55 iContext.Registry().AddObjectL( *(streamPtrs[streamIndex]) ); |
|
56 TBuf8< KTcMaxObjectName > streamId = |
|
57 iContext.Registry().ObjectNameL( streamPtrs[streamIndex] ); |
|
58 mediaStreams->AppendL( streamId ); |
|
59 } |
|
60 |
|
61 // ---------- Execution ---------------------------------------------------- |
|
62 |
|
63 // ---------- Response creation -------------------------------------------- |
|
64 |
|
65 AddIdResponseL(KSessionId, session); // uses CleanupStack internally |
|
66 |
|
67 if ( mediaStreams->Count() > 0 ) |
|
68 { |
|
69 AddArrayResponseL( KResponseStreams, *mediaStreams ); |
|
70 |
|
71 for (TInt streamIndex=0; streamIndex < streamPtrs.Count(); streamIndex++) |
|
72 { |
|
73 if ((streamPtrs[streamIndex])->Type()==KMceAudio) |
|
74 { |
|
75 CMceAudioStream* audioStream =reinterpret_cast<CMceAudioStream*> |
|
76 (iContext.Registry().ObjectPtrL( mediaStreams->MdcaPoint(streamIndex) )); |
|
77 //get the audio stream info |
|
78 GetAudioStreamInfo( audioStream ); |
|
79 } |
|
80 else if ((streamPtrs[streamIndex])->Type()==KMceVideo) |
|
81 { |
|
82 CMceVideoStream* videoStream =reinterpret_cast<CMceVideoStream*> |
|
83 (iContext.Registry().ObjectPtrL( mediaStreams->MdcaPoint(streamIndex) )); |
|
84 //get the video stream info |
|
85 GetVideoStreamInfo( videoStream ); |
|
86 } |
|
87 else |
|
88 { |
|
89 // Keep pc-lint happy |
|
90 } |
|
91 } |
|
92 CleanupStack::PopAndDestroy( mediaStreams ); |
|
93 } |
|
94 else |
|
95 { |
|
96 CleanupStack::PopAndDestroy( mediaStreams ); |
|
97 } |
|
98 |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // TCmdGetStreamInfo::AddSourceToResponse |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void |
|
106 TCmdGetStreamInfo::AddSourceToResponseL( const TDesC8& aParamNameForSourceId, |
|
107 const TDesC8& aParamNameForSource, |
|
108 CMceMediaStream& aStream ) |
|
109 { |
|
110 CMceMediaSource* source = aStream.Source(); |
|
111 |
|
112 iContext.Registry().AddObjectL( *source ); |
|
113 TBuf8< KTcMaxObjectName > sourceId = |
|
114 iContext.Registry().ObjectNameL( source ); |
|
115 AddTextResponseL( aParamNameForSourceId, sourceId ); |
|
116 switch ( source->Type() ) |
|
117 { |
|
118 case KMceRTPSource: |
|
119 { |
|
120 AddTextResponseL( aParamNameForSource, KValueSourceRTP ); |
|
121 break; |
|
122 } |
|
123 case KMceMicSource: |
|
124 { |
|
125 AddTextResponseL( aParamNameForSource, KValueSourceMic ); |
|
126 break; |
|
127 } |
|
128 case KMceCameraSource: |
|
129 { |
|
130 AddTextResponseL( aParamNameForSource, KValueSourceCamera ); |
|
131 break; |
|
132 } |
|
133 case KMceFileSource: |
|
134 { |
|
135 AddTextResponseL( aParamNameForSource, KValueSourceFile ); |
|
136 break; |
|
137 } |
|
138 default: |
|
139 { |
|
140 AddTextResponseL( aParamNameForSource, KValueSourceUnknown ); |
|
141 break; |
|
142 } |
|
143 } |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // TCmdGetStreamInfo::AddSinksToResponse |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void TCmdGetStreamInfo::AddSinksToResponseL( const TDesC8& aParamNameForSinkIds, |
|
151 const TDesC8& aParamNameForSinks, |
|
152 CMceMediaStream& aStream ) |
|
153 { |
|
154 // Array for sink ids |
|
155 CDesC8Array* sinkIds = new(ELeave)CDesC8ArraySeg(1); |
|
156 CleanupStack::PushL( sinkIds ); |
|
157 |
|
158 // Array for sink names |
|
159 CDesC8Array* sinks = new(ELeave)CDesC8ArraySeg(1); |
|
160 CleanupStack::PushL( sinks ); |
|
161 |
|
162 const RPointerArray<CMceMediaSink>& sinkPtrs = aStream.Sinks(); |
|
163 for ( TInt i = 0; i < sinkPtrs.Count(); i++ ) |
|
164 { |
|
165 // Id |
|
166 iContext.Registry().AddObjectL( *(sinkPtrs[i]) ); |
|
167 TPtrC8 sinkId = iContext.Registry().ObjectNameL( sinkPtrs[i] ); |
|
168 sinkIds->AppendL( sinkId ); |
|
169 |
|
170 // Name |
|
171 switch ( sinkPtrs[i]->Type() ) |
|
172 { |
|
173 case KMceRTPSink: |
|
174 { |
|
175 sinks->AppendL( KValueSinkRTP ); |
|
176 break; |
|
177 } |
|
178 case KMceSpeakerSink: |
|
179 { |
|
180 sinks->AppendL( KValueSinkSpeaker ); |
|
181 break; |
|
182 } |
|
183 case KMceDisplaySink: |
|
184 { |
|
185 sinks->AppendL( KValueSinkDisplay ); |
|
186 break; |
|
187 } |
|
188 case KMceFileSink: |
|
189 { |
|
190 sinks->AppendL( KValueSinkFile ); |
|
191 break; |
|
192 } |
|
193 default: |
|
194 { |
|
195 sinks->AppendL( KValueSinkUnknown ); |
|
196 break; |
|
197 } |
|
198 } |
|
199 } |
|
200 |
|
201 if ( sinks->Count() ) |
|
202 { |
|
203 AddArrayResponseL( aParamNameForSinkIds, *sinkIds ); |
|
204 AddArrayResponseL( aParamNameForSinks, *sinks ); |
|
205 } |
|
206 |
|
207 CleanupStack::PopAndDestroy( sinks ); |
|
208 CleanupStack::PopAndDestroy( sinkIds ); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // TCmdGetStreamInfo::AddAudioCodecsToResponse |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void TCmdGetStreamInfo::AddAudioCodecsToResponseL( const TDesC8& aName, |
|
216 CMceAudioStream& aStream ) |
|
217 { |
|
218 CDesC8Array* codecs = new(ELeave)CDesC8ArraySeg(1); |
|
219 CleanupStack::PushL( codecs ); |
|
220 |
|
221 const RPointerArray<CMceAudioCodec>& codecPtrs = aStream.Codecs(); |
|
222 for (TInt codecIndex = 0; codecIndex < codecPtrs.Count(); codecIndex++ ) |
|
223 { |
|
224 // Add codec to registry by reference and fetch name |
|
225 iContext.Registry().AddObjectL( *(codecPtrs[codecIndex]) ); |
|
226 TBuf8< KTcMaxObjectName > codecId = |
|
227 iContext.Registry().ObjectNameL( codecPtrs[codecIndex] ); |
|
228 codecs->AppendL( codecId ); |
|
229 } |
|
230 |
|
231 if ( codecs->Count() ) |
|
232 { |
|
233 AddArrayResponseL( aName, *codecs ); |
|
234 } |
|
235 |
|
236 CleanupStack::PopAndDestroy( codecs ); |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // TCmdGetStreamInfo::AddVideoCodecsToResponse |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 void TCmdGetStreamInfo::AddVideoCodecsToResponseL( const TDesC8& aName, |
|
244 CMceVideoStream& aStream ) |
|
245 { |
|
246 CDesC8Array* codecs = new(ELeave)CDesC8ArraySeg(1); |
|
247 CleanupStack::PushL( codecs ); |
|
248 |
|
249 const RPointerArray<CMceVideoCodec>& codecPtrs = aStream.Codecs(); |
|
250 for (TInt codecIndex = 0; codecIndex < codecPtrs.Count(); codecIndex++ ) |
|
251 { |
|
252 // Add codec to registry by reference and fetch name |
|
253 iContext.Registry().AddObjectL( *(reinterpret_cast<CBase*>(codecPtrs[codecIndex]) )); |
|
254 |
|
255 TBuf8< KTcMaxObjectName > codecId = |
|
256 iContext.Registry().ObjectNameL( codecPtrs[codecIndex] ); |
|
257 codecs->AppendL( codecId ); |
|
258 } |
|
259 |
|
260 if ( codecs->Count() ) |
|
261 { |
|
262 AddArrayResponseL( aName, *codecs ); |
|
263 } |
|
264 |
|
265 CleanupStack::PopAndDestroy( codecs ); |
|
266 } |
|
267 |
|
268 void TCmdGetStreamInfo::GetAudioStreamInfo( CMceAudioStream* aAudioStream ) |
|
269 { |
|
270 if (aAudioStream != NULL) |
|
271 { |
|
272 AddTextResponseL( KResponseStreamType, KValueStreamTypeAudio ); |
|
273 |
|
274 AddTextualStreamStateL( aAudioStream->IsEnabled(), EFalse ); |
|
275 |
|
276 AddIntegerResponseL( KResponseLocalMediaPort, aAudioStream->LocalMediaPort() ); |
|
277 |
|
278 AddSourceToResponseL( KResponseSourceId, |
|
279 KResponseSource, |
|
280 *aAudioStream ); |
|
281 |
|
282 AddSinksToResponseL( KResponseSinkIds, |
|
283 KResponseSinks, |
|
284 *aAudioStream ); |
|
285 |
|
286 AddAudioCodecsToResponseL( KResponseAudioCodecs, *aAudioStream ); |
|
287 |
|
288 // Check boundStream |
|
289 if ( aAudioStream->BoundStream() ) |
|
290 { |
|
291 // Add to registry by reference and fetch name |
|
292 iContext.Registry().AddObjectL( aAudioStream->BoundStreamL() ); |
|
293 TBuf8< KTcMaxObjectName > boundStreamId = |
|
294 iContext.Registry().ObjectNameL( |
|
295 &(aAudioStream->BoundStreamL()) ); |
|
296 // Name is numeric, but adding is easier this way |
|
297 AddTextResponseL( KResponseBoundStream, boundStreamId ); |
|
298 |
|
299 if ( aAudioStream->BoundStreamL().Type() == KMceAudio ) |
|
300 { |
|
301 CMceAudioStream* boundAudioStream = |
|
302 static_cast<CMceAudioStream*> |
|
303 (&(aAudioStream->BoundStreamL())); |
|
304 |
|
305 AddTextResponseL( KResponseBoundStreamType, |
|
306 KValueStreamTypeAudio ); |
|
307 |
|
308 /*AddIntegerResponseL( KResponseBoundStreamState, |
|
309 boundAudioStream->State() );*/ |
|
310 |
|
311 AddTextualStreamStateL( boundAudioStream->IsEnabled(), ETrue ); |
|
312 |
|
313 AddIntegerResponseL( KResponseBoundLocalMediaPort, |
|
314 boundAudioStream->LocalMediaPort() ); |
|
315 |
|
316 AddSourceToResponseL( KResponseBoundStreamSourceId, |
|
317 KResponseBoundStreamSource, |
|
318 *boundAudioStream ); |
|
319 |
|
320 AddSinksToResponseL( KResponseBoundStreamSinkIds, |
|
321 KResponseBoundStreamSinks, |
|
322 *boundAudioStream ); |
|
323 AddAudioCodecsToResponseL( KResponseBoundStreamCodecs, |
|
324 *boundAudioStream ); |
|
325 } |
|
326 } |
|
327 } |
|
328 |
|
329 } |
|
330 |
|
331 void TCmdGetStreamInfo::GetVideoStreamInfo( CMceVideoStream* aVideoStream ) |
|
332 { |
|
333 if (aVideoStream != NULL) |
|
334 { |
|
335 AddTextResponseL( KResponseStreamType, KValueStreamTypeVideo ); |
|
336 |
|
337 AddTextualStreamStateL( aVideoStream->IsEnabled(), EFalse ); |
|
338 |
|
339 AddIntegerResponseL( KResponseLocalMediaPort, aVideoStream->LocalMediaPort() ); |
|
340 |
|
341 AddSourceToResponseL( KResponseSourceId, |
|
342 KResponseSource, |
|
343 *aVideoStream ); |
|
344 |
|
345 AddSinksToResponseL( KResponseSinkIds, KResponseSinks, *aVideoStream ); |
|
346 |
|
347 AddVideoCodecsToResponseL( KResponseVideoCodecs, *aVideoStream ); |
|
348 |
|
349 // Check boundStream |
|
350 |
|
351 if ( aVideoStream->BoundStream() ) |
|
352 { |
|
353 // Add to registry by reference and fetch name |
|
354 iContext.Registry().AddObjectL( aVideoStream->BoundStreamL() ); |
|
355 TBuf8< KTcMaxObjectName > boundStreamId = |
|
356 iContext.Registry().ObjectNameL( |
|
357 &(aVideoStream->BoundStreamL()) ); |
|
358 // Name is numeric, but adding is easier this way |
|
359 AddTextResponseL( KResponseBoundStream, boundStreamId ); |
|
360 |
|
361 if ( aVideoStream->BoundStreamL().Type() == KMceVideo ) |
|
362 { |
|
363 |
|
364 CMceVideoStream* boundVideoStream = |
|
365 static_cast<CMceVideoStream*> |
|
366 (&(aVideoStream->BoundStreamL())); |
|
367 |
|
368 AddTextResponseL( KResponseBoundStreamType, |
|
369 KValueStreamTypeVideo ); |
|
370 |
|
371 AddTextualStreamStateL( boundVideoStream->IsEnabled(), ETrue ); |
|
372 |
|
373 AddIntegerResponseL( KResponseBoundLocalMediaPort, |
|
374 boundVideoStream->LocalMediaPort() ); |
|
375 |
|
376 AddSourceToResponseL( KResponseBoundStreamSourceId, |
|
377 KResponseBoundStreamSource, |
|
378 *boundVideoStream ); |
|
379 |
|
380 AddSinksToResponseL( KResponseBoundStreamSinkIds, |
|
381 KResponseBoundStreamSinks, |
|
382 *boundVideoStream ); |
|
383 |
|
384 AddVideoCodecsToResponseL( KResponseBoundStreamCodecs, |
|
385 *boundVideoStream ); |
|
386 } |
|
387 } |
|
388 } |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // TCmdGetStreamInfo::Match |
|
393 // ----------------------------------------------------------------------------- |
|
394 // |
|
395 TBool TCmdGetStreamInfo::Match( const TTcIdentifier& aId ) |
|
396 { |
|
397 return TTcMceCommandBase::Match( aId, _L8("GetStreamInfo") ); |
|
398 } |
|
399 |
|
400 // ----------------------------------------------------------------------------- |
|
401 // TCmdGetStreamInfo::CreateL |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 TTcCommandBase* TCmdGetStreamInfo::CreateL( MTcTestContext& aContext ) |
|
405 { |
|
406 return new( ELeave ) TCmdGetStreamInfo( aContext ); |
|
407 } |