• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
26 namespace OHOS {
27 namespace Telephony {
28 struct RingtoneStream {
29     std::string ringtonePath;
30     uint32_t playedPosition;
31 };
32 enum RingState {
33     RINGING = 0,
34     STOPPED,
35 };
36 
37 /**
38  * @class Ring
39  * plays the default or specific ringtone.
40  */
41 class Ring {
42 public:
43     Ring();
44     explicit Ring(const std::string &path);
45     virtual ~Ring();
46     void Init(const std::string &ringtonePath);
47     int32_t Play();
48     int32_t Stop();
49     int32_t StartVibrate();
50     int32_t CancelVibrate();
51 
52 private:
53     bool isVibrating_;
54     bool shouldRing_;
55     bool shouldVibrate_;
56     bool ShouldVibrate();
57     std::string ringtonePath_;
58     std::mutex mutex_;
59 };
60 } // namespace Telephony
61 } // namespace OHOS
62 #endif // TELEPHONY_AUDIO_RING_H