1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef ANDROID_V4L2_CODEC2_COMPONENTS_V4L2_COMPONENT_STORE_H 6 #define ANDROID_V4L2_CODEC2_COMPONENTS_V4L2_COMPONENT_STORE_H 7 8 #include <map> 9 #include <mutex> 10 11 #include <C2Component.h> 12 #include <C2ComponentFactory.h> 13 #include <android-base/thread_annotations.h> 14 #include <util/C2InterfaceHelper.h> 15 16 namespace android { 17 18 class V4L2ComponentStore : public C2ComponentStore { 19 public: 20 static std::shared_ptr<C2ComponentStore> Create(); 21 ~V4L2ComponentStore(); 22 23 // C2ComponentStore implementation. 24 C2String getName() const override; 25 c2_status_t createComponent(C2String name, 26 std::shared_ptr<C2Component>* const component) override; 27 c2_status_t createInterface(C2String name, 28 std::shared_ptr<C2ComponentInterface>* const interface) override; 29 std::vector<std::shared_ptr<const C2Component::Traits>> listComponents() override; 30 std::shared_ptr<C2ParamReflector> getParamReflector() const override; 31 c2_status_t copyBuffer(std::shared_ptr<C2GraphicBuffer> src, 32 std::shared_ptr<C2GraphicBuffer> dst) override; 33 c2_status_t querySupportedParams_nb( 34 std::vector<std::shared_ptr<C2ParamDescriptor>>* const params) const override; 35 c2_status_t query_sm(const std::vector<C2Param*>& stackParams, 36 const std::vector<C2Param::Index>& heapParamIndices, 37 std::vector<std::unique_ptr<C2Param>>* const heapParams) const override; 38 c2_status_t config_sm(const std::vector<C2Param*>& params, 39 std::vector<std::unique_ptr<C2SettingResult>>* const failures) override; 40 c2_status_t querySupportedValues_sm( 41 std::vector<C2FieldSupportedValuesQuery>& fields) const override; 42 43 private: 44 V4L2ComponentStore(); 45 46 ::C2ComponentFactory* GetFactory(const C2String& name); 47 std::shared_ptr<const C2Component::Traits> GetTraits(const C2String& name); 48 49 std::shared_ptr<C2ReflectorHelper> mReflector; 50 51 std::mutex mCachedFactoriesLock; 52 std::map<C2String, std::unique_ptr<::C2ComponentFactory>> mCachedFactories 53 GUARDED_BY(mCachedFactoriesLock); 54 std::mutex mCachedTraitsLock; 55 std::map<C2String, std::shared_ptr<const C2Component::Traits>> mCachedTraits 56 GUARDED_BY(mCachedTraitsLock); 57 }; 58 59 } // namespace android 60 61 #endif // ANDROID_V4L2_CODEC2_COMPONENTS_V4L2_COMPONENT_STORE_H 62