1 /*
2  * Copyright (c) 2023-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_CAMERA_DPS_VIDEO_REPORT_H
17 #define OHOS_CAMERA_DPS_VIDEO_REPORT_H
18 
19 #include "dp_utils.h"
20 #include "deferred_video_job.h"
21 #include "singleton.h"
22 #include "safe_map.h"
23 
24 namespace OHOS {
25 namespace CameraStandard {
26 namespace DeferredProcessing {
27 const std::string EVENT_KEY_PNAMEID = "PNAMEID";
28 const std::string EVENT_KEY_PVERSIONID = "PVERSIONID";
29 const std::string EVENT_KEY_VIDEOID = "VIDEOID";
30 const std::string EVENT_KEY_ABORTTYPE = "ABORTTYPE";
31 const std::string EVENT_KEY_ABORTTIME = "ABORTTIME";
32 const std::string EVENT_KEY_RECOVERTIME = "RECOVERTIME";
33 const std::string EVENT_KEY_COMPLETETIME = "COMPLETETIME";
34 const std::string EVENT_KEY_REALCOMPLETETIME = "REALCOMPLETETIME";
35 
36 struct VideoRecord {
37     std::string videoId;
38     std::string calleBundle;
39     std::string calleVersion;
40     uint64_t addTime = 0;
41     uint64_t processTime = 0;
42     uint64_t pauseStartTime = 0;
43     uint64_t pauseEndTime = 0;
44     uint64_t totlePauseTime = 0;
~VideoRecordVideoRecord45     ~VideoRecord()
46     {}
47 };
48 
49 class DfxVideoReport : public Singleton<DfxVideoReport> {
50     DECLARE_SINGLETON(DfxVideoReport)
51 
52 public:
53     void ReportAddVideoEvent(const std::string& videoId, DpsCallerInfo callerInfo);
54     void ReportRemoveVideoEvent(const std::string& videoId, DpsCallerInfo callerInfo);
55     void ReportPauseVideoEvent(const std::string& videoId, int32_t pauseReason);
56     void ReportResumeVideoEvent(const std::string& videoId);
57     void ReportCompleteVideoEvent(const std::string &videoId);
58 
59 private:
60     SafeMap<std::string, VideoRecord> processVideoInfo_;
61 };
62 } // namespace DeferredProcessingService
63 } // namespace CameraStandard
64 } // namespace OHOS
65 #endif // OHOS_CAMERA_DPS_VIDEO_REPORT_H