1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include "vedmovie.h" |
|
18 |
|
19 _LIT( KMccTranscodedFile, "C:\\data\\videos\\timeraudio.3gp" ); |
|
20 _LIT( KMccTranscodedAvcFile, "C:\\data\\videos\\H264_QCIF_AMR_output.3gp" ); |
|
21 |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CVedMovie |
|
25 // ----------------------------------------------------------------------------- |
|
26 // |
|
27 CVedMovie* CVedMovie::NewL(RFs* aFs) |
|
28 { |
|
29 CVedMovie* movie = CVedMovie::NewLC( aFs ); |
|
30 CleanupStack::Pop( movie ); |
|
31 return movie; |
|
32 } |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CVedMovie |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CVedMovie* CVedMovie::NewLC(RFs* /*aFs*/) |
|
39 { |
|
40 CVedMovie* movie = new ( ELeave ) CVedMovie; |
|
41 CleanupStack::PushL( movie ); |
|
42 movie->ConstructL(); |
|
43 return movie; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CVedMovie |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CVedMovie::~CVedMovie() |
|
51 { |
|
52 CancelProcessing(); |
|
53 |
|
54 delete iDeltaTimer; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CVedMovie |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CVedMovie::CVedMovie() : |
|
62 iDeltaTimerCallBack(AsyncTimerExpired, this) |
|
63 { |
|
64 iDeltaTimerEntry.Set(iDeltaTimerCallBack); |
|
65 iAudioType = EVedAudioTypeAMR; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CVedMovie |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CVedMovie::ConstructL() |
|
73 { |
|
74 iDeltaTimer = CDeltaTimer::NewL(CActive::EPriorityStandard); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CVedMovie |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CVedMovie::SetQuality(TVedMovieQuality aQuality) |
|
82 { |
|
83 iQuality = aQuality; |
|
84 IssueCallback( ENotifyMovieQualityChanged ); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CVedMovie |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 TVedVideoType CVedMovie::VideoType() const |
|
92 { |
|
93 return EVedVideoTypeH263Profile0Level45; |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CVedMovie |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 TSize CVedMovie::Resolution() const |
|
101 { |
|
102 return TSize( 176, 144 ); |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CVedMovie |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TVedAudioType CVedMovie::AudioType() const |
|
110 { |
|
111 return iAudioType; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CVedMovie |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 TInt CVedMovie::AudioSamplingRate() const |
|
119 { |
|
120 return 8000; |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CVedMovie |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TVedAudioChannelMode CVedMovie::AudioChannelMode() const |
|
128 { |
|
129 return EVedAudioChannelModeSingleChannel; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CVedMovie |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CVedMovie::InsertVideoClipL(const TDesC& /*aFileName*/, TInt /*aIndex*/) |
|
137 { |
|
138 IssueCallback( ENotifyVideoClipAdded ); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CVedMovie |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CVedMovie::ProcessL(const TDesC& aFileName, |
|
146 MVedMovieProcessingObserver& aObserver) |
|
147 { |
|
148 TFileName sourcePath; |
|
149 |
|
150 if ( iOutputParams.iVideoType == EVedVideoTypeAVCBaselineProfile ) |
|
151 { |
|
152 // AVC output |
|
153 sourcePath.Copy( KMccTranscodedAvcFile ); |
|
154 } |
|
155 else |
|
156 { |
|
157 // H263 output |
|
158 sourcePath.Copy( KMccTranscodedFile ); |
|
159 } |
|
160 |
|
161 RFs fs; |
|
162 User::LeaveIfError( fs.Connect() ); |
|
163 CleanupClosePushL( fs ); |
|
164 |
|
165 CFileMan* fileMan = CFileMan::NewL(fs); |
|
166 CleanupStack::PushL(fileMan); |
|
167 |
|
168 // Make sure path exists, ignore errors since path might exist already |
|
169 fs.MkDirAll( aFileName ); |
|
170 |
|
171 // Make the destination file writeable, ignore errors since most probably |
|
172 // file doesn't exist yet |
|
173 fileMan->Attribs( aFileName, 0, KEntryAttReadOnly, TTime( 0 ), 0 ); |
|
174 |
|
175 User::LeaveIfError( fileMan->Copy( sourcePath, aFileName ) ); |
|
176 |
|
177 CleanupStack::PopAndDestroy( 2 ); // fileMan, fs |
|
178 |
|
179 iProcessObserver = &aObserver; |
|
180 iProgress = 0; |
|
181 |
|
182 IssueCallback( ENotifyMovieProcessingStartedL ); |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CVedMovie |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void CVedMovie::CancelProcessing() |
|
190 { |
|
191 if ( iDeltaTimer ) |
|
192 { |
|
193 iDeltaTimer->Remove( iDeltaTimerEntry ); |
|
194 } |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CVedMovie |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 void CVedMovie::RegisterMovieObserverL(MVedMovieObserver* aObserver) |
|
202 { |
|
203 iObserver = aObserver; |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CVedMovie |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 void CVedMovie::UnregisterMovieObserver(MVedMovieObserver* /*aObserver*/) |
|
211 { |
|
212 iObserver = NULL; |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CVedMovie |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 TInt CVedMovie::AudioBitrate() const |
|
220 { |
|
221 return 12200; |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CVedMovie |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 TReal CVedMovie::VideoFrameRate() const |
|
229 { |
|
230 return 15.0; |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CVedMovie |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 void CVedMovie::SetOutputParametersL(TVedOutputParameters& aOutputParams) |
|
238 { |
|
239 iOutputParams = aOutputParams; |
|
240 IssueCallback( ENotifyMovieOutputParametersChanged ); |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CVedMovie |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 void CVedMovie::IssueCallback( TVedMovieCurrentCallbackType aCallback ) |
|
248 { |
|
249 iDeltaTimer->Remove(iDeltaTimerEntry); |
|
250 iCurrentCallback = aCallback; |
|
251 TTimeIntervalMicroSeconds32 interval(200000); |
|
252 iDeltaTimer->Queue(interval, iDeltaTimerEntry); |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CVedMovie |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 TInt CVedMovie::AsyncTimerExpired(TAny* aPtr) |
|
260 { |
|
261 CVedMovie* self = reinterpret_cast<CVedMovie*>(aPtr); |
|
262 |
|
263 TRAP_IGNORE( self->DoCurrentCallbackL() ) |
|
264 |
|
265 return ETrue; |
|
266 } |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // CVedMovie |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 void CVedMovie::DoCurrentCallbackL() |
|
273 { |
|
274 __ASSERT_ALWAYS( iObserver, User::Leave( KErrNotReady ) ); |
|
275 |
|
276 switch ( iCurrentCallback ) |
|
277 { |
|
278 case ENotifyVideoClipAdded: |
|
279 { |
|
280 iObserver->NotifyVideoClipAdded( *this, 0 ); |
|
281 break; |
|
282 } |
|
283 case ENotifyMovieQualityChanged: |
|
284 { |
|
285 iObserver->NotifyMovieQualityChanged( *this ); |
|
286 break; |
|
287 } |
|
288 case ENotifyMovieOutputParametersChanged: |
|
289 { |
|
290 iObserver->NotifyMovieOutputParametersChanged( *this ); |
|
291 break; |
|
292 } |
|
293 case ENotifyMovieProcessingStartedL: |
|
294 { |
|
295 __ASSERT_ALWAYS( iProcessObserver, User::Leave( KErrNotReady ) ); |
|
296 |
|
297 iProcessObserver->NotifyMovieProcessingStartedL( *this ); |
|
298 IssueCallback( ENotifyMovieProcessingProgressed ); |
|
299 break; |
|
300 } |
|
301 case ENotifyMovieProcessingProgressed: |
|
302 { |
|
303 __ASSERT_ALWAYS( iProcessObserver, User::Leave( KErrNotReady ) ); |
|
304 |
|
305 iProgress += 20; |
|
306 if ( iProgress < 100 ) |
|
307 { |
|
308 iProcessObserver->NotifyMovieProcessingProgressed( *this, iProgress ); |
|
309 IssueCallback( ENotifyMovieProcessingProgressed ); |
|
310 } |
|
311 else |
|
312 { |
|
313 IssueCallback( ENotifyMovieProcessingCompleted ); |
|
314 } |
|
315 break; |
|
316 } |
|
317 case ENotifyMovieProcessingCompleted: |
|
318 { |
|
319 __ASSERT_ALWAYS( iProcessObserver, User::Leave( KErrNotReady ) ); |
|
320 |
|
321 iProgress = 100; |
|
322 iProcessObserver->NotifyMovieProcessingCompleted( *this, KErrNone ); |
|
323 break; |
|
324 } |
|
325 default: |
|
326 { |
|
327 break; |
|
328 } |
|
329 } |
|
330 } |
|
331 |
|