1 /* 2 * Copyright (C) 2021 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 TELEPHONY_AUDIO_RING_H 17 #define TELEPHONY_AUDIO_RING_H 18 19 #include <memory> 20 21 #include "audio_renderer.h" 22 #include "ffrt.h" 23 24 #include "audio_player.h" 25 #include "audio_proxy.h" 26 #include "ringtone_player.h" 27 #include "system_sound_manager.h" 28 29 namespace OHOS { 30 namespace Telephony { 31 enum class RingState { 32 RINGING = 0, 33 STOPPED, 34 }; 35 36 static constexpr const char* RING_PLAY_THREAD = "ringPlayThread"; 37 38 /** 39 * @class Ring 40 * plays the default or specific ringtone. 41 */ 42 class Ring { 43 public: 44 Ring(); 45 virtual ~Ring(); 46 void Init(); 47 int32_t Play(int32_t slotId, std::string ringtonePath, Media::HapticStartupMode mode); 48 int32_t Stop(); 49 void ReleaseRenderer(); 50 int32_t SetMute(); 51 int32_t SetRingToneVolume(float volume); 52 bool isMutedRing_ = false; 53 54 private: 55 ffrt::mutex mutex_; 56 AudioPlayer *audioPlayer_ = nullptr; 57 std::shared_ptr<Media::SystemSoundManager> SystemSoundManager_ = nullptr; 58 std::shared_ptr<Media::RingtonePlayer> RingtonePlayer_ = nullptr; 59 int32_t defaultVolume_ = 1; 60 }; 61 } // namespace Telephony 62 } // namespace OHOS 63 #endif // TELEPHONY_AUDIO_RING_H