|
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: videoplaylistutility test class for STIF testing |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 2 % |
|
19 |
|
20 #include <f32file.h> |
|
21 #include <mediarecognizer.h> |
|
22 #include <mpxmediaarray.h> |
|
23 #include <mpxmediacontainerdefs.h> |
|
24 #include <mpxmediageneralextdefs.h> |
|
25 |
|
26 #include "videoplaylistutilitytester.h" |
|
27 #include "videoplaylistutility.h" |
|
28 |
|
29 |
|
30 // ------------------------------------------------------------------------------------------------- |
|
31 // CVideoPlaylistUtility_Tester::NewL |
|
32 // ------------------------------------------------------------------------------------------------- |
|
33 // |
|
34 CVideoPlaylistUtility_Tester* CVideoPlaylistUtility_Tester::NewL() |
|
35 { |
|
36 CVideoPlaylistUtility_Tester* self = new (ELeave) CVideoPlaylistUtility_Tester; |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CVideoPlaylistUtility_Tester::~CVideoPlaylistUtility_Tester |
|
45 // |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CVideoPlaylistUtility_Tester::~CVideoPlaylistUtility_Tester() |
|
49 { |
|
50 delete iPlaylistUtility; |
|
51 iPlaylistUtility = NULL; |
|
52 |
|
53 } |
|
54 |
|
55 // ------------------------------------------------------------------------------------------------- |
|
56 // CVideoPlaylistUtility_Tester::ConstructL |
|
57 // ------------------------------------------------------------------------------------------------- |
|
58 // |
|
59 void CVideoPlaylistUtility_Tester::ConstructL() |
|
60 { |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CVideoPlaylistUtility_Tester::CVideoPlaylistUtility_Tester |
|
65 // |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CVideoPlaylistUtility_Tester::CVideoPlaylistUtility_Tester() |
|
69 { |
|
70 } |
|
71 |
|
72 // ------------------------------------------------------------------------------------------------- |
|
73 // CVideoPlaylistUtility_Tester::CreateEngineL |
|
74 // ------------------------------------------------------------------------------------------------- |
|
75 // |
|
76 TInt CVideoPlaylistUtility_Tester::CreatePlaylistUtilityL( CStifItemParser& /*aItem*/ ) |
|
77 { |
|
78 iPlaylistUtility = CVideoPlaylistUtility::NewL(); |
|
79 |
|
80 return KErrNone; |
|
81 } |
|
82 |
|
83 |
|
84 // ------------------------------------------------------------------------------------------------- |
|
85 // CVideoPlaylistUtility_Tester::GetFileInfoL |
|
86 // ------------------------------------------------------------------------------------------------- |
|
87 // |
|
88 TInt CVideoPlaylistUtility_Tester::GetFileInfoL( CStifItemParser& aItem ) |
|
89 { |
|
90 CMediaRecognizer::TMediaType mediaType = CMediaRecognizer::ELocalRamFile; |
|
91 TInt error = KErrNone; |
|
92 |
|
93 TBool useFileHandle; |
|
94 TInt media; |
|
95 TBool expectedSingleLink; |
|
96 TBool expectedLocalFile; |
|
97 TBool singleLink; |
|
98 TBool localFile; |
|
99 |
|
100 User::LeaveIfError( aItem.GetNextInt( useFileHandle ) ); |
|
101 |
|
102 TFileName filename = GetFileNameAndPathL( aItem ); |
|
103 |
|
104 User::LeaveIfError( aItem.GetNextInt( media ) ); |
|
105 |
|
106 |
|
107 // Get the mediaType |
|
108 switch ( media ) |
|
109 { |
|
110 case ERamFile: |
|
111 { |
|
112 mediaType = CMediaRecognizer::ELocalRamFile; |
|
113 break; |
|
114 } |
|
115 case EAsxFile: |
|
116 { |
|
117 mediaType = CMediaRecognizer::ELocalAsxFile; |
|
118 break; |
|
119 } |
|
120 } |
|
121 |
|
122 if ( useFileHandle ) |
|
123 { |
|
124 RFs fs; |
|
125 RFile file; |
|
126 |
|
127 User::LeaveIfError( fs.Connect() ); |
|
128 |
|
129 fs.ShareProtected(); |
|
130 |
|
131 User::LeaveIfError( file.Open( fs, filename, EFileRead ) ); |
|
132 |
|
133 iPlaylistUtility->GetFileInfoL( file, mediaType, singleLink, localFile ); |
|
134 |
|
135 file.Close(); |
|
136 fs.Close(); |
|
137 } |
|
138 else |
|
139 { |
|
140 iPlaylistUtility->GetFileInfoL( filename, mediaType, singleLink, localFile ); |
|
141 } |
|
142 |
|
143 // Read the expected result |
|
144 User::LeaveIfError( aItem.GetNextInt( expectedSingleLink ) ); |
|
145 User::LeaveIfError( aItem.GetNextInt( expectedLocalFile ) ); |
|
146 |
|
147 if ( expectedSingleLink != singleLink || expectedLocalFile != localFile ) |
|
148 { |
|
149 error = KErrGeneral; |
|
150 } |
|
151 |
|
152 return error; |
|
153 } |
|
154 |
|
155 |
|
156 // ------------------------------------------------------------------------------------------------- |
|
157 // CVideoPlaylistUtility_Tester::GetLinkL |
|
158 // ------------------------------------------------------------------------------------------------- |
|
159 // |
|
160 TInt CVideoPlaylistUtility_Tester::GetLinkL( CStifItemParser& aItem ) |
|
161 { |
|
162 TInt error = KErrNone; |
|
163 |
|
164 _LIT( KRamStreamingLink, "rtsp://stream.3gp" ); |
|
165 _LIT( KAsxStreamingLink, "http://10.48.2.56:443/stream.wmv" ); |
|
166 |
|
167 #ifdef __WINSCW__ |
|
168 _LIT( KRamLocalLink, "c:\\data\\videos\\local.3gp" ); |
|
169 #else |
|
170 _LIT( KRamLocalLink, "e:\\testing\\data\\local.3gp" ); |
|
171 #endif |
|
172 |
|
173 TInt linkType; |
|
174 TPtrC link; |
|
175 |
|
176 User::LeaveIfError( aItem.GetNextInt( linkType ) ); |
|
177 |
|
178 link.Set(iPlaylistUtility->GetLinkLC()); |
|
179 |
|
180 // Get the linkType |
|
181 switch ( linkType ) |
|
182 { |
|
183 case ERamFileStreaming: |
|
184 { |
|
185 if ( link.CompareF(KRamStreamingLink) ) |
|
186 { |
|
187 error = KErrArgument; |
|
188 } |
|
189 break; |
|
190 } |
|
191 case ERamFileLocal: |
|
192 { |
|
193 if ( link.CompareF(KRamLocalLink) ) |
|
194 { |
|
195 error = KErrArgument; |
|
196 } |
|
197 break; |
|
198 } |
|
199 case EAsxFileStreaming: |
|
200 { |
|
201 if ( link.CompareF(KAsxStreamingLink) ) |
|
202 { |
|
203 error = KErrArgument; |
|
204 } |
|
205 break; |
|
206 } |
|
207 |
|
208 } |
|
209 |
|
210 CleanupStack::PopAndDestroy(); |
|
211 return error; |
|
212 } |
|
213 |
|
214 |
|
215 // ------------------------------------------------------------------------------------------------- |
|
216 // CVideoPlaylistUtility_Tester::GetPlaylistL |
|
217 // ------------------------------------------------------------------------------------------------- |
|
218 // |
|
219 TInt CVideoPlaylistUtility_Tester::GetPlaylistL( CStifItemParser& aItem ) |
|
220 { |
|
221 TInt error = KErrNone; |
|
222 TInt linkCount; |
|
223 TInt expectedCount; |
|
224 |
|
225 TInt accessPointId; |
|
226 TInt embeddedInfo; |
|
227 |
|
228 User::LeaveIfError( aItem.GetNextInt( accessPointId ) ); |
|
229 User::LeaveIfError( aItem.GetNextInt( expectedCount ) ); |
|
230 User::LeaveIfError( aItem.GetNextInt( embeddedInfo ) ); |
|
231 |
|
232 CMPXMedia* playlist = iPlaylistUtility->GetPlayListL(accessPointId); |
|
233 |
|
234 linkCount = playlist->ValueTObjectL<TInt>(KMPXMediaArrayCount); |
|
235 |
|
236 if ( linkCount != expectedCount ) |
|
237 { |
|
238 error = KErrArgument; |
|
239 } |
|
240 |
|
241 // Get the mediaType |
|
242 switch ( embeddedInfo ) |
|
243 { |
|
244 case EEmbeddedSeekInfo: |
|
245 { |
|
246 CMPXMediaArray* mediaArray = |
|
247 playlist->Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
248 |
|
249 for ( TInt i = 0; i < mediaArray->Count(); i++ ) |
|
250 { |
|
251 CMPXMedia* media = mediaArray->AtL( i ); |
|
252 if ( !(media->IsSupported( KMPXMediaGeneralExtVideoSeekable )) ) |
|
253 { |
|
254 // The test clip has all the links set to non seek } |
|
255 error = KErrArgument; |
|
256 break; |
|
257 } |
|
258 } |
|
259 break; |
|
260 } |
|
261 case ENoEmbeddedInfo: |
|
262 { |
|
263 CMPXMediaArray* mediaArray = |
|
264 playlist->Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
265 |
|
266 for ( TInt i = 0; i < mediaArray->Count(); i++ ) |
|
267 { |
|
268 CMPXMedia* media = mediaArray->AtL( i ); |
|
269 if ((media->IsSupported( KMPXMediaGeneralExtVideoSeekable )) ) |
|
270 { |
|
271 // The test clip has all the links set to non seek } |
|
272 error = KErrArgument; |
|
273 break; |
|
274 } |
|
275 } |
|
276 break; |
|
277 } |
|
278 default: |
|
279 { |
|
280 break; |
|
281 } |
|
282 } |
|
283 |
|
284 |
|
285 delete playlist; |
|
286 return error; |
|
287 } |
|
288 |
|
289 // ------------------------------------------------------------------------------------------------- |
|
290 // CVideoPlaylistUtility_Tester::IsSeekableL |
|
291 // ------------------------------------------------------------------------------------------------- |
|
292 // |
|
293 TInt CVideoPlaylistUtility_Tester::IsSeekableL( CStifItemParser& aItem ) |
|
294 { |
|
295 TInt error = KErrNone; |
|
296 TBool seekable; |
|
297 |
|
298 User::LeaveIfError( aItem.GetNextInt( seekable ) ); |
|
299 |
|
300 if ( seekable != iPlaylistUtility->IsSeekable()) |
|
301 { |
|
302 error = KErrArgument; |
|
303 } |
|
304 |
|
305 return error; |
|
306 } |
|
307 |
|
308 |
|
309 TFileName CVideoPlaylistUtility_Tester::GetFileNameAndPathL( CStifItemParser& aItem ) |
|
310 { |
|
311 TPtrC filename; |
|
312 |
|
313 #ifdef __WINSCW__ |
|
314 _LIT( KVideoTestPath, "c:\\data\\Videos\\" ); |
|
315 #else |
|
316 _LIT( KVideoTestPath, "e:\\testing\\data\\" ); |
|
317 #endif |
|
318 |
|
319 User::LeaveIfError( aItem.GetNextString( filename ) ); |
|
320 |
|
321 TFileName fullPath; |
|
322 |
|
323 fullPath.Append( KVideoTestPath ); |
|
324 |
|
325 fullPath.Append( filename ); |
|
326 |
|
327 return fullPath; |
|
328 } |
|
329 |
|
330 // EOF |