summaryrefslogtreecommitdiffstats
path: root/media/codec2
diff options
context:
space:
mode:
Diffstat (limited to 'media/codec2')
-rw-r--r--media/codec2/hidl/client/client.cpp83
-rw-r--r--media/codec2/hidl/client/include/codec2/hidl/client.h11
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 &params,
+ 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();