1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include "VedVideoClipInfoGeneratedImp.h" |
|
23 #include "VedMovieImp.h" |
|
24 #include "VedVideoClip.h" |
|
25 #include "VedVideoClipGenerator.h" |
|
26 |
|
27 #include <fbs.h> |
|
28 |
|
29 // Print macro |
|
30 #ifdef _DEBUG |
|
31 #include <e32svr.h> |
|
32 #define PRINT(x) RDebug::Print x |
|
33 #else |
|
34 #define PRINT(x) |
|
35 #endif |
|
36 |
|
37 |
|
38 CVedVideoClipInfoGeneratedImp::CVedVideoClipInfoGeneratedImp(CVedVideoClipGenerator& aGenerator, TBool aOwnsGenerator) |
|
39 : iGenerator(&aGenerator), iOwnsGenerator(aOwnsGenerator) |
|
40 { |
|
41 } |
|
42 |
|
43 |
|
44 void CVedVideoClipInfoGeneratedImp::ConstructL(MVedVideoClipInfoObserver& aObserver) |
|
45 { |
|
46 PRINT(_L("CVedVideoClipInfoGeneratedImp::ConstructL in")); |
|
47 |
|
48 iInfoOperation = CVedVideoClipInfoGeneratedOperation::NewL(this, aObserver); |
|
49 iAdapter = new (ELeave) CVedVideoClipGeneratedFrameToFrameAdapter(*this); |
|
50 |
|
51 PRINT(_L("CVedVideoClipInfoGeneratedImp::ConstructL out")); |
|
52 } |
|
53 |
|
54 |
|
55 CVedVideoClipInfoGeneratedImp::~CVedVideoClipInfoGeneratedImp() |
|
56 { |
|
57 PRINT(_L("CVedVideoClipInfoGeneratedImp::~CVedVideoClipInfoGeneratedImp in")); |
|
58 |
|
59 if ( iGenerator ) |
|
60 { |
|
61 if ( (TInt)iOwnsGenerator == (TInt)ETrue ) |
|
62 { |
|
63 delete iGenerator; |
|
64 } |
|
65 |
|
66 iGenerator = 0; |
|
67 } |
|
68 |
|
69 delete iInfoOperation; |
|
70 delete iAdapter; |
|
71 |
|
72 PRINT(_L("CVedVideoClipInfoGeneratedImp::~CVedVideoClipInfoGeneratedImp out")); |
|
73 } |
|
74 |
|
75 TPtrC CVedVideoClipInfoGeneratedImp::DescriptiveName() const |
|
76 { |
|
77 __ASSERT_ALWAYS(iReady, |
|
78 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
79 return iGenerator->DescriptiveName(); |
|
80 } |
|
81 |
|
82 CVedVideoClipGenerator* CVedVideoClipInfoGeneratedImp::Generator() const |
|
83 { |
|
84 __ASSERT_ALWAYS(iReady, |
|
85 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
86 return iGenerator; |
|
87 } |
|
88 |
|
89 |
|
90 TVedVideoClipClass CVedVideoClipInfoGeneratedImp::Class() const |
|
91 { |
|
92 __ASSERT_ALWAYS(iReady, |
|
93 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
94 return EVedVideoClipClassGenerated; |
|
95 } |
|
96 |
|
97 |
|
98 TInt CVedVideoClipInfoGeneratedImp::GetVideoFrameIndexL(TTimeIntervalMicroSeconds aTime) |
|
99 { |
|
100 __ASSERT_ALWAYS(iReady, |
|
101 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
102 return iGenerator->GetVideoFrameIndex(aTime); |
|
103 } |
|
104 |
|
105 |
|
106 void CVedVideoClipInfoGeneratedImp::GetFrameL(MVedVideoClipFrameObserver& aObserver, |
|
107 TInt aIndex, |
|
108 TSize* const aResolution, |
|
109 TDisplayMode aDisplayMode, |
|
110 TBool aEnhance, |
|
111 TInt aPriority) |
|
112 { |
|
113 PRINT(_L("CVedVideoClipInfoGeneratedImp::GetFrameL in")); |
|
114 __ASSERT_ALWAYS(iReady, |
|
115 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
116 iAdapter->iFrameObserver = &aObserver; |
|
117 iGenerator->GetFrameL(*iAdapter, aIndex, aResolution, aDisplayMode, aEnhance, aPriority); |
|
118 PRINT(_L("CVedVideoClipInfoGeneratedImp::GetFrameL out")); |
|
119 } |
|
120 |
|
121 |
|
122 void CVedVideoClipInfoGeneratedImp::CancelFrame() |
|
123 { |
|
124 PRINT(_L("CVedVideoClipInfoGeneratedImp::CancelFrame in")); |
|
125 |
|
126 __ASSERT_ALWAYS(iReady, |
|
127 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
128 iGenerator->CancelFrame(); |
|
129 PRINT(_L("CVedVideoClipInfoGeneratedImp::CancelFrame out")); |
|
130 } |
|
131 |
|
132 TPtrC CVedVideoClipInfoGeneratedImp::FileName() const |
|
133 { |
|
134 // Always panic |
|
135 TVedPanic::Panic(TVedPanic::EVideoClipInfoNoFileAssociated); |
|
136 |
|
137 // This will never be reached. |
|
138 return NULL; |
|
139 } |
|
140 |
|
141 |
|
142 RFile* CVedVideoClipInfoGeneratedImp::FileHandle() const |
|
143 { |
|
144 // Always panic |
|
145 TVedPanic::Panic(TVedPanic::EVideoClipInfoNoFileAssociated); |
|
146 |
|
147 // This will never be reached. |
|
148 return NULL; |
|
149 } |
|
150 |
|
151 |
|
152 TVedVideoFormat CVedVideoClipInfoGeneratedImp::Format() const |
|
153 { |
|
154 // Always panic |
|
155 TVedPanic::Panic(TVedPanic::EVideoClipInfoNoFileAssociated); |
|
156 |
|
157 // This will never be reached. |
|
158 return EVedVideoFormatUnrecognized; |
|
159 } |
|
160 |
|
161 |
|
162 TVedVideoType CVedVideoClipInfoGeneratedImp::VideoType() const |
|
163 { |
|
164 // Always panic |
|
165 TVedPanic::Panic(TVedPanic::EVideoClipInfoNoFileAssociated); |
|
166 |
|
167 // This will never be reached. |
|
168 return EVedVideoTypeUnrecognized; |
|
169 } |
|
170 |
|
171 |
|
172 TSize CVedVideoClipInfoGeneratedImp::Resolution() const |
|
173 { |
|
174 __ASSERT_ALWAYS(iReady, |
|
175 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
176 |
|
177 return iGenerator->Movie()->Resolution(); |
|
178 } |
|
179 |
|
180 |
|
181 TBool CVedVideoClipInfoGeneratedImp::HasAudio() const |
|
182 { |
|
183 __ASSERT_ALWAYS(iReady, |
|
184 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
185 |
|
186 return EFalse; |
|
187 } |
|
188 |
|
189 |
|
190 TVedAudioType CVedVideoClipInfoGeneratedImp::AudioType() const |
|
191 { |
|
192 // Always panic |
|
193 TVedPanic::Panic(TVedPanic::EVideoClipInfoNoFileAssociated); |
|
194 |
|
195 // This will never be reached. |
|
196 return EVedAudioTypeUnrecognized; |
|
197 } |
|
198 |
|
199 TVedAudioChannelMode CVedVideoClipInfoGeneratedImp::AudioChannelMode() const |
|
200 { |
|
201 // Always panic |
|
202 TVedPanic::Panic(TVedPanic::EVideoClipInfoNoFileAssociated); |
|
203 |
|
204 // This will never be reached. |
|
205 return EVedAudioChannelModeUnrecognized; |
|
206 } |
|
207 |
|
208 TInt CVedVideoClipInfoGeneratedImp::AudioSamplingRate() const |
|
209 { |
|
210 // Always panic |
|
211 TVedPanic::Panic(TVedPanic::EVideoClipInfoNoFileAssociated); |
|
212 |
|
213 // This will never be reached. |
|
214 return -1; |
|
215 } |
|
216 |
|
217 |
|
218 |
|
219 TTimeIntervalMicroSeconds CVedVideoClipInfoGeneratedImp::Duration() const |
|
220 { |
|
221 __ASSERT_ALWAYS(iReady, |
|
222 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
223 |
|
224 return iGenerator->Duration(); |
|
225 } |
|
226 |
|
227 |
|
228 TInt CVedVideoClipInfoGeneratedImp::VideoFrameCount() const |
|
229 { |
|
230 __ASSERT_ALWAYS(iReady, |
|
231 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
232 |
|
233 return iGenerator->VideoFrameCount(); |
|
234 } |
|
235 |
|
236 |
|
237 TTimeIntervalMicroSeconds CVedVideoClipInfoGeneratedImp::VideoFrameStartTimeL(TInt aIndex) |
|
238 { |
|
239 __ASSERT_ALWAYS(iReady, |
|
240 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
241 |
|
242 return iGenerator->VideoFrameStartTime(aIndex); |
|
243 } |
|
244 |
|
245 |
|
246 TTimeIntervalMicroSeconds CVedVideoClipInfoGeneratedImp::VideoFrameEndTimeL(TInt aIndex) |
|
247 { |
|
248 __ASSERT_ALWAYS(iReady, |
|
249 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
250 return iGenerator->VideoFrameEndTime(aIndex); |
|
251 } |
|
252 |
|
253 |
|
254 TTimeIntervalMicroSeconds CVedVideoClipInfoGeneratedImp::VideoFrameDurationL(TInt aIndex) |
|
255 { |
|
256 __ASSERT_ALWAYS(iReady, |
|
257 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
258 return iGenerator->VideoFrameDuration(aIndex); |
|
259 } |
|
260 |
|
261 |
|
262 TInt CVedVideoClipInfoGeneratedImp::VideoFrameSizeL(TInt /*aIndex*/) |
|
263 { |
|
264 __ASSERT_ALWAYS(iReady, |
|
265 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
266 |
|
267 // always panic |
|
268 TVedPanic::Panic(TVedPanic::EVideoClipInfoNoFileAssociated); |
|
269 |
|
270 // will never be reached |
|
271 return 0; |
|
272 } |
|
273 |
|
274 |
|
275 TBool CVedVideoClipInfoGeneratedImp::VideoFrameIsIntraL(TInt aIndex) |
|
276 { |
|
277 __ASSERT_ALWAYS(iReady, |
|
278 TVedPanic::Panic(TVedPanic::EVideoClipInfoNotReady)); |
|
279 |
|
280 if (aIndex == 0) |
|
281 { |
|
282 return ETrue; |
|
283 } |
|
284 return EFalse; |
|
285 } |
|
286 |
|
287 |
|
288 void CVedVideoClipInfoGeneratedImp::SetTranscodeFactor(TVedTranscodeFactor aFactor) |
|
289 { |
|
290 iTFactor.iStreamType =aFactor.iStreamType; |
|
291 iTFactor.iTRes = aFactor.iTRes; |
|
292 } |
|
293 |
|
294 TVedTranscodeFactor CVedVideoClipInfoGeneratedImp::TranscodeFactor() |
|
295 { |
|
296 return iTFactor; |
|
297 } |
|
298 |
|
299 |
|
300 TBool CVedVideoClipInfoGeneratedImp::IsMMSCompatible() |
|
301 { |
|
302 // Always panic |
|
303 TVedPanic::Panic(TVedPanic::EVideoClipInfoNoFileAssociated); |
|
304 |
|
305 // This will never be reached. |
|
306 return ETrue;; |
|
307 } |
|
308 |
|
309 |
|
310 CVedVideoClipInfoGeneratedOperation* CVedVideoClipInfoGeneratedOperation::NewL(CVedVideoClipInfoGeneratedImp* aInfo, |
|
311 MVedVideoClipInfoObserver& aObserver) |
|
312 { |
|
313 PRINT(_L("CVedVideoClipInfoGeneratedOperation::NewL in")); |
|
314 |
|
315 CVedVideoClipInfoGeneratedOperation* self = |
|
316 new (ELeave) CVedVideoClipInfoGeneratedOperation(aInfo, aObserver); |
|
317 CleanupStack::PushL(self); |
|
318 self->ConstructL(); |
|
319 CleanupStack::Pop(self); |
|
320 |
|
321 PRINT(_L("CVedVideoClipInfoGeneratedOperation::NewL out")); |
|
322 return self; |
|
323 } |
|
324 |
|
325 |
|
326 CVedVideoClipInfoGeneratedOperation::CVedVideoClipInfoGeneratedOperation(CVedVideoClipInfoGeneratedImp* aInfo, |
|
327 MVedVideoClipInfoObserver& aObserver) |
|
328 : CActive(EPriorityStandard), iInfo(aInfo) |
|
329 { |
|
330 PRINT(_L("CVedVideoClipInfoGeneratedOperation::CVedVideoClipInfoGeneratedOperation in")); |
|
331 |
|
332 iObserver = &aObserver; |
|
333 CActiveScheduler::Add(this); |
|
334 |
|
335 PRINT(_L("CVedVideoClipInfoGeneratedOperation::CVedVideoClipInfoGeneratedOperation out")); |
|
336 } |
|
337 |
|
338 |
|
339 void CVedVideoClipInfoGeneratedOperation::ConstructL() |
|
340 { |
|
341 PRINT(_L("CVedVideoClipInfoGeneratedOperation::ConstructL in")); |
|
342 |
|
343 SetActive(); |
|
344 TRequestStatus* status = &iStatus; |
|
345 User::RequestComplete(status, KErrNone); |
|
346 |
|
347 PRINT(_L("CVedVideoClipInfoGeneratedOperation::ConstructL out")); |
|
348 } |
|
349 |
|
350 |
|
351 CVedVideoClipInfoGeneratedOperation::~CVedVideoClipInfoGeneratedOperation() |
|
352 { |
|
353 Cancel(); |
|
354 } |
|
355 |
|
356 |
|
357 void CVedVideoClipInfoGeneratedOperation::RunL() |
|
358 { |
|
359 PRINT(_L("CVedVideoClipInfoGeneratedOperation::RunL in")); |
|
360 |
|
361 iInfo->iReady = ETrue; |
|
362 |
|
363 iObserver->NotifyVideoClipInfoReady(*iInfo, KErrNone); |
|
364 |
|
365 PRINT(_L("CVedVideoClipInfoGeneratedOperation::RunL out")); |
|
366 } |
|
367 |
|
368 |
|
369 void CVedVideoClipInfoGeneratedOperation::DoCancel() |
|
370 { |
|
371 } |
|
372 |
|
373 |
|
374 |
|
375 CVedVideoClipGeneratedFrameToFrameAdapter::CVedVideoClipGeneratedFrameToFrameAdapter(CVedVideoClipInfo& aInfo) |
|
376 : iInfo(aInfo) |
|
377 { |
|
378 } |
|
379 |
|
380 void CVedVideoClipGeneratedFrameToFrameAdapter::NotifyVideoClipGeneratorFrameCompleted( |
|
381 CVedVideoClipGenerator& /*aInfo*/, TInt aError, CFbsBitmap* aFrame) |
|
382 { |
|
383 iFrameObserver->NotifyVideoClipFrameCompleted(iInfo, aError, aFrame); |
|
384 } |
|