• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 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 //#define LOG_NDEBUG 0
6 #define LOG_TAG "C2CompIntfTest"
7 
8 #include <C2CompIntfTest.h>
9 
10 #include <stdio.h>
11 
12 namespace android {
13 
14 namespace {
15 
dumpType(const C2FieldDescriptor::type_t type)16 void dumpType(const C2FieldDescriptor::type_t type) {
17     switch (type) {
18     case C2FieldDescriptor::INT32:
19         printf("int32_t");
20         break;
21     case C2FieldDescriptor::UINT32:
22         printf("uint32_t");
23         break;
24     case C2FieldDescriptor::INT64:
25         printf("int64_t");
26         break;
27     case C2FieldDescriptor::UINT64:
28         printf("uint64_t");
29         break;
30     case C2FieldDescriptor::FLOAT:
31         printf("float");
32         break;
33     default:
34         printf("<flex>");
35         break;
36     }
37 }
38 
dumpStruct(const C2StructDescriptor & sd)39 void dumpStruct(const C2StructDescriptor& sd) {
40     printf("  struct: { ");
41     for (const C2FieldDescriptor& f : sd) {
42         printf("%s:", f.name().c_str());
43         dumpType(f.type());
44         printf(", ");
45     }
46     printf("}\n");
47 }
48 
49 }  // namespace
50 
dumpParamDescriptions()51 void C2CompIntfTest::dumpParamDescriptions() {
52     std::vector<std::shared_ptr<C2ParamDescriptor>> params;
53 
54     ASSERT_EQ(mIntf->querySupportedParams_nb(&params), C2_OK);
55     for (const auto& paramDesc : params) {
56         printf("name: %s\n", paramDesc->name().c_str());
57         printf("  required: %s\n", paramDesc->isRequired() ? "yes" : "no");
58         printf("  type: %x\n", paramDesc->index().type());
59         std::unique_ptr<C2StructDescriptor> desc{mReflector->describe(paramDesc->index().type())};
60         if (desc.get()) dumpStruct(*desc);
61     }
62 }
63 
64 }  // namespace android
65