1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef HARDWARE_GOOGLE_CAMERA_HAL_HIDL_SERVICE_HIDL_PROFILER_H_
18 #define HARDWARE_GOOGLE_CAMERA_HAL_HIDL_SERVICE_HIDL_PROFILER_H_
19 
20 #include <memory>
21 
22 #include "profiler.h"
23 
24 namespace android {
25 namespace hardware {
26 namespace camera {
27 namespace implementation {
28 namespace hidl_profiler {
29 
30 class HidlProfilerItem {
31  public:
32   HidlProfilerItem(
33       std::shared_ptr<google::camera_common::Profiler> profiler,
34       const std::string target, std::function<void()> on_end,
35       int request_id = google::camera_common::Profiler::kInvalidRequestId);
36 
37   ~HidlProfilerItem();
38 
39  private:
40   std::shared_ptr<google::camera_common::Profiler> profiler_;
41   const std::string target_;
42   int request_id_;
43   std::function<void()> on_end_;
44 };
45 
46 // Start timer for open camera. The timer will stop when the returned
47 // ProfilerItem is destroyed.
48 std::unique_ptr<HidlProfilerItem> OnCameraOpen();
49 
50 // Start timer for flush camera. The timer will stop when the returned
51 // ProfilerItem is destroyed.
52 std::unique_ptr<HidlProfilerItem> OnCameraFlush();
53 
54 // Start timer for close camera. The timer will stop when the returned
55 // ProfilerItem is destroyed.
56 std::unique_ptr<HidlProfilerItem> OnCameraClose();
57 
58 // Start timer for configure streams. The timer will stop when the returned
59 // ProfilerItem is destroyed.
60 std::unique_ptr<HidlProfilerItem> OnCameraStreamConfigure();
61 
62 // Call when first frame is requested.
63 void OnFirstFrameRequest();
64 
65 // Call when all bufer in first frame is received.
66 void OnFirstFrameResult();
67 
68 }  // namespace hidl_profiler
69 }  // namespace implementation
70 }  // namespace camera
71 }  // namespace hardware
72 }  // namespace android
73 
74 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_HIDL_SERVICE_HIDL_PROFILER_H_
75