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 #include "vpe_trace.h"
17 #include <unistd.h>
18 #include "hitrace_meter.h"
19
20 namespace OHOS {
21 namespace Media {
22 namespace VideoProcessingEngine {
VPETrace(const std::string & funcName)23 VPETrace::VPETrace(const std::string& funcName)
24 {
25 StartTrace(HITRACE_TAG_ZMEDIA, funcName);
26 isSync_ = true;
27 }
28
TraceBegin(const std::string & funcName,int32_t taskId)29 void VPETrace::TraceBegin(const std::string& funcName, int32_t taskId)
30 {
31 StartAsyncTrace(HITRACE_TAG_ZMEDIA, funcName, taskId);
32 }
33
TraceEnd(const std::string & funcName,int32_t taskId)34 void VPETrace::TraceEnd(const std::string& funcName, int32_t taskId)
35 {
36 FinishAsyncTrace(HITRACE_TAG_ZMEDIA, funcName, taskId);
37 }
38
CounterTrace(const std::string & varName,int32_t val)39 void VPETrace::CounterTrace(const std::string& varName, int32_t val)
40 {
41 CountTrace(HITRACE_TAG_ZMEDIA, varName, val);
42 }
43
~VPETrace()44 VPETrace::~VPETrace()
45 {
46 if (isSync_) {
47 FinishTrace(HITRACE_TAG_ZMEDIA);
48 }
49 }
50 } // namespace VideoProcessingEngine
51 } // namespace Media
52 } // namespace OHOS
53