Loading media/codec2/hidl/client/client.cpp +80 −3 Original line number Diff line number Diff line Loading @@ -93,6 +93,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 Loading Loading @@ -850,10 +913,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:: Loading media/codec2/hidl/client/include/codec2/hidl/client.h +9 −2 Original line number Diff line number Diff line Loading @@ -184,8 +184,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(); Loading Loading
media/codec2/hidl/client/client.cpp +80 −3 Original line number Diff line number Diff line Loading @@ -93,6 +93,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 Loading Loading @@ -850,10 +913,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:: Loading
media/codec2/hidl/client/include/codec2/hidl/client.h +9 −2 Original line number Diff line number Diff line Loading @@ -184,8 +184,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(); Loading