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_HAL_AIDL_SERVICE_AIDL_PROFILER_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_AIDL_SERVICE_AIDL_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 29 class AidlScopedProfiler { 30 public: 31 AidlScopedProfiler(std::shared_ptr<google::camera_common::Profiler> profiler, 32 const std::string name, int id, 33 std::function<void()> end_callback); 34 35 ~AidlScopedProfiler(); 36 37 private: 38 std::shared_ptr<google::camera_common::Profiler> profiler_; 39 const std::string name_; 40 int id_; 41 std::function<void()> end_callback_; 42 }; 43 44 class AidlProfiler { 45 public: 46 enum class ScopedType { 47 kOpen, 48 kConfigureStream, 49 kFlush, 50 kClose, 51 }; 52 virtual ~AidlProfiler() = default; 53 54 static std::shared_ptr<AidlProfiler> Create(uint32_t camera_id); 55 56 // Make a ScopedProfiler for given type. 57 virtual std::unique_ptr<AidlScopedProfiler> MakeScopedProfiler( 58 ScopedType type, 59 std::unique_ptr<google::camera_common::Profiler> custom_latency_profiler, 60 std::unique_ptr<google::camera_common::Profiler> custom_fps_profiler) = 0; 61 62 // Call when first frame is requested. 63 virtual void FirstFrameStart() = 0; 64 65 // Call when all bufer in first frame is received. 66 virtual void FirstFrameEnd() = 0; 67 68 // Call to profile frame rate for each stream. 69 virtual void ProfileFrameRate(const std::string& name) = 0; 70 71 virtual uint32_t GetCameraId() const = 0; 72 virtual int32_t GetLatencyFlag() const = 0; 73 virtual int32_t GetFpsFlag() const = 0; 74 75 protected: 76 AidlProfiler() = default; 77 }; 78 79 } // namespace implementation 80 } // namespace camera 81 } // namespace hardware 82 } // namespace android 83 84 #endif // HARDWARE_GOOGLE_CAMERA_HAL_AIDL_SERVICE_AIDL_PROFILER_H_ 85