|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
3 * |
|
4 * This library is free software; you can redistribute it and/or |
|
5 * modify it under the terms of the GNU Lesser General Public |
|
6 * License as published by the Free Software Foundation; either |
|
7 * version 2 of the License, or (at your option) any later version. |
|
8 * |
|
9 * This library is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 * Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public |
|
15 * License along with this library; if not, write to the |
|
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
17 * Boston, MA 02111-1307, USA. |
|
18 * |
|
19 * Description: |
|
20 * |
|
21 */ |
|
22 /* |
|
23 * ============================================================================== |
|
24 * Name : gstplayerappui.cpp |
|
25 * Part of : gstplayer |
|
26 * Interface : |
|
27 * Description : |
|
28 * Version : |
|
29 * |
|
30 |
|
31 * ============================================================================== |
|
32 */ |
|
33 |
|
34 // INCLUDE FILES |
|
35 #include <avkon.hrh> |
|
36 #include <aknnotewrappers.h> |
|
37 #include <stringloader.h> |
|
38 #include <GSTPlayer.rsg> |
|
39 #include <CAknMemorySelectionDialog.h> |
|
40 #include <f32file.h> |
|
41 #include <s32file.h> |
|
42 #include <PathInfo.h> |
|
43 #include <gst/gst.h> |
|
44 |
|
45 #include "GSTPlayer.pan" |
|
46 #include "GSTPlayerAppUi.h" |
|
47 #include "GSTPlayerAppView.h" |
|
48 #include "GSTPlayer.hrh" |
|
49 |
|
50 #include "GlibEventHandler.h" |
|
51 #include "gstreamer.h" |
|
52 |
|
53 TFileName fileName; |
|
54 |
|
55 _LIT( KHelloFileName, "\\private\\A000017F\\Hello.txt" ); |
|
56 _LIT( KHelloText, "HELLO WORLD!"); |
|
57 |
|
58 // ============================ MEMBER FUNCTIONS =============================== |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CGSTPlayerAppUi::ConstructL() |
|
63 // Symbian 2nd phase constructor can leave. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CGSTPlayerAppUi::ConstructL() |
|
67 { |
|
68 // Initialise app UI with standard value. |
|
69 BaseConstructL(CAknAppUi::EAknEnableSkin); |
|
70 // Here the Hello.txt file can be created, if it is not copied automatically. |
|
71 /* |
|
72 RFs fsSession; |
|
73 User::LeaveIfError(fsSession.Connect()); |
|
74 |
|
75 RFile file; |
|
76 |
|
77 // Create a file to write the text to |
|
78 if ( file.Replace(fsSession, KHelloFileName, EFileWrite ) != KErrNone ) |
|
79 { |
|
80 return; |
|
81 } |
|
82 CleanupClosePushL( file ); |
|
83 |
|
84 RFileWriteStream outputFileStream( file ); |
|
85 CleanupClosePushL( outputFileStream ); |
|
86 outputFileStream << KHelloText; |
|
87 |
|
88 CleanupStack::PopAndDestroy(2); // file, outputFileStream |
|
89 |
|
90 fsSession.Close(); |
|
91 */ |
|
92 |
|
93 // Create view object |
|
94 iAppView = CGSTPlayerAppView::NewL(ClientRect() ); |
|
95 |
|
96 iGstView = iAppView; |
|
97 |
|
98 } |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CGSTPlayerAppUi::CGSTPlayerAppUi() |
|
101 // C++ default constructor can NOT contain any code, that might leave. |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 CGSTPlayerAppUi::CGSTPlayerAppUi() |
|
105 { |
|
106 // No implementation required |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CGSTPlayerAppUi::~CGSTPlayerAppUi() |
|
111 // Destructor. |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 CGSTPlayerAppUi::~CGSTPlayerAppUi() |
|
115 { |
|
116 |
|
117 if (iAppView) |
|
118 { |
|
119 delete iAppView; |
|
120 iAppView = NULL; |
|
121 } |
|
122 |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CGSTPlayerAppUi::HandleCommandL() |
|
127 // Takes care of command handling. |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CGSTPlayerAppUi::HandleCommandL(TInt aCommand) |
|
131 { |
|
132 switch (aCommand) |
|
133 { |
|
134 case EEikCmdExit: |
|
135 case EAknSoftkeyExit: |
|
136 if (pipeline!=NULL && pipeline ->current_state |
|
137 == GST_STATE_PLAYING) |
|
138 { |
|
139 |
|
140 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
141 gst_object_unref(GST_OBJECT (pipeline)); |
|
142 |
|
143 } |
|
144 Exit(); |
|
145 break; |
|
146 |
|
147 case EGSTPlayerNewSong: |
|
148 { |
|
149 /*TDes& aPath; |
|
150 TBool aMemoryCardStorageAllowed;*/ |
|
151 if (pipeline!=NULL && pipeline ->current_state |
|
152 == GST_STATE_PLAYING) |
|
153 { |
|
154 |
|
155 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
156 gst_object_unref(GST_OBJECT (pipeline)); |
|
157 |
|
158 } |
|
159 CAknMemorySelectionDialog* memoryDialog = |
|
160 CAknMemorySelectionDialog::NewL(ECFDDialogTypeSave, |
|
161 R_MUSICSHOP_MEMORY_SELECTION_DIALOG, EFalse); |
|
162 CleanupStack::PushL(memoryDialog); |
|
163 |
|
164 CAknMemorySelectionDialog::TMemory |
|
165 mem(CAknMemorySelectionDialog::EPhoneMemory); |
|
166 TFileName ignore; |
|
167 //TFileName path; |
|
168 if (! (memoryDialog->ExecuteL(mem, &fileName, &ignore) )) |
|
169 { |
|
170 // User dnt select the memory location. |
|
171 // retVal = EFalse; |
|
172 } |
|
173 else |
|
174 { |
|
175 //aPath.Copy( path ); |
|
176 } |
|
177 CleanupStack::PopAndDestroy(); // memoryDialog |
|
178 |
|
179 |
|
180 //if user has pressed cancel button, then just return |
|
181 if (!ShowDirListL(fileName)) |
|
182 { |
|
183 return; |
|
184 } //end if |
|
185 if (GstreamerNew(fileName) == -1) |
|
186 { |
|
187 // Load a string from the resource file and display it |
|
188 HBufC* textResource = |
|
189 StringLoader::LoadLC( R_HEWB_COMMAND1_TEXT); |
|
190 CAknInformationNote* informationNote; |
|
191 |
|
192 informationNote = new ( ELeave ) CAknInformationNote; |
|
193 |
|
194 // Show the information Note with |
|
195 // textResource loaded with StringLoader. |
|
196 informationNote->ExecuteLD( *textResource); |
|
197 |
|
198 // Pop HBuf from CleanUpStack and Destroy it. |
|
199 CleanupStack::PopAndDestroy(textResource); |
|
200 |
|
201 } |
|
202 |
|
203 } |
|
204 break; |
|
205 case EGSTPlayerPlay: |
|
206 if (pipeline!=NULL && pipeline ->current_state |
|
207 == GST_STATE_PLAYING) |
|
208 { |
|
209 |
|
210 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
211 //gst_object_unref (GST_OBJECT (pipeline)); |
|
212 |
|
213 } |
|
214 if (GstreamerNew(fileName) == -1) |
|
215 { |
|
216 // Load a string from the resource file and display it |
|
217 HBufC* textResource = |
|
218 StringLoader::LoadLC( R_HEWB_COMMAND2_TEXT); |
|
219 CAknInformationNote* informationNote; |
|
220 |
|
221 informationNote = new ( ELeave ) CAknInformationNote; |
|
222 |
|
223 // Show the information Note with |
|
224 // textResource loaded with StringLoader. |
|
225 informationNote->ExecuteLD( *textResource); |
|
226 |
|
227 // Pop HBuf from CleanUpStack and Destroy it. |
|
228 CleanupStack::PopAndDestroy(textResource); |
|
229 |
|
230 } |
|
231 |
|
232 break; |
|
233 case EGSTPlayerStop: |
|
234 if (pipeline!=NULL) |
|
235 { |
|
236 |
|
237 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
238 gst_object_unref (GST_OBJECT (pipeline)); |
|
239 pipeline = NULL; |
|
240 } |
|
241 break; |
|
242 case EGSTRecorderStop: |
|
243 if (pipeline!=NULL) |
|
244 { |
|
245 gst_element_send_event (pipeline, gst_event_new_eos ()); |
|
246 } |
|
247 break; |
|
248 |
|
249 case EGSTPlayerPause: |
|
250 if (pipeline!=NULL && pipeline ->current_state |
|
251 == GST_STATE_PLAYING) |
|
252 { |
|
253 |
|
254 gst_element_set_state(pipeline, GST_STATE_PAUSED); |
|
255 //gst_object_unref (GST_OBJECT (pipeline)); |
|
256 |
|
257 } |
|
258 break; |
|
259 |
|
260 case EGSTPlayerResume: |
|
261 if (pipeline!=NULL && pipeline ->current_state |
|
262 == GST_STATE_PAUSED) |
|
263 { |
|
264 |
|
265 gst_element_set_state(pipeline, GST_STATE_PLAYING); |
|
266 //gst_object_unref (GST_OBJECT (pipeline)); |
|
267 |
|
268 } |
|
269 break; |
|
270 |
|
271 case EGSTPlayerRecordWav: |
|
272 { |
|
273 if (pipeline!=NULL && pipeline ->current_state |
|
274 == GST_STATE_PLAYING) |
|
275 { |
|
276 |
|
277 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
278 //gst_object_unref (GST_OBJECT (pipeline)); |
|
279 |
|
280 } |
|
281 gst_record_wav(); |
|
282 } |
|
283 break; |
|
284 case EGSTPlayerRecordAac: |
|
285 { |
|
286 if (pipeline!=NULL && pipeline ->current_state |
|
287 == GST_STATE_PLAYING) |
|
288 { |
|
289 |
|
290 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
291 //gst_object_unref (GST_OBJECT (pipeline)); |
|
292 |
|
293 } |
|
294 gst_record_aac(); |
|
295 } |
|
296 break; |
|
297 |
|
298 case EGSTPlayerRecordRaw: |
|
299 { |
|
300 if (pipeline!=NULL && pipeline ->current_state |
|
301 == GST_STATE_PLAYING) |
|
302 { |
|
303 |
|
304 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
305 //gst_object_unref (GST_OBJECT (pipeline)); |
|
306 |
|
307 } |
|
308 gst_record_raw(); |
|
309 } |
|
310 break; |
|
311 |
|
312 case EGSTPlayerRecordAmr: |
|
313 { |
|
314 if (pipeline!=NULL && pipeline ->current_state |
|
315 == GST_STATE_PLAYING) |
|
316 { |
|
317 |
|
318 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
319 //gst_object_unref (GST_OBJECT (pipeline)); |
|
320 |
|
321 } |
|
322 gst_record_amr(); |
|
323 } |
|
324 break; |
|
325 |
|
326 case EGSTPlayerRecordG711: |
|
327 { |
|
328 if (pipeline!=NULL && pipeline ->current_state |
|
329 == GST_STATE_PLAYING) |
|
330 { |
|
331 |
|
332 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
333 //gst_object_unref (GST_OBJECT (pipeline)); |
|
334 |
|
335 } |
|
336 gst_record_g711(); |
|
337 } |
|
338 break; |
|
339 case EGSTPlayerRecordG729: |
|
340 { |
|
341 if (pipeline!=NULL && pipeline ->current_state |
|
342 == GST_STATE_PLAYING) |
|
343 { |
|
344 |
|
345 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
346 //gst_object_unref (GST_OBJECT (pipeline)); |
|
347 |
|
348 } |
|
349 gst_record_g729(); |
|
350 } |
|
351 break; |
|
352 case EGSTPlayerRecordIlbc: |
|
353 { |
|
354 if (pipeline!=NULL && pipeline ->current_state |
|
355 == GST_STATE_PLAYING) |
|
356 { |
|
357 |
|
358 gst_element_set_state(pipeline, GST_STATE_NULL); |
|
359 //gst_object_unref (GST_OBJECT (pipeline)); |
|
360 |
|
361 } |
|
362 gst_record_ilbc(); |
|
363 } |
|
364 break; |
|
365 |
|
366 case EGSTPlayerCurrentVolume: |
|
367 gst_current_volume(); |
|
368 break; |
|
369 case EGSTPlayerMaxVolume: |
|
370 gst_max_volume(); |
|
371 break; |
|
372 case EGSTPlayerVolumeUp: |
|
373 gst_volume_up(); |
|
374 break; |
|
375 case EGSTPlayerVolumeDown: |
|
376 gst_volume_down(); |
|
377 break; |
|
378 case EGSTPlayerLeftBalance: |
|
379 case EGSTPlayerRightBalance: |
|
380 gst_balance(); |
|
381 break; |
|
382 case EGSTPlayerCurrentGain: |
|
383 gst_current_gain(); |
|
384 break; |
|
385 case EGSTPlayerMaxGain: |
|
386 gst_max_gain(); |
|
387 break; |
|
388 case EGSTPlayerGainUp: |
|
389 gst_gain_up(); |
|
390 break; |
|
391 case EGSTPlayerGainDown: |
|
392 gst_gain_down(); |
|
393 break; |
|
394 case EGSTPlayerSamplesPlayed: |
|
395 samplesplayed(); |
|
396 break; |
|
397 case EGSTPlayerSamplesRecorded: |
|
398 samplesrecorded(); |
|
399 break; |
|
400 case EGSTPlayerSinkPadCaps: |
|
401 getsinkpadcaps(); |
|
402 break; |
|
403 case EGSTPlayerSrcPadCaps: |
|
404 getsrcpadcaps(); |
|
405 break; |
|
406 case EGSTPlayerNegotiatedSinkCaps: |
|
407 negotiatedsinkcaps(); |
|
408 break; |
|
409 case EGSTPlayerNegotiatedSrcCaps: |
|
410 negotiatedsrccaps(); |
|
411 break; |
|
412 default: |
|
413 Panic(EGSTPlayerUi); |
|
414 break; |
|
415 } |
|
416 } |
|
417 // ----------------------------------------------------------------------------- |
|
418 // Called by the framework when the application status pane |
|
419 // size is changed. Passes the new client rectangle to the |
|
420 // AppView |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 void CGSTPlayerAppUi::HandleStatusPaneSizeChange() |
|
424 { |
|
425 iAppView->SetRect(ClientRect() ); |
|
426 |
|
427 } |
|
428 |
|
429 TBool CGSTPlayerAppUi::ShowDirListL(TFileName &filePath) |
|
430 { |
|
431 |
|
432 _LIT(KDialogTitle, "Select File"); |
|
433 |
|
434 TBool ret = CAknFileSelectionDialog::RunDlgLD(filePath, // on return, contains the selected file's name |
|
435 PathInfo::PhoneMemoryRootPath(), // default root path for browsing |
|
436 KDialogTitle, // Dialog's title |
|
437 0 // Pointer to class implementing |
|
438 // MAknFileSelectionObserver. OkToExitL is called |
|
439 // when user has selected an file. |
|
440 ); |
|
441 |
|
442 return ret; |
|
443 |
|
444 } |
|
445 |
|
446 void ShowNoteL() |
|
447 { |
|
448 // Load a string from the resource file and display it |
|
449 HBufC* textResource = StringLoader::LoadLC( R_HEWB_COMMAND1_TEXT); |
|
450 CAknInformationNote* informationNote; |
|
451 |
|
452 informationNote = new ( ELeave ) CAknInformationNote; |
|
453 |
|
454 // Show the information Note with |
|
455 // textResource loaded with StringLoader. |
|
456 informationNote->ExecuteLD( *textResource); |
|
457 |
|
458 // Pop HBuf from CleanUpStack and Destroy it. |
|
459 CleanupStack::PopAndDestroy(textResource); |
|
460 } |
|
461 // End of File |
|
462 |