1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef AUDIO_TONEPLAYER_H 17 #define AUDIO_TONEPLAYER_H 18 19 #include <memory> 20 21 #include "audio_info.h" 22 #include "timestamp.h" 23 24 namespace OHOS { 25 namespace AudioStandard { 26 /** 27 * @brief Defines information about ToneType Enum 28 */ 29 // This enum must be kept consistant with constants in TonePlayer 30 enum ToneType { 31 // DTMF tones ITU-T Recommendation Q.23 32 TONE_TYPE_DIAL_0 = 0, 33 TONE_TYPE_DIAL_1, 34 TONE_TYPE_DIAL_2, 35 TONE_TYPE_DIAL_3, 36 TONE_TYPE_DIAL_4, 37 TONE_TYPE_DIAL_5, 38 TONE_TYPE_DIAL_6, 39 TONE_TYPE_DIAL_7, 40 TONE_TYPE_DIAL_8, 41 TONE_TYPE_DIAL_9, 42 TONE_TYPE_DIAL_S, 43 TONE_TYPE_DIAL_P, 44 TONE_TYPE_DIAL_A, 45 TONE_TYPE_DIAL_B, 46 TONE_TYPE_DIAL_C, 47 TONE_TYPE_DIAL_D, 48 49 // Call supervisory tones: 3GPP TS 22.001 (CEPT) 50 TONE_TYPE_COMMON_SUPERVISORY_DIAL = 100, 51 FIRST_SUPERVISORY_TONE = TONE_TYPE_COMMON_SUPERVISORY_DIAL, 52 TONE_TYPE_COMMON_SUPERVISORY_BUSY = 101, 53 TONE_TYPE_COMMON_SUPERVISORY_CONGESTION = 102, 54 TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK = 103, 55 TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE = 104, 56 TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING = 106, 57 TONE_TYPE_COMMON_SUPERVISORY_RINGTONE = 107, 58 LAST_SUPERVISORY_TONE = TONE_TYPE_COMMON_SUPERVISORY_RINGTONE, 59 60 // Proprietary tones: 3GPP TS 31.111 61 TONE_TYPE_COMMON_PROPRIETARY_BEEP = 200, 62 TONE_TYPE_COMMON_PROPRIETARY_ACK = 201, 63 TONE_TYPE_COMMON_PROPRIETARY_PROMPT = 203, 64 TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP = 204, 65 66 NUM_TONES, 67 NUM_SUP_TONES = LAST_SUPERVISORY_TONE - FIRST_SUPERVISORY_TONE + 1 68 }; 69 class TonePlayer { 70 public: 71 72 /** 73 * @brief create tonePlayer instance. 74 * 75 * @param cachePath Application cache path 76 * @param rendererInfo Indicates information about audio renderer. For details, see 77 * {@link AudioRendererInfo}. 78 * @return Returns unique pointer to the TonePlayer object 79 * @since 9 80 */ 81 static std::shared_ptr<TonePlayer> Create(const std::string cachePath, const AudioRendererInfo &rendererInfo); 82 83 /** 84 * @brief create tonePlayer instance. 85 * 86 * @param rendererInfo Indicates information about audio renderer. For details, see 87 * {@link AudioRendererInfo}. 88 * @return Returns unique pointer to the TonePlayer object 89 * @since 9 90 */ 91 static std::shared_ptr<TonePlayer> Create(const AudioRendererInfo &rendererInfo); 92 93 /** 94 * @brief Load audio tonePlayer. 95 * 96 * @return Returns <b>true</b> if the tonePlayer is successfully started; returns <b>false</b> otherwise. 97 * @since 9 98 */ 99 virtual bool LoadTone(ToneType toneType) = 0; 100 101 /** 102 * @brief Starts audio tonePlayer. 103 * 104 * @return Returns <b>true</b> if the tonePlayer is successfully started; returns <b>false</b> otherwise. 105 * @since 9 106 */ 107 virtual bool StartTone() = 0; 108 109 /** 110 * @brief Stop audio tonePlayer. 111 * 112 * @return Returns <b>true</b> if the tonePlayer is successfully started; returns <b>false</b> otherwise. 113 * @since 9 114 */ 115 virtual bool StopTone() = 0; 116 117 /** 118 * @brief Release audio tonePlayer. 119 * 120 * @return Returns <b>true</b> if the tonePlayer is successfully started; returns <b>false</b> otherwise. 121 * @since 9 122 */ 123 virtual bool Release() = 0; 124 virtual ~TonePlayer() = default; 125 }; 126 } // namespace AudioStandard 127 } // namespace OHOS 128 #endif // AUDIO_TONEPLAYER_H 129