Fix -Werror=format for toolchain upgrade
[platform/core/api/audio-io.git] / include / CAudioInfo.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __TIZEN_MEDIA_AUDIO__IO_CAUDIO_INFO_H__
18 #define __TIZEN_MEDIA_AUDIO__IO_CAUDIO_INFO_H__
19
20
21 #ifdef __cplusplus
22
23 #include <type_traits>
24
25 namespace tizen_media_audio {
26
27     template<typename E>
28     constexpr auto to_integral(E e) -> typename std::underlying_type<E>::type {
29         return static_cast<typename std::underlying_type<E>::type>(e);
30     }
31
32     /**
33      * Audio Information
34      */
35     class CAudioInfo {
36     public:
37         enum class EChannel : unsigned int {
38             CHANNEL_MONO = 1,               /**< 1 channel, mono */
39             CHANNEL_STEREO,                 /**< 2 channel, stereo */
40             CHANNEL_MAX
41         };
42
43         enum class ESampleType : unsigned int {
44             SAMPLE_TYPE_U8 = 1,             /**< Unsigned 8-bit audio samples */
45             SAMPLE_TYPE_S16_LE,             /**< Signed 16-bit audio samples */
46             SAMPLE_TYPE_MAX
47         };
48
49         enum class EAudioType : unsigned int {
50             /* Input Type */
51             AUDIO_IN_TYPE_MEDIA = 0,
52             //AUDIO_IN_TYPE_SYSTEM,
53             //AUDIO_IN_TYPE_ALARM,
54             //AUDIO_IN_TYPE_NOTIFICATION,
55             //AUDIO_IN_TYPE_EMERGENCY,
56             //AUDIO_IN_TYPE_VOICE_INFORMATION,
57             AUDIO_IN_TYPE_VOICE_RECOGNITION,
58             //AUDIO_IN_TYPE_RINGTONE_VOIP,
59             AUDIO_IN_TYPE_VOIP,
60             AUDIO_IN_TYPE_MEDIA_EXTERNAL_ONLY,
61             //AUDIO_IN_TYPE_RINGTONE_CALL,
62             //AUDIO_IN_TYPE_VOICE_CALL,
63             //AUDIO_IN_TYPE_VIDEO_CALL,
64             //AUDIO_IN_TYPE_RADIO,
65             AUDIO_IN_TYPE_LOOPBACK,
66
67             /* Output Type */
68             AUDIO_OUT_TYPE_MEDIA,
69             AUDIO_OUT_TYPE_SYSTEM,
70             AUDIO_OUT_TYPE_ALARM,
71             AUDIO_OUT_TYPE_NOTIFICATION,
72             AUDIO_OUT_TYPE_EMERGENCY,
73             AUDIO_OUT_TYPE_VOICE_INFORMATION,
74             //AUDIO_OUT_TYPE_VOICE_RECOGNITION,
75             AUDIO_OUT_TYPE_RINGTONE_VOIP,
76             AUDIO_OUT_TYPE_VOIP,
77             AUDIO_OUT_TYPE_MEDIA_EXTERNAL_ONLY,
78             AUDIO_OUT_TYPE_RINGTONE_CALL,
79             //AUDIO_OUT_TYPE_VOICE_CALL,
80             //AUDIO_OUT_TYPE_VIDEO_CALL,
81             //AUDIO_OUT_TYPE_RADIO,
82             //AUDIO_OUT_TYPE_LOOPBACK,
83
84             AUDIO_TYPE_MAX
85         };
86
87         enum class EAudioIOState : unsigned int {
88             AUDIO_IO_STATE_NONE,      /**< Audio-io handle is not created */
89             AUDIO_IO_STATE_IDLE,      /**< Audio-io handle is created, but not prepared */
90             AUDIO_IO_STATE_RUNNING,   /**< Audio-io handle is ready and the stream is running */
91             AUDIO_IO_STATE_PAUSED,    /**< Audio-io handle is ready and the stream is paused */
92             AUDIO_IO_STATE_MAX
93         };
94
95         const static unsigned int MIN_SYSTEM_SAMPLERATE = 8000;
96         const static unsigned int MAX_SYSTEM_SAMPLERATE = 48000;
97
98         /* Constructors */
99         CAudioInfo();
100         CAudioInfo(unsigned int sampleRate, EChannel channel, ESampleType sampleType, EAudioType audioType, int audioIndex) throw(CAudioError);
101
102         /* Setter & Getter */
103         unsigned int getSampleRate();
104         EChannel getChannel();
105         ESampleType getSampleType();
106         EAudioType getAudioType();
107         void setAudioType(EAudioType audioType);
108         int getAudioIndex();
109         void setAudioIndex(int audioIndex);
110         void convertAudioType2StreamType(CAudioInfo::EAudioType audioType, char **streamType);
111         void convertInputStreamType2AudioType(char *streamType, CAudioInfo::EAudioType *audioType);
112         void convertOutputStreamType2AudioType(char *streamType, CAudioInfo::EAudioType *audioType);
113         int getSampleSize();
114
115     private:
116         const char *__STREAM_TYPE_TABLE[(unsigned int)EAudioType::AUDIO_TYPE_MAX] = {
117             /* Input Type */
118             "media",                  /**< AUDIO_IN_TYPE_MEDIA */
119             //"system",               /**< AUDIO_IN_TYPE_SYSTEM */
120             //"alarm",                /**< AUDIO_IN_TYPE_ALARM */
121             //"notification",         /**< AUDIO_IN_TYPE_NOTIFICATION */
122             //"emergency",            /**< AUDIO_IN_TYPE_EMERGENCY */
123             //"voice-information",    /**< AUDIO_IN_TYPE_VOICE_INFORMATION */
124             "voice-recognition",      /**< AUDIO_IN_TYPE_VOICE_RECOGNITION */
125             //"ringtone-voip",        /**< AUDIO_IN_TYPE_RINGTONE_VOIP */
126             "voip",                   /**< AUDIO_IN_TYPE_VOIP */
127             "ext-media",              /**< AUDIO_IN_TYPE_MEDIA_EXTERNAL_ONLY */
128             //"ringtone-call",        /**< AUDIO_IN_TYPE_RINGTONE_CALL */
129             //"call-voice",           /**< AUDIO_IN_TYPE_VOICE_CALL */
130             //"call-video",           /**< AUDIO_IN_TYPE_VIDEO_CALL */
131             //"radio",                /**< AUDIO_IN_TYPE_RADIO */
132             "loopback-mirroring",     /**< AUDIO_IN_TYPE_LOOPBACK */
133
134             /* Output Type */
135             "media",                  /**< AUDIO_OUT_TYPE_MEDIA */
136             "system",                 /**< AUDIO_OUT_TYPE_SYSTEM */
137             "alarm",                  /**< AUDIO_OUT_TYPE_ALARM */
138             "notification",           /**< AUDIO_OUT_TYPE_NOTIFICATION */
139             "emergency",              /**< AUDIO_OUT_TYPE_EMERGENCY */
140             "voice-information",      /**< AUDIO_OUT_TYPE_VOICE_INFORMATION */
141             //"voice-recognition",    /**< AUDIO_OUT_TYPE_VOICE_RECOGNITION */
142             "ringtone-voip",          /**< AUDIO_OUT_TYPE_RINGTONE_VOIP */
143             "voip",                   /**< AUDIO_OUT_TYPE_VOIP */
144             "ext-media",              /**< AUDIO_OUT_TYPE_MEDIA_EXTERNAL_ONLY */
145             "ringtone-call",          /**< AUDIO_OUT_TYPE_RINGTONE_CALL */
146             //"call-voice",           /**< AUDIO_OUT_TYPE_VOICE_CALL */
147             //"call-video",           /**< AUDIO_OUT_TYPE_VIDEO_CALL */
148             //"radio",                /**< AUDIO_OUT_TYPE_RADIO */
149             //"loopback-mirroring",   /**< AUDIO_OUT_TYPE_LOOPBACK */
150         };
151
152         unsigned int __mSampleRate;
153         EChannel     __mChannel;
154         ESampleType  __mSampleType;
155         EAudioType   __mAudioType;
156         int          __mAudioIndex;
157     };
158
159
160 } /* namespace tizen_media_audio */
161
162 #endif
163 #endif /* __TIZEN_MEDIA_AUDIO__IO_CAUDIO_INFO_H__ */