2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __TIZEN_MEDIA_AUDIO__IO_CAUDIO_INFO_H__
18 #define __TIZEN_MEDIA_AUDIO__IO_CAUDIO_INFO_H__
23 #include <type_traits>
25 namespace tizen_media_audio {
28 constexpr auto to_integral(E e) -> typename std::underlying_type<E>::type {
29 return static_cast<typename std::underlying_type<E>::type>(e);
37 enum class EChannel : unsigned int {
38 CHANNEL_MONO = 1, /**< 1 channel, mono */
39 CHANNEL_STEREO, /**< 2 channel, stereo */
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 */
49 enum class EAudioType : unsigned int {
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,
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,
69 AUDIO_OUT_TYPE_SYSTEM,
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,
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,
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 */
95 const static unsigned int MIN_SYSTEM_SAMPLERATE = 8000;
96 const static unsigned int MAX_SYSTEM_SAMPLERATE = 48000;
100 CAudioInfo(unsigned int sampleRate, EChannel channel, ESampleType sampleType, EAudioType audioType, int audioIndex) throw(CAudioError);
102 /* Setter & Getter */
103 unsigned int getSampleRate();
104 EChannel getChannel();
105 ESampleType getSampleType();
106 EAudioType getAudioType();
107 void setAudioType(EAudioType audioType);
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);
116 const char *__STREAM_TYPE_TABLE[(unsigned int)EAudioType::AUDIO_TYPE_MAX] = {
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 */
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 */
152 unsigned int __mSampleRate;
154 ESampleType __mSampleType;
155 EAudioType __mAudioType;
160 } /* namespace tizen_media_audio */
163 #endif /* __TIZEN_MEDIA_AUDIO__IO_CAUDIO_INFO_H__ */