diff options
author | Pawin Vongmasa <pawin@google.com> | 2020-03-05 04:36:08 -0800 |
---|---|---|
committer | Bruno Martins <bgcngm@gmail.com> | 2020-06-06 18:17:47 +0200 |
commit | eb8b20132fdcff88d4a1f2a7db6881eee02e5794 (patch) | |
tree | 9728be2742607204d7a6d02293e4bd473333335f | |
parent | 472ff18aac21b921e25756ed917ffb70ead1dc0d (diff) | |
download | frameworks_av-eb8b20132fdcff88d4a1f2a7db6881eee02e5794.tar.gz frameworks_av-eb8b20132fdcff88d4a1f2a7db6881eee02e5794.tar.bz2 frameworks_av-eb8b20132fdcff88d4a1f2a7db6881eee02e5794.zip |
Codec2Client: Add function to set preferred store
Test: None
Bug: 142782942
Change-Id: Ic2bc89bb3b44652717ee65d2bfd73b7d4af8d080
Merged-In: Ic2bc89bb3b44652717ee65d2bfd73b7d4af8d080
(cherry picked from commit a87e24eac1287fd36891c76fb19ebcc5e5664390)
-rw-r--r-- | media/codec2/hidl/client/client.cpp | 83 | ||||
-rw-r--r-- | media/codec2/hidl/client/include/codec2/hidl/client.h | 11 |
2 files changed, 89 insertions, 5 deletions
diff --git a/media/codec2/hidl/client/client.cpp b/media/codec2/hidl/client/client.cpp index c747190397..15bdb5bed9 100644 --- a/media/codec2/hidl/client/client.cpp +++ b/media/codec2/hidl/client/client.cpp @@ -89,6 +89,69 @@ size_t getServiceIndex(char const* name) { return i; } +class Client2Store : public C2ComponentStore { + std::shared_ptr<Codec2Client> mClient; + +public: + Client2Store(std::shared_ptr<Codec2Client> const& client) + : mClient(client) { } + + virtual ~Client2Store() = default; + + virtual c2_status_t config_sm( + std::vector<C2Param*> const ¶ms, + std::vector<std::unique_ptr<C2SettingResult>>* const failures) { + return mClient->config(params, C2_MAY_BLOCK, failures); + }; + + virtual c2_status_t copyBuffer( + std::shared_ptr<C2GraphicBuffer>, + std::shared_ptr<C2GraphicBuffer>) { + return C2_OMITTED; + } + + virtual c2_status_t createComponent( + C2String, std::shared_ptr<C2Component>* const component) { + component->reset(); + return C2_OMITTED; + } + + virtual c2_status_t createInterface( + C2String, std::shared_ptr<C2ComponentInterface>* const interface) { + interface->reset(); + return C2_OMITTED; + } + + virtual c2_status_t query_sm( + std::vector<C2Param*> const& stackParams, + std::vector<C2Param::Index> const& heapParamIndices, + std::vector<std::unique_ptr<C2Param>>* const heapParams) const { + return mClient->query(stackParams, heapParamIndices, C2_MAY_BLOCK, heapParams); + } + + virtual c2_status_t querySupportedParams_nb( + std::vector<std::shared_ptr<C2ParamDescriptor>>* const params) const { + return mClient->querySupportedParams(params); + } + + virtual c2_status_t querySupportedValues_sm( + std::vector<C2FieldSupportedValuesQuery>& fields) const { + return mClient->querySupportedValues(fields, C2_MAY_BLOCK); + } + + virtual C2String getName() const { + return mClient->getName(); + } + + virtual std::shared_ptr<C2ParamReflector> getParamReflector() const { + return mClient->getParamReflector(); + } + + virtual std::vector<std::shared_ptr<C2Component::Traits const>> listComponents() { + return std::vector<std::shared_ptr<C2Component::Traits const>>(); + } +}; + } // unnamed namespace // This class caches a Codec2Client object and its component traits. The client @@ -806,10 +869,24 @@ std::vector<std::string> const& Codec2Client::GetServiceNames() { } std::shared_ptr<Codec2Client> Codec2Client::CreateFromService( - const char* name) { + const char* name, + bool setAsPreferredCodec2ComponentStore) { size_t index = getServiceIndex(name); - return index == GetServiceNames().size() ? - nullptr : _CreateFromIndex(index); + if (index == GetServiceNames().size()) { + if (setAsPreferredCodec2ComponentStore) { + LOG(WARNING) << "CreateFromService(" << name + << ") -- preferred C2ComponentStore not set."; + } + return nullptr; + } + std::shared_ptr<Codec2Client> client = _CreateFromIndex(index); + if (setAsPreferredCodec2ComponentStore) { + SetPreferredCodec2ComponentStore( + std::make_shared<Client2Store>(client)); + LOG(INFO) << "CreateFromService(" << name + << ") -- service set as preferred C2ComponentStore."; + } + return client; } std::vector<std::shared_ptr<Codec2Client>> Codec2Client:: diff --git a/media/codec2/hidl/client/include/codec2/hidl/client.h b/media/codec2/hidl/client/include/codec2/hidl/client.h index c37407f5a4..f5884a0634 100644 --- a/media/codec2/hidl/client/include/codec2/hidl/client.h +++ b/media/codec2/hidl/client/include/codec2/hidl/client.h @@ -172,8 +172,15 @@ struct Codec2Client : public Codec2ConfigurableClient { // Note: A software service will have "_software" as a suffix. static std::vector<std::string> const& GetServiceNames(); - // Create a service with a given service name. - static std::shared_ptr<Codec2Client> CreateFromService(char const* name); + // Create a client to a service with a given name. + // + // After a client to the service is successfully created, if + // setAsPreferredCodec2ComponentStore is true, the component store that the + // service hosts will be set as the preferred C2ComponentStore for this + // process. (See SetPreferredCodec2ComponentStore() for more information.) + static std::shared_ptr<Codec2Client> CreateFromService( + char const* name, + bool setAsPreferredCodec2ComponentStore = false); // Get clients to all services. static std::vector<std::shared_ptr<Codec2Client>> CreateFromAllServices(); |