1 /*
2  * Copyright (C) 2023 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 FRAMEWORKS_SERVICES_MEDIA_MULTI_STAGES_CAPTURE_INCLUDE_MULTISTAGES_CAPTURE_DFX_TRIGGER_RATIO_H
17 #define FRAMEWORKS_SERVICES_MEDIA_MULTI_STAGES_CAPTURE_INCLUDE_MULTISTAGES_CAPTURE_DFX_TRIGGER_RATIO_H
18 
19 #include <mutex>
20 #include <string>
21 #include <thread>
22 
23 namespace OHOS {
24 namespace Media {
25 #define EXPORT __attribute__ ((visibility ("default")))
26 
27 enum class MultiStagesCaptureTriggerType : int32_t {
28     THIRD_PART,
29     AUTO,
30 };
31 
32 class MultiStagesCaptureDfxTriggerRatio {
33 public:
34     EXPORT static MultiStagesCaptureDfxTriggerRatio& GetInstance();
35     EXPORT void SetTrigger(const MultiStagesCaptureTriggerType &type);
36 
37 private:
38     MultiStagesCaptureDfxTriggerRatio();
39     ~MultiStagesCaptureDfxTriggerRatio();
40 
41     MultiStagesCaptureDfxTriggerRatio(const MultiStagesCaptureDfxTriggerRatio &totalTime) = delete;
42     const MultiStagesCaptureDfxTriggerRatio &operator=(const MultiStagesCaptureDfxTriggerRatio &totalTime) = delete;
43 
44     bool ShouldReport();
45     void Report();
46 
47     int32_t thirdPartCount_;
48     int32_t autoCount_;
49     int64_t lastReportTime_;
50     volatile bool isReporting_;
51     std::mutex shouldReportMutex_;
52 };
53 
54 } // namespace Media
55 } // namespace OHOS
56 #endif  // FRAMEWORKS_SERVICES_MEDIA_MULTI_STAGES_CAPTURE_INCLUDE_MULTISTAGES_CAPTURE_DFX_TRIGGER_RATIO_H