1 /* 2 * Copyright (C) 2022 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_UTIL_AIDL_SERVICE_AIDL_PROFILER_H_ 18 #define HARDWARE_GOOGLE_CAMERA_UTIL_AIDL_SERVICE_AIDL_PROFILER_H_ 19 20 #include <functional> 21 #include <memory> 22 #include <string> 23 24 #include "profiler.h" 25 #include "profiler_util.h" 26 27 namespace android { 28 namespace google_camera_hal { 29 30 class AidlScopedProfiler { 31 public: 32 AidlScopedProfiler(std::shared_ptr<google::camera_common::Profiler> profiler, 33 const std::string name, int id, 34 std::function<void()> end_callback); 35 36 ~AidlScopedProfiler(); 37 38 private: 39 std::shared_ptr<google::camera_common::Profiler> profiler_; 40 const std::string name_; 41 int id_; 42 std::function<void()> end_callback_; 43 }; 44 45 class AidlProfiler { 46 public: 47 virtual ~AidlProfiler() = default; 48 49 static std::shared_ptr<AidlProfiler> Create(uint32_t camera_id); 50 51 // Make a ScopedProfiler for given type. 52 virtual std::unique_ptr<AidlScopedProfiler> MakeScopedProfiler( 53 EventType type, 54 std::unique_ptr<google::camera_common::Profiler> custom_latency_profiler, 55 std::unique_ptr<google::camera_common::Profiler> custom_fps_profiler) = 0; 56 57 // Call when first frame is requested. 58 virtual void FirstFrameStart() = 0; 59 60 // Call when all bufer in first frame is received. 61 virtual void FirstFrameEnd() = 0; 62 63 // Call when a request is made for a reprocess capture. 64 // Provide a profiler for custom implementation, or a default will be created. 65 // Repeated calls create a new profiler if there is none set. 66 virtual void ReprocessingRequestStart( 67 std::unique_ptr<google::camera_common::Profiler> custom_reprocessing_profiler, 68 int32_t id) = 0; 69 70 // Call when reprocess capture result is received. 71 // Delete reprocessing profiler if all open requests have ended. 72 virtual void ReprocessingResultEnd(int32_t id) = 0; 73 74 // Call to profile frame rate for each stream. 75 virtual void ProfileFrameRate(const std::string& name) = 0; 76 77 virtual uint32_t GetCameraId() const = 0; 78 virtual int32_t GetLatencyFlag() const = 0; 79 virtual int32_t GetFpsFlag() const = 0; 80 virtual int32_t GetReprocessLatencyFlag() const = 0; 81 82 protected: 83 AidlProfiler() = default; 84 }; 85 86 } // namespace google_camera_hal 87 } // namespace android 88 89 #endif // HARDWARE_GOOGLE_CAMERA_UTIL_AIDL_SERVICE_AIDL_PROFILER_H_ 90