1. Add new API - mm_camcorder_get_fps_list_by_resolution
[platform/core/multimedia/libmm-camcorder.git] / src / include / mm_camcorder_sound.h
1 /*
2  * libmm-camcorder
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __MM_CAMCORDER_SOUND_H__
23 #define __MM_CAMCORDER_SOUND_H__
24
25 /*=======================================================================================
26 | INCLUDE FILES                                                                         |
27 ========================================================================================*/
28 #include <pulse/pulseaudio.h>
29 #include <pulse/ext-policy.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /*=======================================================================================
36 | GLOBAL DEFINITIONS AND DECLARATIONS FOR CAMCORDER                                     |
37 ========================================================================================*/
38
39
40 /*=======================================================================================
41 | MACRO DEFINITIONS                                                                     |
42 ========================================================================================*/
43 #define _MMCAMCORDER_FILEPATH_CAPTURE_SND        "/usr/share/sounds/mm-camcorder/capture_shutter_01.wav"
44 #define _MMCAMCORDER_FILEPATH_CAPTURE2_SND       "/usr/share/sounds/mm-camcorder/capture_shutter_02.wav"
45 #define _MMCAMCORDER_FILEPATH_REC_START_SND      "/usr/share/sounds/mm-camcorder/recording_start_01.wav"
46 #define _MMCAMCORDER_FILEPATH_REC_STOP_SND       "/usr/share/sounds/mm-camcorder/recording_stop_01.wav"
47 #define _MMCAMCORDER_SAMPLE_SOUND_NAME_CAPTURE   "camera-shutter"
48 #define _MMCAMCORDER_SAMPLE_SOUND_NAME_REC_STOP  "recording-stop"
49
50 /*=======================================================================================
51 | ENUM DEFINITIONS                                                                      |
52 ========================================================================================*/
53 typedef enum {
54         _MMCAMCORDER_SOUND_STATE_NONE,
55         _MMCAMCORDER_SOUND_STATE_INIT,
56         _MMCAMCORDER_SOUND_STATE_PLAYING,
57 } _MMCamcorderSoundState;
58
59 /*=======================================================================================
60 | STRUCTURE DEFINITIONS                                                                 |
61 ========================================================================================*/
62 /**
63  * Structure of sound info
64  */
65 typedef struct __SOUND_INFO {
66         /* PCM */
67         MMSoundPcmHandle_t handle;
68         mm_sound_device_out active_out_backup;
69         int volume_type;
70         unsigned int volume_level;
71
72         /* mutex and cond */
73         pthread_mutex_t play_mutex;
74         pthread_cond_t play_cond;
75         pthread_mutex_t open_mutex;
76         pthread_cond_t open_cond;
77
78         /* pulse audio */
79         pa_threaded_mainloop *pulse_mainloop;
80         pa_context *pulse_context;
81
82 #ifdef _MMCAMCORDER_UPLOAD_SAMPLE
83         /* sound file */
84         SF_INFO sfinfo;
85         SNDFILE *infile;
86         char *filename;
87         pa_stream *sample_stream;
88         pa_sample_spec sample_spec;
89         size_t sample_length;
90         pa_channel_map channel_map;
91 #else /* _MMCAMCORDER_UPLOAD_SAMPLE */
92         pa_stream *sample_stream;
93         pa_sample_spec sample_spec;
94 #endif /* _MMCAMCORDER_UPLOAD_SAMPLE */
95
96         _MMCamcorderSoundState state;
97 } SOUND_INFO;
98
99 /*=======================================================================================
100 | CONSTANT DEFINITIONS                                                                  |
101 ========================================================================================*/
102
103
104 /*=======================================================================================
105 | GLOBAL FUNCTION PROTOTYPES                                                            |
106 ========================================================================================*/
107 #ifdef _MMCAMCORDER_UPLOAD_SAMPLE
108 gboolean _mmcamcorder_sound_init(MMHandleType handle, char *filename);
109 #else /* _MMCAMCORDER_UPLOAD_SAMPLE */
110 gboolean _mmcamcorder_sound_init(MMHandleType handle);
111 #endif /* _MMCAMCORDER_UPLOAD_SAMPLE */
112 gboolean _mmcamcorder_sound_play(MMHandleType handle, const char *sample_name, gboolean sync_play);
113 gboolean _mmcamcorder_sound_finalize(MMHandleType handle);
114
115 void _mmcamcorder_sound_solo_play(MMHandleType handle, const char *filepath, gboolean sync_play);
116 void _mmcamcorder_sound_solo_play_wait(MMHandleType handle);
117
118 #ifdef __cplusplus
119 }
120 #endif
121
122 #endif /* __MM_CAMCORDER_SOUND_H__ */