• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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  *     http://www.apache.org/licenses/LICENSE-2.0
7  * Unless required by applicable law or agreed to in writing, software
8  * distributed under the License is distributed on an "AS IS" BASIS,
9  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10  * See the License for the specific language governing permissions and
11  * limitations under the License.
12  */
13 
14 #ifndef STREAM_STATISTICS_H
15 #define STREAM_STATISTICS_H
16 
17 #include <cstdint>
18 #include <string>
19 #include "surface.h"
20 #include "surface_type.h"
21 #include "display_type.h"
22 #include "camera.h"
23 
24 namespace OHOS::Camera {
25 class StreamStatistics {
26 public:
27     StreamStatistics();
28     StreamStatistics(int32_t streamId);
29     ~StreamStatistics();
30     void SetStreamId(int32_t streamId);
31     void RequestBufferSuccess();
32     void RequestBufferFail();
33     void RequestBufferResult(OHOS::SurfaceError sfError);
34     void RequestBufferResult(OHOS::SurfaceBuffer *sbuffer);
35     void FlushBufferSuccess();
36     void FlushBufferFail();
37     void FlushBufferResult(int32_t ret);
38     void CancelBufferSuccess();
39     void CancelBufferFail();
40     void CancelBufferResult(int32_t ret);
41     void Clear();
42     void DumpStats(int interval = 0);
43 
44 private:
45     int32_t streamId_;
46     uint32_t requestBufferSuccessCount_;
47     uint32_t requestBufferFailCount_;
48     uint32_t flushBufferSuccessCount_;
49     uint32_t flushBufferFailCount_;
50     uint32_t cancelBufferSuccessCount_;
51     uint32_t cancelBufferFailCount_;
52     uint64_t lastOutputTime_ = 0;
53     timespec timestamp_ = {0, 0};
54 };
55 } // end namespace OHOS::Camera
56 #endif // STREAM_STATISTICS_H
57