• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
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 #include "pbreader_hidump_parser.h"
16 #include "clock_filter_ex.h"
17 #include "hidump_plugin_result.pbreader.h"
18 #include "process_filter.h"
19 #include "stat_filter.h"
20 namespace SysTuning {
21 namespace TraceStreamer {
PbreaderHidumpParser(TraceDataCache * dataCache,const TraceStreamerFilters * ctx)22 PbreaderHidumpParser::PbreaderHidumpParser(TraceDataCache *dataCache, const TraceStreamerFilters *ctx)
23     : EventParserBase(dataCache, ctx), clockId_(0)
24 {
25 }
26 
~PbreaderHidumpParser()27 PbreaderHidumpParser::~PbreaderHidumpParser()
28 {
29     TS_LOGI("Fps data ts MIN:%llu, MAX:%llu", static_cast<unsigned long long>(GetPluginStartTime()),
30             static_cast<unsigned long long>(GetPluginEndTime()));
31 }
Parse(ProtoReader::BytesView tracePacket)32 void PbreaderHidumpParser::Parse(ProtoReader::BytesView tracePacket)
33 {
34     ProtoReader::HidumpInfo_Reader hidumpInfo(tracePacket.data_, tracePacket.size_);
35     if (!hidumpInfo.has_fps_event()) {
36         return;
37     }
38     for (auto i = hidumpInfo.fps_event(); i; ++i) {
39         streamFilters_->statFilter_->IncreaseStat(TRACE_HIDUMP_FPS, STAT_EVENT_RECEIVED);
40         ProtoReader::FpsData_Reader hidumpData(i->ToBytes());
41         auto hidumpTime = ProtoReader::FpsData_TimeSpec_Reader(hidumpData.time());
42         auto timeStamp = hidumpTime.tv_nsec() + hidumpTime.tv_sec() * SEC_TO_NS;
43         auto newTimeStamp = streamFilters_->clockFilter_->ToPrimaryTraceTime(hidumpData.id(), timeStamp);
44         UpdatePluginTimeRange(hidumpData.id(), timeStamp, newTimeStamp);
45         clockId_ = hidumpData.id();
46         auto fps = hidumpData.fps();
47         traceDataCache_->GetHidumpData()->AppendNewHidumpInfo(newTimeStamp, fps);
48     }
49 }
Finish()50 void PbreaderHidumpParser::Finish()
51 {
52     traceDataCache_->MixTraceTime(GetPluginStartTime(), GetPluginEndTime());
53 }
54 } // namespace TraceStreamer
55 } // namespace SysTuning
56