comparison src/ui/bmi/mmiVoiceMemo.c @ 3:67bfe9f274f6

src/ui: import of src/ui3 from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:33:10 +0000
parents
children c0052fe355d3
comparison
equal deleted inserted replaced
2:3a14ee9a9843 3:67bfe9f274f6
1 /*******************************************************************************
2
3 CONDAT (UK)
4
5 ********************************************************************************
6
7 This software product is the property of Condat (UK) Ltd and may not be
8 disclosed to any third party without the express permission of the owner.
9
10 ********************************************************************************
11
12 $Project name: Basic MMI
13 $Project code: BMI (6349)
14 $Module: VOICEMEMO
15 $File: MmiVoiceMemo.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 09/04/01
20
21 ********************************************************************************
22
23 Description:
24
25 This provides the start code for the MMI
26
27 ********************************************************************************
28 $History: MmiVoiceMemo.c
29
30 Mar 28, 2007 DR: OMAPS00122762 x0039928
31 Description: MM: Deleting a PCM Voice Memo message in one particular memory,
32 delete them in all memories
33 Solution: voice memo position and pcm voice memo position is provided for all the devices.
34
35 Mar 31, 2006 ER: OMAPS00067709 x0pleela
36 Description: Voice Buffering implementation on C+ for PTT via PCM API
37 Solution: Added prototype for voice_buffering_stop_recording
38 Updating voicebuffering data for play stopped in play callback
39
40 Mar 15, 2006 ER: OMAPS00067709 x0pleela
41 Description: Voice Buffering implementation on C+ for PTT via PCM API
42 Solution: Defined new macro "PCM_VOICE_MEMO_MAX_DURATION" to restrict the recording
43 timeout to 20 secs for PCM voice memo and voice buffering
44 Added prototypes of new functions inputVoiceMemoNumberEditor, voiceMemoNumberCB,
45 voice_buffering_tim_cb, voice_buffering_data_reset
46 Added following new functions:
47 pcm_voice_memo_play: Sets voice memo type to PCM_VOICE_MEMO which indicates
48 PCM voice memo is active and start playing the voice
49 pcm_voice_memo_record: Sets voice memo type to PCM_VOICE_MEMO which indicates
50 PCM voice memo is active and start recording the voice
51 voice_buffering_edit_num: Opens an edtor for the user to enter PTT number. Also resets
52 voice buffering data with default values
53 voiceMemoNumberCB: call back for number entry
54 inputVoiceMemoNumberEditor: Settings of Editor
55 voice_buffering_record_start: Starts recording voice and conects to the PTT number if the
56 call is not active. If in call, then start playing the voice
57 voice_buffering_record_stop: Stops the timer and recording. If call is not active the
58 disconnects the call
59 voice_buffering_playback_start: Starts playing the voice. If any error while playing,
60 stops timer and recording
61 voice_buffering_stop_recording: A wrapper function for record stop to invoke from other
62 modules. Stops the timer and recording
63 voice_buffering_stop_playing: A wrapper function for play stop to invoke from other modules
64 voice_buffering_tim_cb: Timer callback. Stops the timer. If PTT call is not setup disconnect
65 the call, else call record stop
66 voice_buffering_data_reset: Resets voice buffering data to default values
67
68 Function: voice_memo_play, voice_memo_record, voice_memo_destroy
69 Changes: Added code to set voice memo type
70
71 Function: voice_memo
72 Changes: Added code to handle record start, play start for PCM voice memo
73
74 Function: voice_memo_tim_cb
75 Changes: Added code to handle record stop, play stop for PCM voice memo
76
77 Function: voice_memo_riv_play_cb
78 Changes: Added code to allow user to accept ant incoming call after the buffering phase
79
80 Feb 27, 2006 ER: OMAPS00067709 x0pleela
81 Description: Voice Buffering implementation on C+ for PTT via PCM API
82 Solution: Defined a global variable gPcm_voice_Memo which indicates which Voice memo is active
83 and corresponding audio APIs will be invoked and duplication of code is avoided
84
85 Feb 24, 2006 ER: OMAPS00067709 x0pleela
86 Description: Voice Buffering implementation on C+ for PTT via PCM API
87 Solution: Defined new macro PCM_VOICE_MEMO_MAX_DURATION which defines maximum
88 recording and playing duration for PCM voice memo and voice buffering
89 Implemented following functions to support PCM voice memo feature
90 pcm_voice_memo_init: Initialization of PCM voice memo
91 pcm_voice_memo_exit:Termination of PCM voice memo
92 pcm_voice_memo_play:Starts PCM voice memo play functionality
93 pcm_voice_memo_record:Starts PCM voice memo record functionality
94 pcm_voice_memo_start: create a new voicememo dialog
95 pcm_voice_memo_create: Creation of window
96 pcm_voice_memo_destroy: Destruction of an dialog
97 pcm_voice_memo: Dialog function for PCM voice memo dialog
98 pcm_voice_memo_win_cb:Callback function for information dialog
99 pcm_voice_memo_tim_cb: Callback function for the PCM voice_memo timer.
100 pcm_voice_memo_kbd_cb: Keyboard event handler
101 pcm_voice_memo_riv_record_cb: Callback that handles the return status for PCM voice memo recording
102 pcm_voice_memo_riv_play_cb:Callback that handles the return status for PCM voice memo palying
103
104 09/04/01 Original Condat(UK) BMI version.
105
106 $End
107
108 *******************************************************************************/
109
110
111
112
113 /*******************************************************************************
114
115 Include files
116
117 *******************************************************************************/
118 #define ENTITY_MFW
119
120 /* includes */
121 #include <string.h>
122 #include <stdio.h>
123 #include <stdlib.h>
124
125 #include "typedefs.h"
126 #include "vsi.h"
127 #include "pei.h"
128 #include "custom.h"
129 #include "gsm.h"
130
131 #include "mfw_sys.h"
132
133 #include "prim.h"
134
135 #include "cus_aci.h"
136
137 #include "mfw_mfw.h"
138 #include "mfw_win.h"
139 #include "mfw_kbd.h"
140 /* SPR#1428 - SH - New Editor changes */
141 #ifndef NEW_EDITOR
142 #include "mfw_edt.h"
143 #endif
144 #include "mfw_lng.h"
145 #include "mfw_tim.h"
146 #include "mfw_icn.h"
147 #include "mfw_mnu.h"
148 #include "mfw_phb.h"
149 #include "mfw_cm.h"
150 #include "mfw_sim.h"
151 #include "mfw_nm.h"
152 #include "mfw_sat.h"
153 #include "mfw_phb.h"
154 #include "ksd.h"
155 #include "psa.h"
156 #include "mfw_sms.h"
157 #include "mfw_cphs.h"
158 #include "mfw_sat.h"
159
160 #include "dspl.h"
161
162
163 #include "MmiMmi.h"
164 #include "MmiDummy.h"
165 #include "MmiDialogs.h"
166 #include "MmiLists.h"
167 #include "MmiIdle.h"
168 #include "MmiSoftKeys.h"
169 #include "Mmiicons.h"
170 #include "MmiMenu.h"
171 #include "MmiMain.h"
172 #include "MmiStart.h"
173 #include "MmiPins.h"
174 #include "MmiSettings.h"
175
176 #include "gdi.h"
177 #include "audio.h"
178 #include "MmiSounds.h"
179 #include "MmiResources.h"
180 #include "mmiColours.h"
181
182 //#include "vmd.h"
183 #include "MmiVoiceMemo.h"
184 #include "mfw_ffs.h"
185
186 /* BEGIN ADD: Req ID: : Sumit : 14-Mar-05 */
187 #ifndef NEPTUNE_BOARD
188 /* END ADD: Req ID: : Sumit : 14-Mar-05 */
189 #include "Audio/audio_api.h"
190 /* BEGIN ADD: Req ID: : Sumit : 14-Mar-05 */
191 #endif /* NEPTUNE_BOARD*/
192 /* END ADD: Req ID: : Sumit : 14-Mar-05 */
193
194 #include "mfw_aud.h"
195
196 //x0pleela 09 Mar, 2006 ER:OMAPS00067709
197 //Including this header to support number editor
198 #ifdef FF_PCM_VM_VB
199 #include "MmiBookshared.h"
200 #endif
201 /*******************************************************************************
202
203 internal data
204
205 *******************************************************************************/
206
207 /*
208 * Internal events
209 */
210 #define VM_INIT 500
211 #define VM_DESTROY 501
212 #define VM_PLAY 502
213 #define VM_RECORD 503
214 #define VM_DELETE_BUFFER 504
215
216 #define VOICE_MEMO_MAX_DURATION 10 // 10 Secs
217
218 typedef struct
219 {
220 T_MMI_CONTROL mmi_control;
221 T_MFW_HND parent_win;
222 T_MFW_HND info_win;
223 T_MFW_HND info_tim;
224 T_MFW_HND info_kbd;
225 USHORT Identifier;
226 USHORT time;
227 char elapsed_time[7];
228 int play_sk2;
229 } T_voice_memo;
230
231 //x0pleela 09 Mar, 2006 ER:OMAPS00067709
232 #ifdef FF_PCM_VM_VB
233 EXTERN T_voice_buffering voice_buffering_data;
234 EXTERN T_call call_data;
235 #endif
236 /*******************************************************************************
237
238 Local prototypes
239
240 *******************************************************************************/
241
242
243 T_MFW_HND voice_memo_start (T_MFW_HND parent_win, SHORT ID);
244 static T_MFW_HND voice_memo_create (T_MFW_HND parent_win);
245 static void voice_memo_destroy (T_MFW_HND own_window);
246 static void voice_memo (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
247 static int voice_memo_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
248 static T_MFW_CB voice_memo_tim_cb (T_MFW_EVENT event, T_MFW_TIM * tc);
249 static int voice_memo_kbd_cb (T_MFW_EVENT event, T_MFW_KBD * keyboard);
250 static void voice_memo_dialog_create(T_MFW_HND win, int str1, int str2);
251 void voice_memo_dialog_cb (T_MFW_HND win, UBYTE identifier, UBYTE reason);
252 GLOBAL void voice_buffering_playback_start(void );
253 /*
254 ** Rivera Callback functions
255 */
256 static void voice_memo_riv_record_cb(void *parameter);
257 static void voice_memo_riv_play_cb(void *parameter);
258
259 //x0pleela 02 Mar, 2006 ER:OMAPS00067709
260 //Including this header to support number editor
261 #ifdef FF_PCM_VM_VB
262 MfwHnd inputVoiceMemoNumberEditor( MfwHnd parent, void *buffer );
263 void voiceMemoNumberCB( T_MFW_HND win, USHORT Identifier, UBYTE reason );
264 static int voice_buffering_tim_cb (T_MFW_EVENT event, T_MFW_TIM *tc);
265 static void voice_buffering_data_reset( void );
266 GLOBAL void voice_buffering_stop_recording(void );
267 #endif
268 /*******************************************************************************
269
270 $Function: voice_memo_init
271
272 $Description:
273
274 $Returns:
275
276 $Arguments:
277
278 *******************************************************************************/
279 GLOBAL void voice_memo_init (void)
280 {
281 TRACE_FUNCTION ("voice_memo_init()");
282
283 #ifdef FF_PCM_VM_VB
284 voice_buffering_data_reset();
285 #endif
286
287 }
288
289 /*******************************************************************************
290
291 $Function: voice_memo_exit
292
293 $Description:
294
295
296 $Returns:
297
298 $Arguments:
299
300 *******************************************************************************/
301 GLOBAL void voice_memo_exit (void)
302 {
303 TRACE_FUNCTION ("voice_memo_exit()");
304
305 }
306
307
308
309
310 /*******************************************************************************
311
312 $Function: voice_memo_play
313
314 $Description:
315
316 $Returns:
317
318 $Arguments:
319
320 *******************************************************************************/
321 GLOBAL int voice_memo_play (MfwMnu* m, MfwMnuItem* i)
322 {
323 T_MFW_HND win = mfw_parent(mfw_header());
324
325 TRACE_FUNCTION ("voice_memo_play()");
326
327 //x0pleela 27 Feb, 2006 ER: OMAPA00067709
328 //Set this variable to VOICE_MEMOwhich indicates voice memo is active
329 #ifdef FF_PCM_VM_VB
330 set_voice_memo_type( AMR_VOICE_MEMO);
331 #endif
332
333 //create a new voice memo dialog
334 voice_memo_start (win, VM_PLAY);
335 return 1; // ADDED BY RAVI - 29-11-2005
336 }
337
338 #if 0 /* FreeCalypso */
339 /*******************************************************************************
340
341 $Function: voice_memo_storeage
342
343 $Description:
344
345
346 $Returns:
347
348 $Arguments:
349
350 *******************************************************************************/
351 GLOBAL int PCM_voice_memo_storeage (MfwMnu* m, MfwMnuItem* i)
352 {
353 T_MFW_HND parent_win = mfwParent(mfw_header());
354 int txtId = TxtFFS;
355
356 TRACE_FUNCTION("mmi_camera_set_storage()");
357
358 switch (m->lCursor[m->level])
359 {
360 case 0:
361 txtId = TxtFFS;
362 FFS_flashData.PCM_voicememo_storage = SNAP_STG_FFS;
363 break;
364
365 case 1:
366 txtId = TxtNORMS;
367 FFS_flashData.PCM_voicememo_storage = SNAP_STG_NORMS;
368 break;
369
370 case 2:
371 txtId = TxtNAND;
372 FFS_flashData.PCM_voicememo_storage = SNAP_STG_NAND;
373 break;
374
375 case 3:
376 txtId = TxtTflash;
377 FFS_flashData.PCM_voicememo_storage = SNAP_STG_MMC;
378 break;
379 }
380
381 flash_write();
382 //Set the Quality Factor.
383 TRACE_EVENT_P1("STorage set to %d ", FFS_flashData.PCM_voicememo_storage);
384 //Display the dialgbox to the user.
385 voice_memo_dialog_create(parent_win,txtId,TxtSelected);
386 return MFW_EVENT_CONSUMED;
387 }
388
389 /*******************************************************************************
390
391 $Function: voice_memo_storeage
392
393 $Description:
394
395
396 $Returns:
397
398 $Arguments:
399
400 *******************************************************************************/
401 GLOBAL int voice_buffer_storeage (MfwMnu* m, MfwMnuItem* i)
402 {
403 T_MFW_HND parent_win = mfwParent(mfw_header());
404 int txtId = TxtFFS;
405
406 TRACE_FUNCTION("mmi_camera_set_storage()");
407
408 switch (m->lCursor[m->level])
409 {
410 case 0:
411 txtId = TxtFFS;
412 FFS_flashData.voicebuffer_storage = SNAP_STG_FFS;
413 break;
414
415 case 1:
416 txtId = TxtNORMS;
417 FFS_flashData.voicebuffer_storage = SNAP_STG_NORMS;
418 break;
419
420 case 2:
421 txtId = TxtNAND;
422 FFS_flashData.voicebuffer_storage = SNAP_STG_NAND;
423 break;
424
425 case 3:
426 txtId = TxtTflash;
427 FFS_flashData.voicebuffer_storage = SNAP_STG_MMC;
428 break;
429 }
430
431 flash_write();
432 //Set the Quality Factor.
433 TRACE_EVENT_P1("STorage set to %d ", FFS_flashData.voicebuffer_storage);
434 //Display the dialgbox to the user.
435 voice_memo_dialog_create(parent_win,txtId,TxtSelected);
436 return MFW_EVENT_CONSUMED;
437 }
438
439 /*******************************************************************************
440
441 $Function: voice_memo_storeage
442
443 $Description:
444
445
446 $Returns:
447
448 $Arguments:
449
450 *******************************************************************************/
451 GLOBAL int voice_memo_storeage (MfwMnu* m, MfwMnuItem* i)
452 {
453 T_MFW_HND parent_win = mfwParent(mfw_header());
454 int txtId = TxtFFS;
455
456 TRACE_FUNCTION("mmi_camera_set_storage()");
457
458 switch (m->lCursor[m->level])
459 {
460 case 0:
461 txtId = TxtFFS;
462 FFS_flashData.voicememo_storage = SNAP_STG_FFS;
463 break;
464
465 case 1:
466 txtId = TxtNORMS;
467 FFS_flashData.voicememo_storage = SNAP_STG_NORMS;
468 break;
469
470 case 2:
471 txtId = TxtNAND;
472 FFS_flashData.voicememo_storage = SNAP_STG_NAND;
473 break;
474
475 case 3:
476 txtId = TxtTflash;
477 FFS_flashData.voicememo_storage = SNAP_STG_MMC;
478 break;
479 }
480
481 flash_write();
482 //Set the Quality Factor.
483 TRACE_EVENT_P1("STorage set to %d ", FFS_flashData.voicememo_storage);
484 //Display the dialgbox to the user.
485 voice_memo_dialog_create(parent_win,txtId,TxtSelected);
486 return MFW_EVENT_CONSUMED;
487 }
488 #endif
489
490
491 /*******************************************************************************
492
493 $Function: voice_memo_record
494
495 $Description:
496
497
498 $Returns:
499
500 $Arguments:
501
502 *******************************************************************************/
503 GLOBAL int voice_memo_record (MfwMnu* m, MfwMnuItem* i)
504 {
505
506 T_MFW_HND win = mfw_parent(mfw_header());
507
508 TRACE_FUNCTION ("voice_memo_record()");
509
510 //x0pleela 27 Feb, 2006 ER: OMAPA00067709
511 //Set this variable to VOICE_MEMOwhich indicates voice memo is active
512 #ifdef FF_PCM_VM_VB
513 set_voice_memo_type( AMR_VOICE_MEMO);
514 #endif
515 //create a new voice memo dialog
516 voice_memo_start (win, VM_RECORD);
517 return 1; // RAVI - 29-11-2005
518 }
519
520
521 /*******************************************************************************
522
523 $Function: voice_memo_start
524
525 $Description: create a new voicememo dialog
526
527 $Returns: Dialogue info win
528
529 $Arguments: parent win, display info
530
531 *******************************************************************************/
532 T_MFW_HND voice_memo_start (T_MFW_HND parent_win, SHORT ID)
533 {
534 T_MFW_HND win;
535
536 win = voice_memo_create (parent_win);
537
538 if (win NEQ NULL)
539 {
540 SEND_EVENT (win, VM_INIT, ID, 0);
541 }
542 return win;
543 }
544
545
546
547 /*******************************************************************************
548
549 $Function: vocie_memo_create
550
551 $Description: Creation of window
552
553 $Returns: Dialogue info win
554
555 $Arguments: parent win
556
557 *******************************************************************************/
558 static T_MFW_HND voice_memo_create (T_MFW_HND parent_win)
559 {
560 T_MFW_WIN * win_data;
561 T_voice_memo * data = (T_voice_memo *)ALLOC_MEMORY (sizeof (T_voice_memo));
562
563 TRACE_FUNCTION ("vocie_memo_create()");
564
565 data->info_win = win_create (parent_win, 0, E_WIN_VISIBLE, (T_MFW_CB)voice_memo_win_cb);
566
567 if (data->info_win EQ 0)
568 return 0;
569
570 /*
571 * Create window handler
572 */
573 data->mmi_control.dialog = (T_DIALOG_FUNC)voice_memo;
574 data->mmi_control.data = data;
575 data->parent_win = parent_win;
576 win_data = ((T_MFW_HDR *)data->info_win)->data;
577 win_data->user = (void *)data;
578
579 /*
580 ** Initialise values to safe defualts
581 */
582 data->play_sk2 = TxtSoftBack;
583
584 /*
585 * return window handle
586 */
587 return data->info_win;
588 }
589
590
591 /*******************************************************************************
592
593 $Function: voice_memo_destroy
594
595 $Description: Destruction of an dialog
596
597 $Returns: void
598
599 $Arguments: win
600
601 *******************************************************************************/
602 void voice_memo_destroy (T_MFW_HND own_window)
603 {
604 T_MFW_WIN * win = ((T_MFW_HDR *)own_window)->data;
605 T_voice_memo * data = (T_voice_memo *)win->user;
606
607 TRACE_FUNCTION ("voice_memo_destroy()");
608
609 if (own_window == NULL)
610 {
611 TRACE_EVENT ("Error : Called with NULL Pointer");
612 return;
613 }
614
615 if (data)
616 {
617 /*
618 * Exit TIMER & KEYBOARD Handle
619 */
620 kbd_delete (data->info_kbd);
621 tim_delete (data->info_tim);
622
623 /*
624 * Delete WIN Handler
625 */
626 win_delete (data->info_win);
627 /*
628 * Free Memory
629 */
630 FREE_MEMORY ((void *)data, sizeof (T_voice_memo));
631 }
632
633 //x0pleela 27 Feb, 2006 ER: OMAPA00067709
634 //Set gVoiceMemo to NONE while destroying voice memo dialog
635 #ifdef FF_PCM_VM_VB
636 set_voice_memo_type( NONE);
637 #endif
638 }
639
640
641
642 /*******************************************************************************
643
644 $Function: voice_memo
645
646 $Description: Dialog function for voice memo dialog
647
648 $Returns: void
649
650 $Arguments: win, window handle event, value, parameter
651
652 *******************************************************************************/
653 void voice_memo (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
654 {
655 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
656 T_voice_memo * data = (T_voice_memo *)win_data->user;
657
658 // T_DISPLAY_DATA display_info; // RAVI
659
660 SHORT mfw_aud_retVal = 0; /* x0039928 - Lint warning fix */
661 #ifdef FF_PCM_VM_VB
662 UBYTE vm_type; //to store voice memo type
663 #endif
664
665
666 data->Identifier = value;
667
668 TRACE_FUNCTION ("voice_memo()");
669
670 switch (event)
671 {
672 case VM_INIT:
673 TRACE_EVENT ("VM_INIT()");
674 /*
675 * Initialize dialog
676 */
677
678 /*
679 * Create timer and keyboard handler
680 */
681 data->info_tim = tim_create (win, 1000, (T_MFW_CB)voice_memo_tim_cb);
682 data->info_kbd = kbd_create (win, KEY_ALL, (T_MFW_CB)voice_memo_kbd_cb);
683
684
685 if (value EQ VM_PLAY)
686 {
687 TRACE_EVENT ("VM_PLAY()");
688
689 mfw_aud_retVal = mfw_aud_vm_start_playback(voice_memo_riv_play_cb);
690
691 if (mfw_aud_retVal == MFW_AUD_VM_OK)
692 {
693 //start the second timer
694 data->time = 0;
695 tim_start (data->info_tim);
696
697 //Set the Right Softkey Id
698 data->play_sk2 = TxtStop;
699 }
700 else
701 {
702 if (mfw_aud_retVal == MFW_AUD_VM_MEM_EMPTY)
703 {
704 voice_memo_dialog_create(win, TxtRecording, TxtEmpty);
705 }
706 else
707 {
708 //Display a dialog and exit
709 TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_start_playback failed with return value : %d", mfw_aud_retVal);
710
711 voice_memo_dialog_create( win, TxtPlayback, TxtFailed);
712 }
713 }
714 }
715 else if (value EQ VM_RECORD)
716 {
717 TRACE_FUNCTION ("VM_RECORD()");
718 //x0pleela 27 Feb, 2006 ER: OMAPA00067709
719 //Pass 20 secs time out for PCM voice memo and 10 secs for AMR Voice memo
720 #ifdef FF_PCM_VM_VB
721 //get the voice memo type
722 vm_type = get_voice_memo_type();
723
724 if(vm_type EQ PCM_VOICE_MEMO)
725 mfw_aud_retVal = mfw_aud_vm_start_record(PCM_VOICE_MEMO_MAX_DURATION,
726 voice_memo_riv_record_cb);
727 else
728 {
729 if(vm_type EQ AMR_VOICE_MEMO )
730 #endif
731 mfw_aud_retVal = mfw_aud_vm_start_record(VOICE_MEMO_MAX_DURATION, voice_memo_riv_record_cb);
732 #ifdef FF_PCM_VM_VB
733 }
734 #endif
735
736 // If the Riviera call failed
737 if (mfw_aud_retVal == MFW_AUD_VM_OK)
738 {
739 //start the second timer
740 data->time = 0;
741 tim_start (data->info_tim);
742 }
743 else
744 {
745 if (mfw_aud_retVal == MFW_AUD_VM_MEM_FULL)
746 {
747 TRACE_EVENT ("memory full ");
748 /* RAVI - 20-1-2006 */
749 /* Silent Implementation */
750 #ifdef NEPTUNE_BOARD
751 audio_PlaySoundID(0, TONES_KEYBEEP, getCurrentVoulmeSettings(),
752 AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
753 #else
754 /* play Keybeep */
755 audio_PlaySoundID(0, TONES_KEYBEEP, 200, AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
756 #endif
757 /* END RAVI */
758
759 voice_memo_dialog_create( win, TxtRecording, TxtFull );
760 }
761 else
762 {
763 //Display a dialog and exit
764 TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_start_record failed with return value : %d", mfw_aud_retVal);
765
766 voice_memo_dialog_create( win, TxtRecording, TxtFailed );
767 }
768 }
769 }
770 win_show (win);
771 break;
772
773
774 //if the user selected to clear the Voicememo buffer
775 case VM_DELETE_BUFFER:
776 voice_memo_dialog_create( win, TxtDeleted, TxtNull );
777
778 /*
779 ** Delete the voice memo file
780 */
781 mfw_aud_vm_delete_file();
782 break;
783
784 case VM_DESTROY:
785 voice_memo_destroy(win);
786 break;
787 }
788 return;
789 }
790
791 /*******************************************************************************
792
793 $Function: voice_memo_win_cb
794
795 $Description: Callback function for information dialog
796
797 $Returns: void
798
799 $Arguments: window handle event, win
800 *******************************************************************************/
801 static int voice_memo_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
802 {
803 T_voice_memo * data = (T_voice_memo *)win->user;
804
805 TRACE_FUNCTION ("voice_memo_win_cb()");
806
807 if (data EQ 0)
808 return 1;
809
810 switch (event)
811 {
812 case E_WIN_VISIBLE:
813 if (win->flags & E_WIN_VISIBLE)
814 {
815 /*
816 * Clear Screen
817 */
818 dspl_ClearAll();
819
820 switch (data->Identifier)
821 {
822 case VM_PLAY:
823 /*
824 * Print the information screen
825 */
826 ALIGNED_PROMPT((T_MMI_ALIGN)LEFT,Mmi_layout_line(1),0, TxtPlayback);
827
828 /*
829 * Print the elapsed time
830 */
831 displayAlignedText(LEFT, Mmi_layout_line(2), 0, data->elapsed_time);
832
833 /*
834 * Print softkeys
835 */
836 displaySoftKeys(TxtDelete, data->play_sk2);
837 break;
838
839 case VM_RECORD:
840 /*
841 * Print the information screen
842 */
843 ALIGNED_PROMPT((T_MMI_ALIGN)LEFT,Mmi_layout_line(1),0, TxtRecording);
844
845 /*
846 * Print the elapsed time
847 */
848 displayAlignedText(LEFT, Mmi_layout_line(2), 0, data->elapsed_time);
849
850 /*
851 * Print softkeys
852 */
853 displaySoftKeys(TxtStop, '\0');
854 break;
855 }
856
857 }
858 break;
859
860 default:
861 return 0;
862 }
863 return 1;
864 }
865
866
867 /*******************************************************************************
868
869 $Function: voice_memo_tim_cb
870
871 $Description: Callback function for the voice_memo timer.
872
873
874 $Returns: MFW event handler
875
876 $Arguments: window handle event, timer control block
877
878 *******************************************************************************/
879 static T_MFW_CB voice_memo_tim_cb (T_MFW_EVENT event, T_MFW_TIM *tc)
880 {
881 T_MFW_HND win = mfw_parent (mfw_header());
882 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
883 T_voice_memo * data = (T_voice_memo *)win_data->user;
884
885 SHORT mfw_aud_retVal;
886 //x0pleela 27 Feb, 2006 ER:OMAPS00067709
887 //to store PCM/AMR voice memo record/play duration
888 USHORT vm_duration = 0; /* x0039928 - Lint warning fix */
889 // char buf[40]; // RAVI
890
891 //x0pleela 08 Mar, 2006 ER:OMAPS00067709
892 #ifdef FF_PCM_VM_VB
893 UBYTE vm_type; //to store voice memo type
894 #endif
895
896 TRACE_FUNCTION ("voice_memo_tim_cb()");
897
898 //x0pleela 27 Feb, 2006 ER:OMAPS00067709
899 #ifdef FF_PCM_VM_VB
900 //x0pleela 06 Mar, 2006 ER:OMAPS00067709
901 //get the voice memo type
902 vm_type = get_voice_memo_type();
903
904 if(vm_type EQ PCM_VOICE_MEMO)
905 vm_duration = PCM_VOICE_MEMO_MAX_DURATION;
906 else
907 {
908 if (vm_type EQ AMR_VOICE_MEMO)
909 #endif
910 vm_duration = VOICE_MEMO_MAX_DURATION;
911 #ifdef FF_PCM_VM_VB
912 }
913 #endif
914
915 switch (data->Identifier)
916 {
917 case VM_PLAY:
918 //the max. playback time is 10 second
919 if (data->time < mfw_aud_vm_get_duration())
920 {
921 TRACE_EVENT ("continue the second timer");
922
923 data->time ++;
924 // it shows here the elapsed time
925 sprintf(data->elapsed_time,"%02d sec", data->time);
926
927 TRACE_EVENT (data->elapsed_time);
928
929 //continue the second timer
930 tim_start (data->info_tim);
931 }
932 else
933 {
934 data->play_sk2 = TxtSoftBack;
935 #ifndef _SIMULATION_
936 /*
937 ** Stop playing the Voice Memo.
938 */
939 mfw_aud_retVal = mfw_aud_vm_stop_playback(voice_memo_riv_play_cb);
940
941 if (mfw_aud_retVal != MFW_AUD_VM_OK)
942 TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_playback failed with return value : %d", mfw_aud_retVal);
943 #else
944 TRACE_EVENT("call mfw_aud_vm_stop_playback()");
945 #endif
946 }
947 break;
948
949
950 case VM_RECORD:
951
952 data->time++;
953
954 if (data->time < vm_duration)
955 {
956 TRACE_EVENT ("continue the second timer");
957 //x0pleela 27 Feb, 2006 ER:OMAPS00067709
958 //changed from Macro VOICE_MEMO_MAX_DURATION to local variable vm_duration
959 // it shows here the remainig time
960 sprintf(data->elapsed_time,"%02d sec", (vm_duration - data->time));
961
962 TRACE_EVENT (data->elapsed_time);
963
964 //continue the second timer
965 tim_start (data->info_tim);
966 }
967 else
968 {
969 //x0pleela 27 Feb, 2006 ER:OMAPS00067709
970 //changed from Macro VOICE_MEMO_MAX_DURATION to local variable vm_duration
971 mfw_aud_vm_set_duration(vm_duration);
972
973 #ifndef _SIMULATION_
974 /*
975 ** Stop recording the Voice Memo.
976 */
977 mfw_aud_retVal = mfw_aud_vm_stop_record(voice_memo_riv_record_cb);
978
979 if (mfw_aud_retVal != MFW_AUD_VM_OK)
980 TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_record failed with return value : %d", mfw_aud_retVal);
981 /* RAVI - 20-1-2006 */
982 #ifdef NEPTUNE_BOARD
983 audio_PlaySoundID(0, TONES_KEYBEEP, getCurrentVoulmeSettings(),
984 AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
985 #else
986 /*the voice memo is now full, show "memory full" */
987 audio_PlaySoundID(0, TONES_KEYBEEP, 200, AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
988 #endif
989 /* END RAVI */
990
991 voice_memo_dialog_create( win, TxtRecording, TxtFull );
992 #else
993 TRACE_EVENT("call mfw_aud_vm_stop_record()");
994 #endif
995 }
996 break;
997 }
998
999 //Update the screen
1000 winShow(win);
1001
1002 return 0;
1003 }
1004
1005
1006 /*******************************************************************************
1007
1008 $Function: voice_memo_kbd_cb
1009
1010 $Description: Keyboard event handler
1011
1012 $Returns: status int
1013
1014 $Arguments: window handle event, keyboard control block
1015
1016 *******************************************************************************/
1017
1018 static int voice_memo_kbd_cb (T_MFW_EVENT event, T_MFW_KBD *keyboard)
1019 {
1020 T_MFW_HND win = mfw_parent (mfw_header());
1021 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1022 T_voice_memo * data = (T_voice_memo *)win_data->user;
1023
1024 USHORT Identifier = data->Identifier;
1025 SHORT mfw_aud_retVal;
1026
1027
1028 TRACE_FUNCTION("voice_memo_kbd_cb");
1029
1030 switch (keyboard->code)
1031 {
1032 case KCD_HUP:
1033 case KCD_LEFT:
1034 if (Identifier EQ VM_PLAY)
1035 {
1036 #ifndef _SIMULATION_
1037 /*
1038 ** Stop playing the Voice Memo and Delete it.
1039 */
1040 mfw_aud_retVal = mfw_aud_vm_stop_playback(voice_memo_riv_play_cb);
1041
1042 if (mfw_aud_retVal != MFW_AUD_VM_OK)
1043 TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_playback failed with return value : %d", mfw_aud_retVal);
1044 #else
1045 TRACE_EVENT("call mfw_aud_vm_stop_playback()");
1046 #endif
1047 //delete the voicememo buffer
1048 /* Mar 28, 2007 DR: OMAPS00122762 x0039928 */
1049 /* Fix: Commented duration reset */
1050 /* mfw_aud_vm_set_duration(0); */
1051
1052 //user selected the delete-key
1053 SEND_EVENT (win, VM_DELETE_BUFFER, 0, 0);
1054 }
1055 else if (Identifier EQ VM_RECORD)
1056 {
1057 mfw_aud_vm_set_duration(data->time);
1058
1059 #ifndef _SIMULATION_
1060 /*
1061 ** Stop recording the Voice Memo.
1062 */
1063 mfw_aud_retVal = mfw_aud_vm_stop_record(voice_memo_riv_record_cb);
1064
1065 if (mfw_aud_retVal != MFW_AUD_VM_OK)
1066 TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_record failed with return value : %d", mfw_aud_retVal);
1067
1068 //go back to the previous dialog
1069 SEND_EVENT (win, VM_DESTROY, 0, 0);
1070 #else
1071 TRACE_EVENT("call mfw_aud_vm_stop_record()");
1072 #endif
1073 }
1074 break;
1075
1076 case KCD_RIGHT:
1077 if (Identifier EQ VM_PLAY)
1078 {
1079
1080 #ifndef _SIMULATION_
1081 /*
1082 ** Stop playing the Voice Memo.
1083 */
1084 mfw_aud_retVal = mfw_aud_vm_stop_playback(voice_memo_riv_play_cb);
1085
1086 if (mfw_aud_retVal != MFW_AUD_VM_OK)
1087 TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_playback failed with return value : %d", mfw_aud_retVal);
1088 #else
1089 TRACE_EVENT("call mfw_aud_vm_stop_playback()");
1090 #endif
1091
1092 //go back to the previous dialog
1093 SEND_EVENT (win, VM_DESTROY, 0, 0);
1094 }
1095 else if (Identifier EQ VM_RECORD)
1096 {
1097 //nothing
1098 }
1099 break;
1100
1101 default:
1102 break;
1103 }
1104 return MFW_EVENT_CONSUMED;
1105 }
1106
1107
1108 /*******************************************************************************
1109
1110 $Function: voice_memo_dialog_cb
1111
1112 $Description:
1113
1114 $Returns:
1115
1116 $Arguments:
1117
1118 *******************************************************************************/
1119 void voice_memo_dialog_cb(T_MFW_HND win, UBYTE identifier, UBYTE reason)
1120 {
1121 TRACE_FUNCTION ("voice_memo_dialog_cb()");
1122
1123 switch (reason)
1124 {
1125 case INFO_KCD_LEFT:
1126 /* no break; */
1127 case INFO_TIMEOUT:
1128 /* no break; */
1129 case INFO_KCD_HUP:
1130 /* no break; */
1131 case INFO_KCD_RIGHT:
1132 /* no break; */
1133 case INFO_KCD_CLEAR:
1134
1135 //go back to the previous dialog
1136 SEND_EVENT (win, VM_DESTROY,0, 0);
1137
1138 break;
1139 }
1140 }
1141
1142
1143 /*******************************************************************************
1144
1145 $Function: voice_memo_dialog_create
1146
1147 $Description:
1148
1149 $Returns:
1150
1151 $Arguments:
1152
1153 *******************************************************************************/
1154 static void voice_memo_dialog_create(T_MFW_HND win, int str1, int str2)
1155 {
1156 T_DISPLAY_DATA display_info;
1157
1158 TRACE_FUNCTION ("voice_memo_dialog_create()");
1159
1160 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, str1, str2, COLOUR_STATUS);
1161 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)voice_memo_dialog_cb, THREE_SECS, KEY_CLEAR | KEY_RIGHT | KEY_LEFT );
1162 /*
1163 * Call Info Screen
1164 */
1165 info_dialog (win, &display_info);
1166 }
1167
1168 static void voice_memo_riv_record_cb(void *parameter)
1169 {
1170 /* BEGIN ADD: Req ID: : Sumit : 14-Mar-05 */
1171 #ifndef NEPTUNE_BOARD
1172 /* END ADD: Req ID: : Sumit : 14-Mar-05 */
1173
1174 //x0pleela 16 Mar, 2006 ER:OMAPS00067709
1175 #ifdef FF_PCM_VM_VB
1176 UBYTE vm_type; //to store voice memo type
1177 #endif
1178
1179
1180 //x0pleela 16 Mar, 2006 ER:OMAPS00067709
1181 #ifdef FF_PCM_VM_VB
1182 vm_type = get_voice_memo_type();
1183 switch( vm_type )
1184 {
1185 case AMR_VOICE_MEMO:
1186 {
1187 #endif /* FF_PCM_VM_VB */
1188 T_AUDIO_VM_RECORD_STATUS *record_status;
1189 record_status = (T_AUDIO_VM_RECORD_STATUS *)parameter;
1190 if (record_status->status != AUDIO_OK)
1191 {
1192 TRACE_EVENT_P1("ERROR : voice_memo_riv_record_cb received AUDIO_ERROR, recorded duration is %d",
1193 record_status->recorded_duration);
1194 }
1195 else
1196 {
1197 TRACE_EVENT_P1("INFO : voice_memo_riv_record_cb received AUDIO_OK, recorded duration is %d",
1198 record_status->recorded_duration);
1199 mfw_aud_vm_set_duration((UINT8)record_status->recorded_duration);
1200 }
1201 #ifdef FF_PCM_VM_VB
1202 }
1203 break;
1204
1205 case PCM_VOICE_MEMO:
1206 {
1207 T_AUDIO_VM_PCM_RECORD_STATUS *pcm_vm_record_status;
1208
1209 pcm_vm_record_status = (T_AUDIO_VM_PCM_RECORD_STATUS *)parameter;
1210 if (pcm_vm_record_status->status != AUDIO_OK)
1211 {
1212 TRACE_EVENT_P1("ERROR : voice_memo_riv_record_cb received AUDIO_ERROR, recorded duration is %d",
1213 pcm_vm_record_status->recorded_duration);
1214 }
1215 else
1216 {
1217 TRACE_EVENT_P1("INFO : voice_memo_riv_record_cb received AUDIO_OK, recorded duration is %d",
1218 pcm_vm_record_status->recorded_duration);
1219 mfw_aud_vm_set_duration((UINT8)pcm_vm_record_status->recorded_duration);
1220 }
1221 }
1222 break;
1223
1224 case VOICE_BUFFERING:
1225 {
1226 T_AUDIO_VBUF_PCM_RECORD_STATUS *vbuf_pcm_record_status;
1227
1228 vbuf_pcm_record_status = (T_AUDIO_VBUF_PCM_RECORD_STATUS *)parameter;
1229
1230 if (vbuf_pcm_record_status->status != AUDIO_OK)
1231 {
1232 TRACE_EVENT_P1("ERROR : voice_memo_riv_record_cb received AUDIO_ERROR, recorded duration is %d",
1233 vbuf_pcm_record_status->recorded_duration);
1234 }
1235 else
1236 {
1237 TRACE_EVENT_P1("INFO : voice_memo_riv_record_cb received AUDIO_OK, recorded duration is %d",
1238 vbuf_pcm_record_status->recorded_duration);
1239 //x0pleela 13 Mar, 2006 ER:OMAPS00067709
1240 //check for reason to call record_stop
1241 switch( voice_buffering_data.rec_stop_reason)
1242 {
1243 case CALLING_PARTY_END_CALL: //calling party hangs up
1244 case CALLED_PARTY_END_CALL: //called party hangs up
1245 voice_buffering_data.call_active = FALSE;
1246 break;
1247
1248 case PLAY_ERROR: //recording timeout while playing
1249 voice_buffering_data.buffering_phase = FALSE;
1250 break;
1251
1252 case CALL_END_BEF_SETUP: //calling party hangs up before call setup
1253 case USER_SEL_STOP: //user selected "STOP" option, then just return
1254 case RECORDING_TIMEOUT: //recording timeout
1255 case CALLED_PARTY_NOT_AVAILABLE: //not reachable
1256 default:
1257 break;
1258 }
1259 voice_buffering_data.recording_possible = TRUE;
1260 voice_buffering_data.incoming_call_discon = FALSE;
1261 //destroy timer
1262 timDelete(voice_buffering_data.voice_buffering_tim);
1263 }
1264 //x0pleela 03 Apr, 2006 ER: OMAPS00067709
1265 //Set voice memo type to NONE
1266 set_voice_memo_type(NONE);
1267 }
1268
1269 break;
1270
1271 default:
1272 break;
1273 }
1274
1275
1276
1277 #endif /* FF_PCM_VM_VB */
1278
1279 /* BEGIN ADD: Req ID: : Sumit : 14-Mar-05 */
1280 #endif /* NEPTUNE_BOARD */
1281 /* END ADD: Req ID: : Sumit : 14-Mar-05 */
1282
1283 }
1284
1285 static void voice_memo_riv_play_cb(void *parameter)
1286 {
1287 /* BEGIN ADD: Req ID: : Sumit : 14-Mar-05 */
1288 #ifndef NEPTUNE_BOARD
1289 /* END ADD: Req ID: : Sumit : 14-Mar-05 */
1290
1291 //x0pleela 16 Mar, 2006 ER:OMAPS00067709
1292 #ifdef FF_PCM_VM_VB
1293 UBYTE vm_type; //to store voice memo type
1294 #endif
1295
1296 //x0pleela 16 Mar, 2006 ER:OMAPS00067709
1297 #ifdef FF_PCM_VM_VB
1298 vm_type = get_voice_memo_type();
1299 switch( vm_type )
1300 {
1301 case AMR_VOICE_MEMO:
1302 {
1303 #endif /* FF_PCM_VM_VB */
1304
1305 T_AUDIO_VM_PLAY_STATUS *play_status;
1306 play_status = (T_AUDIO_VM_PLAY_STATUS *)parameter;
1307 if (play_status->status != AUDIO_OK)
1308 {
1309 TRACE_EVENT("ERROR : voice_memo_riv_play_cb received AUDIO_ERROR");
1310 }
1311 else
1312 {
1313 TRACE_EVENT("INFO : voice_memo_riv_play_cb received AUDIO_OK");
1314 }
1315
1316 #ifdef FF_PCM_VM_VB
1317 }
1318 break;
1319
1320 case PCM_VOICE_MEMO:
1321 {
1322 T_AUDIO_VM_PCM_PLAY_STATUS *pcm_vm_play_status;
1323 pcm_vm_play_status = (T_AUDIO_VM_PCM_PLAY_STATUS *)parameter;
1324 if (pcm_vm_play_status->status != AUDIO_OK)
1325 {
1326 TRACE_EVENT("ERROR : voice_memo_riv_play_cb received AUDIO_ERROR");
1327 }
1328 else
1329 {
1330 TRACE_EVENT("INFO : voice_memo_riv_play_cb received AUDIO_OK");
1331 }
1332 }
1333 break;
1334
1335 case VOICE_BUFFERING:
1336 {
1337 T_AUDIO_VBUF_PCM_PLAY_STATUS *voice_buffering_play_status;
1338 voice_buffering_play_status = (T_AUDIO_VBUF_PCM_PLAY_STATUS *)parameter;
1339
1340 if (voice_buffering_play_status->status != AUDIO_OK)
1341 {
1342 TRACE_EVENT("ERROR : voice_memo_riv_play_cb received AUDIO_ERROR");
1343 }
1344 else
1345 {
1346 TRACE_EVENT("INFO : voice_memo_riv_play_cb received AUDIO_OK");
1347 voice_buffering_data.buffering_phase = FALSE;
1348 voice_buffering_data.play_stopped = TRUE;
1349 }
1350
1351 //x0pleela 06 Jul, 2006 DR: OMAPS00067709
1352 //Fix from AS team
1353 vocoder_mute_ul(0);
1354
1355 //x0pleela 03 Apr, 2006 ER: OMAPS00067709
1356 //Set voice memo type to NONE
1357 set_voice_memo_type(NONE);
1358 }
1359
1360 break;
1361
1362 default:
1363 break;
1364 }
1365
1366
1367
1368 #endif /* FF_PCM_VM_VB */
1369
1370 /* BEGIN ADD: Req ID: : Sumit : 14-Mar-05 */
1371 #endif /* NEPTUNE_BOARD*/
1372 /* END ADD: Req ID: : Sumit : 14-Mar-05 */
1373
1374 }
1375
1376 //x0pleela 24 Feb, 2006 ER OMAPS00067709
1377 #ifdef FF_PCM_VM_VB
1378
1379 /*******************************************************************************
1380
1381 $Function: pcm_voice_memo_play
1382
1383 $Description: Sets voice memo type to PCM_VOICE_MEMO which indicates PCM voice memo is
1384 active and start playing the voice
1385
1386 $Returns:
1387
1388 $Arguments:
1389
1390 *******************************************************************************/
1391 GLOBAL int pcm_voice_memo_play (MfwMnu* m, MfwMnuItem* i)
1392 {
1393 T_MFW_HND win = mfw_parent(mfw_header());
1394
1395 TRACE_FUNCTION ("pcm_voice_memo_play()");
1396
1397 //x0pleela 27 Feb, 2006 ER: OMAPA00067709
1398 //Set this variable to PCM_VOICE_MEMO which indicates PCM voice memo is active
1399 set_voice_memo_type( PCM_VOICE_MEMO);
1400 //create a new voice memo dialog
1401 voice_memo_start (win, VM_PLAY);
1402 return 1;
1403 }
1404
1405 /*******************************************************************************
1406
1407 $Function: pcm_voice_memo_record
1408
1409 $Description: Sets voice memo type to PCM_VOICE_MEMO which indicates PCM voice memo is
1410 active and start recording the voice
1411
1412
1413 $Returns:
1414
1415 $Arguments:
1416
1417 *******************************************************************************/
1418 GLOBAL int pcm_voice_memo_record (MfwMnu* m, MfwMnuItem* i)
1419 {
1420 T_MFW_HND win = mfw_parent(mfw_header());
1421
1422 TRACE_FUNCTION ("pcm_voice_memo_record()");
1423
1424 //x0pleela 27 Feb, 2006 ER: OMAPA00067709
1425 //Set this variable to PCM_VOICE_MEMO which indicates PCM voice memo is active
1426 set_voice_memo_type( PCM_VOICE_MEMO);
1427 //create a new voice memo dialog
1428 voice_memo_start (win, VM_RECORD);
1429 return 1;
1430 }
1431
1432 /*******************************************************************************
1433
1434 $Function: voice_buffering_edit_num
1435
1436 $Description: Opens an edtor for the user to enter PTT number. Also resets voice buffering data
1437 with default values
1438
1439 $Returns:
1440
1441 $Arguments:
1442
1443 *******************************************************************************/
1444 GLOBAL int voice_buffering_edit_num (MfwMnu* m, MfwMnuItem* i)
1445 {
1446 T_MFW_HND win = mfw_parent(mfw_header());
1447 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
1448 tBookStandard *data = (tBookStandard *) win_data->user;
1449 T_phbk *Phbk = data->phbk;
1450
1451 TRACE_FUNCTION ("voice_buffering_edit_num()");
1452
1453 set_voice_memo_type( VOICE_BUFFERING );
1454
1455 memset( Phbk->phbk->edt_buf_number, '\0', PHB_MAX_LEN );
1456 Phbk->input_number_win = inputVoiceMemoNumberEditor( win, Phbk->edt_buf_number );
1457
1458 //Reset voice buffering data with default values
1459 voice_buffering_data_reset();
1460
1461 /* Always return event consumed */
1462 return MFW_EVENT_CONSUMED;
1463 }
1464
1465 /*******************************************************************************
1466
1467 $Function: voiceMemoNumberCB
1468
1469 $Description: Call back for number entry
1470
1471 $Returns: None
1472
1473 $Arguments: win, parent window, reason, for call back
1474
1475 *******************************************************************************/
1476
1477 void voiceMemoNumberCB( T_MFW_HND win, USHORT Identifier, UBYTE reason )
1478 {
1479 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
1480 tBookStandard *data = (tBookStandard *) win_data->user;
1481
1482 TRACE_FUNCTION("voiceMemoNumberCB()");
1483
1484 switch ( reason )
1485 {
1486 case INFO_KCD_LEFT:
1487 {
1488 //copy phone number to global
1489 memset( voice_buffering_data.vb_PTTnum, 0, PHB_MAX_LEN );
1490 memcpy( voice_buffering_data.vb_PTTnum, data->phbk->edt_buf_number, strlen(data->phbk->edt_buf_number) );
1491 SEND_EVENT( data->phbk->input_number_win, E_ED_DESTROY, 0, 0 );
1492 data->phbk->input_number_win = 0;
1493 }
1494 break;
1495
1496 case INFO_KCD_RIGHT:
1497 case INFO_KCD_HUP:
1498 {
1499 AUI_edit_Destroy( data->phbk->input_number_win );
1500 data->phbk->input_number_win = 0;
1501 }
1502 break;
1503
1504 default:
1505 {
1506 /* otherwise no action to be performed
1507 */
1508 break;
1509 }
1510 }
1511 }
1512 /*******************************************************************************
1513
1514 $Function: inputVoiceMemoNumberEditor
1515
1516 $Description: Settings of Editor
1517
1518 $Returns:
1519
1520 $Arguments:
1521
1522 *******************************************************************************/
1523 MfwHnd inputVoiceMemoNumberEditor( MfwHnd parent, void *buffer )
1524 {
1525 T_AUI_EDITOR_DATA editor_data;
1526
1527 TRACE_FUNCTION ("inputVoiceMemoNumberEditor()");
1528
1529 AUI_edit_SetDefault(&editor_data);
1530 AUI_edit_SetDisplay(&editor_data, NUMBER_EDITOR, COLOUR_EDITOR_XX, EDITOR_FONT);
1531 AUI_edit_SetEvents(&editor_data, 0, FALSE, FOREVER, (T_AUI_EDIT_CB)voiceMemoNumberCB);
1532 AUI_edit_SetTextStr(&editor_data, TxtSoftOK, TxtDelete, TxtEnterNumber, NULL);
1533 AUI_edit_SetAltTextStr(&editor_data, 0, NULL, TRUE, TxtSoftBack);
1534 AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)buffer, NUMBER_LENGTH);
1535 AUI_edit_SetMode(&editor_data, 0, ED_CURSOR_UNDERLINE);
1536
1537 return AUI_edit_Start(parent, &editor_data);
1538 }
1539
1540 /*******************************************************************************
1541 $Function: voice_buffering_record_start
1542
1543 $Description: Starts recording voice and conects to the PTT number if the call is not active.
1544 If in call, then start playing the voice
1545
1546 $Returns:
1547
1548 $Arguments:
1549
1550 *******************************************************************************/
1551 GLOBAL int voice_buffering_record_start (MfwMnu* m, MfwMnuItem* i)
1552 {
1553 T_MFW_HND win = mfw_parent(mfw_header());
1554 SHORT mfw_aud_retVal;
1555
1556 TRACE_FUNCTION ("voice_buffering_record_start()");
1557 TRACE_EVENT_P1("PTT#: %s", voice_buffering_data.vb_PTTnum);
1558
1559 set_voice_memo_type( VOICE_BUFFERING );
1560
1561 //store window handler
1562 voice_buffering_data.win_hnd = win;
1563
1564 if( voice_buffering_data.recording_possible )
1565 {
1566 //create timer
1567 voice_buffering_data.voice_buffering_tim= tim_create (win, 20000,
1568 (T_MFW_CB)voice_buffering_tim_cb);
1569 //start timer
1570 timStart(voice_buffering_data.voice_buffering_tim);
1571 voice_buffering_data.buffering_phase = TRUE;
1572 voice_buffering_data.recording_possible = FALSE;
1573
1574 mfw_aud_retVal = mfw_aud_vm_start_record(PCM_VOICE_MEMO_MAX_DURATION,
1575 voice_memo_riv_record_cb);
1576 if(voice_buffering_data.call_active )
1577 {
1578 //start playing the recorded voice
1579 voice_buffering_playback_start();
1580 }
1581 else
1582 {
1583 //call PTT number
1584 callNumber((UBYTE*)voice_buffering_data.vb_PTTnum);
1585 }
1586
1587 // If the Riviera call failed
1588 if (mfw_aud_retVal EQ MFW_AUD_VM_OK)
1589 {
1590 //no action to be performed
1591 }
1592 else
1593 {
1594 if (mfw_aud_retVal == MFW_AUD_VM_MEM_FULL)
1595 {
1596 TRACE_EVENT ("memory full ");
1597 /* Silent Implementation */
1598 /* play Keybeep */
1599 audio_PlaySoundID(0, TONES_KEYBEEP, 200, AUDIO_PLAY_ONCE ); /* GW#2355 /CQ11341 */
1600
1601 voice_memo_dialog_create( win, TxtRecording, TxtFull );
1602 }
1603 else
1604 {
1605 //Display a dialog and exit
1606 TRACE_EVENT_P1 ("ERROR : voice_buffering_record_start failed with return value : %d", mfw_aud_retVal);
1607
1608 voice_memo_dialog_create( win, TxtRecording, TxtFailed );
1609 }
1610 }
1611 }
1612 else
1613 {
1614 //Display a dialog saying "Already Recording"
1615 voice_memo_dialog_create(win, TxtAlready, TxtRecording);
1616 }
1617 win_show (win);
1618 return 1;
1619 }
1620
1621 /*******************************************************************************
1622
1623 $Function: voice_buffering_record_stop
1624
1625 $Description: Stops the timer and recording. If call is not active the disconnects the call
1626
1627 $Returns:
1628
1629 $Arguments:
1630
1631 *******************************************************************************/
1632 GLOBAL int voice_buffering_record_stop (MfwMnu* m, MfwMnuItem* i)
1633 {
1634 T_MFW_HND win = mfw_parent(mfw_header());
1635
1636 TRACE_FUNCTION ("voice_buffering_record_stop()");
1637
1638 set_voice_memo_type ( VOICE_BUFFERING );
1639
1640 //store window handler
1641 voice_buffering_data.win_hnd = win;
1642
1643 voice_buffering_data.rec_stop_reason = USER_SEL_STOP;
1644 voice_buffering_data.recording_possible = TRUE;
1645
1646 if(!voice_buffering_data.call_active )
1647 {
1648 //stop the timer, if recording
1649 timStop(voice_buffering_data.voice_buffering_tim);
1650
1651 /* destroy the redial windows if exit*/
1652 cm_redial_abort();
1653 cm_disconnect(call_data.outCall);
1654
1655 if (!call_data.calls.numCalls)
1656 {
1657 call_data.ignore_disconnect = TRUE;
1658 call_destroy(call_data.win);
1659 }
1660 }
1661 else
1662 {
1663 //Stop recording
1664 voice_buffering_stop_recording();
1665 }
1666
1667 return 1;
1668 }
1669
1670 /*******************************************************************************
1671
1672 $Function: voice_buffering_playback_start
1673
1674 $Description: Starts playing the voice. If any error while playing, stops timer and recording
1675
1676 $Returns:
1677
1678 $Arguments:
1679
1680 *******************************************************************************/
1681 GLOBAL void voice_buffering_playback_start(void )
1682 {
1683 SHORT mfw_aud_retVal;
1684
1685 TRACE_FUNCTION ("voice_buffering_playback_start()");
1686
1687 voice_buffering_data.buffering_phase = TRUE;
1688 mfw_aud_retVal = mfw_aud_vm_start_playback(voice_memo_riv_play_cb);
1689 if (mfw_aud_retVal == MFW_AUD_VM_OK)
1690 {
1691 //no action to be performed
1692 }
1693 else
1694 {
1695 if (mfw_aud_retVal == MFW_AUD_VM_MEM_EMPTY)
1696 {
1697 voice_memo_dialog_create(voice_buffering_data.win_hnd, TxtRecording, TxtEmpty);
1698 }
1699 else
1700 {
1701 //Display a dialog and exit
1702 TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_start_playback failed with return value : %d", mfw_aud_retVal);
1703 voice_memo_dialog_create( voice_buffering_data.win_hnd, TxtPlayback, TxtFailed);
1704
1705 //update the reason to stop recording
1706 voice_buffering_data.rec_stop_reason = PLAY_ERROR;
1707
1708 //stop recording
1709 voice_buffering_stop_recording();
1710 }
1711 }
1712 return;
1713 }
1714
1715 /*******************************************************************************
1716
1717 $Function: voice_buffering_stop_recording
1718
1719 $Description: A wrapper function for record stop to invoke from other modules.
1720 Stops the timer and recording
1721
1722 $Returns:
1723
1724 $Arguments:
1725
1726 *******************************************************************************/
1727 GLOBAL void voice_buffering_stop_recording(void )
1728 {
1729 SHORT mfw_aud_retVal;
1730
1731 TRACE_FUNCTION ("voice_buffering_stop_recording()");
1732
1733 //stop the timer, if recording
1734 timStop(voice_buffering_data.voice_buffering_tim);
1735
1736 mfw_aud_retVal = mfw_aud_vm_stop_record(voice_memo_riv_record_cb);
1737
1738 if (mfw_aud_retVal != MFW_AUD_VM_OK)
1739 {
1740 TRACE_EVENT_P1 ("ERROR : voice_buffering_record_stop failed with return value : %d", mfw_aud_retVal);
1741
1742 //display dialog saying "Recording Stop Failed"
1743 voice_memo_dialog_create( voice_buffering_data.win_hnd, TxtRecord, TxtStopFailed );
1744 }
1745 return;
1746 }
1747
1748 /*******************************************************************************
1749
1750 $Function: voice_buffering_stop_playing
1751
1752 $Description: A wrapper function for play stop to invoke from other modules.
1753
1754 $Returns:
1755
1756 $Arguments:
1757
1758 *******************************************************************************/
1759 GLOBAL void voice_buffering_stop_playing(void )
1760 {
1761 SHORT mfw_aud_retVal;
1762
1763 TRACE_FUNCTION ("voice_buffering_stop_playing()");
1764
1765 mfw_aud_retVal = mfw_aud_vm_stop_playback(voice_memo_riv_play_cb);
1766
1767 if (mfw_aud_retVal != MFW_AUD_VM_OK)
1768 {
1769 TRACE_EVENT_P1 ("ERROR : voice_buffering_record_stop failed with return value : %d", mfw_aud_retVal);
1770
1771 //display dialog saying "Recording Stop Failed"
1772 voice_memo_dialog_create( voice_buffering_data.win_hnd, TxtPlay, TxtStopFailed );
1773 }
1774 return;
1775 }
1776
1777
1778 /*******************************************************************************
1779
1780 $Function: voice_memo_tim_cb
1781
1782 $Description: Timer callback. Stops the timer. If PTT call is not setup disconnect the call,
1783 else call record stop
1784
1785 $Returns:
1786
1787 $Arguments:
1788
1789 *******************************************************************************/
1790 static int voice_buffering_tim_cb (T_MFW_EVENT event, T_MFW_TIM *tc)
1791 {
1792 T_MFW_HND win = mfw_parent (mfw_header());
1793 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1794 T_voice_buffering * data = (T_voice_buffering *)win_data->user;
1795 SHORT mfw_aud_retVal;
1796
1797 TRACE_FUNCTION("voice_buffering_tim_cb()");
1798 //get the voice memo type
1799 if( ( get_voice_memo_type() EQ VOICE_BUFFERING ) AND ( data->voice_buffering_tim ) )
1800 {
1801 timStop(voice_buffering_data.voice_buffering_tim);
1802 }
1803 voice_buffering_data.rec_stop_reason = RECORDING_TIMEOUT;
1804
1805 if( !voice_buffering_data.call_active ) //timeout before call setup
1806 {
1807 cm_disconnect(call_data.outCall);
1808
1809 if (!call_data.calls.numCalls)
1810 {
1811 call_data.ignore_disconnect = TRUE;
1812 call_destroy(call_data.win);
1813 }
1814 }
1815 else //timeout after call setup
1816 {
1817 mfw_aud_retVal = mfw_aud_vm_stop_record(voice_memo_riv_record_cb);
1818
1819 if (mfw_aud_retVal != MFW_AUD_VM_OK)
1820 {
1821 TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_record failed with return value : %d", mfw_aud_retVal);
1822
1823 //display dialog saying "Recording Stop Failed"
1824 voice_memo_dialog_create( voice_buffering_data.win_hnd, TxtRecording, TxtStopFailed );
1825 }
1826 }
1827
1828 return MFW_EVENT_CONSUMED;
1829 }
1830
1831 /*******************************************************************************
1832
1833 $Function: voice_buffering_data_reset
1834
1835 $Description: Resets voice buffering data to default values
1836
1837 $Returns:
1838
1839 $Arguments:
1840
1841 *******************************************************************************/
1842 static void voice_buffering_data_reset( void )
1843 {
1844 TRACE_FUNCTION("voice_buffering_data_reset()");
1845
1846 voice_buffering_data.win_hnd = 0;
1847 voice_buffering_data.voice_buffering_tim = 0;
1848 memset( voice_buffering_data.vb_PTTnum, 0, PTT_NUM_LEN );
1849 voice_buffering_data.rec_stop_reason = VB_NONE;
1850 voice_buffering_data.call_active = FALSE;
1851 voice_buffering_data.recording_possible = TRUE;
1852 voice_buffering_data.buffering_phase = FALSE;
1853 voice_buffering_data.incoming_call_discon = FALSE;
1854 voice_buffering_data.play_stopped = FALSE;
1855
1856 }
1857 #endif