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 "VedMovieImp.h" |
|
23 #include "VedVideoClipGenerator.h" |
|
24 #include "movieprocessor.h" |
|
25 #include "VedVideosettings.h" |
|
26 #include "VedAudiosettings.h" |
|
27 #include <ecom/ecom.h> |
|
28 #include "VedAudioClipInfoImp.h" |
|
29 #include "AudSong.h" |
|
30 #include "AudClip.h" |
|
31 #include "AudClipInfo.h" |
|
32 #include "Vedqualitysettingsapi.h" |
|
33 #include "ctrtranscoder.h" |
|
34 #include "ctrtranscoderobserver.h" |
|
35 #include "vedproctimeestimate.h" |
|
36 #include "vedcodecchecker.h" |
|
37 |
|
38 #include <vedcommon.h> |
|
39 |
|
40 const TInt KVedAudioTrackIndex = 1; |
|
41 |
|
42 // Print macro |
|
43 #ifdef _DEBUG |
|
44 #include <e32svr.h> |
|
45 #define PRINT(x) RDebug::Print x |
|
46 #else |
|
47 #define PRINT(x) |
|
48 #endif |
|
49 |
|
50 |
|
51 |
|
52 // Near-dummy observer class for temporary transcoder instance. In practice is only used to provide input framerate |
|
53 // to the transcoder |
|
54 class CTrObs : public CBase, public MTRTranscoderObserver |
|
55 { |
|
56 public: |
|
57 /* Constructor & destructor */ |
|
58 |
|
59 inline CTrObs(TReal aFrameRate) : iInputFrameRate(aFrameRate) |
|
60 { |
|
61 }; |
|
62 inline ~CTrObs() |
|
63 { |
|
64 }; |
|
65 |
|
66 // Dummy methods from MTRTranscoderObserver, just used to complete the observer class |
|
67 inline void MtroInitializeComplete(TInt /*aError*/) |
|
68 { |
|
69 }; |
|
70 inline void MtroFatalError(TInt /*aError*/) |
|
71 { |
|
72 }; |
|
73 inline void MtroReturnCodedBuffer(CCMRMediaBuffer* /*aBuffer*/) |
|
74 { |
|
75 }; |
|
76 // method to provide clip input framerate to transcoder |
|
77 inline void MtroSetInputFrameRate(TReal& aRate) |
|
78 { |
|
79 aRate = iInputFrameRate; |
|
80 }; |
|
81 inline void MtroAsyncStopComplete() |
|
82 { |
|
83 }; |
|
84 |
|
85 inline void MtroSuspend() |
|
86 { |
|
87 }; |
|
88 |
|
89 inline void MtroResume() |
|
90 { |
|
91 }; |
|
92 |
|
93 private:// data |
|
94 |
|
95 // clip input framerate (fps) |
|
96 TReal iInputFrameRate; |
|
97 |
|
98 }; |
|
99 |
|
100 |
|
101 // -------- Local functions --------- |
|
102 |
|
103 // Map video format mimetype to editor's internal enumeration |
|
104 static TVedVideoFormat MapVideoFormatTypes(const TText8* aVideoFormatType) |
|
105 { |
|
106 TPtrC8 mimeType(aVideoFormatType); |
|
107 TBuf8<256> string; |
|
108 string = _L8("video/3gpp"); |
|
109 |
|
110 if ( mimeType.MatchF( (const TDesC8& )string ) != KErrNotFound ) |
|
111 { |
|
112 return EVedVideoFormat3GPP; |
|
113 } |
|
114 else |
|
115 { |
|
116 string = _L8("video/mp4"); |
|
117 if ( mimeType.MatchF( (const TDesC8& )string ) != KErrNotFound ) |
|
118 { |
|
119 return EVedVideoFormatMP4; |
|
120 } |
|
121 } |
|
122 |
|
123 return EVedVideoFormatUnrecognized; |
|
124 } |
|
125 |
|
126 // Map video codec mimetype to editor's internal enumeration |
|
127 static TVedVideoType MapVideoCodecTypes(const TText8* aVideoCodecType) |
|
128 { |
|
129 TPtrC8 mimeType(aVideoCodecType); |
|
130 TBuf8<256> string; |
|
131 string = _L8("video/H263*"); |
|
132 |
|
133 if ( mimeType.MatchF( (const TDesC8& )string ) != KErrNotFound ) |
|
134 { |
|
135 // H.263 |
|
136 string = _L8("*level*"); |
|
137 if ( mimeType.MatchF( (const TDesC8& )string ) != KErrNotFound ) |
|
138 { |
|
139 string = _L8("*level=10"); |
|
140 if ( mimeType.MatchF( (const TDesC8& )string ) != KErrNotFound ) |
|
141 { |
|
142 return EVedVideoTypeH263Profile0Level10; |
|
143 } |
|
144 string = _L8("*level=45"); |
|
145 if ( mimeType.MatchF( (const TDesC8& )string ) != KErrNotFound ) |
|
146 { |
|
147 return EVedVideoTypeH263Profile0Level45; |
|
148 } |
|
149 } |
|
150 // no level specified => 10 |
|
151 return EVedVideoTypeH263Profile0Level10; |
|
152 } |
|
153 else |
|
154 { |
|
155 string = _L8("video/mp4v-es*"); |
|
156 if ( mimeType.MatchF( (const TDesC8& )string ) != KErrNotFound ) |
|
157 { |
|
158 return EVedVideoTypeMPEG4SimpleProfile; |
|
159 } |
|
160 |
|
161 else |
|
162 { |
|
163 string = _L8("video/h264*"); |
|
164 if ( mimeType.MatchF( (const TDesC8& )string ) != KErrNotFound ) |
|
165 { |
|
166 return EVedVideoTypeAVCBaselineProfile; |
|
167 } |
|
168 } |
|
169 } |
|
170 return EVedVideoTypeUnrecognized; |
|
171 } |
|
172 |
|
173 // Map editor's internal enumeration to video codec mimetype |
|
174 static void MapVideoCodecTypeToMime(TVedVideoType aType, TBufC8<255>& aMimeType) |
|
175 { |
|
176 switch ( aType ) |
|
177 { |
|
178 case EVedVideoTypeH263Profile0Level10: |
|
179 { |
|
180 aMimeType = KVedMimeTypeH263BaselineProfile; |
|
181 } |
|
182 break; |
|
183 case EVedVideoTypeH263Profile0Level45: |
|
184 { |
|
185 aMimeType = KVedMimeTypeH263Level45; |
|
186 } |
|
187 break; |
|
188 default: |
|
189 { |
|
190 //EVedVideoTypeMPEG4SimpleProfile |
|
191 aMimeType = KVedMimeTypeMPEG4Visual; |
|
192 } |
|
193 } |
|
194 } |
|
195 |
|
196 |
|
197 // Map audio codec fourcc to editor's internal enumeration |
|
198 static TAudType MapAudioCodecTypes(const TText8* aAudioCodecType) |
|
199 { |
|
200 TPtrC8 fourCCType(aAudioCodecType); |
|
201 TBuf8<256> string; |
|
202 string = _L8(" AMR"); |
|
203 |
|
204 if ( fourCCType.MatchF( (const TDesC8& )string ) != KErrNotFound ) |
|
205 { |
|
206 return EAudAMR; |
|
207 } |
|
208 else |
|
209 { |
|
210 string = _L8(" AAC"); |
|
211 if ( fourCCType.MatchF( (const TDesC8& )string ) != KErrNotFound ) |
|
212 { |
|
213 return EAudAAC_MPEG4; |
|
214 } |
|
215 |
|
216 } |
|
217 return EAudTypeUnrecognized; |
|
218 } |
|
219 |
|
220 // -------- Member functions --------- |
|
221 EXPORT_C CVedMovie* CVedMovie::NewL(RFs *aFs) |
|
222 { |
|
223 PRINT(_L("CVedMovie::NewL")); |
|
224 |
|
225 CVedMovieImp* self = (CVedMovieImp*)NewLC(aFs); |
|
226 CleanupStack::Pop(self); |
|
227 return self; |
|
228 } |
|
229 |
|
230 |
|
231 EXPORT_C CVedMovie* CVedMovie::NewLC(RFs *aFs) |
|
232 { |
|
233 PRINT(_L("CVedMovie::NewLC")); |
|
234 |
|
235 CVedMovieImp* self = new (ELeave) CVedMovieImp(aFs); |
|
236 CleanupStack::PushL(self); |
|
237 self->ConstructL(); |
|
238 return self; |
|
239 } |
|
240 |
|
241 |
|
242 CVedMovieImp::CVedMovieImp(RFs *aFs) |
|
243 : iFs(aFs), |
|
244 iVideoClipArray(8), // Initial size of video clip array is 8 |
|
245 iAudioClipInfoArray(8), // Initial size of audio clip array is 8 |
|
246 iObserverArray(4), // Initial size of observer array is 4 |
|
247 iStartTransitionEffect(EVedStartTransitionEffectNone), |
|
248 iEndTransitionEffect(EVedEndTransitionEffectNone), |
|
249 iQuality(EQualityAutomatic), |
|
250 iNotifyObserver(ETrue), |
|
251 iMovieProcessingObserver(0) |
|
252 { |
|
253 } |
|
254 |
|
255 |
|
256 void CVedMovieImp::ConstructL() |
|
257 { |
|
258 iAudSong = CAudSong::NewL(iFs); |
|
259 iAudSong->RegisterSongObserverL(this); |
|
260 iAddOperation = CVedMovieAddClipOperation::NewL(this); |
|
261 |
|
262 iCodecChecker = CVedCodecChecker::NewL(); |
|
263 iProcessor = CMovieProcessor::NewL(); |
|
264 |
|
265 PRINT((_L("CVedMovie::ConstructL() CVideoQualitySelector in use"))); |
|
266 iQualitySelector = CVideoQualitySelector::NewL(); |
|
267 |
|
268 CalculatePropertiesL(); |
|
269 } |
|
270 |
|
271 |
|
272 CVedMovieImp::~CVedMovieImp() |
|
273 { |
|
274 DoReset(); |
|
275 iObserverArray.Reset(); |
|
276 |
|
277 delete iAddOperation; |
|
278 delete iCodecChecker; |
|
279 delete iProcessor; |
|
280 |
|
281 delete iAudSong; |
|
282 delete iAddedVideoClipFilename; |
|
283 |
|
284 delete iQualitySelector; |
|
285 |
|
286 REComSession::FinalClose(); |
|
287 } |
|
288 |
|
289 CVedMovie::TVedMovieQuality CVedMovieImp::Quality() const |
|
290 { |
|
291 return iQuality; |
|
292 } |
|
293 |
|
294 void CVedMovieImp::SetQuality(TVedMovieQuality aQuality) |
|
295 { |
|
296 __ASSERT_ALWAYS(aQuality >= EQualityAutomatic && aQuality < EQualityLast, |
|
297 TVedPanic::Panic(TVedPanic::EMovieIllegalQuality)); |
|
298 if (aQuality != iQuality) |
|
299 { |
|
300 iOutputParamsSet = EFalse; |
|
301 TVedMovieQuality prevQuality = iQuality; |
|
302 iQuality = aQuality; |
|
303 TRAPD(err,CalculatePropertiesL());//should not leave with current implementation, but try to handle it anyway |
|
304 if ( err == KErrNone ) |
|
305 { |
|
306 // successful |
|
307 FireMovieQualityChanged(this); |
|
308 } |
|
309 else |
|
310 { |
|
311 // setting was not successful, use the previous value |
|
312 iQuality = prevQuality; |
|
313 TRAP(err,CalculatePropertiesL());// previous should always succee |
|
314 } |
|
315 |
|
316 } |
|
317 } |
|
318 |
|
319 TVedVideoFormat CVedMovieImp::Format() const |
|
320 { |
|
321 return iFormat; |
|
322 } |
|
323 |
|
324 TVedVideoType CVedMovieImp::VideoType() const |
|
325 { |
|
326 return iVideoType; |
|
327 } |
|
328 |
|
329 TSize CVedMovieImp::Resolution() const |
|
330 { |
|
331 return iResolution; |
|
332 } |
|
333 |
|
334 TInt CVedMovieImp::MaximumFramerate() const |
|
335 { |
|
336 return iMaximumFramerate; |
|
337 } |
|
338 |
|
339 TVedAudioType CVedMovieImp::AudioType() const |
|
340 { |
|
341 TAudType audioType = iAudSong->OutputFileProperties().iAudioType; |
|
342 TVedAudioType vedAudioType = EVedAudioTypeUnrecognized; |
|
343 |
|
344 if (iAudSong->ClipCount(KAllTrackIndices) == 0) |
|
345 { |
|
346 vedAudioType = EVedAudioTypeNoAudio; |
|
347 } |
|
348 else if (audioType == EAudAMR) |
|
349 { |
|
350 vedAudioType = EVedAudioTypeAMR; |
|
351 } |
|
352 else if (audioType == EAudAAC_MPEG4 ) |
|
353 { |
|
354 vedAudioType = EVedAudioTypeAAC_LC; |
|
355 } |
|
356 else if (audioType == EAudNoAudio) |
|
357 { |
|
358 vedAudioType = EVedAudioTypeNoAudio; |
|
359 } |
|
360 |
|
361 return vedAudioType; |
|
362 } |
|
363 |
|
364 TInt CVedMovieImp::AudioSamplingRate() const |
|
365 { |
|
366 return iAudSong->OutputFileProperties().iSamplingRate; |
|
367 } |
|
368 |
|
369 TVedAudioChannelMode CVedMovieImp::AudioChannelMode() const |
|
370 { |
|
371 TVedAudioChannelMode vedChannelMode = EVedAudioChannelModeUnrecognized; |
|
372 if (iAudSong->OutputFileProperties().iChannelMode == EAudStereo) |
|
373 { |
|
374 vedChannelMode = EVedAudioChannelModeStereo; |
|
375 } |
|
376 else if (iAudSong->OutputFileProperties().iChannelMode == EAudSingleChannel) |
|
377 { |
|
378 vedChannelMode = EVedAudioChannelModeSingleChannel; |
|
379 } |
|
380 else if (iAudSong->OutputFileProperties().iChannelMode == EAudDualChannel) |
|
381 { |
|
382 vedChannelMode = EVedAudioChannelModeDualChannel; |
|
383 } |
|
384 return vedChannelMode; |
|
385 } |
|
386 |
|
387 |
|
388 TVedBitrateMode CVedMovieImp::AudioBitrateMode() const |
|
389 { |
|
390 TVedBitrateMode vedBitrateMode = EVedBitrateModeUnrecognized; |
|
391 switch(iAudSong->OutputFileProperties().iBitrateMode) |
|
392 { |
|
393 case EAudConstant: |
|
394 vedBitrateMode = EVedBitrateModeConstant; |
|
395 break; |
|
396 case EAudVariable: |
|
397 vedBitrateMode = EVedBitrateModeVariable; |
|
398 break; |
|
399 default: |
|
400 TVedPanic::Panic(TVedPanic::EInternal); |
|
401 } |
|
402 return vedBitrateMode; |
|
403 } |
|
404 TInt CVedMovieImp::AudioBitrate() const |
|
405 { |
|
406 return iAudSong->OutputFileProperties().iBitrate; |
|
407 } |
|
408 |
|
409 TInt CVedMovieImp::VideoBitrate() const |
|
410 { |
|
411 // restricted bitrate: forces transcoding of video content to this bitrate |
|
412 return iVideoRestrictedBitrate; |
|
413 } |
|
414 |
|
415 TInt CVedMovieImp::VideoStandardBitrate() const |
|
416 { |
|
417 // the default bitrate to be used when encoding new content. This can be actually lower than the standard limit |
|
418 // but it is not restricted bitrate that would trigger transcoding to happen |
|
419 return iVideoStandardBitrate; |
|
420 } |
|
421 |
|
422 TReal CVedMovieImp::VideoFrameRate() const |
|
423 { |
|
424 return iVideoFrameRate; |
|
425 } |
|
426 |
|
427 // This must not be called for 3gp clips that should always have AMR audio |
|
428 // returns ETrue if aAudioProperties contain settings found in input (can be modified by this method) |
|
429 // and EFalse if client should decide what to do with them |
|
430 TBool CVedMovieImp::MatchAudioPropertiesWithInput( TAudFileProperties& aAudioProperties ) |
|
431 { |
|
432 // If there are no audio clips |
|
433 if (iAudSong->ClipCount(KAllTrackIndices) == 0) |
|
434 { |
|
435 return ETrue; |
|
436 } |
|
437 |
|
438 // Go through the audio clips and select the best one |
|
439 TAudFileProperties prop; |
|
440 TAudFileProperties highestProp; |
|
441 TBool highestPropFound = EFalse; |
|
442 |
|
443 for (TInt a = 0; a < iAudSong->ClipCount(KAllTrackIndices); a++) |
|
444 { |
|
445 CAudClip* clip = iAudSong->Clip(a, KAllTrackIndices); |
|
446 prop = clip->Info()->Properties(); |
|
447 |
|
448 if ( ( prop.iChannelMode == aAudioProperties.iChannelMode ) && |
|
449 ( prop.iSamplingRate == aAudioProperties.iSamplingRate ) ) |
|
450 { |
|
451 // there is a match => keep the properties |
|
452 PRINT((_L("CVedMovie::MatchAudioPropertiesWithInput() found preferred set from input, sampling rate & channels %d & %d"), prop.iSamplingRate, prop.iChannelMode)); |
|
453 return ETrue; |
|
454 } |
|
455 else |
|
456 { |
|
457 // need to stay within limits given by aAudioProperties (it has the highest preferred mode) |
|
458 if ( ( prop.iAudioType == aAudioProperties.iAudioType ) && |
|
459 ( prop.iSamplingRate <= aAudioProperties.iSamplingRate ) ) |
|
460 { |
|
461 // take the highest channelmode & sampling rate from input. |
|
462 if ( !highestPropFound || |
|
463 ( (prop.iSamplingRate > highestProp.iSamplingRate) || |
|
464 ( (prop.iSamplingRate == highestProp.iSamplingRate) && (prop.iChannelMode > highestProp.iChannelMode) ) ) ) |
|
465 { |
|
466 PRINT((_L("CVedMovie::MatchAudioPropertiesWithInput() found new highest prop from input, sampling rate & channels %d & %d"), prop.iSamplingRate, prop.iChannelMode)); |
|
467 highestProp.iAudioType = prop.iAudioType; |
|
468 highestProp.iChannelMode = prop.iChannelMode; |
|
469 highestProp.iSamplingRate = prop.iSamplingRate; |
|
470 highestPropFound = ETrue; |
|
471 } |
|
472 } |
|
473 } |
|
474 } |
|
475 |
|
476 // if we come here, there was no exact match found. Use the best one, if found |
|
477 if ( highestPropFound ) |
|
478 { |
|
479 // take the sampling rate and channel mode from inProp. Currently we support only 16k and 48k output, but this should be changed |
|
480 // once we know what we need to support; but requires synchronization with audio editor engine |
|
481 |
|
482 if ( iAudSong->AreOutputPropertiesSupported(highestProp)) |
|
483 { |
|
484 PRINT((_L("CVedMovie::MatchAudioPropertiesWithInput() selected audio parameters, sampling rate & channels %d & %d"), highestProp.iSamplingRate, highestProp.iChannelMode)); |
|
485 aAudioProperties.iChannelMode = highestProp.iChannelMode; |
|
486 aAudioProperties.iSamplingRate = highestProp.iSamplingRate; |
|
487 aAudioProperties.iBitrate = KAudBitRateDefault; //use default since we don't know the bitrate of the input. |
|
488 return ETrue; |
|
489 } |
|
490 else |
|
491 { |
|
492 // We have some AAC in the input but it is not any of our supported sampling rates. |
|
493 // The aAudioProperties may have 48k here but since we don't have such high input, better to use 16k in output |
|
494 PRINT((_L("CVedMovie::MatchAudioPropertiesWithInput() no good match with input"))); |
|
495 return EFalse; |
|
496 } |
|
497 } |
|
498 else |
|
499 { |
|
500 // Not even a close match |
|
501 PRINT((_L("CVedMovie::MatchAudioPropertiesWithInput() not even a close match with input"))); |
|
502 return EFalse; |
|
503 } |
|
504 |
|
505 } |
|
506 |
|
507 |
|
508 // Set video codec mimetype member variable, and also max values that level defines (e.g. max framerate; actual values are taken from quality set) |
|
509 void CVedMovieImp::SetVideoCodecMimeType(const TText8* aVideoCodecType) |
|
510 { |
|
511 TPtrC8 mimeType(aVideoCodecType); |
|
512 |
|
513 if ( mimeType.MatchF( KVedMimeTypeH263 ) != KErrNotFound ) |
|
514 { |
|
515 // H.263 baseline |
|
516 iVideoCodecMimeType.Set(KVedMimeTypeH263BaselineProfile); |
|
517 iMaximumFramerate = 15; |
|
518 } |
|
519 else if ( mimeType.MatchF( KVedMimeTypeH263BaselineProfile ) != KErrNotFound ) |
|
520 { |
|
521 // H.263 baseline |
|
522 iVideoCodecMimeType.Set(KVedMimeTypeH263BaselineProfile); |
|
523 iMaximumFramerate = 15; |
|
524 } |
|
525 else if (mimeType.MatchF( KVedMimeTypeH263Level45 ) != KErrNotFound ) |
|
526 { |
|
527 // H.263 level 45 |
|
528 iVideoCodecMimeType.Set(KVedMimeTypeH263Level45); |
|
529 iMaximumFramerate = 15; |
|
530 } |
|
531 else if (mimeType.MatchF( KVedMimeTypeMPEG4SimpleVisualProfileLevel2 ) != KErrNotFound ) |
|
532 { |
|
533 // MPEG-4 SP level 2 |
|
534 iVideoCodecMimeType.Set(KVedMimeTypeMPEG4SimpleVisualProfileLevel2); |
|
535 iMaximumFramerate = 15; |
|
536 } |
|
537 else if (mimeType.MatchF( KVedMimeTypeMPEG4SimpleVisualProfileLevel3 ) != KErrNotFound ) |
|
538 { |
|
539 // MPEG-4 SP level 3 |
|
540 iVideoCodecMimeType.Set(KVedMimeTypeMPEG4SimpleVisualProfileLevel3); |
|
541 iMaximumFramerate = 30; |
|
542 } |
|
543 else if (mimeType.MatchF( KVedMimeTypeMPEG4SimpleVisualProfileLevel4A ) != KErrNotFound ) |
|
544 { |
|
545 // MPEG-4 SP level 4a |
|
546 iVideoCodecMimeType.Set(KVedMimeTypeMPEG4SimpleVisualProfileLevel4A); |
|
547 iMaximumFramerate = 30; |
|
548 } |
|
549 else if (mimeType.MatchF( KVedMimeTypeMPEG4Visual ) != KErrNotFound ) |
|
550 { |
|
551 // MPEG-4 SP level 0 |
|
552 iVideoCodecMimeType.Set(KVedMimeTypeMPEG4SimpleVisualProfile); |
|
553 iMaximumFramerate = 15; |
|
554 } |
|
555 else if (mimeType.MatchF( KVedMimeTypeAVCBaselineProfileLevel1B ) != KErrNotFound ) |
|
556 { |
|
557 // AVC level 1b |
|
558 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel1B); |
|
559 iMaximumFramerate = 15; |
|
560 } |
|
561 else if (mimeType.MatchF( KVedMimeTypeAVCBaselineProfileLevel1_1 ) != KErrNotFound ) |
|
562 { |
|
563 // AVC level 1.1 |
|
564 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel1_1); |
|
565 iMaximumFramerate = 7.5; |
|
566 } |
|
567 else if (mimeType.MatchF( KVedMimeTypeAVCBaselineProfileLevel1_2 ) != KErrNotFound ) |
|
568 { |
|
569 // AVC level 1.2 |
|
570 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel1_2); |
|
571 iMaximumFramerate = 15; |
|
572 } |
|
573 //WVGA task |
|
574 else if (mimeType.MatchF( KVedMimeTypeAVCBaselineProfileLevel1_3 ) != KErrNotFound ) |
|
575 { |
|
576 // AVC level 1.3 |
|
577 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel1_3); |
|
578 iMaximumFramerate = 15; |
|
579 } |
|
580 else if (mimeType.MatchF( KVedMimeTypeAVCBaselineProfileLevel2 ) != KErrNotFound ) |
|
581 { |
|
582 // AVC level 2 |
|
583 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel2); |
|
584 iMaximumFramerate = 15; |
|
585 } |
|
586 else if (mimeType.MatchF( KVedMimeTypeAVCBaselineProfileLevel2_1 ) != KErrNotFound ) |
|
587 { |
|
588 // AVC level 2.1 |
|
589 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel2_1); |
|
590 iMaximumFramerate = 15; |
|
591 } |
|
592 else if (mimeType.MatchF( KVedMimeTypeAVCBaselineProfileLevel2_2 ) != KErrNotFound ) |
|
593 { |
|
594 // AVC level 2.2 |
|
595 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel2_2); |
|
596 iMaximumFramerate = 15; |
|
597 } |
|
598 else if (mimeType.MatchF( KVedMimeTypeAVCBaselineProfileLevel3 ) != KErrNotFound ) |
|
599 { |
|
600 // AVC level 3 |
|
601 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel3); |
|
602 iMaximumFramerate = 15; |
|
603 } |
|
604 else if (mimeType.MatchF( KVedMimeTypeAVCBaselineProfileLevel3_1 ) != KErrNotFound ) |
|
605 { |
|
606 // AVC level 3.1 |
|
607 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel3_1); |
|
608 iMaximumFramerate = 15; |
|
609 } |
|
610 else |
|
611 { |
|
612 // AVC level 1 |
|
613 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel1); |
|
614 iMaximumFramerate = 15; |
|
615 } |
|
616 |
|
617 } |
|
618 |
|
619 |
|
620 // ----------------------------------------------------------------------------- |
|
621 // CVedMovieImp::GetQCIFPropertiesL |
|
622 // Get settings for QCIF or subQCIF resolution; H.263, H.264 or MPEG-4 |
|
623 // This is a special case since it has also H.263 codec support. |
|
624 // (other items were commented in a header). |
|
625 // ----------------------------------------------------------------------------- |
|
626 // |
|
627 TInt CVedMovieImp::GetQCIFPropertiesL(SVideoQualitySet& aLocalQualitySet) |
|
628 { |
|
629 TInt foundQualitySetForLevelError = KErrNone; |
|
630 |
|
631 // QCIF and subQCIF are handled together, since they are covered by the same levels of the H.263, MPEG-4 and H.264. |
|
632 // We have the preferred video codec in iVideoType (based on input clips) |
|
633 |
|
634 if ( iVideoType == EVedVideoTypeAVCBaselineProfile ) |
|
635 { |
|
636 // first check if we support H.264 output |
|
637 // level 1B |
|
638 PRINT((_L("CVedMovie::GetQCIFPropertiesL() check H.264 level 1B"))); |
|
639 TRAP(foundQualitySetForLevelError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeAVCBaselineProfileLevel1B))); |
|
640 |
|
641 if ( foundQualitySetForLevelError == KErrNotSupported ) |
|
642 { |
|
643 // check H.264 level 1 instead |
|
644 PRINT((_L("CVedMovie::GetQCIFPropertiesL() check H.264 level 1"))); |
|
645 TRAP(foundQualitySetForLevelError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeAVCBaselineProfileLevel1))); |
|
646 if ( foundQualitySetForLevelError == KErrNotSupported ) |
|
647 { |
|
648 // H.264 @ QCIF is not supported. Fall back to H.263 (=> input is transcoded to H.263) |
|
649 PRINT((_L("CVedMovie::getQCIFPropertiesL() no set for MPEG-4 level 0, switch to H.263"))); |
|
650 iVideoType = EVedVideoTypeH263Profile0Level45; // use level 45 since it is better than 10, and we don't have bitrate restrictions here |
|
651 foundQualitySetForLevelError = GetQCIFPropertiesL(aLocalQualitySet); |
|
652 // keep H.263; H.264 may not be supported at all |
|
653 } |
|
654 } |
|
655 |
|
656 if ( foundQualitySetForLevelError == KErrNone ) |
|
657 { |
|
658 SetVideoCodecMimeType(aLocalQualitySet.iVideoCodecMimeType); |
|
659 } |
|
660 } |
|
661 else if ( iVideoType == EVedVideoTypeMPEG4SimpleProfile ) |
|
662 { |
|
663 // MPEG-4 @ QCIF is an exceptional case; should not happen for locally recorded clips, but support is kept here for compatibility |
|
664 PRINT((_L("CVedMovie::GetQCIFPropertiesL() check MPEG-4 level 0"))); |
|
665 TRAP(foundQualitySetForLevelError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeMPEG4SimpleVisualProfile))); |
|
666 if ( foundQualitySetForLevelError == KErrNotSupported ) |
|
667 { |
|
668 // MPEG-4 QCIF is not listed in the quality set. Use it with H.263 settings, except the codec type |
|
669 PRINT((_L("CVedMovie::GetQCIFPropertiesL() no set for MPEG-4 level 0, take settings from H.263"))); |
|
670 iVideoType = EVedVideoTypeH263Profile0Level10;// level 10 is comparable to level 0 of MPEG-4; level 0b is not used |
|
671 foundQualitySetForLevelError = GetQCIFPropertiesL(aLocalQualitySet); |
|
672 // change back to MPEG-4 |
|
673 iVideoType = EVedVideoTypeMPEG4SimpleProfile; |
|
674 } |
|
675 if ( foundQualitySetForLevelError == KErrNone ) |
|
676 { |
|
677 // set MPEG-4 MIME-type and other related settings; |
|
678 // also if the quality set showed H.263; this way we can support mpeg-4 even if it is not any of the preferred ones, since we have supported it earlier too... |
|
679 iVideoCodecMimeType.Set(KVedMimeTypeMPEG4SimpleVisualProfile); |
|
680 iMaximumFramerate = 15; |
|
681 } |
|
682 } |
|
683 else |
|
684 { |
|
685 // H.263 |
|
686 if ( iVideoType == EVedVideoTypeH263Profile0Level45 ) |
|
687 { |
|
688 PRINT((_L("CVedMovie::GetQCIFPropertiesL() check H.263 level 45"))); |
|
689 TRAP(foundQualitySetForLevelError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeH263Level45))); |
|
690 } |
|
691 if ( (iVideoType == EVedVideoTypeH263Profile0Level10) || (foundQualitySetForLevelError == KErrNotSupported) ) |
|
692 { |
|
693 PRINT((_L("CVedMovie::GetQCIFPropertiesL() check H.263 level 10"))); |
|
694 TRAP(foundQualitySetForLevelError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeH263))); |
|
695 } |
|
696 |
|
697 if ( foundQualitySetForLevelError == KErrNone ) |
|
698 { |
|
699 SetVideoCodecMimeType(aLocalQualitySet.iVideoCodecMimeType); |
|
700 } |
|
701 } |
|
702 // assume subQCIF can use other QCIF settings except resolution |
|
703 |
|
704 |
|
705 return foundQualitySetForLevelError; |
|
706 } |
|
707 |
|
708 |
|
709 // ----------------------------------------------------------------------------- |
|
710 // CVedMovieImp::GetCIFQVGAPropertiesL |
|
711 // Get settings for CIF or QVGA resolution; H.264 or MPEG-4 |
|
712 // Some encoders may not support both, hence we may need to change the resolution here |
|
713 // and that's why this is treated as a special case. |
|
714 // (other items were commented in a header). |
|
715 // ----------------------------------------------------------------------------- |
|
716 // |
|
717 TInt CVedMovieImp::GetCIFQVGAPropertiesL(TSize aSize, TReal aFrameRate, SVideoQualitySet& aLocalQualitySet) |
|
718 { |
|
719 TInt foundQualitySetForLevelError = KErrNone; |
|
720 |
|
721 // CIF and QVGA are handled together, since they are covered by the same levels of the MPEG-4 and H.264; |
|
722 // framerate brings a difference though. |
|
723 // We have the preferred video codec in iVideoType (based on input clips), and framerate in aFrameRate |
|
724 // so let's check the level first, and then additionally check if the resolution is supported. |
|
725 |
|
726 if ( iVideoType == EVedVideoTypeAVCBaselineProfile ) |
|
727 { |
|
728 // first check if we support H.264 output |
|
729 // try level 1.2; higher levels not supported yet, and hence aFrameRate has no impact; |
|
730 // level 1.1 is not seen relevant since it supports only 7.5 fps |
|
731 PRINT((_L("CVedMovie::GetCIFQVGAPropertiesL() check H.264 level 1.2"))); |
|
732 TRAP(foundQualitySetForLevelError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeAVCBaselineProfileLevel1_2))); |
|
733 if ( foundQualitySetForLevelError == KErrNotSupported ) |
|
734 { |
|
735 // H.264 level 1.2 is not supported; switch to MPEG-4 |
|
736 iVideoType = EVedVideoTypeMPEG4SimpleProfile; |
|
737 } |
|
738 } |
|
739 |
|
740 if ( iVideoType == EVedVideoTypeMPEG4SimpleProfile ) |
|
741 { |
|
742 // MPEG-4 was dominant in the input, OR H.264 is not supported in quality set. |
|
743 // The order is like this since MPEG-4 is generally more supported than H.264. |
|
744 // Hence this CANNOT handle the case where MPEG-4 CIF/QVGA is not in the quality set but H.264 is, but in that case it falls back to H.263 QCIF in the host method |
|
745 if ( aFrameRate > 15.0 ) |
|
746 { |
|
747 // check level 3 |
|
748 PRINT((_L("CVedMovie::GetCIFQVGAPropertiesL() check MPEG-4 level 3"))); |
|
749 TRAP(foundQualitySetForLevelError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeMPEG4SimpleVisualProfileLevel3))); |
|
750 } |
|
751 if ( (aFrameRate <= 15.0) || (foundQualitySetForLevelError == KErrNotSupported) ) |
|
752 { |
|
753 // try level 2 |
|
754 PRINT((_L("CVedMovie::GetCIFQVGAPropertiesL() check MPEG-4 level 2"))); |
|
755 TRAP(foundQualitySetForLevelError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeMPEG4SimpleVisualProfileLevel2))); |
|
756 } |
|
757 } |
|
758 |
|
759 if ( foundQualitySetForLevelError == KErrNotSupported ) |
|
760 { |
|
761 // these resolutions are not supported! The default one will be taken into use in CalculatePropertiesL |
|
762 PRINT((_L("CVedMovie::GetCIFQVGAPropertiesL() no support for CIF/QVGA found in quality set"))); |
|
763 return foundQualitySetForLevelError; |
|
764 } |
|
765 |
|
766 |
|
767 |
|
768 SVideoQualitySet tmpSet; |
|
769 TRAPD(resolutionSupported, iQualitySelector->GetVideoQualitySetL( tmpSet, aSize)); |
|
770 if ( resolutionSupported == KErrNotSupported ) |
|
771 { |
|
772 // the preferred resolution is not supported => must use the other one |
|
773 // the level was supported already, so no need to check support for the other one |
|
774 if ( aSize == KVedResolutionCIF ) |
|
775 { |
|
776 PRINT((_L("CVedMovie::GetCIFQVGAPropertiesL() CIF support not available, must use QVGA instead"))); |
|
777 iResolution = KVedResolutionQVGA; |
|
778 } |
|
779 else |
|
780 { |
|
781 PRINT((_L("CVedMovie::GetCIFQVGAPropertiesL() QVGA support not available, must use CIF instead"))); |
|
782 iResolution = KVedResolutionCIF; |
|
783 } |
|
784 } |
|
785 else |
|
786 { |
|
787 PRINT((_L("CVedMovie::GetCIFQVGAPropertiesL() resolution support ok"))); |
|
788 iResolution = aSize; |
|
789 } |
|
790 |
|
791 // at this point we must have found a suitable set |
|
792 SetVideoCodecMimeType(aLocalQualitySet.iVideoCodecMimeType); |
|
793 return foundQualitySetForLevelError; |
|
794 } |
|
795 |
|
796 |
|
797 // ----------------------------------------------------------------------------- |
|
798 // CVedMovieImp::GetVGAPropertiesL |
|
799 // Get settings for VGA resolution. If not supported, get High settings instead |
|
800 // (other items were commented in a header). |
|
801 // ----------------------------------------------------------------------------- |
|
802 // |
|
803 TInt CVedMovieImp::GetVGAPropertiesL(SVideoQualitySet& aLocalQualitySet) |
|
804 { |
|
805 TInt foundQualitySetForResolutionError = KErrNone; |
|
806 |
|
807 if ( iVideoType == EVedVideoTypeAVCBaselineProfile ) |
|
808 { |
|
809 PRINT((_L("CVedMovie::GetWVGAPropertiesL() check H.264 level 3.0"))); |
|
810 TRAP(foundQualitySetForResolutionError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeAVCBaselineProfileLevel3))); |
|
811 if (foundQualitySetForResolutionError == KErrNotSupported ) |
|
812 { |
|
813 PRINT((_L("CVedMovie::GetVGAPropertiesL() H.264 level 3.0 not supported"))); |
|
814 // H.264 level 3.0 is not supported; switch to MPEG-4 |
|
815 iVideoType = EVedVideoTypeMPEG4SimpleProfile; |
|
816 } |
|
817 else |
|
818 { |
|
819 PRINT((_L("CVedMovie::GetVGAPropertiesL() H.264 level 3.0 supported"))); |
|
820 iResolution = KVedResolutionVGA; |
|
821 SetVideoCodecMimeType(aLocalQualitySet.iVideoCodecMimeType); |
|
822 } |
|
823 } |
|
824 |
|
825 if ( iVideoType == EVedVideoTypeMPEG4SimpleProfile ) |
|
826 { |
|
827 // VGA; check MPEG-4 level 4a |
|
828 // Settings may not exist => trap the leave |
|
829 TRAP(foundQualitySetForResolutionError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeMPEG4SimpleVisualProfileLevel4A))); |
|
830 if ( foundQualitySetForResolutionError == KErrNotSupported ) |
|
831 { |
|
832 PRINT((_L("CVedMovie::GetVGAPropertiesL() VGA not supported as output, try highest supported"))); |
|
833 // No VGA, try the highest instead |
|
834 foundQualitySetForResolutionError = GetHighPropertiesL(aLocalQualitySet); |
|
835 } |
|
836 else |
|
837 { |
|
838 PRINT((_L("CVedMovie::GetVGAPropertiesL() VGA with MPEG-4 level 4a selected as output"))); |
|
839 iResolution = KVedResolutionVGA; |
|
840 SetVideoCodecMimeType(aLocalQualitySet.iVideoCodecMimeType); |
|
841 } |
|
842 } |
|
843 |
|
844 return foundQualitySetForResolutionError; |
|
845 } |
|
846 |
|
847 // ----------------------------------------------------------------------------- |
|
848 // CVedMovieImp::GetVGA16By9PropertiesL |
|
849 // Get settings for VGA 16:9 resolution. If not supported, get High settings instead |
|
850 // (other items were commented in a header). |
|
851 // ----------------------------------------------------------------------------- |
|
852 // |
|
853 TInt CVedMovieImp::GetVGA16By9PropertiesL(SVideoQualitySet& aLocalQualitySet) |
|
854 { |
|
855 TInt foundQualitySetForResolutionError = KErrNone; |
|
856 |
|
857 if ( iVideoType != EVedVideoTypeMPEG4SimpleProfile ) |
|
858 { |
|
859 // NOTE: max supported H.264/AVC level currently (1.2) allows only CIF 15 fps, no VGA. |
|
860 PRINT((_L("CVedMovie::GetVGA16By9PropertiesL() VGA & H.264 == NOT SUPPORTED"))); |
|
861 TVedPanic::Panic(TVedPanic::EInternal); |
|
862 } |
|
863 |
|
864 // VGA; check MPEG-4 level 4a |
|
865 // Settings may not exist => trap the leave |
|
866 TRAP(foundQualitySetForResolutionError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeMPEG4SimpleVisualProfileLevel4A))); |
|
867 if ( foundQualitySetForResolutionError == KErrNotSupported ) |
|
868 { |
|
869 PRINT((_L("CVedMovie::GetVGAPropertiesL() VGA 16:9 not supported as output, try highest supported"))); |
|
870 // No VGA, try the highest instead |
|
871 foundQualitySetForResolutionError = GetHighPropertiesL(aLocalQualitySet); |
|
872 } |
|
873 else |
|
874 { |
|
875 PRINT((_L("CVedMovie::GetVGAPropertiesL() VGA 16:9 with MPEG-4 level 4a selected as output"))); |
|
876 iResolution = KVedResolutionVGA16By9; |
|
877 SetVideoCodecMimeType(aLocalQualitySet.iVideoCodecMimeType); |
|
878 } |
|
879 return foundQualitySetForResolutionError; |
|
880 } |
|
881 |
|
882 //WVGA task |
|
883 // ----------------------------------------------------------------------------- |
|
884 // CVedMovieImp::GetWVGAPropertiesL |
|
885 // ----------------------------------------------------------------------------- |
|
886 // |
|
887 TInt CVedMovieImp::GetWVGAPropertiesL(SVideoQualitySet& aLocalQualitySet) |
|
888 { |
|
889 TInt foundQualitySetForResolutionError = KErrNone;; |
|
890 |
|
891 if ( iVideoType == EVedVideoTypeAVCBaselineProfile ) |
|
892 { |
|
893 PRINT((_L("CVedMovie::GetWVGAPropertiesL() check H.264 level 3.1"))); |
|
894 TRAP(foundQualitySetForResolutionError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeAVCBaselineProfileLevel3))); |
|
895 if (foundQualitySetForResolutionError == KErrNotSupported ) |
|
896 { |
|
897 PRINT((_L("CVedMovie::GetWVGAPropertiesL() H.264 level 3.0 not supported"))); |
|
898 // H.264 level 3.0 is not supported; switch to MPEG-4 |
|
899 iVideoType = EVedVideoTypeMPEG4SimpleProfile; |
|
900 } |
|
901 else |
|
902 { |
|
903 PRINT((_L("CVedMovie::GetWVGAPropertiesL() H.264 level 3.0 supported"))); |
|
904 iResolution = KVedResolutionWVGA; |
|
905 SetVideoCodecMimeType(aLocalQualitySet.iVideoCodecMimeType); |
|
906 } |
|
907 } |
|
908 |
|
909 if ( iVideoType == EVedVideoTypeMPEG4SimpleProfile ) |
|
910 { |
|
911 // Settings may not exist => trap the leave |
|
912 TRAP(foundQualitySetForResolutionError,iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, TPtrC8(KVedMimeTypeMPEG4SimpleVisualProfileLevel4A))); |
|
913 if ( foundQualitySetForResolutionError == KErrNotSupported ) |
|
914 { |
|
915 PRINT((_L("CVedMovie::GetWVGAPropertiesL() WVGA not supported as output, try highest supported"))); |
|
916 // No WVGA, try the highest instead |
|
917 foundQualitySetForResolutionError = GetHighPropertiesL(aLocalQualitySet); |
|
918 } |
|
919 else |
|
920 { |
|
921 PRINT((_L("CVedMovie::GetWVGAPropertiesL() WVGA with MPEG-4 level 4a selected as output"))); |
|
922 iResolution = KVedResolutionWVGA; |
|
923 SetVideoCodecMimeType(aLocalQualitySet.iVideoCodecMimeType); |
|
924 } |
|
925 |
|
926 } |
|
927 return foundQualitySetForResolutionError; |
|
928 |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CVedMovieImp::GetHighPropertiesL |
|
933 // Get settings for High quality and apply relevant parts to member variables; |
|
934 // the rest are applied in common part |
|
935 // (other items were commented in a header). |
|
936 // ----------------------------------------------------------------------------- |
|
937 // |
|
938 TInt CVedMovieImp::GetHighPropertiesL(SVideoQualitySet& aLocalQualitySet) |
|
939 { |
|
940 TInt foundQualitySetForResolutionError = KErrNone; |
|
941 |
|
942 PRINT((_L("CVedMovie::SetHighPropertiesL() use the highest supported"))); |
|
943 TRAP(foundQualitySetForResolutionError, iQualitySelector->GetVideoQualitySetL( aLocalQualitySet, CVideoQualitySelector::EVideoQualityHigh)); |
|
944 if ( foundQualitySetForResolutionError == KErrNone ) |
|
945 { |
|
946 iResolution.iWidth = aLocalQualitySet.iVideoWidth; |
|
947 iResolution.iHeight = aLocalQualitySet.iVideoHeight; |
|
948 iVideoType = MapVideoCodecTypes(aLocalQualitySet.iVideoCodecMimeType); |
|
949 SetVideoCodecMimeType(aLocalQualitySet.iVideoCodecMimeType); |
|
950 } |
|
951 else |
|
952 { |
|
953 // handled in the end of CalculatePropertiesL, but should not be possible to reach this since High should always exist |
|
954 } |
|
955 |
|
956 return foundQualitySetForResolutionError; |
|
957 } |
|
958 |
|
959 |
|
960 // ----------------------------------------------------------------------------- |
|
961 // CVedMovieImp::ApplyAutomaticPropertiesL |
|
962 // Apply the settings based on properties of input clips |
|
963 // (other items were commented in a header). |
|
964 // ----------------------------------------------------------------------------- |
|
965 // |
|
966 void CVedMovieImp::ApplyAutomaticPropertiesL(TAudFileProperties &aAudioProperties) |
|
967 { |
|
968 // Automatic quality selection |
|
969 |
|
970 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() automatic quality selected"))); |
|
971 TTimeIntervalMicroSeconds durationOfMP4MPEG4(0); |
|
972 TTimeIntervalMicroSeconds durationOfMP4AVC(0); |
|
973 |
|
974 TTimeIntervalMicroSeconds durationOf3gppH263(0); |
|
975 TTimeIntervalMicroSeconds durationOf3gppMPEG4(0); |
|
976 TTimeIntervalMicroSeconds durationOf3gppAVC(0); |
|
977 |
|
978 TTimeIntervalMicroSeconds durationOfVGA(0); |
|
979 TTimeIntervalMicroSeconds durationOfVGA16By9(0); |
|
980 TTimeIntervalMicroSeconds durationOfQVGA(0); |
|
981 TTimeIntervalMicroSeconds durationOfCIF(0); |
|
982 TTimeIntervalMicroSeconds durationOfQCIF(0); |
|
983 TTimeIntervalMicroSeconds durationOfSubQCIF(0); |
|
984 TReal frameRateOfQVGA(0); |
|
985 TReal frameRateOfCIF(0); |
|
986 TReal framerate(0); |
|
987 TBool audioOnlyMP4 = EFalse; |
|
988 |
|
989 //WVGA task |
|
990 TTimeIntervalMicroSeconds durationOfWVGA(0); |
|
991 TReal frameRateOfWVGA(0); |
|
992 |
|
993 iVideoType = EVedVideoTypeH263Profile0Level10; |
|
994 |
|
995 for (TInt i = 0; i < VideoClipCount(); i++) |
|
996 { |
|
997 CVedVideoClipInfo* currentInfo = VideoClip(i)->Info(); |
|
998 |
|
999 if (currentInfo->Class() == EVedVideoClipClassFile) |
|
1000 { |
|
1001 // Add up the durations of different resolution video |
|
1002 if (currentInfo->Resolution() == KVedResolutionSubQCIF) |
|
1003 { |
|
1004 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() subQCIF input"))); |
|
1005 durationOfSubQCIF= durationOfSubQCIF.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1006 } |
|
1007 else if (currentInfo->Resolution() == KVedResolutionQCIF) |
|
1008 { |
|
1009 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() QCIF input"))); |
|
1010 durationOfQCIF= durationOfQCIF.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1011 } |
|
1012 else if (currentInfo->Resolution() == KVedResolutionCIF) |
|
1013 { |
|
1014 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() CIF input"))); |
|
1015 durationOfCIF= durationOfCIF.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1016 framerate = (1000*currentInfo->VideoFrameCount())/(currentInfo->Duration().Int64()/1000); |
|
1017 if ( framerate > frameRateOfCIF ) |
|
1018 { |
|
1019 frameRateOfCIF = framerate; |
|
1020 } |
|
1021 } |
|
1022 else if (currentInfo->Resolution() == KVedResolutionQVGA) |
|
1023 { |
|
1024 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() QVGA input"))); |
|
1025 durationOfQVGA= durationOfQVGA.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1026 framerate = (1000*currentInfo->VideoFrameCount())/(currentInfo->Duration().Int64()/1000); |
|
1027 if ( framerate > frameRateOfQVGA ) |
|
1028 { |
|
1029 frameRateOfQVGA = framerate; |
|
1030 } |
|
1031 } |
|
1032 else if (currentInfo->Resolution() == KVedResolutionVGA16By9) |
|
1033 { |
|
1034 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() VGA 16:9 input"))); |
|
1035 durationOfVGA16By9 = durationOfVGA16By9.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1036 } |
|
1037 |
|
1038 else if (currentInfo->Resolution() == KVedResolutionVGA) |
|
1039 { |
|
1040 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() VGA input"))); |
|
1041 durationOfVGA= durationOfVGA.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1042 } |
|
1043 //WVGA task |
|
1044 else if (currentInfo->Resolution() == KVedResolutionWVGA) |
|
1045 { |
|
1046 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() WVGA input"))); |
|
1047 durationOfWVGA= durationOfWVGA.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1048 } |
|
1049 |
|
1050 |
|
1051 if (currentInfo->Format() == EVedVideoFormat3GPP) |
|
1052 { |
|
1053 if ( currentInfo->VideoType() == EVedVideoTypeMPEG4SimpleProfile ) |
|
1054 { |
|
1055 // 3gpp file with MPEG-4 video |
|
1056 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() 3gpp with MPEG-4 input"))); |
|
1057 durationOf3gppMPEG4 = durationOf3gppMPEG4.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1058 } |
|
1059 else if ( currentInfo->VideoType() == EVedVideoTypeAVCBaselineProfile ) |
|
1060 { |
|
1061 // 3gpp file with AVC video |
|
1062 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() 3gpp with AVC input"))); |
|
1063 durationOf3gppAVC = durationOf3gppAVC.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1064 // NOTE: Level 1B is assumed always for QCIF AVC in automatic input case. |
|
1065 } |
|
1066 else |
|
1067 { |
|
1068 // 3gpp file with H.263 video |
|
1069 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() 3gpp with H.263 input"))); |
|
1070 durationOf3gppH263 = durationOf3gppH263.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1071 if (currentInfo->VideoType() == EVedVideoTypeH263Profile0Level45) |
|
1072 { |
|
1073 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() 3gpp with H.263 L45 input"))); |
|
1074 iVideoType = EVedVideoTypeH263Profile0Level45; |
|
1075 } |
|
1076 } |
|
1077 } |
|
1078 |
|
1079 else if (currentInfo->Format() == EVedVideoFormatMP4) |
|
1080 { |
|
1081 |
|
1082 if ( currentInfo->VideoType() == EVedVideoTypeMPEG4SimpleProfile ) |
|
1083 { |
|
1084 // MP4 file with MPEG-4 video |
|
1085 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() MP4 with MPEG-4 input"))); |
|
1086 durationOfMP4MPEG4 = durationOfMP4MPEG4.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1087 } |
|
1088 |
|
1089 else if ( currentInfo->VideoType() == EVedVideoTypeAVCBaselineProfile ) |
|
1090 { |
|
1091 // MP4 file with AVC video |
|
1092 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() MP4 with AVC input"))); |
|
1093 durationOfMP4AVC = durationOfMP4AVC.Int64() + VideoClip(i)->EditedDuration().Int64(); |
|
1094 // NOTE: What about levels ? |
|
1095 } |
|
1096 |
|
1097 else |
|
1098 { |
|
1099 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() MP4 with other input, not supported"))); |
|
1100 TVedPanic::Panic(TVedPanic::EInternal); |
|
1101 } |
|
1102 |
|
1103 } |
|
1104 else |
|
1105 { |
|
1106 // Unknown format |
|
1107 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() not 3gpp nor MP4 , not supported"))); |
|
1108 TVedPanic::Panic(TVedPanic::EInternal); |
|
1109 } |
|
1110 } |
|
1111 } // end of for loop, all input has been checked now |
|
1112 |
|
1113 |
|
1114 |
|
1115 // |
|
1116 // Decide the output format |
|
1117 // |
|
1118 |
|
1119 // First check if we had any video |
|
1120 if ( (durationOfMP4MPEG4.Int64() == 0) && (durationOfMP4AVC.Int64() == 0) && |
|
1121 (durationOf3gppH263.Int64() == 0) && (durationOf3gppMPEG4.Int64() == 0) && (durationOf3gppAVC.Int64() == 0) |
|
1122 ) |
|
1123 { |
|
1124 // no video, check audio |
|
1125 for ( TInt i = 0; i < iAudSong->ClipCount(KVedAudioTrackIndex); i++) |
|
1126 { |
|
1127 if ( iAudSong->Clip(i, KVedAudioTrackIndex)->Info()->Properties().iAudioType == EAudAMR ) |
|
1128 { |
|
1129 // 3gpp |
|
1130 durationOf3gppH263 = durationOf3gppH263.Int64() + iAudSong->Clip(i, KVedAudioTrackIndex)->EditedDuration().Int64(); |
|
1131 } |
|
1132 else |
|
1133 { |
|
1134 // mp4; mark audio-only as Mpeg4 video at this point |
|
1135 durationOfMP4MPEG4 = durationOfMP4MPEG4.Int64() + iAudSong->Clip(i, KVedAudioTrackIndex)->EditedDuration().Int64(); |
|
1136 audioOnlyMP4 = ETrue; |
|
1137 } |
|
1138 } |
|
1139 } |
|
1140 |
|
1141 // Then decide the file format |
|
1142 if ( ( durationOfMP4MPEG4.Int64() + durationOfMP4AVC.Int64() > 0 ) && |
|
1143 ( ( durationOfMP4MPEG4.Int64() + durationOfMP4AVC.Int64() ) >= |
|
1144 ( durationOf3gppH263.Int64() + durationOf3gppMPEG4.Int64() + durationOf3gppAVC.Int64() ) ) ) |
|
1145 { |
|
1146 // majority of input is MP4 |
|
1147 iFormat = EVedVideoFormatMP4; |
|
1148 if ( audioOnlyMP4 ) |
|
1149 { |
|
1150 // no video, just audio, use highest quality; this branch is only used to skip the else-branches |
|
1151 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() audio only with MP4"))); |
|
1152 // iVideoType is set in GetHighPropertiesL based on high quality level |
|
1153 } |
|
1154 else if ( durationOfMP4MPEG4 > durationOfMP4AVC ) |
|
1155 { |
|
1156 // MP4, video is MPEG-4 |
|
1157 iVideoType = EVedVideoTypeMPEG4SimpleProfile; |
|
1158 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is MP4 with MPEG-4 video"))); |
|
1159 } |
|
1160 else |
|
1161 { |
|
1162 // MP4, video is AVC |
|
1163 iVideoType = EVedVideoTypeAVCBaselineProfile; |
|
1164 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is MP4 with AVC video"))); |
|
1165 } |
|
1166 } |
|
1167 else |
|
1168 { |
|
1169 // majority of input is 3gpp, or no video. Keep 3gpp as in previous versions |
|
1170 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is 3gpp or no video"))); |
|
1171 iFormat = EVedVideoFormat3GPP; |
|
1172 |
|
1173 if ((durationOf3gppMPEG4 > 0) && |
|
1174 (durationOf3gppMPEG4 >= durationOf3gppAVC) && |
|
1175 (durationOf3gppMPEG4 >= durationOf3gppH263)) |
|
1176 { |
|
1177 iVideoType = EVedVideoTypeMPEG4SimpleProfile; |
|
1178 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is 3gpp with MPEG-4 video"))); |
|
1179 } |
|
1180 |
|
1181 else if ((durationOf3gppAVC > 0) && |
|
1182 (durationOf3gppAVC >= durationOf3gppH263)) |
|
1183 { |
|
1184 iVideoType = EVedVideoTypeAVCBaselineProfile; |
|
1185 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is 3gpp with AVC video"))); |
|
1186 } |
|
1187 |
|
1188 else |
|
1189 { |
|
1190 // H.263 |
|
1191 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is 3gpp with H.263 video"))); |
|
1192 if ( iVideoType != EVedVideoTypeH263Profile0Level45 ) |
|
1193 { |
|
1194 //use level 10 as used in previous versions |
|
1195 iVideoType = EVedVideoTypeH263Profile0Level10; |
|
1196 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is 3gpp with H.263 L10 video"))); |
|
1197 } |
|
1198 |
|
1199 } |
|
1200 } |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 // Then decide the resolution |
|
1206 |
|
1207 |
|
1208 |
|
1209 // cannot use the iQualitySet since it overrides the video settings. Use this mainly for checking audio settings |
|
1210 SVideoQualitySet localQualitySet; |
|
1211 TInt foundQualitySetForResolutionError = KErrNone; |
|
1212 |
|
1213 if ( audioOnlyMP4 ) |
|
1214 { |
|
1215 // get video parameters for audio-only MP4 clip; audio-only 3gpp is handled as QCIF |
|
1216 foundQualitySetForResolutionError = GetHighPropertiesL(localQualitySet); |
|
1217 } |
|
1218 //WVGA task |
|
1219 else if ((durationOfWVGA > 0) && |
|
1220 (durationOfWVGA >= durationOfVGA) && |
|
1221 (durationOfWVGA >= durationOfVGA16By9) && |
|
1222 (durationOfWVGA >= durationOfQVGA) && |
|
1223 (durationOfWVGA >= durationOfCIF) && |
|
1224 (durationOfWVGA >= durationOfQCIF) && |
|
1225 (durationOfWVGA >= durationOfSubQCIF)) |
|
1226 { |
|
1227 // VGA |
|
1228 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is WVGA"))); |
|
1229 iResolution = KVedResolutionWVGA; |
|
1230 foundQualitySetForResolutionError = GetWVGAPropertiesL(localQualitySet); |
|
1231 } |
|
1232 else if ((durationOfVGA > 0) && |
|
1233 (durationOfVGA >= durationOfVGA16By9) && |
|
1234 (durationOfVGA >= durationOfQVGA) && |
|
1235 (durationOfVGA >= durationOfCIF) && |
|
1236 (durationOfVGA >= durationOfQCIF) && |
|
1237 (durationOfVGA >= durationOfSubQCIF)) |
|
1238 { |
|
1239 // VGA |
|
1240 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is VGA"))); |
|
1241 iResolution = KVedResolutionVGA; |
|
1242 foundQualitySetForResolutionError = GetVGAPropertiesL(localQualitySet); |
|
1243 } |
|
1244 |
|
1245 else if ((durationOfVGA16By9 > 0) && |
|
1246 (durationOfVGA16By9 >= durationOfCIF) && |
|
1247 (durationOfVGA16By9 >= durationOfQVGA) && |
|
1248 (durationOfVGA16By9 >= durationOfQCIF) && |
|
1249 (durationOfVGA16By9 >= durationOfSubQCIF)) |
|
1250 { |
|
1251 // VGA 16:9 |
|
1252 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is VGA 16:9"))); |
|
1253 iResolution = KVedResolutionVGA16By9; |
|
1254 foundQualitySetForResolutionError = GetVGA16By9PropertiesL(localQualitySet); |
|
1255 } |
|
1256 |
|
1257 else if ((durationOfCIF > 0) && |
|
1258 (durationOfCIF >= durationOfQVGA) && |
|
1259 (durationOfCIF >= durationOfQCIF) && |
|
1260 (durationOfCIF >= durationOfSubQCIF)) |
|
1261 { |
|
1262 // CIF, but may be translated to QVGA if CIF not supported as output |
|
1263 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is CIF"))); |
|
1264 iResolution = KVedResolutionCIF; |
|
1265 foundQualitySetForResolutionError = GetCIFQVGAPropertiesL(KVedResolutionCIF, frameRateOfCIF, localQualitySet); |
|
1266 // audio parameters set in the end |
|
1267 } |
|
1268 else if ((durationOfQVGA > 0) && |
|
1269 (durationOfQVGA >= durationOfQCIF) && |
|
1270 (durationOfQVGA >= durationOfSubQCIF)) |
|
1271 { |
|
1272 // QVGA, but may be translated to CIF if QVGA not supported as output |
|
1273 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is QVGA"))); |
|
1274 iResolution = KVedResolutionQVGA; |
|
1275 foundQualitySetForResolutionError = GetCIFQVGAPropertiesL(KVedResolutionQVGA, frameRateOfQVGA, localQualitySet); |
|
1276 // audio parameters set in the end |
|
1277 } |
|
1278 else if ((durationOfSubQCIF > 0) && |
|
1279 (durationOfSubQCIF > durationOfQCIF)) // keep the > and not >= since QCIF is better than subQCIF |
|
1280 { |
|
1281 // subQCIF is not that important but is kept here anyway |
|
1282 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is subQCIF"))); |
|
1283 iResolution = KVedResolutionSubQCIF; |
|
1284 foundQualitySetForResolutionError = GetQCIFPropertiesL(localQualitySet); |
|
1285 // audio parameters set in the end |
|
1286 } |
|
1287 else |
|
1288 { |
|
1289 // QCIF |
|
1290 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() majority of input is QCIF"))); |
|
1291 iResolution = KVedResolutionQCIF; |
|
1292 foundQualitySetForResolutionError = GetQCIFPropertiesL(localQualitySet); |
|
1293 // audio parameters set in the end |
|
1294 } |
|
1295 |
|
1296 if ( foundQualitySetForResolutionError == KErrNone ) |
|
1297 { |
|
1298 // iVideoType and MIME-type were set earlier. |
|
1299 iVideoStandardBitrate = localQualitySet.iVideoBitRate; |
|
1300 iVideoFrameRate = localQualitySet.iVideoFrameRate; |
|
1301 iRandomAccessRate = localQualitySet.iRandomAccessRate; |
|
1302 // audio parameters set in the end |
|
1303 } |
|
1304 |
|
1305 |
|
1306 // Then handle cases where we didn't found suitable output format based on input resolution |
|
1307 // (i.e. we can't generate output that matches with majority of input) |
|
1308 if ( foundQualitySetForResolutionError == KErrNotSupported ) |
|
1309 { |
|
1310 |
|
1311 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() no suitable quality set found yet..."))); |
|
1312 // did not get preferred set from qualityselector; use highest one; may be overruled in MatchAudioPropertiesWithInput |
|
1313 if (iFormat == EVedVideoFormatMP4 ) |
|
1314 { |
|
1315 // MP4 => AAC |
|
1316 // High quality should be always present |
|
1317 |
|
1318 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() try taking the high quality"))); |
|
1319 TRAPD(err,iQualitySelector->GetVideoQualitySetL( localQualitySet, CVideoQualitySelector::EVideoQualityHigh)); |
|
1320 if ( err ) |
|
1321 { |
|
1322 // should not happen if the variation is done properly |
|
1323 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() problem in getting high quality set, ERROR"))); |
|
1324 User::Leave( err ); |
|
1325 } |
|
1326 |
|
1327 aAudioProperties.iAudioType = MapAudioCodecTypes(localQualitySet.iAudioFourCCType); |
|
1328 aAudioProperties.iSamplingRate = localQualitySet.iAudioSamplingRate; |
|
1329 if ( localQualitySet.iAudioChannels == 1 ) |
|
1330 { |
|
1331 aAudioProperties.iChannelMode = EAudSingleChannel; |
|
1332 } |
|
1333 else |
|
1334 { |
|
1335 aAudioProperties.iChannelMode = EAudStereo; |
|
1336 } |
|
1337 aAudioProperties.iBitrate = localQualitySet.iAudioBitRate; |
|
1338 // take also video settings from the new set |
|
1339 iResolution.iWidth = localQualitySet.iVideoWidth; |
|
1340 iResolution.iHeight = localQualitySet.iVideoHeight; |
|
1341 // MIME-type and bitrate |
|
1342 SetVideoCodecMimeType(localQualitySet.iVideoCodecMimeType); |
|
1343 iVideoStandardBitrate = localQualitySet.iVideoBitRate; |
|
1344 } |
|
1345 else |
|
1346 { |
|
1347 PRINT((_L("CVedMovie::ApplyAutomaticPropertiesL() use 3gpp"))); |
|
1348 // 3gp => use AMR |
|
1349 aAudioProperties.iAudioType = EAudAMR; |
|
1350 aAudioProperties.iSamplingRate = KVedAudioSamplingRate8k; |
|
1351 aAudioProperties.iChannelMode = EAudSingleChannel; |
|
1352 aAudioProperties.iBitrate = KAudBitRateDefault; //use default. |
|
1353 // set also video settings for 3gpp |
|
1354 iResolution = KVedResolutionQCIF; |
|
1355 // MIME-type and bitrate |
|
1356 iVideoCodecMimeType.Set(KVedMimeTypeH263); |
|
1357 iVideoStandardBitrate = KVedBitRateH263Level10; |
|
1358 } |
|
1359 |
|
1360 } |
|
1361 else |
|
1362 { |
|
1363 // preferred settings were got from quality set API without any error; take the audio settings too |
|
1364 |
|
1365 aAudioProperties.iAudioType = MapAudioCodecTypes(localQualitySet.iAudioFourCCType); |
|
1366 aAudioProperties.iSamplingRate = localQualitySet.iAudioSamplingRate; |
|
1367 if ( localQualitySet.iAudioChannels == 1 ) |
|
1368 { |
|
1369 aAudioProperties.iChannelMode = EAudSingleChannel; |
|
1370 } |
|
1371 else |
|
1372 { |
|
1373 aAudioProperties.iChannelMode = EAudStereo; |
|
1374 } |
|
1375 aAudioProperties.iBitrate = localQualitySet.iAudioBitRate; |
|
1376 } |
|
1377 |
|
1378 |
|
1379 |
|
1380 if ( aAudioProperties.iAudioType != EAudAMR ) |
|
1381 { |
|
1382 // still check that we don't do unnecessary audio transcoding. AMR output is not changed to anything else |
|
1383 if ( !MatchAudioPropertiesWithInput( aAudioProperties ) ) |
|
1384 { |
|
1385 // there was no input clip that matched the properties |
|
1386 |
|
1387 if ( foundQualitySetForResolutionError == KErrNotSupported ) |
|
1388 { |
|
1389 // the properties were taken from highest quality set after not finding a suitable set; better to ensure we have 16k |
|
1390 aAudioProperties.iSamplingRate = KVedAudioSamplingRate16k; |
|
1391 aAudioProperties.iChannelMode = EAudSingleChannel; |
|
1392 aAudioProperties.iBitrate = KAudBitRateDefault; //use default. |
|
1393 } |
|
1394 // else the properties were taken from a suitable set; convert audio to match them |
|
1395 |
|
1396 } |
|
1397 } |
|
1398 |
|
1399 } |
|
1400 |
|
1401 // ----------------------------------------------------------------------------- |
|
1402 // CVedMovieImp::ApplyRequestedPropertiesL |
|
1403 // Apply the settings the client requested |
|
1404 // (other items were commented in a header). |
|
1405 // ----------------------------------------------------------------------------- |
|
1406 // |
|
1407 void CVedMovieImp::ApplyRequestedPropertiesL(TAudFileProperties &aAudioProperties) |
|
1408 { |
|
1409 TBool legacyMode = EFalse; |
|
1410 |
|
1411 if (iQuality == EQualityMMSInteroperability) |
|
1412 { |
|
1413 // MMS interoperability settings |
|
1414 PRINT((_L("CVedMovie::ApplyRequestedPropertiesL() MMS quality selected"))); |
|
1415 // MMS interoperability should be always there => no leave |
|
1416 iQualitySelector->GetVideoQualitySetL( iQualitySet, CVideoQualitySelector::EVideoQualityMMS); |
|
1417 // map the set to member variables later |
|
1418 |
|
1419 } |
|
1420 |
|
1421 else if (iQuality == EQualityResolutionQCIF) |
|
1422 { |
|
1423 // this is a legacy branch, used only with older editor UI |
|
1424 PRINT((_L("CVedMovie::ApplyRequestedPropertiesL() QCIF quality selected; check level 45 vs level 10"))); |
|
1425 legacyMode = ETrue; |
|
1426 |
|
1427 iResolution = KVedResolutionQCIF; |
|
1428 |
|
1429 // Start with MMS and upgrade based on input if needed |
|
1430 iQualitySelector->GetVideoQualitySetL( iQualitySet, CVideoQualitySelector::EVideoQualityMMS); |
|
1431 iFormat = MapVideoFormatTypes(iQualitySet.iVideoFileMimeType); |
|
1432 iVideoType = MapVideoCodecTypes(iQualitySet.iVideoCodecMimeType); |
|
1433 |
|
1434 aAudioProperties.iAudioType = MapAudioCodecTypes(iQualitySet.iAudioFourCCType); |
|
1435 aAudioProperties.iSamplingRate = iQualitySet.iAudioSamplingRate; |
|
1436 if ( iQualitySet.iAudioChannels == 1 ) |
|
1437 { |
|
1438 aAudioProperties.iChannelMode = EAudSingleChannel; |
|
1439 } |
|
1440 else |
|
1441 { |
|
1442 aAudioProperties.iChannelMode = EAudStereo; |
|
1443 } |
|
1444 aAudioProperties.iBitrate = iQualitySet.iAudioBitRate; |
|
1445 |
|
1446 |
|
1447 for (TInt i = 0; i < VideoClipCount(); i++) |
|
1448 { |
|
1449 CVedVideoClipInfo* currentInfo = VideoClip(i)->Info(); |
|
1450 |
|
1451 // Go through all files and check if any are H.263 Profile0 Level45 |
|
1452 if (currentInfo->Class() == EVedVideoClipClassFile) |
|
1453 { |
|
1454 if (currentInfo->VideoType() == EVedVideoTypeH263Profile0Level45) |
|
1455 { |
|
1456 iVideoType = EVedVideoTypeH263Profile0Level45; |
|
1457 } |
|
1458 } |
|
1459 } |
|
1460 |
|
1461 |
|
1462 if ( iVideoType == EVedVideoTypeH263Profile0Level45 ) |
|
1463 { |
|
1464 iVideoCodecMimeType.Set(KVedMimeTypeH263Level45); |
|
1465 iVideoStandardBitrate = KVedBitRateH263Level45; |
|
1466 } |
|
1467 else |
|
1468 { |
|
1469 iVideoCodecMimeType.Set(KVedMimeTypeH263); |
|
1470 iVideoStandardBitrate = KVedBitRateH263Level10; |
|
1471 } |
|
1472 } |
|
1473 |
|
1474 else if (iQuality == EQualityResolutionCIF) |
|
1475 { |
|
1476 // this is a legacy branch, used only with older editor UI |
|
1477 PRINT((_L("CVedMovie::ApplyRequestedPropertiesL() CIF quality selected"))); |
|
1478 legacyMode = ETrue; |
|
1479 iFormat = EVedVideoFormatMP4; |
|
1480 iVideoType = EVedVideoTypeMPEG4SimpleProfile; |
|
1481 iResolution = KVedResolutionCIF; |
|
1482 iVideoCodecMimeType.Set(KVedMimeTypeMPEG4SimpleVisualProfileLevel2); |
|
1483 iVideoStandardBitrate = KVedBitRateMPEG4Level2; |
|
1484 // use 16 kHz mono AAC, as used to be the selection with CIF in older editor versions |
|
1485 aAudioProperties.iAudioType = EAudAAC_MPEG4; |
|
1486 aAudioProperties.iSamplingRate = KVedAudioSamplingRate16k; |
|
1487 aAudioProperties.iChannelMode = EAudSingleChannel; |
|
1488 aAudioProperties.iBitrate = KAudBitRateDefault; //use default. |
|
1489 } |
|
1490 else if (iQuality == EQualityResolutionMedium) |
|
1491 { |
|
1492 PRINT((_L("CVedMovie::ApplyRequestedPropertiesL() medium quality selected"))); |
|
1493 // Medium quality should be always there => no leave |
|
1494 iQualitySelector->GetVideoQualitySetL( iQualitySet, CVideoQualitySelector::EVideoQualityNormal); |
|
1495 // map the set to member variables later |
|
1496 |
|
1497 } |
|
1498 else if (iQuality == EQualityResolutionHigh) |
|
1499 { |
|
1500 PRINT((_L("CVedMovie::ApplyRequestedPropertiesL() high quality selected"))); |
|
1501 // High quality should be always there => no leave |
|
1502 iQualitySelector->GetVideoQualitySetL( iQualitySet, CVideoQualitySelector::EVideoQualityHigh); |
|
1503 // map the set to member variables later |
|
1504 |
|
1505 } |
|
1506 |
|
1507 if ( !legacyMode ) // legacyMode is forced CIF or QCIF; their parameters were set already, this is for others |
|
1508 { |
|
1509 // set common video settings from the obtained iQualitySet. In automatic case they were taken from input |
|
1510 iFormat = MapVideoFormatTypes(iQualitySet.iVideoFileMimeType); |
|
1511 iVideoType = MapVideoCodecTypes(iQualitySet.iVideoCodecMimeType); |
|
1512 iResolution.iWidth = iQualitySet.iVideoWidth; |
|
1513 iResolution.iHeight = iQualitySet.iVideoHeight; |
|
1514 iVideoFrameRate = iQualitySet.iVideoFrameRate; |
|
1515 iVideoStandardBitrate = iQualitySet.iVideoBitRate; // still not restricted => not necessary to transcode |
|
1516 SetVideoCodecMimeType(iQualitySet.iVideoCodecMimeType); |
|
1517 iRandomAccessRate = iQualitySet.iRandomAccessRate; |
|
1518 |
|
1519 aAudioProperties.iAudioType = MapAudioCodecTypes(iQualitySet.iAudioFourCCType); |
|
1520 aAudioProperties.iSamplingRate = iQualitySet.iAudioSamplingRate; |
|
1521 if ( iQualitySet.iAudioChannels == 1 ) |
|
1522 { |
|
1523 aAudioProperties.iChannelMode = EAudSingleChannel; |
|
1524 } |
|
1525 else |
|
1526 { |
|
1527 aAudioProperties.iChannelMode = EAudStereo; |
|
1528 } |
|
1529 aAudioProperties.iBitrate = iQualitySet.iAudioBitRate; |
|
1530 } |
|
1531 } |
|
1532 |
|
1533 |
|
1534 // ----------------------------------------------------------------------------- |
|
1535 // CVedMovieImp::CalculatePropertiesL |
|
1536 // Determine & apply the output properties for movie |
|
1537 // (other items were commented in a header). |
|
1538 // ----------------------------------------------------------------------------- |
|
1539 // |
|
1540 void CVedMovieImp::CalculatePropertiesL() |
|
1541 { |
|
1542 PRINT((_L("CVedMovie::CalculatePropertiesL() in"))); |
|
1543 |
|
1544 if (iOutputParamsSet) |
|
1545 return; |
|
1546 |
|
1547 if ( (VideoClipCount() == 0) && (AudioClipCount() == 0) ) |
|
1548 { |
|
1549 PRINT((_L("CVedMovie::CalculatePropertiesL() no clips in movie, out"))); |
|
1550 return; |
|
1551 } |
|
1552 |
|
1553 |
|
1554 // set some default values. These will be updated if needed, in the two functions called below |
|
1555 // default video framerate is 15 |
|
1556 iVideoFrameRate = iMaximumFramerate = 15.0; |
|
1557 // default random access rate is 1/5 fps |
|
1558 iRandomAccessRate = 0.2; |
|
1559 |
|
1560 TAudFileProperties audioProperties; |
|
1561 |
|
1562 if ( iQuality == EQualityAutomatic ) |
|
1563 { |
|
1564 // Automatic quality selection based on input |
|
1565 ApplyAutomaticPropertiesL(audioProperties); |
|
1566 } |
|
1567 else |
|
1568 { |
|
1569 // forced quality |
|
1570 ApplyRequestedPropertiesL(audioProperties); |
|
1571 } |
|
1572 |
|
1573 |
|
1574 |
|
1575 // Common finalization |
|
1576 |
|
1577 PRINT((_L("CVedMovie::CalculatePropertiesL() fileformat: %d"), iFormat)); |
|
1578 PRINT((_L("CVedMovie::CalculatePropertiesL() video codec, resolution, bitrate, framerate, random access rate: %d, (%d,%d), %d, %f, %f"), iVideoType, iResolution.iWidth, iResolution.iHeight, iVideoStandardBitrate, iVideoFrameRate, iRandomAccessRate)); |
|
1579 PRINT((_L("CVedMovie::CalculatePropertiesL() audio codec, samplingrate, channels: %d, %d, %d"), audioProperties.iAudioType, audioProperties.iSamplingRate, audioProperties.iChannelMode)); |
|
1580 |
|
1581 // Set the audio output properties here to the values specified above |
|
1582 if ( !iAudSong->SetOutputFileFormat(audioProperties.iAudioType, audioProperties.iSamplingRate,audioProperties.iChannelMode, audioProperties.iBitrate ) ) |
|
1583 { |
|
1584 PRINT((_L("CVedMovie::CalculatePropertiesL() iAudSong->SetOutputFileFormat failed, try again with default settings"))); |
|
1585 // something was wrong with the settings. Use default ones that should always work: |
|
1586 if ( audioProperties.iAudioType == EAudAMR ) |
|
1587 { |
|
1588 audioProperties.iSamplingRate = KVedAudioSamplingRate8k; |
|
1589 audioProperties.iChannelMode = EAudSingleChannel; |
|
1590 } |
|
1591 else |
|
1592 { |
|
1593 audioProperties.iAudioType = EAudAAC_MPEG4; |
|
1594 audioProperties.iSamplingRate = KVedAudioSamplingRate16k; |
|
1595 audioProperties.iChannelMode = EAudSingleChannel; |
|
1596 } |
|
1597 // try again; bitrate is default |
|
1598 iAudSong->SetOutputFileFormat(audioProperties.iAudioType, audioProperties.iSamplingRate, audioProperties.iChannelMode); |
|
1599 } |
|
1600 |
|
1601 } |
|
1602 |
|
1603 |
|
1604 void CVedMovieImp::SetAudioFadingL() |
|
1605 { |
|
1606 // Apply fading only if there are no specific dynamic level marks inserted. |
|
1607 // I.e. this is used only if audio volume is set by SetxxVolumeGainL or not set at all |
|
1608 if ( !iApplyDynamicLevelMark ) |
|
1609 { |
|
1610 |
|
1611 iNotifyObserver = EFalse; |
|
1612 for (TInt index = 0; index < VideoClipCount(); index++) |
|
1613 { |
|
1614 TBool fadeIn = EFalse; |
|
1615 TBool fadeOut = EFalse; |
|
1616 if ( index == 0 ) |
|
1617 { |
|
1618 // first clip, allow fade in always |
|
1619 fadeIn = ETrue; |
|
1620 } |
|
1621 else if (iVideoClipArray[index-1]->iMiddleTransitionEffect != EVedMiddleTransitionEffectNone) |
|
1622 { |
|
1623 // there is a transition effect before this clip, allow fade in |
|
1624 fadeIn = ETrue; |
|
1625 } |
|
1626 else |
|
1627 { |
|
1628 // no transition, no audio fading either |
|
1629 fadeIn = EFalse; |
|
1630 } |
|
1631 |
|
1632 if ( index == VideoClipCount()-1 ) |
|
1633 { |
|
1634 // last clip, allow fade out always |
|
1635 fadeOut = ETrue; |
|
1636 } |
|
1637 else if (iVideoClipArray[index]->iMiddleTransitionEffect != EVedMiddleTransitionEffectNone) |
|
1638 { |
|
1639 // there is a transition effect after this clip, allow fade out |
|
1640 fadeOut = ETrue; |
|
1641 } |
|
1642 else |
|
1643 { |
|
1644 // no transition, no audio fading either |
|
1645 fadeOut = EFalse; |
|
1646 } |
|
1647 |
|
1648 CVedVideoClip* clip = iVideoClipArray[index]; |
|
1649 |
|
1650 if (clip->EditedHasAudio() && !clip->IsMuted() && (fadeIn || fadeOut)) |
|
1651 { |
|
1652 |
|
1653 TTimeIntervalMicroSeconds clipLength = |
|
1654 TTimeIntervalMicroSeconds( clip->CutOutTime().Int64() - clip->CutInTime().Int64() ); |
|
1655 |
|
1656 // Do fading only if clip length is over 1 second |
|
1657 // Otherwise the original markers remain untouched |
|
1658 if ( clipLength > TTimeIntervalMicroSeconds(1000000) ) |
|
1659 { |
|
1660 // get normal level |
|
1661 TInt normalLevel = 0; |
|
1662 |
|
1663 // get normal level |
|
1664 |
|
1665 // NOTE: This assumes that the client has set a constant |
|
1666 // gain value for the whole clip, i.e. two markers, |
|
1667 // one at the beginning and other at the end |
|
1668 // iApplyDynamicLevelMark now controls that removing others is safe |
|
1669 |
|
1670 normalLevel = clip->GetVolumeGain(); |
|
1671 |
|
1672 // remove all existing markers |
|
1673 while (clip->DynamicLevelMarkCount()) |
|
1674 { |
|
1675 clip->RemoveDynamicLevelMark(0); |
|
1676 } |
|
1677 |
|
1678 // add movie-level volume gain |
|
1679 normalLevel += iVolumeGainForAllVideoClips; |
|
1680 |
|
1681 // use normal - 50dB as lower level; step in values is 0.5db |
|
1682 TInt lowLevel = normalLevel - 100; |
|
1683 if ( lowLevel < -127 ) |
|
1684 { |
|
1685 lowLevel = -127; |
|
1686 } |
|
1687 |
|
1688 // 0s: low |
|
1689 TVedDynamicLevelMark mark1(clip->CutInTime(), lowLevel); |
|
1690 |
|
1691 // 0.5s: normal |
|
1692 TTimeIntervalMicroSeconds time = |
|
1693 TTimeIntervalMicroSeconds(clip->CutInTime().Int64() + |
|
1694 TInt64(500000) ); |
|
1695 |
|
1696 TVedDynamicLevelMark mark2(time, normalLevel); |
|
1697 |
|
1698 // clip length - 0.5s: normal |
|
1699 time = TTimeIntervalMicroSeconds(clip->CutOutTime().Int64() - |
|
1700 TInt64(500000) ); |
|
1701 |
|
1702 TVedDynamicLevelMark mark3(time, normalLevel); |
|
1703 |
|
1704 // clip length: low |
|
1705 TVedDynamicLevelMark mark4(clip->CutOutTime(), lowLevel); |
|
1706 |
|
1707 if ( fadeIn ) |
|
1708 { |
|
1709 clip->InsertDynamicLevelMarkL(mark1); |
|
1710 clip->InsertDynamicLevelMarkL(mark2); |
|
1711 } |
|
1712 if ( fadeOut ) |
|
1713 { |
|
1714 clip->InsertDynamicLevelMarkL(mark3); |
|
1715 clip->InsertDynamicLevelMarkL(mark4); |
|
1716 } |
|
1717 } |
|
1718 } |
|
1719 } |
|
1720 |
|
1721 for (TInt index = 0; index < AudioClipCount(); index++) |
|
1722 { |
|
1723 CAudClip* clip = iAudSong->Clip(index, KVedAudioTrackIndex); |
|
1724 |
|
1725 if (!clip->Muting()) |
|
1726 { |
|
1727 |
|
1728 TTimeIntervalMicroSeconds clipLength = |
|
1729 TTimeIntervalMicroSeconds( clip->CutOutTime().Int64() - clip->CutInTime().Int64() ); |
|
1730 |
|
1731 // Do fading only if clip length is over 1 second |
|
1732 // Otherwise the original markers remain untouched |
|
1733 if ( clipLength > TTimeIntervalMicroSeconds(1000000) ) |
|
1734 { |
|
1735 // get normal level |
|
1736 TInt normalLevel = 0; |
|
1737 |
|
1738 // get normal level |
|
1739 |
|
1740 // NOTE: This assumes that the client has set a constant |
|
1741 // gain value for the whole clip, i.e. two markers, |
|
1742 // one at the beginning and other at the end |
|
1743 // iApplyDynamicLevelMark now controls that removing others is safe |
|
1744 |
|
1745 normalLevel = clip->GetVolumeGain(); |
|
1746 |
|
1747 // remove all existing markers |
|
1748 while (clip->DynamicLevelMarkCount()) |
|
1749 { |
|
1750 clip->RemoveDynamicLevelMark(0); |
|
1751 } |
|
1752 // add movie-level volume gain |
|
1753 normalLevel += iVolumeGainForAllAudioClips; |
|
1754 |
|
1755 // use normal - 50dB as lower level; step in values is 0.5db |
|
1756 TInt lowLevel = normalLevel - 100; |
|
1757 if ( lowLevel < -127 ) |
|
1758 { |
|
1759 lowLevel = -127; |
|
1760 } |
|
1761 |
|
1762 // 0s: low |
|
1763 TAudDynamicLevelMark mark1(clip->CutInTime(), lowLevel); |
|
1764 |
|
1765 // 0.5s: normal |
|
1766 TTimeIntervalMicroSeconds time = |
|
1767 TTimeIntervalMicroSeconds(clip->CutInTime().Int64() + |
|
1768 TInt64(500000) ); |
|
1769 |
|
1770 TAudDynamicLevelMark mark2(time, normalLevel); |
|
1771 |
|
1772 // clip length - 0.5s: normal |
|
1773 time = TTimeIntervalMicroSeconds(clip->CutOutTime().Int64() - |
|
1774 TInt64(500000) ); |
|
1775 |
|
1776 TAudDynamicLevelMark mark3(time, normalLevel); |
|
1777 |
|
1778 // clip length: low |
|
1779 TAudDynamicLevelMark mark4(clip->CutOutTime(), lowLevel); |
|
1780 |
|
1781 clip->InsertDynamicLevelMarkL(mark1); |
|
1782 clip->InsertDynamicLevelMarkL(mark2); |
|
1783 clip->InsertDynamicLevelMarkL(mark3); |
|
1784 clip->InsertDynamicLevelMarkL(mark4); |
|
1785 } |
|
1786 } |
|
1787 } |
|
1788 |
|
1789 iNotifyObserver = ETrue; |
|
1790 } |
|
1791 } |
|
1792 |
|
1793 void CVedMovieImp::SetOutputParametersL(TVedOutputParameters& aOutputParams) |
|
1794 { |
|
1795 PRINT((_L("CVedMovie::SetOutputParametersL(), aOutputParams: video %d, (%dx%d), %d bps, %ffps"), aOutputParams.iVideoType, aOutputParams.iVideoResolution.iWidth, aOutputParams.iVideoResolution.iHeight, aOutputParams.iVideoBitrate, aOutputParams.iVideoFrameRate)); |
|
1796 PRINT((_L("CVedMovie::SetOutputParametersL(), aOutputParams: audio %d, %d bps, s/m: %d, %d Hz"), aOutputParams.iAudioType, aOutputParams.iAudioBitrate, aOutputParams.iAudioChannelMode, aOutputParams.iAudioSamplingRate)); |
|
1797 PRINT((_L("CVedMovie::SetOutputParametersL(), aOutputParams: video segmentation: %d GOBs, %d bytes/segment"), aOutputParams.iSyncIntervalInPicture, aOutputParams.iSegmentSizeInBytes)); |
|
1798 |
|
1799 if (aOutputParams.iVideoType != EVedVideoTypeUnrecognized && |
|
1800 aOutputParams.iVideoType != EVedVideoTypeNoVideo) |
|
1801 { |
|
1802 iVideoType = aOutputParams.iVideoType; |
|
1803 } |
|
1804 |
|
1805 if ( (aOutputParams.iVideoResolution != TSize(0, 0)) && |
|
1806 (aOutputParams.iVideoResolution != KVedResolutionSubQCIF) && |
|
1807 (aOutputParams.iVideoResolution != KVedResolutionQCIF) && |
|
1808 (aOutputParams.iVideoResolution != KVedResolutionCIF) && |
|
1809 (aOutputParams.iVideoResolution != KVedResolutionQVGA) && |
|
1810 (aOutputParams.iVideoResolution != KVedResolutionVGA16By9) && |
|
1811 (aOutputParams.iVideoResolution != KVedResolutionVGA) && |
|
1812 (aOutputParams.iVideoResolution != KVedResolutionWVGA) ) |
|
1813 { |
|
1814 User::Leave(KErrNotSupported); |
|
1815 } |
|
1816 |
|
1817 #ifndef VIDEOEDITORENGINE_AVC_EDITING |
|
1818 if ( iVideoType == EVedVideoTypeAVCBaselineProfile ) |
|
1819 User::Leave(KErrNotSupported); |
|
1820 #endif |
|
1821 |
|
1822 // Allow AVC & MPEG-4 QVGA/CIF |
|
1823 if ( ( aOutputParams.iVideoResolution == KVedResolutionCIF ) || |
|
1824 ( aOutputParams.iVideoResolution == KVedResolutionQVGA ) ) |
|
1825 { |
|
1826 if ( iVideoType == EVedVideoTypeH263Profile0Level10 || |
|
1827 iVideoType == EVedVideoTypeH263Profile0Level45 ) |
|
1828 User::Leave(KErrNotSupported); |
|
1829 |
|
1830 } |
|
1831 // Allow MPEG VGA |
|
1832 if ( aOutputParams.iVideoResolution == KVedResolutionVGA ) |
|
1833 { |
|
1834 if ( iVideoType != EVedVideoTypeMPEG4SimpleProfile ) |
|
1835 User::Leave(KErrNotSupported); |
|
1836 } |
|
1837 |
|
1838 if (aOutputParams.iVideoResolution != TSize(0,0)) |
|
1839 iResolution = aOutputParams.iVideoResolution; |
|
1840 |
|
1841 switch (iVideoType) |
|
1842 { |
|
1843 case EVedVideoTypeH263Profile0Level10: |
|
1844 |
|
1845 // check bitrate |
|
1846 if ( aOutputParams.iVideoBitrate > KVedBitRateH263Level10 ) |
|
1847 User::Leave(KErrNotSupported); |
|
1848 iVideoCodecMimeType.Set(KVedMimeTypeH263); |
|
1849 break; |
|
1850 |
|
1851 case EVedVideoTypeH263Profile0Level45: |
|
1852 |
|
1853 // check bitrate |
|
1854 if ( aOutputParams.iVideoBitrate > KVedBitRateH263Level45 ) |
|
1855 User::Leave(KErrNotSupported); |
|
1856 iVideoCodecMimeType.Set(KVedMimeTypeH263Level45); |
|
1857 break; |
|
1858 |
|
1859 case EVedVideoTypeMPEG4SimpleProfile: |
|
1860 |
|
1861 // check bitrate |
|
1862 if ( iResolution == KVedResolutionCIF || iResolution == KVedResolutionQVGA ) |
|
1863 { |
|
1864 if ( aOutputParams.iVideoBitrate > KVedBitRateMPEG4Level2 ) |
|
1865 User::Leave(KErrNotSupported); |
|
1866 iVideoCodecMimeType.Set(KVedMimeTypeMPEG4SimpleVisualProfileLevel2); |
|
1867 } |
|
1868 |
|
1869 else if ( iResolution == KVedResolutionVGA || iResolution == KVedResolutionVGA16By9 ) |
|
1870 { |
|
1871 if ( aOutputParams.iVideoBitrate > KVedBitRateMPEG4Level4A ) |
|
1872 User::Leave(KErrNotSupported); |
|
1873 iVideoCodecMimeType.Set(KVedMimeTypeMPEG4SimpleVisualProfileLevel4A); |
|
1874 } |
|
1875 |
|
1876 else |
|
1877 { |
|
1878 if ( aOutputParams.iVideoBitrate > KVedBitRateMPEG4Level0 ) |
|
1879 User::Leave(KErrNotSupported); |
|
1880 iVideoCodecMimeType.Set(KVedMimeTypeMPEG4SimpleVisualProfile); |
|
1881 } |
|
1882 break; |
|
1883 |
|
1884 case EVedVideoTypeAVCBaselineProfile: |
|
1885 |
|
1886 // check bitrate |
|
1887 //WVGA task |
|
1888 if ( iResolution == KVedResolutionWVGA ) |
|
1889 { |
|
1890 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel3_1); |
|
1891 } |
|
1892 |
|
1893 else if ( iResolution == KVedResolutionCIF || iResolution == KVedResolutionQVGA ) |
|
1894 { |
|
1895 if ( aOutputParams.iVideoBitrate > KVedBitRateAVCLevel1_2 ) |
|
1896 User::Leave(KErrNotSupported); |
|
1897 if ( aOutputParams.iVideoBitrate <= KVedBitRateAVCLevel1_1 ) |
|
1898 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel1_1); |
|
1899 else |
|
1900 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel1_2); |
|
1901 } |
|
1902 else |
|
1903 { |
|
1904 if ( aOutputParams.iVideoBitrate > KVedBitRateAVCLevel1b ) |
|
1905 User::Leave(KErrNotSupported); |
|
1906 if ( aOutputParams.iVideoBitrate <= KVedBitRateAVCLevel1 ) |
|
1907 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel1); |
|
1908 else |
|
1909 iVideoCodecMimeType.Set(KVedMimeTypeAVCBaselineProfileLevel1B); |
|
1910 } |
|
1911 break; |
|
1912 |
|
1913 default: |
|
1914 User::Leave(KErrArgument); |
|
1915 |
|
1916 } |
|
1917 |
|
1918 // check if the selected codec/resolution is a supported format |
|
1919 TBool supported = iCodecChecker->IsSupportedOutputFormatL(iVideoCodecMimeType, iResolution); |
|
1920 if ( !supported ) |
|
1921 { |
|
1922 PRINT(_L("CVedMovie::SetOutputParametersL(), format not supported")); |
|
1923 User::Leave(KErrNotSupported); |
|
1924 } |
|
1925 |
|
1926 // can be zero => not used |
|
1927 iVideoStandardBitrate = iVideoRestrictedBitrate = aOutputParams.iVideoBitrate; |
|
1928 |
|
1929 // check frame rate |
|
1930 if (aOutputParams.iVideoFrameRate > KVedMaxVideoFrameRate) |
|
1931 User::Leave(KErrNotSupported); |
|
1932 |
|
1933 // default random access rate is 1/5 fps |
|
1934 iRandomAccessRate = 0.2; |
|
1935 |
|
1936 // can be zero => not used |
|
1937 iVideoFrameRate = aOutputParams.iVideoFrameRate; |
|
1938 |
|
1939 if (aOutputParams.iAudioType == EVedAudioTypeNoAudio) |
|
1940 { |
|
1941 // use default audio for this video |
|
1942 switch (iVideoType) |
|
1943 { |
|
1944 case EVedVideoTypeH263Profile0Level10: |
|
1945 case EVedVideoTypeH263Profile0Level45: |
|
1946 aOutputParams.iAudioType = EVedAudioTypeAMR; |
|
1947 break; |
|
1948 |
|
1949 case EVedVideoTypeMPEG4SimpleProfile: |
|
1950 case EVedVideoTypeAVCBaselineProfile: |
|
1951 default: |
|
1952 aOutputParams.iAudioType = EVedAudioTypeAAC_LC; |
|
1953 break; |
|
1954 } |
|
1955 |
|
1956 } |
|
1957 |
|
1958 if (aOutputParams.iAudioType != EVedAudioTypeAMR && |
|
1959 aOutputParams.iAudioType != EVedAudioTypeAAC_LC ) |
|
1960 User::Leave(KErrNotSupported); |
|
1961 |
|
1962 if ( aOutputParams.iAudioChannelMode != EVedAudioChannelModeStereo && |
|
1963 aOutputParams.iAudioChannelMode != EVedAudioChannelModeDualChannel && |
|
1964 aOutputParams.iAudioChannelMode != EVedAudioChannelModeSingleChannel ) |
|
1965 User::Leave(KErrArgument); |
|
1966 |
|
1967 if ( aOutputParams.iAudioType == EVedAudioTypeAMR ) |
|
1968 { |
|
1969 if ( aOutputParams.iAudioBitrate != 0 && |
|
1970 aOutputParams.iAudioBitrate != KVedAMRBitrate4_75k && |
|
1971 aOutputParams.iAudioBitrate != KVedAMRBitrate5_15k && |
|
1972 aOutputParams.iAudioBitrate != KVedAMRBitrate5_90k && |
|
1973 aOutputParams.iAudioBitrate != KVedAMRBitrate6_70k && |
|
1974 aOutputParams.iAudioBitrate != KVedAMRBitrate7_40k && |
|
1975 aOutputParams.iAudioBitrate != KVedAMRBitrate7_95k && |
|
1976 aOutputParams.iAudioBitrate != KVedAMRBitrate10_2k && |
|
1977 aOutputParams.iAudioBitrate != KVedAMRBitrate12_2k ) |
|
1978 { |
|
1979 User::Leave(KErrNotSupported); |
|
1980 } |
|
1981 |
|
1982 if ( aOutputParams.iAudioSamplingRate != 0 && |
|
1983 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate8k ) |
|
1984 User::Leave(KErrNotSupported); |
|
1985 |
|
1986 if ( aOutputParams.iAudioChannelMode != EVedAudioChannelModeSingleChannel ) |
|
1987 User::Leave(KErrNotSupported); |
|
1988 |
|
1989 } |
|
1990 |
|
1991 else if (aOutputParams.iAudioType == EVedAudioTypeAAC_LC) |
|
1992 { |
|
1993 if ( aOutputParams.iAudioSamplingRate != 0 && |
|
1994 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate8k && |
|
1995 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate11_025k && |
|
1996 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate12k && |
|
1997 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate16k && |
|
1998 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate22_050k && |
|
1999 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate24k && |
|
2000 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate32k && |
|
2001 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate44_1k && |
|
2002 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate48k && |
|
2003 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate64k && |
|
2004 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate88_2k && |
|
2005 aOutputParams.iAudioSamplingRate != KVedAudioSamplingRate96k ) |
|
2006 { |
|
2007 User::Leave(KErrNotSupported); |
|
2008 } |
|
2009 |
|
2010 TInt numChannels = 1; |
|
2011 if ( aOutputParams.iAudioChannelMode == EVedAudioChannelModeStereo || |
|
2012 aOutputParams.iAudioChannelMode == EVedAudioChannelModeDualChannel ) |
|
2013 numChannels = 2; |
|
2014 |
|
2015 TInt samplingRate = (aOutputParams.iAudioSamplingRate != 0) ? aOutputParams.iAudioSamplingRate : KVedAudioSamplingRate16k; |
|
2016 |
|
2017 TInt minBitrate = 1 * numChannels * samplingRate; |
|
2018 TInt maxBitrate = 6 * numChannels * samplingRate; |
|
2019 |
|
2020 if ( aOutputParams.iAudioBitrate > 0 && |
|
2021 (aOutputParams.iAudioBitrate < minBitrate || aOutputParams.iAudioBitrate > maxBitrate) ) |
|
2022 User::Leave(KErrNotSupported); |
|
2023 |
|
2024 } |
|
2025 |
|
2026 if ( iVideoType == EVedVideoTypeH263Profile0Level10 || |
|
2027 iVideoType == EVedVideoTypeH263Profile0Level45 ) |
|
2028 { |
|
2029 // For H.263 |
|
2030 iSyncIntervalInPicture = aOutputParams.iSyncIntervalInPicture; |
|
2031 |
|
2032 // Segment size not supported for H.263 |
|
2033 if ( aOutputParams.iSegmentSizeInBytes != 0 ) |
|
2034 User::Leave(KErrNotSupported); |
|
2035 } |
|
2036 else |
|
2037 { |
|
2038 // For H.264 and MPEG-4 |
|
2039 iSyncIntervalInPicture = aOutputParams.iSegmentSizeInBytes; |
|
2040 |
|
2041 // Sync interval not supported for H.264 and MPEG-4 |
|
2042 if ( aOutputParams.iSyncIntervalInPicture != 0 ) |
|
2043 User::Leave(KErrNotSupported); |
|
2044 } |
|
2045 |
|
2046 TAudFileProperties audioProperties; |
|
2047 |
|
2048 if (aOutputParams.iAudioType == EVedAudioTypeAMR) |
|
2049 audioProperties.iAudioType = EAudAMR; |
|
2050 |
|
2051 else if (aOutputParams.iAudioType == EVedAudioTypeAAC_LC) |
|
2052 audioProperties.iAudioType = EAudAAC_MPEG4; |
|
2053 |
|
2054 if (aOutputParams.iAudioBitrate > 0) |
|
2055 audioProperties.iBitrate = aOutputParams.iAudioBitrate; |
|
2056 |
|
2057 if (aOutputParams.iAudioSamplingRate > 0) |
|
2058 audioProperties.iSamplingRate = aOutputParams.iAudioSamplingRate; |
|
2059 |
|
2060 audioProperties.iChannelMode = EAudSingleChannel; |
|
2061 |
|
2062 if (aOutputParams.iAudioChannelMode == EVedAudioChannelModeStereo) |
|
2063 audioProperties.iChannelMode = EAudStereo; |
|
2064 |
|
2065 else if (aOutputParams.iAudioChannelMode == EAudDualChannel) |
|
2066 audioProperties.iChannelMode = EAudDualChannel; |
|
2067 |
|
2068 // Set the audio output properties here to the values specified above |
|
2069 if ( iAudSong->SetOutputFileFormat(audioProperties.iAudioType, audioProperties.iSamplingRate,audioProperties.iChannelMode, audioProperties.iBitrate) ) |
|
2070 { |
|
2071 iOutputParamsSet = ETrue; |
|
2072 FireMovieOutputParametersChanged(this); |
|
2073 } |
|
2074 else |
|
2075 { |
|
2076 // parameters didn't work |
|
2077 User::Leave( KErrArgument ); |
|
2078 } |
|
2079 } |
|
2080 |
|
2081 |
|
2082 TInt CVedMovieImp::CheckVideoClipInsertable(CVedVideoClip *aClip) const |
|
2083 { |
|
2084 /* Check format and video and audio types of a file-based clip. */ |
|
2085 if ( !aClip ) |
|
2086 { |
|
2087 return KErrGeneral; |
|
2088 } |
|
2089 |
|
2090 if (aClip->iInfo->Class() == EVedVideoClipClassFile) |
|
2091 { |
|
2092 if ( (aClip->iInfo->Format() != EVedVideoFormat3GPP) && |
|
2093 (aClip->iInfo->Format() != EVedVideoFormatMP4) |
|
2094 ) |
|
2095 { |
|
2096 return KErrNotSupported; |
|
2097 } |
|
2098 |
|
2099 if ( (aClip->iInfo->VideoType() != EVedVideoTypeH263Profile0Level10) && |
|
2100 (aClip->iInfo->VideoType() != EVedVideoTypeH263Profile0Level45) && |
|
2101 (aClip->iInfo->VideoType() != EVedVideoTypeMPEG4SimpleProfile) && |
|
2102 (aClip->iInfo->VideoType() != EVedVideoTypeAVCBaselineProfile) |
|
2103 ) |
|
2104 { |
|
2105 return KErrNotSupported; |
|
2106 } |
|
2107 |
|
2108 if ( (aClip->iInfo->AudioType() != EVedAudioTypeNoAudio) && |
|
2109 (aClip->iInfo->AudioType() != EVedAudioTypeAMR) && |
|
2110 (aClip->iInfo->AudioType() != EVedAudioTypeAMRWB) && |
|
2111 (aClip->iInfo->AudioType() != EVedAudioTypeAAC_LC) ) |
|
2112 { |
|
2113 return KErrNotSupported; |
|
2114 } |
|
2115 |
|
2116 if ( (aClip->iInfo->AudioType() != EVedAudioTypeNoAudio) && aClip->iInfo->AudioChannelMode() == EVedAudioChannelModeUnrecognized ) |
|
2117 { |
|
2118 return KErrNotSupported; |
|
2119 } |
|
2120 } |
|
2121 |
|
2122 if (aClip->Info()->Class() == EVedVideoClipClassFile) |
|
2123 { |
|
2124 TInt error = KErrNone; |
|
2125 TBool supported = EFalse; |
|
2126 |
|
2127 // check if clip format / resolution is supported |
|
2128 TRAP( error, supported = iCodecChecker->IsSupportedInputClipL(aClip) ); |
|
2129 |
|
2130 if ( error != KErrNone ) |
|
2131 { |
|
2132 return error; |
|
2133 } |
|
2134 |
|
2135 if ( !supported ) |
|
2136 { |
|
2137 PRINT(_L("CVedMovie::CheckVideoClipInsertable(), clip not supported")); |
|
2138 return KErrNotSupported; |
|
2139 } |
|
2140 } |
|
2141 |
|
2142 return KErrNone; |
|
2143 } |
|
2144 |
|
2145 |
|
2146 TInt CVedMovieImp::GetSizeEstimateL() const |
|
2147 { |
|
2148 PRINT(_L("CVedMovieImp::GetSizeEstimateL")); |
|
2149 |
|
2150 if ((VideoClipCount() == 0) && (AudioClipCount() == 0)) |
|
2151 { |
|
2152 return 0; |
|
2153 } |
|
2154 |
|
2155 if ( iProcessor ) |
|
2156 { |
|
2157 return iProcessor->GetMovieSizeEstimateL(this); |
|
2158 } |
|
2159 else |
|
2160 { |
|
2161 return 0; |
|
2162 } |
|
2163 } |
|
2164 |
|
2165 void CVedMovieImp::GetDurationEstimateL(TInt aTargetSize, |
|
2166 TTimeIntervalMicroSeconds aStartTime, |
|
2167 TTimeIntervalMicroSeconds& aEndTime) |
|
2168 { |
|
2169 if ((VideoClipCount() == 0) && (AudioClipCount() == 0)) |
|
2170 { |
|
2171 User::Leave( KErrNotReady ); |
|
2172 } |
|
2173 |
|
2174 if ( iProcessor ) |
|
2175 { |
|
2176 User::LeaveIfError( iProcessor->GetMovieSizeEstimateForMMSL(this, |
|
2177 aTargetSize, |
|
2178 aStartTime, |
|
2179 aEndTime) ); |
|
2180 } |
|
2181 else |
|
2182 { |
|
2183 User::Leave( KErrNotReady ); |
|
2184 } |
|
2185 } |
|
2186 |
|
2187 |
|
2188 TBool CVedMovieImp::IsMovieMMSCompatible() const |
|
2189 { |
|
2190 return ( ( iFormat == EVedVideoFormat3GPP ) && |
|
2191 ( iVideoType == EVedVideoTypeH263Profile0Level10 ) && |
|
2192 ( AudioType() == EVedAudioTypeAMR ) ); |
|
2193 } |
|
2194 |
|
2195 |
|
2196 void CVedMovieImp::InsertVideoClipL(const TDesC& aFileName, TInt aIndex) |
|
2197 { |
|
2198 PRINT(_L("CVedMovieImp::InsertVideoClipL")); |
|
2199 |
|
2200 __ASSERT_ALWAYS(iAddOperation->iVideoClip == 0, |
|
2201 TVedPanic::Panic(TVedPanic::EMovieAddOperationAlreadyRunning)); |
|
2202 iAddedVideoClipIndex = aIndex; |
|
2203 |
|
2204 if (iAddedVideoClipFilename) |
|
2205 { |
|
2206 delete iAddedVideoClipFilename; |
|
2207 iAddedVideoClipFilename = 0; |
|
2208 } |
|
2209 |
|
2210 iAddedVideoClipFilename = HBufC::NewL(aFileName.Size()); |
|
2211 *iAddedVideoClipFilename = aFileName; |
|
2212 iAddedVideoClipFileHandle = NULL; |
|
2213 |
|
2214 // add audio clip |
|
2215 TTimeIntervalMicroSeconds startTime(0); |
|
2216 |
|
2217 if (aIndex > 0) |
|
2218 { |
|
2219 startTime = VideoClipEndTime(aIndex - 1); |
|
2220 } |
|
2221 iAudSong->AddClipL(aFileName, startTime); |
|
2222 } |
|
2223 |
|
2224 void CVedMovieImp::InsertVideoClipL(RFile* aFileHandle, TInt aIndex) |
|
2225 { |
|
2226 PRINT(_L("CVedMovieImp::InsertVideoClipL")); |
|
2227 |
|
2228 __ASSERT_ALWAYS(iAddOperation->iVideoClip == 0, |
|
2229 TVedPanic::Panic(TVedPanic::EMovieAddOperationAlreadyRunning)); |
|
2230 iAddedVideoClipIndex = aIndex; |
|
2231 |
|
2232 if (iAddedVideoClipFilename) |
|
2233 { |
|
2234 delete iAddedVideoClipFilename; |
|
2235 iAddedVideoClipFilename = 0; |
|
2236 } |
|
2237 |
|
2238 iAddedVideoClipFileHandle = aFileHandle; |
|
2239 |
|
2240 // add audio clip |
|
2241 TTimeIntervalMicroSeconds startTime(0); |
|
2242 |
|
2243 if (aIndex > 0) |
|
2244 { |
|
2245 startTime = VideoClipEndTime(aIndex - 1); |
|
2246 } |
|
2247 iAudSong->AddClipL(aFileHandle, startTime); |
|
2248 } |
|
2249 |
|
2250 |
|
2251 |
|
2252 void CVedMovieImp::InsertVideoClipL(CVedVideoClipGenerator& aGenerator, |
|
2253 TBool aIsOwnedByVideoClip, TInt aIndex) |
|
2254 { |
|
2255 PRINT(_L("CVedMovieImp::InsertVideoClipL")); |
|
2256 |
|
2257 __ASSERT_ALWAYS(iAddOperation->iVideoClip == 0, |
|
2258 TVedPanic::Panic(TVedPanic::EMovieAddOperationAlreadyRunning)); |
|
2259 |
|
2260 iAddOperation->iVideoClip = CVedVideoClip::NewL(this, aGenerator, |
|
2261 aIndex, *iAddOperation, aIsOwnedByVideoClip); |
|
2262 iAddOperation->iIsVideoGeneratorOwnedByVideoClip = aIsOwnedByVideoClip; |
|
2263 } |
|
2264 |
|
2265 |
|
2266 void CVedMovieImp::RemoveVideoClip(TInt aIndex) |
|
2267 { |
|
2268 PRINT(_L("CVedMovieImp::RemoveVideoClip")); |
|
2269 |
|
2270 if ( (aIndex > VideoClipCount()) || (aIndex < 0) ) |
|
2271 { |
|
2272 return; |
|
2273 } |
|
2274 |
|
2275 CVedVideoClip* clip = iVideoClipArray[aIndex]; |
|
2276 TBool hasAudio = clip->EditedHasAudio(); |
|
2277 if (hasAudio) |
|
2278 { |
|
2279 iAudSong->RemoveClip(clip->iAudClip->IndexOnTrack(), 0); |
|
2280 } |
|
2281 |
|
2282 iVideoClipArray.Remove(aIndex); |
|
2283 delete clip; |
|
2284 |
|
2285 if (aIndex < VideoClipCount()) |
|
2286 { |
|
2287 clip = iVideoClipArray[aIndex]; |
|
2288 clip->iIndex = aIndex; |
|
2289 RecalculateVideoClipTimings(clip); |
|
2290 } |
|
2291 else if (VideoClipCount() > 0) |
|
2292 { |
|
2293 clip = iVideoClipArray[aIndex - 1]; |
|
2294 RecalculateVideoClipTimings(clip); |
|
2295 } |
|
2296 |
|
2297 TRAPD(err,CalculatePropertiesL());// ignore error? |
|
2298 if (err != KErrNone) { } |
|
2299 |
|
2300 FireVideoClipRemoved(this, aIndex); |
|
2301 } |
|
2302 |
|
2303 |
|
2304 void CVedMovieImp::RecalculateVideoClipTimings(CVedVideoClip* aVideoClip) |
|
2305 { |
|
2306 TInt index = aVideoClip->iIndex; |
|
2307 |
|
2308 TInt64 startTime; |
|
2309 if (index == 0) |
|
2310 { |
|
2311 startTime = 0; |
|
2312 } |
|
2313 else |
|
2314 { |
|
2315 startTime = iVideoClipArray[index - 1]->EndTime().Int64(); |
|
2316 } |
|
2317 |
|
2318 for (; index < VideoClipCount(); index++) |
|
2319 { |
|
2320 CVedVideoClip* clip = iVideoClipArray[index]; |
|
2321 clip->iIndex = index; |
|
2322 clip->iStartTime = startTime; |
|
2323 clip->UpdateAudioClip(); |
|
2324 startTime = clip->EndTime().Int64(); |
|
2325 } |
|
2326 iAudSong->SetDuration(Duration()); |
|
2327 } |
|
2328 |
|
2329 |
|
2330 void CVedMovieImp::SetStartTransitionEffect(TVedStartTransitionEffect aEffect) |
|
2331 { |
|
2332 __ASSERT_ALWAYS(VideoClipCount() > 0, TVedPanic::Panic(TVedPanic::EMovieEmpty)); |
|
2333 __ASSERT_ALWAYS((aEffect >= EVedStartTransitionEffectNone) |
|
2334 && (aEffect < EVedStartTransitionEffectLast), |
|
2335 TVedPanic::Panic(TVedPanic::EMovieIllegalStartTransitionEffect)); |
|
2336 |
|
2337 if (aEffect != iStartTransitionEffect) |
|
2338 { |
|
2339 iStartTransitionEffect = aEffect; |
|
2340 FireStartTransitionEffectChanged(this); |
|
2341 } |
|
2342 } |
|
2343 |
|
2344 |
|
2345 void CVedMovieImp::SetMiddleTransitionEffect(TVedMiddleTransitionEffect aEffect, |
|
2346 TInt aIndex) |
|
2347 { |
|
2348 __ASSERT_ALWAYS((aEffect >= EVedMiddleTransitionEffectNone) |
|
2349 && (aEffect < EVedMiddleTransitionEffectLast), |
|
2350 TVedPanic::Panic(TVedPanic::EMovieIllegalMiddleTransitionEffect)); |
|
2351 |
|
2352 if (aIndex == (iVideoClipArray.Count() - 1)) |
|
2353 { |
|
2354 aIndex++; // make aIndex out of range to cause panic |
|
2355 } |
|
2356 |
|
2357 if (aEffect != iVideoClipArray[aIndex]->iMiddleTransitionEffect) |
|
2358 { |
|
2359 iVideoClipArray[aIndex]->iMiddleTransitionEffect = aEffect; |
|
2360 FireMiddleTransitionEffectChanged(this, aIndex); |
|
2361 } |
|
2362 } |
|
2363 |
|
2364 |
|
2365 void CVedMovieImp::SetEndTransitionEffect(TVedEndTransitionEffect aEffect) |
|
2366 { |
|
2367 __ASSERT_ALWAYS(VideoClipCount() > 0, TVedPanic::Panic(TVedPanic::EMovieEmpty)); |
|
2368 __ASSERT_ALWAYS((aEffect >= EVedEndTransitionEffectNone) |
|
2369 && (aEffect < EVedEndTransitionEffectLast), |
|
2370 TVedPanic::Panic(TVedPanic::EMovieIllegalEndTransitionEffect)); |
|
2371 |
|
2372 if (aEffect != iEndTransitionEffect) |
|
2373 { |
|
2374 iEndTransitionEffect = aEffect; |
|
2375 FireEndTransitionEffectChanged(this); |
|
2376 } |
|
2377 } |
|
2378 |
|
2379 |
|
2380 void CVedMovieImp::AddAudioClipL(const TDesC& aFileName, |
|
2381 TTimeIntervalMicroSeconds aStartTime, |
|
2382 TTimeIntervalMicroSeconds aCutInTime, |
|
2383 TTimeIntervalMicroSeconds aCutOutTime) |
|
2384 { |
|
2385 __ASSERT_ALWAYS(iAddOperation->iVideoClip == 0, |
|
2386 TVedPanic::Panic(TVedPanic::EMovieAddOperationAlreadyRunning)); |
|
2387 |
|
2388 iAudSong->AddClipL(aFileName, aStartTime, KVedAudioTrackIndex, aCutInTime, aCutOutTime); |
|
2389 } |
|
2390 |
|
2391 void CVedMovieImp::AddAudioClipL(RFile* aFileHandle, |
|
2392 TTimeIntervalMicroSeconds aStartTime, |
|
2393 TTimeIntervalMicroSeconds aCutInTime, |
|
2394 TTimeIntervalMicroSeconds aCutOutTime) |
|
2395 { |
|
2396 __ASSERT_ALWAYS(iAddOperation->iVideoClip == 0, |
|
2397 TVedPanic::Panic(TVedPanic::EMovieAddOperationAlreadyRunning)); |
|
2398 |
|
2399 iAudSong->AddClipL(aFileHandle, aStartTime, KVedAudioTrackIndex, aCutInTime, aCutOutTime); |
|
2400 } |
|
2401 |
|
2402 |
|
2403 void CVedMovieImp::RemoveAudioClip(TInt aIndex) |
|
2404 { |
|
2405 iAudSong->RemoveClip(aIndex, KVedAudioTrackIndex); |
|
2406 } |
|
2407 |
|
2408 void CVedMovieImp::Reset() |
|
2409 { |
|
2410 DoReset(); |
|
2411 |
|
2412 FireMovieReseted(this); |
|
2413 } |
|
2414 |
|
2415 |
|
2416 void CVedMovieImp::DoReset() |
|
2417 { |
|
2418 iVideoClipArray.ResetAndDestroy(); |
|
2419 iAudioClipInfoArray.ResetAndDestroy(); |
|
2420 |
|
2421 iStartTransitionEffect = EVedStartTransitionEffectNone; |
|
2422 iEndTransitionEffect = EVedEndTransitionEffectNone; |
|
2423 |
|
2424 if (iAudSong != 0) |
|
2425 { |
|
2426 iAudSong->Reset(EFalse); |
|
2427 } |
|
2428 } |
|
2429 |
|
2430 |
|
2431 void CVedMovieImp::RegisterMovieObserverL(MVedMovieObserver* aObserver) |
|
2432 { |
|
2433 PRINT(_L("CVedMovieImp::RegisterMovieObserverL")); |
|
2434 |
|
2435 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2436 { |
|
2437 if (iObserverArray[i] == aObserver) |
|
2438 { |
|
2439 TVedPanic::Panic(TVedPanic::EMovieObserverAlreadyRegistered); |
|
2440 } |
|
2441 } |
|
2442 |
|
2443 User::LeaveIfError(iObserverArray.Append(aObserver)); |
|
2444 } |
|
2445 |
|
2446 |
|
2447 void CVedMovieImp::UnregisterMovieObserver(MVedMovieObserver* aObserver) |
|
2448 { |
|
2449 PRINT(_L("CVedMovieImp::UnregisterMovieObserver")); |
|
2450 |
|
2451 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2452 { |
|
2453 if (iObserverArray[i] == aObserver) |
|
2454 { |
|
2455 iObserverArray.Remove(i); |
|
2456 return; |
|
2457 } |
|
2458 } |
|
2459 } |
|
2460 |
|
2461 TBool CVedMovieImp::MovieObserverIsRegistered(MVedMovieObserver* aObserver) |
|
2462 { |
|
2463 PRINT(_L("CVedMovieImp::MovieObserverIsRegistered")); |
|
2464 |
|
2465 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2466 { |
|
2467 if (iObserverArray[i] == aObserver) |
|
2468 { |
|
2469 return ETrue; |
|
2470 } |
|
2471 } |
|
2472 |
|
2473 return EFalse; |
|
2474 } |
|
2475 |
|
2476 CVedVideoClipInfo* CVedMovieImp::VideoClipInfo(TInt aIndex) const |
|
2477 { |
|
2478 return iVideoClipArray[aIndex]->Info(); |
|
2479 } |
|
2480 |
|
2481 TBool CVedMovieImp::VideoClipEditedHasAudio(TInt aIndex) const |
|
2482 { |
|
2483 return iVideoClipArray[aIndex]->EditedHasAudio(); |
|
2484 } |
|
2485 |
|
2486 void CVedMovieImp::VideoClipSetIndex(TInt aOldIndex, TInt aNewIndex) |
|
2487 { |
|
2488 iVideoClipArray[aOldIndex]->SetIndex(aNewIndex); |
|
2489 } |
|
2490 |
|
2491 TInt CVedMovieImp::VideoClipSpeed(TInt aIndex) const |
|
2492 { |
|
2493 return iVideoClipArray[aIndex]->Speed(); |
|
2494 } |
|
2495 |
|
2496 void CVedMovieImp::VideoClipSetSpeed(TInt aIndex, TInt aSpeed) |
|
2497 { |
|
2498 iVideoClipArray[aIndex]->SetSpeed(aSpeed); |
|
2499 } |
|
2500 |
|
2501 TVedColorEffect CVedMovieImp::VideoClipColorEffect(TInt aIndex) const |
|
2502 { |
|
2503 return iVideoClipArray[aIndex]->ColorEffect(); |
|
2504 } |
|
2505 |
|
2506 void CVedMovieImp::VideoClipSetColorEffect(TInt aIndex, TVedColorEffect aColorEffect) |
|
2507 { |
|
2508 iVideoClipArray[aIndex]->SetColorEffect(aColorEffect); |
|
2509 } |
|
2510 |
|
2511 TBool CVedMovieImp::VideoClipIsMuteable(TInt aIndex) const |
|
2512 { |
|
2513 return iVideoClipArray[aIndex]->IsMuteable(); |
|
2514 } |
|
2515 |
|
2516 TBool CVedMovieImp::VideoClipIsMuted(TInt aIndex) const |
|
2517 { |
|
2518 return iVideoClipArray[aIndex]->IsMuted(); |
|
2519 } |
|
2520 |
|
2521 void CVedMovieImp::VideoClipSetMuted(TInt aIndex, TBool aMuted) |
|
2522 { |
|
2523 iVideoClipArray[aIndex]->SetMuted(aMuted); |
|
2524 } |
|
2525 |
|
2526 TBool CVedMovieImp::VideoClipNormalizing(TInt aIndex) const |
|
2527 { |
|
2528 return iVideoClipArray[aIndex]->Normalizing(); |
|
2529 } |
|
2530 |
|
2531 void CVedMovieImp::VideoClipSetNormalizing(TInt aIndex, TBool aNormalizing) |
|
2532 { |
|
2533 iVideoClipArray[aIndex]->SetNormalizing(aNormalizing); |
|
2534 } |
|
2535 |
|
2536 void CVedMovieImp::VideoClipInsertDynamicLevelMarkL(TInt aIndex, TVedDynamicLevelMark aMark) |
|
2537 { |
|
2538 __ASSERT_ALWAYS(aIndex >= 0, |
|
2539 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2540 |
|
2541 iApplyDynamicLevelMark = ETrue; |
|
2542 iVideoClipArray[aIndex]->InsertDynamicLevelMarkL(aMark); |
|
2543 } |
|
2544 |
|
2545 void CVedMovieImp::VideoClipRemoveDynamicLevelMark(TInt aClipIndex, TInt aMarkIndex) |
|
2546 { |
|
2547 __ASSERT_ALWAYS(aClipIndex >= 0, |
|
2548 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2549 |
|
2550 iVideoClipArray[aClipIndex]->RemoveDynamicLevelMark(aMarkIndex); |
|
2551 } |
|
2552 |
|
2553 TInt CVedMovieImp::VideoClipDynamicLevelMarkCount(TInt aIndex) const |
|
2554 { |
|
2555 __ASSERT_ALWAYS(aIndex >= 0, |
|
2556 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2557 |
|
2558 return iVideoClipArray[aIndex]->DynamicLevelMarkCount(); |
|
2559 } |
|
2560 |
|
2561 TVedDynamicLevelMark CVedMovieImp::VideoClipDynamicLevelMark(TInt aClipIndex, TInt aMarkIndex) |
|
2562 { |
|
2563 __ASSERT_ALWAYS(aClipIndex >= 0, |
|
2564 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2565 |
|
2566 return iVideoClipArray[aClipIndex]->DynamicLevelMark(aMarkIndex); |
|
2567 } |
|
2568 |
|
2569 TTimeIntervalMicroSeconds CVedMovieImp::VideoClipCutInTime(TInt aIndex) const |
|
2570 { |
|
2571 return iVideoClipArray[aIndex]->CutInTime(); |
|
2572 } |
|
2573 |
|
2574 void CVedMovieImp::VideoClipSetCutInTime(TInt aIndex, TTimeIntervalMicroSeconds aCutInTime) |
|
2575 { |
|
2576 iVideoClipArray[aIndex]->SetCutInTime(aCutInTime); |
|
2577 // basically we should call CalculatePropertiesL after this one, but since it is called in StartMovie, we can probably skip it |
|
2578 } |
|
2579 |
|
2580 TTimeIntervalMicroSeconds CVedMovieImp::VideoClipCutOutTime(TInt aIndex) const |
|
2581 { |
|
2582 return iVideoClipArray[aIndex]->CutOutTime(); |
|
2583 } |
|
2584 |
|
2585 void CVedMovieImp::VideoClipSetCutOutTime(TInt aIndex, TTimeIntervalMicroSeconds aCutOutTime) |
|
2586 { |
|
2587 iVideoClipArray[aIndex]->SetCutOutTime(aCutOutTime); |
|
2588 // basically we should call CalculatePropertiesL after this one, but since it is called in StartMovie, we can probably skip it |
|
2589 } |
|
2590 |
|
2591 TTimeIntervalMicroSeconds CVedMovieImp::VideoClipStartTime(TInt aIndex) const |
|
2592 { |
|
2593 return iVideoClipArray[aIndex]->StartTime(); |
|
2594 } |
|
2595 |
|
2596 TTimeIntervalMicroSeconds CVedMovieImp::VideoClipEndTime(TInt aIndex) const |
|
2597 { |
|
2598 return iVideoClipArray[aIndex]->EndTime(); |
|
2599 } |
|
2600 |
|
2601 TTimeIntervalMicroSeconds CVedMovieImp::VideoClipEditedDuration(TInt aIndex) const |
|
2602 { |
|
2603 return iVideoClipArray[aIndex]->EditedDuration(); |
|
2604 } |
|
2605 |
|
2606 CVedAudioClipInfo* CVedMovieImp::AudioClipInfo(TInt aIndex) const |
|
2607 { |
|
2608 return iAudioClipInfoArray[aIndex]; |
|
2609 } |
|
2610 |
|
2611 TTimeIntervalMicroSeconds CVedMovieImp::AudioClipStartTime(TInt aIndex) const |
|
2612 { |
|
2613 return iAudSong->Clip(aIndex, KVedAudioTrackIndex)->StartTime(); |
|
2614 } |
|
2615 |
|
2616 void CVedMovieImp::AudioClipSetStartTime(TInt aIndex, TTimeIntervalMicroSeconds aStartTime) |
|
2617 { |
|
2618 iAudSong->Clip(aIndex, KVedAudioTrackIndex)->SetStartTime(aStartTime); |
|
2619 } |
|
2620 |
|
2621 TTimeIntervalMicroSeconds CVedMovieImp::AudioClipEndTime(TInt aIndex) const |
|
2622 { |
|
2623 return iAudSong->Clip(aIndex, KVedAudioTrackIndex)->EndTime(); |
|
2624 } |
|
2625 |
|
2626 TTimeIntervalMicroSeconds CVedMovieImp::AudioClipEditedDuration(TInt aIndex) const |
|
2627 { |
|
2628 return iAudSong->Clip(aIndex, KVedAudioTrackIndex)->EditedDuration(); |
|
2629 } |
|
2630 |
|
2631 void CVedMovieImp::AudioClipSetCutInTime(TInt aIndex, TTimeIntervalMicroSeconds aCutInTime) |
|
2632 { |
|
2633 iAudSong->Clip(aIndex, KVedAudioTrackIndex)->SetCutInTime(aCutInTime); |
|
2634 } |
|
2635 |
|
2636 void CVedMovieImp::AudioClipSetCutOutTime(TInt aIndex, TTimeIntervalMicroSeconds aCutOutTime) |
|
2637 { |
|
2638 iAudSong->Clip(aIndex, KVedAudioTrackIndex)->SetCutOutTime(aCutOutTime); |
|
2639 } |
|
2640 |
|
2641 |
|
2642 TBool CVedMovieImp::AudioClipNormalizing(TInt aIndex) const |
|
2643 { |
|
2644 return iAudSong->Clip(aIndex, KVedAudioTrackIndex)->Normalizing(); |
|
2645 } |
|
2646 |
|
2647 void CVedMovieImp::AudioClipSetNormalizing(TInt aIndex, TBool aNormalizing) |
|
2648 { |
|
2649 iAudSong->Clip(aIndex, KVedAudioTrackIndex)->SetNormalizing(aNormalizing); |
|
2650 } |
|
2651 |
|
2652 |
|
2653 void CVedMovieImp::AudioClipInsertDynamicLevelMarkL(TInt aIndex, TVedDynamicLevelMark aMark) |
|
2654 { |
|
2655 __ASSERT_ALWAYS(aMark.iTime.Int64() >= 0, |
|
2656 TVedPanic::Panic(TVedPanic::EIllegalDynamicLevelMark)); |
|
2657 __ASSERT_ALWAYS(aMark.iTime.Int64() <= AudioClipCutOutTime(aIndex).Int64(), |
|
2658 TVedPanic::Panic(TVedPanic::EIllegalDynamicLevelMark)); |
|
2659 __ASSERT_ALWAYS(aIndex >= 0, |
|
2660 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2661 |
|
2662 iApplyDynamicLevelMark = ETrue; |
|
2663 iAudSong->Clip(aIndex, KVedAudioTrackIndex)->InsertDynamicLevelMarkL(TAudDynamicLevelMark(aMark.iTime, aMark.iLevel)); |
|
2664 } |
|
2665 |
|
2666 void CVedMovieImp::AudioClipRemoveDynamicLevelMark(TInt aClipIndex, TInt aMarkIndex) |
|
2667 { |
|
2668 __ASSERT_ALWAYS(aMarkIndex >= 0, |
|
2669 TVedPanic::Panic(TVedPanic::EIllegalDynamicLevelMarkIndex)); |
|
2670 __ASSERT_ALWAYS(aMarkIndex < AudioClipDynamicLevelMarkCount(aClipIndex), |
|
2671 TVedPanic::Panic(TVedPanic::EIllegalDynamicLevelMarkIndex)); |
|
2672 __ASSERT_ALWAYS(aClipIndex >= 0, |
|
2673 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2674 |
|
2675 iAudSong->Clip(aClipIndex, KVedAudioTrackIndex)->RemoveDynamicLevelMark(aMarkIndex); |
|
2676 } |
|
2677 |
|
2678 TInt CVedMovieImp::AudioClipDynamicLevelMarkCount(TInt aIndex) const |
|
2679 { |
|
2680 __ASSERT_ALWAYS(aIndex >= 0, |
|
2681 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2682 return iAudSong->Clip(aIndex, KVedAudioTrackIndex)->DynamicLevelMarkCount(); |
|
2683 } |
|
2684 |
|
2685 TVedDynamicLevelMark CVedMovieImp::AudioClipDynamicLevelMark(TInt aClipIndex, TInt aMarkIndex) |
|
2686 { |
|
2687 __ASSERT_ALWAYS(aMarkIndex >= 0, |
|
2688 TVedPanic::Panic(TVedPanic::EIllegalDynamicLevelMarkIndex)); |
|
2689 __ASSERT_ALWAYS(aMarkIndex < AudioClipDynamicLevelMarkCount(aClipIndex), |
|
2690 TVedPanic::Panic(TVedPanic::EIllegalDynamicLevelMarkIndex)); |
|
2691 __ASSERT_ALWAYS(aClipIndex >= 0, |
|
2692 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2693 |
|
2694 CAudClip* clip = iAudSong->Clip(aClipIndex, KVedAudioTrackIndex); |
|
2695 TAudDynamicLevelMark mark(clip->DynamicLevelMark(aMarkIndex)); |
|
2696 return TVedDynamicLevelMark(mark.iTime, mark.iLevel); |
|
2697 } |
|
2698 |
|
2699 |
|
2700 void CVedMovieImp::SetVideoClipVolumeGainL(TInt aClipIndex, TInt aVolumeGain) |
|
2701 { |
|
2702 iApplyDynamicLevelMark = EFalse; |
|
2703 |
|
2704 TInt marks = 0; |
|
2705 if (aClipIndex == KVedClipIndexAll) |
|
2706 { |
|
2707 // whole movie, sum with clip values in SetAudioFadingL |
|
2708 iVolumeGainForAllVideoClips = aVolumeGain; |
|
2709 marks = 1; |
|
2710 } |
|
2711 else |
|
2712 { |
|
2713 __ASSERT_ALWAYS(aClipIndex >= 0, |
|
2714 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2715 __ASSERT_ALWAYS(aClipIndex <= VideoClipCount(), |
|
2716 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2717 // set volume gain to the clip |
|
2718 CVedVideoClip* clip = iVideoClipArray[aClipIndex]; |
|
2719 clip->SetVolumeGain(aVolumeGain); |
|
2720 |
|
2721 // should also add/remove a dynamic level mark to have the observer calls more meaningful |
|
2722 // and avoid problems if client assumes a mark was really added |
|
2723 // the actual mark is removed when starting to process |
|
2724 if ( aVolumeGain != 0 ) |
|
2725 { |
|
2726 // add |
|
2727 clip->InsertDynamicLevelMarkL(TVedDynamicLevelMark(clip->CutInTime(),aVolumeGain)); |
|
2728 clip->InsertDynamicLevelMarkL(TVedDynamicLevelMark(clip->CutOutTime(),aVolumeGain)); |
|
2729 } |
|
2730 else |
|
2731 { |
|
2732 // gain == 0 => remove marks |
|
2733 while (clip->DynamicLevelMarkCount() > 0) |
|
2734 { |
|
2735 marks++; |
|
2736 clip->RemoveDynamicLevelMark(0); |
|
2737 } |
|
2738 } |
|
2739 } |
|
2740 |
|
2741 // inform observers |
|
2742 if ( aVolumeGain == 0 ) |
|
2743 { |
|
2744 // volume gain was set to 0 => no gain ~= remove level mark |
|
2745 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2746 { |
|
2747 for ( TInt j = 0; j < marks; j++ ) |
|
2748 { |
|
2749 iObserverArray[i]->NotifyVideoClipDynamicLevelMarkRemoved(*this, aClipIndex,0); |
|
2750 } |
|
2751 } |
|
2752 } |
|
2753 else |
|
2754 { |
|
2755 // volume gain was set to nonzero => gain ~= insert level mark |
|
2756 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2757 { |
|
2758 iObserverArray[i]->NotifyVideoClipDynamicLevelMarkInserted(*this, aClipIndex, 0); |
|
2759 iObserverArray[i]->NotifyVideoClipDynamicLevelMarkInserted(*this, aClipIndex, 1); |
|
2760 } |
|
2761 } |
|
2762 } |
|
2763 |
|
2764 TInt CVedMovieImp::GetVideoClipVolumeGainL(TInt aClipIndex) |
|
2765 { |
|
2766 if (aClipIndex == KVedClipIndexAll) |
|
2767 { |
|
2768 return iVolumeGainForAllVideoClips; |
|
2769 } |
|
2770 else |
|
2771 { |
|
2772 // get volume gain from the clip |
|
2773 __ASSERT_ALWAYS(aClipIndex >= 0, |
|
2774 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2775 __ASSERT_ALWAYS(aClipIndex <= VideoClipCount(), |
|
2776 TVedPanic::Panic(TVedPanic::EVideoClipIllegalIndex)); |
|
2777 return iVideoClipArray[aClipIndex]->GetVolumeGain(); |
|
2778 } |
|
2779 } |
|
2780 |
|
2781 void CVedMovieImp::SetAudioClipVolumeGainL(TInt aClipIndex, TInt aVolumeGain) |
|
2782 { |
|
2783 iApplyDynamicLevelMark = EFalse; |
|
2784 TInt marks = 0; |
|
2785 if (aClipIndex == KVedClipIndexAll) |
|
2786 { |
|
2787 // whole movie, sum with clip values in SetAudioFading |
|
2788 iVolumeGainForAllAudioClips = aVolumeGain; |
|
2789 marks = 1; |
|
2790 } |
|
2791 else |
|
2792 { |
|
2793 // set volume gain to the clip; the clip asserts the index |
|
2794 CAudClip* clip = iAudSong->Clip(aClipIndex, KVedAudioTrackIndex); |
|
2795 clip->SetVolumeGain(aVolumeGain); |
|
2796 |
|
2797 // should also add/remove a dynamic level mark to have the observer calls more meaningful |
|
2798 // and avoid problems if client assumes a mark was really added |
|
2799 // the actual mark is removed when starting to process |
|
2800 if ( aVolumeGain != 0 ) |
|
2801 { |
|
2802 // add |
|
2803 clip->InsertDynamicLevelMarkL(TAudDynamicLevelMark(clip->CutInTime(),aVolumeGain)); |
|
2804 clip->InsertDynamicLevelMarkL(TAudDynamicLevelMark(clip->CutOutTime(),aVolumeGain)); |
|
2805 } |
|
2806 else |
|
2807 { |
|
2808 // gain == 0 => remove |
|
2809 while (clip->DynamicLevelMarkCount() > 0) |
|
2810 { |
|
2811 marks++; |
|
2812 clip->RemoveDynamicLevelMark(0); |
|
2813 } |
|
2814 } |
|
2815 } |
|
2816 |
|
2817 // inform observers |
|
2818 if ( aVolumeGain == 0 ) |
|
2819 { |
|
2820 // volume gain was set to 0 => no gain ~= remove level mark |
|
2821 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2822 { |
|
2823 for ( TInt j = 0; j < marks; j++ ) |
|
2824 { |
|
2825 iObserverArray[i]->NotifyAudioClipDynamicLevelMarkRemoved(*this, aClipIndex,0); |
|
2826 } |
|
2827 } |
|
2828 } |
|
2829 else |
|
2830 { |
|
2831 // volume gain was set to nonzero => gain ~= insert level mark |
|
2832 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2833 { |
|
2834 iObserverArray[i]->NotifyAudioClipDynamicLevelMarkInserted(*this, aClipIndex,0); |
|
2835 } |
|
2836 } |
|
2837 } |
|
2838 |
|
2839 TInt CVedMovieImp::GetAudioClipVolumeGainL(TInt aClipIndex) |
|
2840 { |
|
2841 if (aClipIndex == KVedClipIndexAll) |
|
2842 { |
|
2843 return iVolumeGainForAllAudioClips; |
|
2844 } |
|
2845 else |
|
2846 { |
|
2847 // get volume gain from the clip; the clip asserts the index |
|
2848 CAudClip* clip = iAudSong->Clip(aClipIndex, KVedAudioTrackIndex); |
|
2849 return clip->GetVolumeGain(); |
|
2850 } |
|
2851 } |
|
2852 |
|
2853 |
|
2854 TRgb CVedMovieImp::VideoClipColorTone(TInt aVideoClipIndex) const |
|
2855 { |
|
2856 return iVideoClipArray[aVideoClipIndex]->ColorTone(); |
|
2857 } |
|
2858 |
|
2859 void CVedMovieImp::VideoClipSetColorTone(TInt aVideoClipIndex, TRgb aColorTone) |
|
2860 { |
|
2861 iVideoClipArray[aVideoClipIndex]->SetColorTone(aColorTone); |
|
2862 } |
|
2863 |
|
2864 |
|
2865 TTimeIntervalMicroSeconds CVedMovieImp::Duration() const |
|
2866 { |
|
2867 TTimeIntervalMicroSeconds duration = TTimeIntervalMicroSeconds(0); |
|
2868 |
|
2869 if (VideoClipCount() > 0) |
|
2870 { |
|
2871 duration = iVideoClipArray[VideoClipCount() - 1]->EndTime(); |
|
2872 } |
|
2873 |
|
2874 for (TInt i = 0; i < AudioClipCount(); i++) |
|
2875 { |
|
2876 TTimeIntervalMicroSeconds endTime = iAudSong->Clip(i, KVedAudioTrackIndex)->EndTime(); |
|
2877 if (endTime > duration) |
|
2878 { |
|
2879 duration = endTime; |
|
2880 } |
|
2881 } |
|
2882 |
|
2883 return duration; |
|
2884 } |
|
2885 |
|
2886 |
|
2887 TInt CVedMovieImp::VideoClipCount() const |
|
2888 { |
|
2889 return iVideoClipArray.Count(); |
|
2890 } |
|
2891 |
|
2892 |
|
2893 CVedVideoClip* CVedMovieImp::VideoClip(TInt aClipIndex) const |
|
2894 { |
|
2895 return iVideoClipArray[aClipIndex]; |
|
2896 } |
|
2897 |
|
2898 |
|
2899 TVedStartTransitionEffect CVedMovieImp::StartTransitionEffect() const |
|
2900 { |
|
2901 __ASSERT_ALWAYS(VideoClipCount() > 0, TVedPanic::Panic(TVedPanic::EMovieEmpty)); |
|
2902 return iStartTransitionEffect; |
|
2903 } |
|
2904 |
|
2905 |
|
2906 TInt CVedMovieImp::MiddleTransitionEffectCount() const |
|
2907 { |
|
2908 return Max(0, iVideoClipArray.Count() - 1); |
|
2909 } |
|
2910 |
|
2911 |
|
2912 TVedMiddleTransitionEffect CVedMovieImp::MiddleTransitionEffect(TInt aIndex) const |
|
2913 { |
|
2914 if (aIndex == (iVideoClipArray.Count() - 1)) |
|
2915 { |
|
2916 aIndex++; // make aIndex out of range to cause panic |
|
2917 } |
|
2918 |
|
2919 return iVideoClipArray[aIndex]->iMiddleTransitionEffect; |
|
2920 } |
|
2921 |
|
2922 |
|
2923 TVedEndTransitionEffect CVedMovieImp::EndTransitionEffect() const |
|
2924 { |
|
2925 __ASSERT_ALWAYS(VideoClipCount() > 0, TVedPanic::Panic(TVedPanic::EMovieEmpty)); |
|
2926 return iEndTransitionEffect; |
|
2927 } |
|
2928 |
|
2929 |
|
2930 TInt CVedMovieImp::AudioClipCount() const |
|
2931 { |
|
2932 return iAudSong->ClipCount(KVedAudioTrackIndex); |
|
2933 } |
|
2934 |
|
2935 TTimeIntervalMicroSeconds CVedMovieImp::AudioClipCutInTime(TInt aIndex) const |
|
2936 { |
|
2937 return iAudSong->Clip(aIndex, KVedAudioTrackIndex)->CutInTime(); |
|
2938 } |
|
2939 |
|
2940 TTimeIntervalMicroSeconds CVedMovieImp::AudioClipCutOutTime(TInt aIndex) const |
|
2941 { |
|
2942 return iAudSong->Clip(aIndex, KVedAudioTrackIndex)->CutOutTime(); |
|
2943 } |
|
2944 |
|
2945 |
|
2946 |
|
2947 void CVedMovieImp::FireVideoClipAdded(CVedMovie* aMovie, CVedVideoClip* aClip) |
|
2948 { |
|
2949 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2950 { |
|
2951 iObserverArray[i]->NotifyVideoClipAdded(*aMovie, aClip->Index()); |
|
2952 } |
|
2953 // reset the estimated processing time |
|
2954 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
2955 } |
|
2956 |
|
2957 |
|
2958 void CVedMovieImp::FireVideoClipAddingFailed(CVedMovie* aMovie, TInt aError) |
|
2959 { |
|
2960 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2961 { |
|
2962 iObserverArray[i]->NotifyVideoClipAddingFailed(*aMovie, aError); |
|
2963 } |
|
2964 } |
|
2965 |
|
2966 |
|
2967 void CVedMovieImp::FireVideoClipRemoved(CVedMovie* aMovie, TInt aIndex) |
|
2968 { |
|
2969 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2970 { |
|
2971 iObserverArray[i]->NotifyVideoClipRemoved(*aMovie, aIndex); |
|
2972 } |
|
2973 // reset the estimated processing time |
|
2974 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
2975 } |
|
2976 |
|
2977 |
|
2978 void CVedMovieImp::FireVideoClipIndicesChanged(CVedMovie* aMovie, TInt aOldIndex, |
|
2979 TInt aNewIndex) |
|
2980 { |
|
2981 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2982 { |
|
2983 iObserverArray[i]->NotifyVideoClipIndicesChanged(*aMovie, aOldIndex, aNewIndex); |
|
2984 } |
|
2985 } |
|
2986 |
|
2987 |
|
2988 void CVedMovieImp::FireVideoClipTimingsChanged(CVedMovie* aMovie, CVedVideoClip* aClip) |
|
2989 { |
|
2990 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
2991 { |
|
2992 iObserverArray[i]->NotifyVideoClipTimingsChanged(*aMovie, aClip->Index()); |
|
2993 } |
|
2994 // reset the estimated processing time |
|
2995 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
2996 } |
|
2997 |
|
2998 |
|
2999 void CVedMovieImp::FireVideoClipColorEffectChanged(CVedMovie* aMovie, CVedVideoClip* aClip) |
|
3000 { |
|
3001 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3002 { |
|
3003 iObserverArray[i]->NotifyVideoClipColorEffectChanged(*aMovie, aClip->Index()); |
|
3004 } |
|
3005 } |
|
3006 |
|
3007 |
|
3008 void CVedMovieImp::FireVideoClipAudioSettingsChanged(CVedMovie* aMovie, CVedVideoClip* aClip) |
|
3009 { |
|
3010 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3011 { |
|
3012 iObserverArray[i]->NotifyVideoClipAudioSettingsChanged(*aMovie, aClip->Index()); |
|
3013 } |
|
3014 // reset the estimated processing time |
|
3015 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3016 } |
|
3017 |
|
3018 |
|
3019 void CVedMovieImp::FireVideoClipGeneratorSettingsChanged(CVedMovie* aMovie, CVedVideoClip* aClip) |
|
3020 { |
|
3021 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3022 { |
|
3023 iObserverArray[i]->NotifyVideoClipGeneratorSettingsChanged(*aMovie, aClip->Index()); |
|
3024 } |
|
3025 // reset the estimated processing time |
|
3026 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3027 } |
|
3028 |
|
3029 void CVedMovieImp::FireVideoClipDescriptiveNameChanged(CVedMovie* aMovie, CVedVideoClip* aClip) |
|
3030 { |
|
3031 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3032 { |
|
3033 iObserverArray[i]->NotifyVideoClipDescriptiveNameChanged(*aMovie, aClip->Index()); |
|
3034 } |
|
3035 } |
|
3036 |
|
3037 void CVedMovieImp::FireStartTransitionEffectChanged(CVedMovie* aMovie) |
|
3038 { |
|
3039 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3040 { |
|
3041 iObserverArray[i]->NotifyStartTransitionEffectChanged(*aMovie); |
|
3042 } |
|
3043 // reset the estimated processing time |
|
3044 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3045 } |
|
3046 |
|
3047 |
|
3048 void CVedMovieImp::FireMiddleTransitionEffectChanged(CVedMovie* aMovie, TInt aIndex) |
|
3049 { |
|
3050 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3051 { |
|
3052 iObserverArray[i]->NotifyMiddleTransitionEffectChanged(*aMovie, aIndex); |
|
3053 } |
|
3054 // reset the estimated processing time |
|
3055 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3056 } |
|
3057 |
|
3058 |
|
3059 void CVedMovieImp::FireEndTransitionEffectChanged(CVedMovie* aMovie) |
|
3060 { |
|
3061 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3062 { |
|
3063 iObserverArray[i]->NotifyEndTransitionEffectChanged(*aMovie); |
|
3064 } |
|
3065 // reset the estimated processing time |
|
3066 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3067 } |
|
3068 |
|
3069 |
|
3070 void CVedMovieImp::FireAudioClipAdded(CVedMovie* aMovie, TInt aIndex) |
|
3071 { |
|
3072 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3073 { |
|
3074 iObserverArray[i]->NotifyAudioClipAdded(*aMovie, aIndex); |
|
3075 } |
|
3076 |
|
3077 TRAPD(err,CalculatePropertiesL());// ignore error? |
|
3078 if (err != KErrNone) { } |
|
3079 |
|
3080 // reset the estimated processing time |
|
3081 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3082 } |
|
3083 |
|
3084 |
|
3085 void CVedMovieImp::FireAudioClipAddingFailed(CVedMovie* aMovie, TInt aError) |
|
3086 { |
|
3087 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3088 { |
|
3089 iObserverArray[i]->NotifyAudioClipAddingFailed(*aMovie, aError); |
|
3090 } |
|
3091 } |
|
3092 |
|
3093 |
|
3094 void CVedMovieImp::FireAudioClipRemoved(CVedMovie* aMovie, TInt aIndex) |
|
3095 { |
|
3096 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3097 { |
|
3098 iObserverArray[i]->NotifyAudioClipRemoved(*aMovie, aIndex); |
|
3099 } |
|
3100 |
|
3101 TRAPD(err,CalculatePropertiesL());// ignore error? |
|
3102 if (err != KErrNone) { } |
|
3103 |
|
3104 // reset the estimated processing time |
|
3105 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3106 } |
|
3107 |
|
3108 |
|
3109 void CVedMovieImp::FireAudioClipIndicesChanged(CVedMovie* aMovie, TInt aOldIndex, TInt aNewIndex) |
|
3110 { |
|
3111 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3112 { |
|
3113 iObserverArray[i]->NotifyAudioClipIndicesChanged(*aMovie, |
|
3114 aOldIndex, aNewIndex); |
|
3115 } |
|
3116 } |
|
3117 |
|
3118 |
|
3119 void CVedMovieImp::FireAudioClipTimingsChanged(CVedMovie* aMovie, CAudClip* aClip) |
|
3120 { |
|
3121 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3122 { |
|
3123 iObserverArray[i]->NotifyAudioClipTimingsChanged(*aMovie, aClip->IndexOnTrack()); |
|
3124 } |
|
3125 // reset the estimated processing time |
|
3126 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3127 } |
|
3128 |
|
3129 |
|
3130 void CVedMovieImp::FireDynamicLevelMarkRemoved(CAudClip& aClip, TInt aMarkIndex) |
|
3131 { |
|
3132 TInt trackIndex = aClip.TrackIndex(); |
|
3133 TInt clipIndex = aClip.IndexOnTrack(); |
|
3134 |
|
3135 if (!iNotifyObserver) |
|
3136 return; |
|
3137 |
|
3138 if (trackIndex == 0) |
|
3139 { |
|
3140 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3141 { |
|
3142 iObserverArray[i]->NotifyVideoClipDynamicLevelMarkRemoved(*this, clipIndex, aMarkIndex); |
|
3143 } |
|
3144 } |
|
3145 else if (trackIndex == 1) |
|
3146 { |
|
3147 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3148 { |
|
3149 iObserverArray[i]->NotifyAudioClipDynamicLevelMarkRemoved(*this, clipIndex, aMarkIndex); |
|
3150 } |
|
3151 } |
|
3152 else |
|
3153 { |
|
3154 TVedPanic::Panic(TVedPanic::EInternal); |
|
3155 } |
|
3156 // reset the estimated processing time |
|
3157 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3158 } |
|
3159 |
|
3160 void CVedMovieImp::FireDynamicLevelMarkInserted(CAudClip& aClip, TAudDynamicLevelMark& /*aMark*/, TInt aMarkIndex) |
|
3161 { |
|
3162 TInt trackIndex = aClip.TrackIndex(); |
|
3163 TInt clipIndex = aClip.IndexOnTrack(); |
|
3164 |
|
3165 if (!iNotifyObserver) |
|
3166 return; |
|
3167 |
|
3168 if (trackIndex == 0) |
|
3169 { |
|
3170 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3171 { |
|
3172 iObserverArray[i]->NotifyVideoClipDynamicLevelMarkInserted(*this, clipIndex, aMarkIndex); |
|
3173 } |
|
3174 } |
|
3175 else if (trackIndex == 1) |
|
3176 { |
|
3177 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3178 { |
|
3179 iObserverArray[i]->NotifyAudioClipDynamicLevelMarkInserted(*this, clipIndex, aMarkIndex); |
|
3180 } |
|
3181 } |
|
3182 else |
|
3183 { |
|
3184 TVedPanic::Panic(TVedPanic::EInternal); |
|
3185 } |
|
3186 // reset the estimated processing time |
|
3187 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3188 } |
|
3189 |
|
3190 |
|
3191 void CVedMovieImp::FireMovieQualityChanged(CVedMovie* aMovie) |
|
3192 { |
|
3193 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3194 { |
|
3195 iObserverArray[i]->NotifyMovieQualityChanged(*aMovie); |
|
3196 } |
|
3197 // reset the estimated processing time |
|
3198 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3199 } |
|
3200 |
|
3201 |
|
3202 void CVedMovieImp::FireMovieOutputParametersChanged(CVedMovie* aMovie) |
|
3203 { |
|
3204 |
|
3205 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3206 { |
|
3207 iObserverArray[i]->NotifyMovieOutputParametersChanged(*aMovie); |
|
3208 } |
|
3209 // reset the estimated processing time |
|
3210 iEstimatedProcessingTime = TTimeIntervalMicroSeconds(0); |
|
3211 } |
|
3212 |
|
3213 void CVedMovieImp::FireMovieReseted(CVedMovie* aMovie) |
|
3214 { |
|
3215 for (TInt i = 0; i < iObserverArray.Count(); i++) |
|
3216 { |
|
3217 iObserverArray[i]->NotifyMovieReseted(*aMovie); |
|
3218 } |
|
3219 } |
|
3220 |
|
3221 |
|
3222 void CVedMovieImp::ProcessL(const TDesC& aFileName, |
|
3223 MVedMovieProcessingObserver& aObserver) |
|
3224 { |
|
3225 __ASSERT_ALWAYS((VideoClipCount() > 0) || (AudioClipCount() > 0), |
|
3226 TVedPanic::Panic(TVedPanic::EMovieEmpty)); |
|
3227 |
|
3228 CalculatePropertiesL(); |
|
3229 iAudSong->SetDuration(Duration()); |
|
3230 SetAudioFadingL(); |
|
3231 |
|
3232 iMovieProcessingObserver = &aObserver; |
|
3233 |
|
3234 iProcessor->StartMovieL(this, aFileName, NULL, &aObserver); |
|
3235 } |
|
3236 |
|
3237 void CVedMovieImp::ProcessL(RFile* aFileHandle, |
|
3238 MVedMovieProcessingObserver& aObserver) |
|
3239 { |
|
3240 __ASSERT_ALWAYS((VideoClipCount() > 0) || (AudioClipCount() > 0), |
|
3241 TVedPanic::Panic(TVedPanic::EMovieEmpty)); |
|
3242 |
|
3243 CalculatePropertiesL(); |
|
3244 iAudSong->SetDuration(Duration()); |
|
3245 SetAudioFadingL(); |
|
3246 |
|
3247 iMovieProcessingObserver = &aObserver; |
|
3248 TFileName dummy; |
|
3249 |
|
3250 iProcessor->StartMovieL(this, dummy, aFileHandle, &aObserver); |
|
3251 } |
|
3252 |
|
3253 |
|
3254 void CVedMovieImp::CancelProcessing() |
|
3255 { |
|
3256 TRAPD(error, iProcessor->CancelProcessingL()); |
|
3257 |
|
3258 if (error != KErrNone) |
|
3259 iMovieProcessingObserver->NotifyMovieProcessingCompleted(*this, error); |
|
3260 |
|
3261 } |
|
3262 |
|
3263 void CVedMovieImp::SetMovieSizeLimit(TInt aLimit) |
|
3264 { |
|
3265 iProcessor->SetMovieSizeLimit(aLimit); |
|
3266 } |
|
3267 |
|
3268 TInt CVedMovieImp::SyncIntervalInPicture() |
|
3269 { |
|
3270 return iSyncIntervalInPicture; |
|
3271 } |
|
3272 |
|
3273 TReal CVedMovieImp::RandomAccessRate() |
|
3274 { |
|
3275 return iRandomAccessRate; |
|
3276 } |
|
3277 |
|
3278 // Create a temporary transcoder instance and ask for transcoding time factor for the given settings |
|
3279 TReal CVedMovieImp::AskComplexityFactorFromTranscoderL(CVedVideoClipInfo* aInfo, CTRTranscoder::TTROperationalMode aMode, TReal aInputFrameRate) |
|
3280 { |
|
3281 PRINT((_L("CVedMovieImp::AskComplexityFactorFromTranscoderL() in"))); |
|
3282 TReal complexityFactor; |
|
3283 CTRTranscoder *tmpTranscoder; |
|
3284 TTRVideoFormat formIn; |
|
3285 TTRVideoFormat formOut; |
|
3286 formIn.iSize = aInfo->Resolution(); |
|
3287 formIn.iDataType = CTRTranscoder::ETRDuCodedPicture; |
|
3288 formOut.iSize = iResolution; |
|
3289 formOut.iDataType = CTRTranscoder::ETRDuCodedPicture; |
|
3290 TBufC8<255> inputMime; |
|
3291 MapVideoCodecTypeToMime(aInfo->VideoType(), inputMime); |
|
3292 |
|
3293 // create temporary transcoder observer object, with input framerate as parameter, since it is asked by the transcoder |
|
3294 CTrObs* tmpObs = new (ELeave) CTrObs(aInputFrameRate); |
|
3295 CleanupStack::PushL(tmpObs); |
|
3296 |
|
3297 // create temporary transcoder instance |
|
3298 tmpTranscoder = CTRTranscoder::NewL(*tmpObs); |
|
3299 CleanupStack::PushL(tmpTranscoder); |
|
3300 tmpTranscoder->OpenL(reinterpret_cast<MCMRMediaSink*>(1),//the sink will not be used, hence this is acceptable |
|
3301 aMode, |
|
3302 inputMime, |
|
3303 iVideoCodecMimeType, |
|
3304 formIn, |
|
3305 formOut, |
|
3306 EFalse ); |
|
3307 |
|
3308 // ask complexity/time factor from the transcoder |
|
3309 complexityFactor = tmpTranscoder->EstimateTranscodeTimeFactorL(formIn, formOut); |
|
3310 |
|
3311 CleanupStack::PopAndDestroy(tmpTranscoder); |
|
3312 CleanupStack::PopAndDestroy(tmpObs); |
|
3313 |
|
3314 PRINT((_L("CVedMovieImp::AskComplexityFactorFromTranscoderL() out, complexity factor %f"), complexityFactor)); |
|
3315 return complexityFactor; |
|
3316 } |
|
3317 |
|
3318 |
|
3319 TTimeIntervalMicroSeconds CVedMovieImp::GetProcessingTimeEstimateL() |
|
3320 { |
|
3321 PRINT((_L("CVedMovieImp::GetProcessingTimeEstimateL() in"))); |
|
3322 TInt64 estimatedTime = 0; |
|
3323 TReal complexityFactor; |
|
3324 TBool transcodingImpactIncluded = EFalse; |
|
3325 |
|
3326 // Don't estimate the time if it has been asked already. |
|
3327 // This also means the result is not the remaining time but the total processing time |
|
3328 if ( iEstimatedProcessingTime > 0 ) |
|
3329 { |
|
3330 return iEstimatedProcessingTime; |
|
3331 } |
|
3332 |
|
3333 |
|
3334 // Loop through the clips in the movie and estimate the processing time for each of them |
|
3335 for (TInt i = 0; i < VideoClipCount(); i++) |
|
3336 { |
|
3337 CVedVideoClipInfo* currentInfo = VideoClip(i)->Info(); |
|
3338 |
|
3339 complexityFactor = 0; |
|
3340 transcodingImpactIncluded = EFalse; |
|
3341 |
|
3342 if ( currentInfo->Class() == EVedVideoClipClassGenerated ) |
|
3343 { |
|
3344 // only encoding for generated content. Framerate is low. |
|
3345 transcodingImpactIncluded = ETrue; |
|
3346 |
|
3347 // open transcoder in encoding mode & ask the factor. |
|
3348 // This is in practice for generated content only. Tbd if it is worth opening the transcoder? |
|
3349 complexityFactor = AskComplexityFactorFromTranscoderL(currentInfo, CTRTranscoder::EEncoding, 1.0); |
|
3350 // the temporary clip is then processed like a normal input clip, add the impact |
|
3351 complexityFactor += (KVedBitstreamProcessingFactor*iVideoStandardBitrate) / KVedBitstreamProcessingFactorBitrate; |
|
3352 } |
|
3353 else |
|
3354 { |
|
3355 // check if transcoding is needed |
|
3356 |
|
3357 // If input and output resolutions don't match, transcoder knows it need to do resolution transcoding |
|
3358 // However, we need to check here in which mode we'd open the transcoder |
|
3359 if ((currentInfo->Resolution() != iResolution) || (iVideoRestrictedBitrate != 0) |
|
3360 || ((currentInfo->VideoType() == EVedVideoTypeH263Profile0Level45) && (iVideoType == EVedVideoTypeH263Profile0Level10))) |
|
3361 { |
|
3362 // need to do resolution transcoding |
|
3363 transcodingImpactIncluded = ETrue; |
|
3364 |
|
3365 // open transcoder in full transcoding mode & ask for the factor. |
|
3366 TReal framerate = TReal(1000*currentInfo->VideoFrameCount())/(currentInfo->Duration().Int64()/1000); |
|
3367 complexityFactor = AskComplexityFactorFromTranscoderL(currentInfo, CTRTranscoder::EFullTranscoding, framerate); |
|
3368 } |
|
3369 else |
|
3370 { |
|
3371 // no full transcoding |
|
3372 |
|
3373 if ( currentInfo->VideoType() != iVideoType ) |
|
3374 { |
|
3375 // compressed domain transcoding between H.263 and MPEG-4. Assuming they are equally complex |
|
3376 |
|
3377 complexityFactor = (KVedCompressedDomainTranscodingFactor * iVideoStandardBitrate) / KVedBitstreamProcessingFactorBitrate; |
|
3378 } |
|
3379 else |
|
3380 { |
|
3381 // Only bitstream processing + possibly cut or some other simple operation. Transition effect is estimated later |
|
3382 // It is assumed that pure decoding is needed only for such a short period of time that |
|
3383 // the impact can be estimated here without opening processor/transcoder. |
|
3384 |
|
3385 // Bitrate has impact here. MPEG-4 is more complex to process than H.263 but bitrate is dominant. E,g, H.263 128 kbps vs MPEG4 512 kbps: 1:5 complexity; 1:4 bitrate |
|
3386 complexityFactor = (KVedBitstreamProcessingFactor*iVideoStandardBitrate) / KVedBitstreamProcessingFactorBitrate; |
|
3387 } |
|
3388 |
|
3389 } |
|
3390 } |
|
3391 |
|
3392 // Now we have the video complexity factor for the current clip. Add the contribution to the total time |
|
3393 estimatedTime = estimatedTime + TInt64(complexityFactor * I64INT(VideoClip(i)->EditedDuration().Int64())); |
|
3394 |
|
3395 if (!transcodingImpactIncluded && (VideoClip(i)->iMiddleTransitionEffect != EVedMiddleTransitionEffectNone)) |
|
3396 { |
|
3397 // add impact of transition effect; need decoding + encoding for a short period |
|
3398 |
|
3399 // open transcoder in full transcoding mode & ask for the factor. |
|
3400 TReal framerate = TReal(1000*currentInfo->VideoFrameCount())/(currentInfo->Duration().Int64()/1000); |
|
3401 complexityFactor = this->AskComplexityFactorFromTranscoderL(currentInfo, CTRTranscoder::EFullTranscoding, framerate); |
|
3402 estimatedTime = estimatedTime + TInt64(complexityFactor * 1000000);//transition duration; 1 sec is accurate enough here |
|
3403 } |
|
3404 |
|
3405 } |
|
3406 |
|
3407 PRINT((_L("CVedMovieImp::GetProcessingTimeEstimateL(), video part estimated to %d sec"),I64INT(estimatedTime)/1000000 )); |
|
3408 |
|
3409 // add audio processing time |
|
3410 estimatedTime = estimatedTime + iAudSong->GetTimeEstimateL().Int64(); |
|
3411 |
|
3412 PRINT((_L("CVedMovieImp::GetProcessingTimeEstimateL(), audio included, before rounding the estimate is %d sec"),I64INT(estimatedTime)/1000000 )); |
|
3413 // estimate is not too accurate anyway; round it |
|
3414 if ( estimatedTime > 600000000 ) |
|
3415 { |
|
3416 // more than 10 minutes => round to nearest 2 min |
|
3417 estimatedTime = ((estimatedTime+60000000) / 120000000) * 120000000; |
|
3418 } |
|
3419 else if (estimatedTime > 120000000 ) |
|
3420 { |
|
3421 // more than 2 minutes => round to nearest 30 sec |
|
3422 estimatedTime = ((estimatedTime+30000000) / 30000000) * 30000000; |
|
3423 } |
|
3424 else if (estimatedTime > 30000000 ) |
|
3425 { |
|
3426 // more than 30 secs => round to nearest 10 sec |
|
3427 estimatedTime = ((estimatedTime+5000000) / 10000000) * 10000000; |
|
3428 } |
|
3429 else |
|
3430 { |
|
3431 // less than 30 secs => round to nearest 2 sec |
|
3432 estimatedTime = ((estimatedTime+1000000) / 2000000) * 2000000; |
|
3433 } |
|
3434 |
|
3435 iEstimatedProcessingTime = estimatedTime; |
|
3436 PRINT((_L("CVedMovieImp::GetProcessingTimeEstimateL() out, estimate is %d sec"),I64INT(estimatedTime)/1000000 )); |
|
3437 return estimatedTime; |
|
3438 |
|
3439 } |
|
3440 |
|
3441 |
|
3442 void CVedMovieImp::NotifyClipAdded(CAudSong& aSong, CAudClip& aClip, TInt aIndex, TInt aTrackIndex) |
|
3443 { |
|
3444 PRINT((_L("CVedMovieImp::NotifyClipAdded() in") )); |
|
3445 // Track index 0 means it's the video track - we need to create the video clip |
|
3446 if (aTrackIndex == 0) |
|
3447 { |
|
3448 PRINT((_L("CVedMovieImp::NotifyClipAdded() added audio track of video clip to song successfully") )); |
|
3449 |
|
3450 TInt err; |
|
3451 if (iAddedVideoClipFileHandle) |
|
3452 { |
|
3453 TRAP(err, iAddOperation->iVideoClip = CVedVideoClip::NewL(this, aClip.Info()->FileHandle(), iAddedVideoClipIndex, &aClip, *iAddOperation)); |
|
3454 } |
|
3455 else |
|
3456 { |
|
3457 TRAP(err, iAddOperation->iVideoClip = CVedVideoClip::NewL(this, aClip.Info()->FileName(), iAddedVideoClipIndex, &aClip, *iAddOperation)); |
|
3458 } |
|
3459 |
|
3460 if (err != KErrNone) |
|
3461 { |
|
3462 PRINT((_L("CVedMovieImp::NotifyClipAdded() creating video clip failed, removing also audio") )); |
|
3463 // delete the audio clip from song |
|
3464 aSong.RemoveClip(aIndex); |
|
3465 |
|
3466 FireVideoClipAddingFailed(this, err); |
|
3467 } |
|
3468 delete iAddedVideoClipFilename; |
|
3469 iAddedVideoClipFilename = 0; |
|
3470 iAddedVideoClipFileHandle = 0; |
|
3471 } |
|
3472 else if (aTrackIndex == KVedAudioTrackIndex) |
|
3473 { |
|
3474 // We're on the audio track so we need to create an audio clip info |
|
3475 PRINT((_L("CVedMovieImp::NotifyClipAdded() added audio track of audio clip to song successfully") )); |
|
3476 CVedAudioClipInfoImp* audioClipInfo = 0; |
|
3477 TRAPD(err, audioClipInfo = CVedAudioClipInfoImp::NewL(&aClip, *this)); |
|
3478 if (err != KErrNone) |
|
3479 { |
|
3480 delete audioClipInfo; |
|
3481 FireAudioClipAddingFailed(this, err); |
|
3482 return; |
|
3483 } |
|
3484 err = iAudioClipInfoArray.Insert(audioClipInfo, aIndex); |
|
3485 if (err != KErrNone) |
|
3486 { |
|
3487 delete audioClipInfo; |
|
3488 FireAudioClipAddingFailed(this, err); |
|
3489 } |
|
3490 } |
|
3491 PRINT((_L("CVedMovieImp::NotifyClipAdded() out") )); |
|
3492 } |
|
3493 |
|
3494 void CVedMovieImp::NotifyClipAddingFailed(CAudSong& /*aSong*/, TInt aError, TInt aTrackIndex) |
|
3495 { |
|
3496 if (aTrackIndex == 0) |
|
3497 { |
|
3498 if (aError == KErrNoAudio) |
|
3499 { |
|
3500 // We can have video clips that have no audio track |
|
3501 |
|
3502 TInt err; |
|
3503 if (iAddedVideoClipFileHandle) |
|
3504 { |
|
3505 TRAP(err, iAddOperation->iVideoClip = CVedVideoClip::NewL(this, iAddedVideoClipFileHandle, iAddedVideoClipIndex, NULL, *iAddOperation)); |
|
3506 } |
|
3507 else |
|
3508 { |
|
3509 TRAP(err, iAddOperation->iVideoClip = CVedVideoClip::NewL(this, *iAddedVideoClipFilename, iAddedVideoClipIndex, NULL, *iAddOperation)); |
|
3510 } |
|
3511 if (err != KErrNone) |
|
3512 { |
|
3513 FireAudioClipAddingFailed(this, aError); |
|
3514 } |
|
3515 } |
|
3516 else |
|
3517 { |
|
3518 FireVideoClipAddingFailed(this, aError); |
|
3519 } |
|
3520 |
|
3521 delete iAddedVideoClipFilename; |
|
3522 iAddedVideoClipFilename = 0; |
|
3523 } |
|
3524 else if (aTrackIndex == KVedAudioTrackIndex) |
|
3525 { |
|
3526 FireAudioClipAddingFailed(this, aError); |
|
3527 } |
|
3528 } |
|
3529 |
|
3530 void CVedMovieImp::NotifyClipRemoved(CAudSong& /*aSong*/, TInt aIndex, TInt aTrackIndex) |
|
3531 { |
|
3532 if (aTrackIndex == KVedAudioTrackIndex) |
|
3533 { |
|
3534 CVedAudioClipInfoImp* info = iAudioClipInfoArray[aIndex]; |
|
3535 delete info; |
|
3536 iAudioClipInfoArray.Remove(aIndex); |
|
3537 FireAudioClipRemoved(this, aIndex); |
|
3538 } |
|
3539 } |
|
3540 |
|
3541 void CVedMovieImp::NotifyClipTimingsChanged(CAudSong& /*aSong*/, CAudClip& aClip) |
|
3542 { |
|
3543 if (aClip.TrackIndex() == KVedAudioTrackIndex) |
|
3544 { |
|
3545 FireAudioClipTimingsChanged(this, &aClip); |
|
3546 } |
|
3547 } |
|
3548 |
|
3549 void CVedMovieImp::NotifyClipIndicesChanged(CAudSong& /*aSong*/, TInt aOldIndex, TInt aNewIndex, TInt aTrackIndex) |
|
3550 { |
|
3551 if (aTrackIndex == KVedAudioTrackIndex) |
|
3552 { |
|
3553 TLinearOrder<CVedAudioClipInfoImp> order(CVedAudioClipInfoImp::Compare); |
|
3554 iAudioClipInfoArray.Sort(order); |
|
3555 FireAudioClipIndicesChanged(this, aOldIndex, aNewIndex); |
|
3556 } |
|
3557 } |
|
3558 |
|
3559 void CVedMovieImp::NotifySongReseted(CAudSong& /*aSong*/) |
|
3560 { |
|
3561 // nothing to do here |
|
3562 } |
|
3563 |
|
3564 void CVedMovieImp::NotifyClipReseted(CAudClip& /*aClip*/) |
|
3565 { |
|
3566 // nothing to do here |
|
3567 } |
|
3568 |
|
3569 void CVedMovieImp::NotifyDynamicLevelMarkInserted(CAudClip& aClip, TAudDynamicLevelMark& aMark, TInt aIndex) |
|
3570 { |
|
3571 FireDynamicLevelMarkInserted(aClip, aMark, aIndex); |
|
3572 } |
|
3573 |
|
3574 void CVedMovieImp::NotifyDynamicLevelMarkRemoved(CAudClip& aClip, TInt aIndex) |
|
3575 { |
|
3576 FireDynamicLevelMarkRemoved(aClip, aIndex); |
|
3577 } |
|
3578 |
|
3579 |
|
3580 void CVedMovieImp::NotifyAudioClipInfoReady(CVedAudioClipInfo& aInfo, TInt aError) |
|
3581 { |
|
3582 if (aError != KErrNone) |
|
3583 { |
|
3584 iAudioClipInfoArray.Remove(iAudioClipInfoArray.Count() - 1); |
|
3585 FireAudioClipAddingFailed(this, aError); |
|
3586 } |
|
3587 else |
|
3588 { |
|
3589 CVedAudioClipInfoImp* infoImp = static_cast<CVedAudioClipInfoImp*> (&aInfo); |
|
3590 FireAudioClipAdded(this, infoImp->iAudClip->IndexOnTrack()); |
|
3591 } |
|
3592 } |
|
3593 |
|
3594 CAudSong* CVedMovieImp::Song() |
|
3595 { |
|
3596 return iAudSong; |
|
3597 } |
|
3598 |
|
3599 TPtrC8& CVedMovieImp::VideoCodecMimeType() |
|
3600 { |
|
3601 return iVideoCodecMimeType; |
|
3602 } |
|
3603 |
|
3604 |
|
3605 CVedMovieAddClipOperation* CVedMovieAddClipOperation::NewL(CVedMovie* aMovie) |
|
3606 { |
|
3607 PRINT(_L("CVedMovieAddClipOperation::NewL")); |
|
3608 |
|
3609 CVedMovieAddClipOperation* self = |
|
3610 new (ELeave) CVedMovieAddClipOperation(aMovie); |
|
3611 CleanupStack::PushL(self); |
|
3612 self->ConstructL(); |
|
3613 CleanupStack::Pop(self); |
|
3614 return self; |
|
3615 } |
|
3616 |
|
3617 |
|
3618 CVedMovieAddClipOperation::CVedMovieAddClipOperation(CVedMovie* aMovie) |
|
3619 : CActive(EPriorityStandard), iMovie((CVedMovieImp*)aMovie) |
|
3620 { |
|
3621 |
|
3622 CActiveScheduler::Add(this); |
|
3623 } |
|
3624 |
|
3625 |
|
3626 void CVedMovieAddClipOperation::ConstructL() |
|
3627 { |
|
3628 } |
|
3629 |
|
3630 |
|
3631 CVedMovieAddClipOperation::~CVedMovieAddClipOperation() |
|
3632 { |
|
3633 Cancel(); |
|
3634 |
|
3635 if (iVideoClip) |
|
3636 { |
|
3637 delete iVideoClip; |
|
3638 iVideoClip = NULL; |
|
3639 } |
|
3640 } |
|
3641 |
|
3642 |
|
3643 void CVedMovieAddClipOperation::NotifyVideoClipInfoReady(CVedVideoClipInfo& /*aInfo*/, |
|
3644 TInt aError) |
|
3645 { |
|
3646 |
|
3647 // Cannot delete iVideoClip here, since we are in its callback function, |
|
3648 // so schedule the active object to complete the add operation and |
|
3649 // delete iVideoClip if needed. |
|
3650 |
|
3651 iError = aError; |
|
3652 |
|
3653 SetActive(); |
|
3654 TRequestStatus* status = &iStatus; |
|
3655 User::RequestComplete(status, KErrNone); |
|
3656 } |
|
3657 void CVedMovieAddClipOperation::RunL() |
|
3658 { |
|
3659 __ASSERT_DEBUG((iVideoClip != 0), |
|
3660 TVedPanic::Panic(TVedPanic::EInternal)); |
|
3661 |
|
3662 if (iVideoClip != 0) |
|
3663 { |
|
3664 CompleteAddVideoClipOperation(); |
|
3665 } |
|
3666 |
|
3667 __ASSERT_DEBUG(iVideoClip == 0, |
|
3668 TVedPanic::Panic(TVedPanic::EInternal)); |
|
3669 } |
|
3670 |
|
3671 |
|
3672 void CVedMovieAddClipOperation::DoCancel() |
|
3673 { |
|
3674 if (iVideoClip) |
|
3675 { |
|
3676 if (iVideoClip->EditedHasAudio()) |
|
3677 { |
|
3678 TInt audioClipIndex = iVideoClip->iAudClip->IndexOnTrack(); |
|
3679 iMovie->iAudSong->RemoveClip(audioClipIndex, 0); |
|
3680 } |
|
3681 delete iVideoClip; |
|
3682 iVideoClip = NULL; |
|
3683 iMovie->FireVideoClipAddingFailed(iMovie, KErrCancel); |
|
3684 } |
|
3685 } |
|
3686 |
|
3687 |
|
3688 void CVedMovieAddClipOperation::CompleteAddVideoClipOperation() |
|
3689 { |
|
3690 if (iError != KErrNone) |
|
3691 { |
|
3692 if (iVideoClip->EditedHasAudio()) |
|
3693 { |
|
3694 TInt audioClipIndex = iVideoClip->iAudClip->IndexOnTrack(); |
|
3695 iMovie->iAudSong->RemoveClip(audioClipIndex, 0); |
|
3696 } |
|
3697 delete iVideoClip; |
|
3698 iVideoClip = 0; |
|
3699 iMovie->FireVideoClipAddingFailed(iMovie, iError); |
|
3700 } |
|
3701 else |
|
3702 { |
|
3703 TInt insertableError = iMovie->CheckVideoClipInsertable(iVideoClip); |
|
3704 |
|
3705 if (insertableError != KErrNone) |
|
3706 { |
|
3707 if (iVideoClip->EditedHasAudio()) |
|
3708 { |
|
3709 TInt audioClipIndex = iVideoClip->iAudClip->IndexOnTrack(); |
|
3710 iMovie->iAudSong->RemoveClip(audioClipIndex, 0); |
|
3711 } |
|
3712 delete iVideoClip; |
|
3713 iVideoClip = 0; |
|
3714 iMovie->FireVideoClipAddingFailed(iMovie, insertableError); |
|
3715 } |
|
3716 else |
|
3717 { |
|
3718 iVideoClip->iMiddleTransitionEffect = EVedMiddleTransitionEffectNone; |
|
3719 |
|
3720 if (iVideoClip->iInfo->Class() == EVedVideoClipClassFile) |
|
3721 { |
|
3722 iVideoClip->iCutOutTime = iVideoClip->iInfo->Duration(); |
|
3723 } |
|
3724 else |
|
3725 { |
|
3726 iVideoClip->iCutOutTime = TTimeIntervalMicroSeconds(0); |
|
3727 } |
|
3728 |
|
3729 TInt err = iMovie->iVideoClipArray.Insert(iVideoClip, iVideoClip->iIndex); |
|
3730 if (err != KErrNone) |
|
3731 { |
|
3732 if (iVideoClip->EditedHasAudio()) |
|
3733 { |
|
3734 // delete corresponding audio clip from song |
|
3735 TInt audioClipIndex = iVideoClip->iAudClip->IndexOnTrack(); |
|
3736 iMovie->iAudSong->RemoveClip(audioClipIndex, 0); |
|
3737 } |
|
3738 delete iVideoClip; |
|
3739 iVideoClip = 0; |
|
3740 iMovie->FireVideoClipAddingFailed(iMovie, err); |
|
3741 } |
|
3742 else |
|
3743 { |
|
3744 if (iVideoClip->iInfo->Class() == EVedVideoClipClassGenerated) |
|
3745 { |
|
3746 iVideoClip->iInfo->Generator()->SetVideoClip(*iVideoClip, |
|
3747 iIsVideoGeneratorOwnedByVideoClip); |
|
3748 } |
|
3749 |
|
3750 iMovie->RecalculateVideoClipTimings(iVideoClip); |
|
3751 TRAPD(err,iMovie->CalculatePropertiesL());//ignore error, should not leave with current implementation |
|
3752 if (err != KErrNone) { } |
|
3753 |
|
3754 CVedVideoClip* clip = iVideoClip; |
|
3755 iVideoClip = 0; |
|
3756 iMovie->FireVideoClipAdded(iMovie, clip); |
|
3757 } |
|
3758 } |
|
3759 } |
|
3760 } |
|
3761 |
|
3762 |
|