• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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 //#define LOG_NDEBUG 0
18 #define LOG_TAG "Codec2-ComponentStore@1.2"
19 #include <android-base/logging.h>
20 
21 #include <codec2/hidl/1.2/ComponentStore.h>
22 #include <codec2/hidl/1.2/InputSurface.h>
23 #include <codec2/hidl/1.2/types.h>
24 
25 #include <android-base/file.h>
26 #include <media/stagefright/bqhelper/GraphicBufferSource.h>
27 #include <utils/Errors.h>
28 
29 #include <C2PlatformSupport.h>
30 #include <util/C2InterfaceHelper.h>
31 
32 #include <chrono>
33 #include <ctime>
34 #include <iomanip>
35 #include <ostream>
36 #include <sstream>
37 
38 #ifndef __ANDROID_APEX__
39 #include <codec2/hidl/plugin/FilterPlugin.h>
40 #include <dlfcn.h>
41 #include <C2Config.h>
42 #include <DefaultFilterPlugin.h>
43 #include <FilterWrapper.h>
44 #endif
45 
46 namespace android {
47 namespace hardware {
48 namespace media {
49 namespace c2 {
50 namespace V1_2 {
51 namespace utils {
52 
53 using namespace ::android;
54 using ::android::GraphicBufferSource;
55 using namespace ::android::hardware::media::bufferpool::V2_0::implementation;
56 
57 namespace /* unnamed */ {
58 
59 struct StoreIntf : public ConfigurableC2Intf {
StoreIntfandroid::hardware::media::c2::V1_2::utils::__anon44dae41e0111::StoreIntf60     StoreIntf(const std::shared_ptr<C2ComponentStore>& store)
61           : ConfigurableC2Intf{store ? store->getName() : "", 0},
62             mStore{store} {
63     }
64 
configandroid::hardware::media::c2::V1_2::utils::__anon44dae41e0111::StoreIntf65     virtual c2_status_t config(
66             const std::vector<C2Param*> &params,
67             c2_blocking_t mayBlock,
68             std::vector<std::unique_ptr<C2SettingResult>> *const failures
69             ) override {
70         // Assume all params are blocking
71         // TODO: Filter for supported params
72         if (mayBlock == C2_DONT_BLOCK && params.size() != 0) {
73             return C2_BLOCKING;
74         }
75         return mStore->config_sm(params, failures);
76     }
77 
queryandroid::hardware::media::c2::V1_2::utils::__anon44dae41e0111::StoreIntf78     virtual c2_status_t query(
79             const std::vector<C2Param::Index> &indices,
80             c2_blocking_t mayBlock,
81             std::vector<std::unique_ptr<C2Param>> *const params) const override {
82         // Assume all params are blocking
83         // TODO: Filter for supported params
84         if (mayBlock == C2_DONT_BLOCK && indices.size() != 0) {
85             return C2_BLOCKING;
86         }
87         return mStore->query_sm({}, indices, params);
88     }
89 
querySupportedParamsandroid::hardware::media::c2::V1_2::utils::__anon44dae41e0111::StoreIntf90     virtual c2_status_t querySupportedParams(
91             std::vector<std::shared_ptr<C2ParamDescriptor>> *const params
92             ) const override {
93         return mStore->querySupportedParams_nb(params);
94     }
95 
querySupportedValuesandroid::hardware::media::c2::V1_2::utils::__anon44dae41e0111::StoreIntf96     virtual c2_status_t querySupportedValues(
97             std::vector<C2FieldSupportedValuesQuery> &fields,
98             c2_blocking_t mayBlock) const override {
99         // Assume all params are blocking
100         // TODO: Filter for supported params
101         if (mayBlock == C2_DONT_BLOCK && fields.size() != 0) {
102             return C2_BLOCKING;
103         }
104         return mStore->querySupportedValues_sm(fields);
105     }
106 
107 protected:
108     std::shared_ptr<C2ComponentStore> mStore;
109 };
110 
111 } // unnamed namespace
112 
113 struct ComponentStore::StoreParameterCache : public ParameterCache {
114     std::mutex mStoreMutex;
115     ComponentStore* mStore;
116 
StoreParameterCacheandroid::hardware::media::c2::V1_2::utils::ComponentStore::StoreParameterCache117     StoreParameterCache(ComponentStore* store): mStore{store} {
118     }
119 
validateandroid::hardware::media::c2::V1_2::utils::ComponentStore::StoreParameterCache120     virtual c2_status_t validate(
121             const std::vector<std::shared_ptr<C2ParamDescriptor>>& params
122             ) override {
123         std::scoped_lock _lock(mStoreMutex);
124         return mStore ? mStore->validateSupportedParams(params) : C2_NO_INIT;
125     }
126 
onStoreDestroyedandroid::hardware::media::c2::V1_2::utils::ComponentStore::StoreParameterCache127     void onStoreDestroyed() {
128         std::scoped_lock _lock(mStoreMutex);
129         mStore = nullptr;
130     }
131 };
132 
ComponentStore(const std::shared_ptr<C2ComponentStore> & store)133 ComponentStore::ComponentStore(const std::shared_ptr<C2ComponentStore>& store)
134       : mConfigurable{new CachedConfigurable(std::make_unique<StoreIntf>(store))},
135         mParameterCache{std::make_shared<StoreParameterCache>(this)},
136         mStore{store} {
137 
138     std::shared_ptr<C2ComponentStore> platformStore = android::GetCodec2PlatformComponentStore();
139     SetPreferredCodec2ComponentStore(store);
140 
141     // Retrieve struct descriptors
142     mParamReflectors.push_back(mStore->getParamReflector());
143 #ifndef __ANDROID_APEX__
144     std::shared_ptr<C2ParamReflector> paramReflector =
145         GetFilterWrapper()->getParamReflector();
146     if (paramReflector != nullptr) {
147         ALOGD("[%s] added param reflector from filter wrapper", mStore->getName().c_str());
148         mParamReflectors.push_back(paramReflector);
149     }
150 #endif
151 
152     // MultiAccessUnit reflector helper is allocated once per store.
153     // All components in this store can reuse this reflector helper.
154     if (MultiAccessUnitHelper::isEnabledOnPlatform()) {
155         std::shared_ptr<C2ReflectorHelper> helper = std::make_shared<C2ReflectorHelper>();
156         mParamReflectors.push_back(helper);
157         mMultiAccessUnitReflector = helper;
158     }
159 
160     // Retrieve supported parameters from store
161     using namespace std::placeholders;
162     mInit = mConfigurable->init(mParameterCache);
163 }
164 
~ComponentStore()165 ComponentStore::~ComponentStore() {
166     mParameterCache->onStoreDestroyed();
167 }
168 
status() const169 c2_status_t ComponentStore::status() const {
170     return mInit;
171 }
172 
validateSupportedParams(const std::vector<std::shared_ptr<C2ParamDescriptor>> & params)173 c2_status_t ComponentStore::validateSupportedParams(
174         const std::vector<std::shared_ptr<C2ParamDescriptor>>& params) {
175     c2_status_t res = C2_OK;
176 
177     for (const std::shared_ptr<C2ParamDescriptor> &desc : params) {
178         if (!desc) {
179             // All descriptors should be valid
180             res = res ? res : C2_BAD_VALUE;
181             continue;
182         }
183         C2Param::CoreIndex coreIndex = desc->index().coreIndex();
184         std::lock_guard<std::mutex> lock(mStructDescriptorsMutex);
185         auto it = mStructDescriptors.find(coreIndex);
186         if (it == mStructDescriptors.end()) {
187             std::shared_ptr<C2StructDescriptor> structDesc = describe(coreIndex);
188             if (!structDesc) {
189                 // All supported params must be described
190                 res = C2_BAD_INDEX;
191             }
192             mStructDescriptors.insert({ coreIndex, structDesc });
193         }
194     }
195     return res;
196 }
197 
getParameterCache() const198 std::shared_ptr<ParameterCache> ComponentStore::getParameterCache() const {
199     return mParameterCache;
200 }
201 
202 #ifndef __ANDROID_APEX__
203 // static
GetFilterWrapper()204 std::shared_ptr<FilterWrapper> ComponentStore::GetFilterWrapper() {
205     constexpr const char kPluginPath[] = "libc2filterplugin.so";
206     static std::shared_ptr<FilterWrapper> wrapper = FilterWrapper::Create(
207             std::make_unique<DefaultFilterPlugin>(kPluginPath));
208     return wrapper;
209 }
210 #endif
211 
tryCreateMultiAccessUnitInterface(const std::shared_ptr<C2ComponentInterface> & c2interface)212 std::shared_ptr<MultiAccessUnitInterface> ComponentStore::tryCreateMultiAccessUnitInterface(
213         const std::shared_ptr<C2ComponentInterface> &c2interface) {
214     std::shared_ptr<MultiAccessUnitInterface> multiAccessUnitIntf = nullptr;
215     if (c2interface == nullptr) {
216         return nullptr;
217     }
218     // Framework support for Large audio frame feature depends on:
219     // 1. All feature flags enabled on platform
220     // 2. The capability of the implementation to use the same input buffer
221     //    for different C2Work (C2Config::api_feature_t::API_SAME_INPUT_BUFFER)
222     // 3. Implementation does not inherently support C2LargeFrame::output::PARAM_TYPE param.
223     if (MultiAccessUnitHelper::isEnabledOnPlatform()) {
224         c2_status_t err = C2_OK;
225         C2ComponentDomainSetting domain;
226         std::vector<std::unique_ptr<C2Param>> heapParams;
227         C2ApiFeaturesSetting features = (C2Config::api_feature_t)0;
228         err = c2interface->query_vb({&domain, &features}, {}, C2_MAY_BLOCK, &heapParams);
229         if (err == C2_OK
230                 && (domain.value == C2Component::DOMAIN_AUDIO)
231                 && ((features.value & C2Config::api_feature_t::API_SAME_INPUT_BUFFER) != 0)) {
232             std::vector<std::shared_ptr<C2ParamDescriptor>> params;
233             bool isComponentSupportsLargeAudioFrame = false;
234             c2interface->querySupportedParams_nb(&params);
235             for (const auto &paramDesc : params) {
236                 if (paramDesc->name().compare(C2_PARAMKEY_OUTPUT_LARGE_FRAME) == 0) {
237                     isComponentSupportsLargeAudioFrame = true;
238                     break;
239                 }
240             }
241             if (!isComponentSupportsLargeAudioFrame) {
242                 multiAccessUnitIntf = std::make_shared<MultiAccessUnitInterface>(
243                         c2interface,
244                         mMultiAccessUnitReflector);
245             }
246         }
247     }
248     return multiAccessUnitIntf;
249 }
250 
251 // Methods from ::android::hardware::media::c2::V1_0::IComponentStore
createComponent(const hidl_string & name,const sp<IComponentListener> & listener,const sp<IClientManager> & pool,createComponent_cb _hidl_cb)252 Return<void> ComponentStore::createComponent(
253         const hidl_string& name,
254         const sp<IComponentListener>& listener,
255         const sp<IClientManager>& pool,
256         createComponent_cb _hidl_cb) {
257 
258     sp<Component> component;
259     std::shared_ptr<C2Component> c2component;
260     Status status = static_cast<Status>(
261             mStore->createComponent(name, &c2component));
262 
263     if (status == Status::OK) {
264 #ifndef __ANDROID_APEX__
265         c2component = GetFilterWrapper()->maybeWrapComponent(c2component);
266 #endif
267         onInterfaceLoaded(c2component->intf());
268         component = new Component(c2component, listener, this, pool);
269         if (!component) {
270             status = Status::CORRUPTED;
271         } else {
272             reportComponentBirth(component.get());
273             if (component->status() != C2_OK) {
274                 status = static_cast<Status>(component->status());
275             } else {
276                 component->initListener(component);
277                 if (component->status() != C2_OK) {
278                     status = static_cast<Status>(component->status());
279                 }
280             }
281         }
282     }
283     _hidl_cb(status, component);
284     return Void();
285 }
286 
createInterface(const hidl_string & name,createInterface_cb _hidl_cb)287 Return<void> ComponentStore::createInterface(
288         const hidl_string& name,
289         createInterface_cb _hidl_cb) {
290     std::shared_ptr<C2ComponentInterface> c2interface;
291     c2_status_t res = mStore->createInterface(name, &c2interface);
292     sp<IComponentInterface> interface;
293     if (res == C2_OK) {
294 #ifndef __ANDROID_APEX__
295         c2interface = GetFilterWrapper()->maybeWrapInterface(c2interface);
296 #endif
297         onInterfaceLoaded(c2interface);
298         std::shared_ptr<MultiAccessUnitInterface> multiAccessUnitIntf =
299                 tryCreateMultiAccessUnitInterface(c2interface);
300         interface = new ComponentInterface(c2interface, multiAccessUnitIntf, mParameterCache);
301     }
302     _hidl_cb(static_cast<Status>(res), interface);
303     return Void();
304 }
305 
listComponents(listComponents_cb _hidl_cb)306 Return<void> ComponentStore::listComponents(listComponents_cb _hidl_cb) {
307     std::vector<std::shared_ptr<const C2Component::Traits>> c2traits =
308             mStore->listComponents();
309     hidl_vec<IComponentStore::ComponentTraits> traits(c2traits.size());
310     size_t ix = 0;
311     for (const std::shared_ptr<const C2Component::Traits> &c2trait : c2traits) {
312         if (c2trait) {
313             if (objcpy(&traits[ix], *c2trait)) {
314                 ++ix;
315             } else {
316                 break;
317             }
318         }
319     }
320     traits.resize(ix);
321     _hidl_cb(Status::OK, traits);
322     return Void();
323 }
324 
createInputSurface(createInputSurface_cb _hidl_cb)325 Return<void> ComponentStore::createInputSurface(createInputSurface_cb _hidl_cb) {
326     sp<GraphicBufferSource> source = new GraphicBufferSource();
327     if (source->initCheck() != OK) {
328         _hidl_cb(Status::CORRUPTED, nullptr);
329         return Void();
330     }
331     using namespace std::placeholders;
332     sp<InputSurface> inputSurface = new InputSurface(
333             mParameterCache,
334             std::make_shared<C2ReflectorHelper>(),
335             source->getHGraphicBufferProducer(),
336             source);
337     _hidl_cb(inputSurface ? Status::OK : Status::NO_MEMORY,
338              inputSurface);
339     return Void();
340 }
341 
onInterfaceLoaded(const std::shared_ptr<C2ComponentInterface> & intf)342 void ComponentStore::onInterfaceLoaded(const std::shared_ptr<C2ComponentInterface> &intf) {
343     // invalidate unsupported struct descriptors if a new interface is loaded as it may have
344     // exposed new descriptors
345     std::lock_guard<std::mutex> lock(mStructDescriptorsMutex);
346     if (!mLoadedInterfaces.count(intf->getName())) {
347         mUnsupportedStructDescriptors.clear();
348         mLoadedInterfaces.emplace(intf->getName());
349     }
350 }
351 
getStructDescriptors(const hidl_vec<uint32_t> & indices,getStructDescriptors_cb _hidl_cb)352 Return<void> ComponentStore::getStructDescriptors(
353         const hidl_vec<uint32_t>& indices,
354         getStructDescriptors_cb _hidl_cb) {
355     hidl_vec<StructDescriptor> descriptors(indices.size());
356     size_t dstIx = 0;
357     Status res = Status::OK;
358     for (size_t srcIx = 0; srcIx < indices.size(); ++srcIx) {
359         std::lock_guard<std::mutex> lock(mStructDescriptorsMutex);
360         const C2Param::CoreIndex coreIndex = C2Param::CoreIndex(indices[srcIx]).coreIndex();
361         const auto item = mStructDescriptors.find(coreIndex);
362         if (item == mStructDescriptors.end()) {
363             // not in the cache, and not known to be unsupported, query local reflector
364             if (!mUnsupportedStructDescriptors.count(coreIndex)) {
365                 std::shared_ptr<C2StructDescriptor> structDesc = describe(coreIndex);
366                 if (!structDesc) {
367                     mUnsupportedStructDescriptors.emplace(coreIndex);
368                 } else {
369                     mStructDescriptors.insert({ coreIndex, structDesc });
370                     if (objcpy(&descriptors[dstIx], *structDesc)) {
371                         ++dstIx;
372                         continue;
373                     }
374                     res = Status::CORRUPTED;
375                     break;
376                 }
377             }
378             res = Status::NOT_FOUND;
379         } else if (item->second) {
380             if (objcpy(&descriptors[dstIx], *item->second)) {
381                 ++dstIx;
382                 continue;
383             }
384             res = Status::CORRUPTED;
385             break;
386         } else {
387             res = Status::NO_MEMORY;
388             break;
389         }
390     }
391     descriptors.resize(dstIx);
392     _hidl_cb(res, descriptors);
393     return Void();
394 }
395 
getPoolClientManager()396 Return<sp<IClientManager>> ComponentStore::getPoolClientManager() {
397     return ClientManager::getInstance();
398 }
399 
copyBuffer(const Buffer & src,const Buffer & dst)400 Return<Status> ComponentStore::copyBuffer(const Buffer& src, const Buffer& dst) {
401     // TODO implement
402     (void)src;
403     (void)dst;
404     return Status::OMITTED;
405 }
406 
getConfigurable()407 Return<sp<IConfigurable>> ComponentStore::getConfigurable() {
408     return mConfigurable;
409 }
410 
411 // Methods from ::android::hardware::media::c2::V1_1::IComponentStore
createComponent_1_1(const hidl_string & name,const sp<IComponentListener> & listener,const sp<IClientManager> & pool,createComponent_1_1_cb _hidl_cb)412 Return<void> ComponentStore::createComponent_1_1(
413         const hidl_string& name,
414         const sp<IComponentListener>& listener,
415         const sp<IClientManager>& pool,
416         createComponent_1_1_cb _hidl_cb) {
417 
418     sp<Component> component;
419     std::shared_ptr<C2Component> c2component;
420     Status status = static_cast<Status>(
421             mStore->createComponent(name, &c2component));
422 
423     if (status == Status::OK) {
424 #ifndef __ANDROID_APEX__
425         c2component = GetFilterWrapper()->maybeWrapComponent(c2component);
426 #endif
427         onInterfaceLoaded(c2component->intf());
428         component = new Component(c2component, listener, this, pool);
429         if (!component) {
430             status = Status::CORRUPTED;
431         } else {
432             reportComponentBirth(component.get());
433             if (component->status() != C2_OK) {
434                 status = static_cast<Status>(component->status());
435             } else {
436                 component->initListener(component);
437                 if (component->status() != C2_OK) {
438                     status = static_cast<Status>(component->status());
439                 }
440             }
441         }
442     }
443     _hidl_cb(status, component);
444     return Void();
445 }
446 
447 // Methods from ::android::hardware::media::c2::V1_2::IComponentStore
createComponent_1_2(const hidl_string & name,const sp<IComponentListener> & listener,const sp<IClientManager> & pool,createComponent_1_2_cb _hidl_cb)448 Return<void> ComponentStore::createComponent_1_2(
449         const hidl_string& name,
450         const sp<IComponentListener>& listener,
451         const sp<IClientManager>& pool,
452         createComponent_1_2_cb _hidl_cb) {
453 
454     sp<Component> component;
455     std::shared_ptr<C2Component> c2component;
456     Status status = static_cast<Status>(
457             mStore->createComponent(name, &c2component));
458 
459     if (status == Status::OK) {
460 #ifndef __ANDROID_APEX__
461         c2component = GetFilterWrapper()->maybeWrapComponent(c2component);
462 #endif
463         onInterfaceLoaded(c2component->intf());
464         component = new Component(c2component, listener, this, pool);
465         if (!component) {
466             status = Status::CORRUPTED;
467         } else {
468             reportComponentBirth(component.get());
469             if (component->status() != C2_OK) {
470                 status = static_cast<Status>(component->status());
471             } else {
472                 component->initListener(component);
473                 if (component->status() != C2_OK) {
474                     status = static_cast<Status>(component->status());
475                 }
476             }
477         }
478     }
479     _hidl_cb(status, component);
480     return Void();
481 }
482 
describe(const C2Param::CoreIndex & index)483 std::shared_ptr<C2StructDescriptor> ComponentStore::describe(const C2Param::CoreIndex &index) {
484     for (const std::shared_ptr<C2ParamReflector> &reflector : mParamReflectors) {
485         std::shared_ptr<C2StructDescriptor> desc = reflector->describe(index);
486         if (desc) {
487             return desc;
488         }
489     }
490     return nullptr;
491 }
492 
493 // Called from createComponent() after a successful creation of `component`.
reportComponentBirth(Component * component)494 void ComponentStore::reportComponentBirth(Component* component) {
495     ComponentStatus componentStatus;
496     componentStatus.c2Component = component->mComponent;
497     componentStatus.birthTime = std::chrono::system_clock::now();
498 
499     std::lock_guard<std::mutex> lock(mComponentRosterMutex);
500     mComponentRoster.emplace(component, componentStatus);
501 }
502 
503 // Called from within the destructor of `component`. No virtual function calls
504 // are made on `component` here.
reportComponentDeath(Component * component)505 void ComponentStore::reportComponentDeath(Component* component) {
506     std::lock_guard<std::mutex> lock(mComponentRosterMutex);
507     mComponentRoster.erase(component);
508 }
509 
510 // Dumps component traits.
dump(std::ostream & out,const std::shared_ptr<const C2Component::Traits> & comp)511 std::ostream& ComponentStore::dump(
512         std::ostream& out,
513         const std::shared_ptr<const C2Component::Traits>& comp) {
514 
515     constexpr const char indent[] = "    ";
516 
517     out << indent << "name: " << comp->name << std::endl;
518     out << indent << "domain: " << comp->domain << std::endl;
519     out << indent << "kind: " << comp->kind << std::endl;
520     out << indent << "rank: " << comp->rank << std::endl;
521     out << indent << "mediaType: " << comp->mediaType << std::endl;
522     out << indent << "aliases:";
523     for (const auto& alias : comp->aliases) {
524         out << ' ' << alias;
525     }
526     out << std::endl;
527 
528     return out;
529 }
530 
531 // Dumps component status.
dump(std::ostream & out,ComponentStatus & compStatus)532 std::ostream& ComponentStore::dump(
533         std::ostream& out,
534         ComponentStatus& compStatus) {
535 
536     constexpr const char indent[] = "    ";
537 
538     // Print birth time.
539     std::chrono::milliseconds ms =
540             std::chrono::duration_cast<std::chrono::milliseconds>(
541                 compStatus.birthTime.time_since_epoch());
542     std::time_t birthTime = std::chrono::system_clock::to_time_t(
543             compStatus.birthTime);
544     std::tm tm = *std::localtime(&birthTime);
545     out << indent << "Creation time: "
546         << std::put_time(&tm, "%Y-%m-%d %H:%M:%S")
547         << '.' << std::setfill('0') << std::setw(3) << ms.count() % 1000
548         << std::endl;
549 
550     // Print name and id.
551     std::shared_ptr<C2ComponentInterface> intf = compStatus.c2Component->intf();
552     if (!intf) {
553         out << indent << "Unknown component -- null interface" << std::endl;
554         return out;
555     }
556     out << indent << "Name: " << intf->getName() << std::endl;
557     out << indent << "Id: " << intf->getId() << std::endl;
558 
559     return out;
560 }
561 
562 // Dumps information when lshal is called.
debug(const hidl_handle & handle,const hidl_vec<hidl_string> &)563 Return<void> ComponentStore::debug(
564         const hidl_handle& handle,
565         const hidl_vec<hidl_string>& /* args */) {
566     LOG(INFO) << "debug -- dumping...";
567     const native_handle_t *h = handle.getNativeHandle();
568     if (!h || h->numFds != 1) {
569        LOG(ERROR) << "debug -- dumping failed -- "
570                "invalid file descriptor to dump to";
571        return Void();
572     }
573     std::ostringstream out;
574 
575     { // Populate "out".
576 
577         constexpr const char indent[] = "  ";
578 
579         // Show name.
580         out << "Beginning of dump -- C2ComponentStore: "
581                 << mStore->getName() << std::endl << std::endl;
582 
583         // Retrieve the list of supported components.
584         std::vector<std::shared_ptr<const C2Component::Traits>> traitsList =
585                 mStore->listComponents();
586 
587         // Dump the traits of supported components.
588         out << indent << "Supported components:" << std::endl << std::endl;
589         if (traitsList.size() == 0) {
590             out << indent << indent << "NONE" << std::endl << std::endl;
591         } else {
592             for (const auto& traits : traitsList) {
593                 dump(out, traits) << std::endl;
594             }
595         }
596 
597         // Dump active components.
598         {
599             out << indent << "Active components:" << std::endl << std::endl;
600             std::lock_guard<std::mutex> lock(mComponentRosterMutex);
601             if (mComponentRoster.size() == 0) {
602                 out << indent << indent << "NONE" << std::endl << std::endl;
603             } else {
604                 for (auto& pair : mComponentRoster) {
605                     dump(out, pair.second) << std::endl;
606                 }
607             }
608         }
609 
610         out << "End of dump -- C2ComponentStore: "
611                 << mStore->getName() << std::endl;
612     }
613 
614     if (!android::base::WriteStringToFd(out.str(), h->data[0])) {
615         PLOG(WARNING) << "debug -- dumping failed -- write()";
616     } else {
617         LOG(INFO) << "debug -- dumping succeeded";
618     }
619     return Void();
620 }
621 
622 } // namespace utils
623 } // namespace V1_2
624 } // namespace c2
625 } // namespace media
626 } // namespace hardware
627 } // namespace android
628