1 /*
2  * Copyright (c) 2023-2024 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 OHOS_TIME_STATISTICIAN_H
17 #define OHOS_TIME_STATISTICIAN_H
18 
19 #include <memory>
20 
21 #include "plugin_buffer.h"
22 
23 namespace OHOS {
24 namespace DistributedHardware {
25 using namespace OHOS::Media;
26 using namespace OHOS::Media::Plugin;
27 class TimeStatistician {
28 public:
29     virtual ~TimeStatistician() = default;
30     virtual void CalProcessTime(const std::shared_ptr<Plugin::Buffer>& data);
31     void CalAverPushInterval(const int64_t pushTime);
32     void CalAverTimeStampInterval(const int64_t timeStamp);
33 
34 public:
35     int64_t GetAverPushInterval();
36     int64_t GetAverTimeStampInterval();
37     int64_t GetPushInterval();
38     int64_t GetTimeStampInterval();
39     void ClearStatistics();
40 
41 public:
42     int32_t pushIndex_ = 0;
43     int64_t averPushInterval_ = 0;
44     int64_t lastPushTime_ = 0;
45     int64_t pushTime_ = 0;
46     int64_t pushIntervalSum_ = 0;
47     int64_t pushInterval_ = 0;
48 
49     int32_t timeStampIndex_ = 0;
50     int64_t averTimeStampInterval_ = 0;
51     int64_t lastTimeStamp_ = 0;
52     int64_t timeStamp_ = 0;
53     int64_t timeStampIntervalSum_ = 0;
54     int64_t timeStampInterval_ = 0;
55 };
56 } // namespace DistributedHardware
57 } // namespace OHOS
58 #endif // OHOS_TIME_STATISTICIAN_H