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