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 OHOS_DCAMERA_TIME_STATISTICIAN_H
17 #define OHOS_DCAMERA_TIME_STATISTICIAN_H
18 
19 #include "ifeedable_data.h"
20 #include "time_statistician.h"
21 #include "data_buffer.h"
22 
23 namespace OHOS {
24 namespace DistributedHardware {
25 class DCameraTimeStatistician : public TimeStatistician {
26 public:
27     virtual ~DCameraTimeStatistician() override = default;
28 
29 public:
30     virtual void CalProcessTime(const std::shared_ptr<IFeedableData>& data) override;
31     void CalWholeProcessTime(const std::shared_ptr<DataBuffer>& data);
32 public:
33     int64_t GetAverEncodeTime();
34     int64_t GetAverTransTime();
35     int64_t GetAverDecodeTime();
36     int64_t GetAverDecode2ScaleTime();
37     int64_t GetAverScaleTime();
38     int64_t GetAverRecv2FeedTime();
39     int64_t GetAverSmoothTime();
40     int64_t GetRecv2FeedTime();
41     int64_t GetAverSourceTime();
42     int64_t GetAverWholeTime();
43     int64_t GetRecvTime();
44     void SetRecvTime(const int64_t recvTime);
45     void SetFrameIndex(const int32_t index);
46     int64_t CalAverValue(int64_t& value, int64_t& valueSum);
47 
48 private:
49     int32_t frameIndex_ = -1;
50     int64_t averEncodeTime_ = 0;
51     int64_t encodeTimeSum_ = 0;
52     int64_t averTransTime_ = 0;
53     int64_t transTimeSum_ = 0;
54     int64_t averDecodeTime_ = 0;
55     int64_t decodeTimeSum_ = 0;
56     int64_t averDecode2ScaleTime_ = 0;
57     int64_t decode2ScaleTimeSum_ = 0;
58     int64_t averScaleTime_ = 0;
59     int64_t scaleTimeSum_ = 0;
60     int64_t averSmoothTime_ = 0;
61     int64_t smoothTimeSum_ = 0;
62     int64_t averRecv2FeedTime_ = 0;
63     int64_t recv2FeedTimeSum_ = 0;
64     int64_t averSourceTime_ = 0;
65     int64_t sourceTimeSum_ = 0;
66     int64_t averWholeTime_ = 0;
67     int64_t wholeTimeSum_ = 0;
68     int64_t recvTime_ = 0;
69 };
70 } // namespace DistributedHardware
71 } // namespace OHOS
72 #endif // OHOS_DCAMERA_TIME_STATISTICIAN_H