Codec2: adjust for renaming and C2Component API update
Change-Id: I11d5624251b29347797845b1e6ee5b4e752eb3df
diff --git a/Android.mk b/Android.mk
index 32b3d74..4a05be2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -30,7 +30,7 @@
libv4l2_codec2_vndk \
# -Wno-unused-parameter is needed for libchrome/base codes
-LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -std=c++14
+LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-unused-lambda-capture -std=c++14
LOCAL_CLANG := true
LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index ed234c8..8054ae0 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -218,10 +218,12 @@
return kId;
}
-c2_status_t C2VDAComponentIntf::query_nb(
+c2_status_t C2VDAComponentIntf::query_vb(
const std::vector<C2Param* const>& stackParams,
const std::vector<C2Param::Index>& heapParamIndices,
+ c2_blocking_t mayBlock,
std::vector<std::unique_ptr<C2Param>>* const heapParams) const {
+ UNUSED(mayBlock);
c2_status_t err = C2_OK;
for (C2Param* const param : stackParams) {
if (!param || !*param) {
@@ -253,9 +255,11 @@
return err;
}
-c2_status_t C2VDAComponentIntf::config_nb(
+c2_status_t C2VDAComponentIntf::config_vb(
const std::vector<C2Param* const> ¶ms,
+ c2_blocking_t mayBlock,
std::vector<std::unique_ptr<C2SettingResult>>* const failures) {
+ UNUSED(mayBlock);
c2_status_t err = C2_OK;
for (C2Param* const param : params) {
uint32_t index = restoreIndex(param);
@@ -318,14 +322,6 @@
return err;
}
-c2_status_t C2VDAComponentIntf::commit_sm(
- const std::vector<C2Param* const>& params,
- std::vector<std::unique_ptr<C2SettingResult>>* const failures) {
- UNUSED(params);
- UNUSED(failures);
- return C2_OMITTED;
-}
-
c2_status_t C2VDAComponentIntf::createTunnel_sm(c2_node_id_t targetComponent) {
UNUSED(targetComponent);
return C2_OMITTED; // Tunneling is not supported by now
@@ -343,8 +339,9 @@
return C2_OK;
}
-c2_status_t C2VDAComponentIntf::querySupportedValues_nb(
- std::vector<C2FieldSupportedValuesQuery>& fields) const {
+c2_status_t C2VDAComponentIntf::querySupportedValues_vb(
+ std::vector<C2FieldSupportedValuesQuery>& fields, c2_blocking_t mayBlock) const {
+ UNUSED(mayBlock);
c2_status_t err = C2_OK;
for (auto& query : fields) {
if (mSupportedValues.count(query.field) == 0) {
@@ -508,7 +505,7 @@
void C2VDAComponent::fetchParametersFromIntf() {
C2StreamFormatConfig::input codecProfile;
std::vector<C2Param* const> stackParams{ &codecProfile };
- CHECK_EQ(mIntf->query_nb(stackParams, {}, nullptr), C2_OK);
+ CHECK_EQ(mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr), C2_OK);
// The value should be guaranteed to be within media::VideoCodecProfile enum range by component
// interface.
mCodecProfile = static_cast<media::VideoCodecProfile>(codecProfile.mValue);
@@ -806,7 +803,9 @@
mComponentState = ComponentState::UNINITIALIZED;
}
-c2_status_t C2VDAComponent::setListener_sm(const std::shared_ptr<C2Component::Listener> &listener) {
+c2_status_t C2VDAComponent::setListener_vb(
+ const std::shared_ptr<C2Component::Listener> &listener, c2_blocking_t mayBlock) {
+ UNUSED(mayBlock);
// TODO(johnylin): API says this method must be supported in all states, however I'm quite not
// sure what is the use case.
if (mState != State::LOADED) {
@@ -1082,7 +1081,7 @@
}
c2_status_t C2VDAComponent::drain_nb(drain_mode_t mode) {
- if (mode != DRAIN_COMPONENT) {
+ if (mode != DRAIN_COMPONENT_WITH_EOS) {
return C2_OMITTED; // Tunneling is not supported by now
}
if (mState != State::RUNNING) {
@@ -1126,14 +1125,16 @@
return C2_OK;
}
-void C2VDAComponent::reset() {
+c2_status_t C2VDAComponent::reset() {
stop();
// TODO(johnylin): reset is different than stop that it could be called in any state.
// TODO(johnylin): when reset is called, set ComponentInterface to default values.
+ return C2_OK;
}
-void C2VDAComponent::release() {
+c2_status_t C2VDAComponent::release() {
// TODO(johnylin): what should we do for release?
+ return C2_OK;
}
std::shared_ptr<C2ComponentInterface> C2VDAComponent::intf() {
@@ -1344,7 +1345,7 @@
return C2_OMITTED;
}
-c2_status_t C2VDAComponentStore::querySupportedValues_nb(
+c2_status_t C2VDAComponentStore::querySupportedValues_sm(
std::vector<C2FieldSupportedValuesQuery>& fields) const {
UNUSED(fields);
return C2_OMITTED;
@@ -1368,14 +1369,6 @@
return C2_OMITTED;
}
-c2_status_t C2VDAComponentStore::commit_sm(
- const std::vector<C2Param* const> ¶ms,
- std::vector<std::unique_ptr<C2SettingResult>>* const failures) {
- UNUSED(params);
- UNUSED(failures);
- return C2_OMITTED;
-}
-
} // namespace android
// ---------------------- Factory Functions Interface ----------------
diff --git a/C2VDAComponent.h b/C2VDAComponent.h
index 3bfb49b..6265fbe 100644
--- a/C2VDAComponent.h
+++ b/C2VDAComponent.h
@@ -39,22 +39,22 @@
// Impementation of C2ComponentInterface interface
virtual C2String getName() const override;
virtual c2_node_id_t getId() const override;
- virtual c2_status_t query_nb(
+ virtual c2_status_t query_vb(
const std::vector<C2Param* const> &stackParams,
const std::vector<C2Param::Index> &heapParamIndices,
+ c2_blocking_t mayBlock,
std::vector<std::unique_ptr<C2Param>>* const heapParams) const override;
- virtual c2_status_t config_nb(
+ virtual c2_status_t config_vb(
const std::vector<C2Param* const>& params,
- std::vector<std::unique_ptr<C2SettingResult>>* const failures) override;
- virtual c2_status_t commit_sm(
- const std::vector<C2Param* const>& params,
+ c2_blocking_t mayBlock,
std::vector<std::unique_ptr<C2SettingResult>>* const failures) override;
virtual c2_status_t createTunnel_sm(c2_node_id_t targetComponent) override;
virtual c2_status_t releaseTunnel_sm(c2_node_id_t targetComponent) override;
virtual c2_status_t querySupportedParams_nb(
std::vector<std::shared_ptr<C2ParamDescriptor>>* const params) const override;
- virtual c2_status_t querySupportedValues_nb(
- std::vector<C2FieldSupportedValuesQuery>& fields) const override;
+ virtual c2_status_t querySupportedValues_vb(
+ std::vector<C2FieldSupportedValuesQuery>& fields,
+ c2_blocking_t mayBlock) const override;
c2_status_t status() const;
@@ -113,7 +113,8 @@
virtual ~C2VDAComponent() override;
// Implementation of C2Component interface
- virtual c2_status_t setListener_sm(const std::shared_ptr<Listener>& listener) override;
+ virtual c2_status_t setListener_vb(
+ const std::shared_ptr<Listener>& listener, c2_blocking_t mayBlock) override;
virtual c2_status_t queue_nb(std::list<std::unique_ptr<C2Work>>* const items) override;
virtual c2_status_t announce_nb(const std::vector<C2WorkOutline>& items) override;
virtual c2_status_t flush_sm(
@@ -121,8 +122,8 @@
virtual c2_status_t drain_nb(drain_mode_t mode) override;
virtual c2_status_t start() override;
virtual c2_status_t stop() override;
- virtual void reset() override;
- virtual void release() override;
+ virtual c2_status_t reset() override;
+ virtual c2_status_t release() override;
virtual std::shared_ptr<C2ComponentInterface> intf() override;
// Implementation of VideDecodeAcceleratorAdaptor::Client interface
@@ -336,7 +337,7 @@
c2_status_t querySupportedParams_nb(
std::vector<std::shared_ptr<C2ParamDescriptor>>* const params) const override;
- c2_status_t querySupportedValues_nb(
+ c2_status_t querySupportedValues_sm(
std::vector<C2FieldSupportedValuesQuery>& fields) const override;
c2_status_t query_sm(const std::vector<C2Param* const>& stackParams,
@@ -346,10 +347,6 @@
c2_status_t config_sm(const std::vector<C2Param* const>& params,
std::vector<std::unique_ptr<C2SettingResult>>* const failures) override;
- c2_status_t commit_sm(const std::vector<C2Param* const>& params,
- std::vector<std::unique_ptr<C2SettingResult>>* const failures) override;
-
-
private:
class ParamReflector;
diff --git a/cmds/codec2.cpp b/cmds/codec2.cpp
index 65ab5b9..e49826f 100644
--- a/cmds/codec2.cpp
+++ b/cmds/codec2.cpp
@@ -235,7 +235,7 @@
C2PortBlockPoolsTuning::output::alloc_unique(
{ static_cast<uint64_t>(C2BlockPool::BASIC_GRAPHIC) });
std::vector<std::unique_ptr<C2SettingResult>> result;
- (void)component->intf()->config_nb({pools.get()}, &result);
+ (void)component->intf()->config_vb({pools.get()}, C2_DONT_BLOCK, &result);
component->start();
mProcessedWork.clear();
diff --git a/tests/C2VDACompIntf_test.cpp b/tests/C2VDACompIntf_test.cpp
index 16f3e24..4fe9613 100644
--- a/tests/C2VDACompIntf_test.cpp
+++ b/tests/C2VDACompIntf_test.cpp
@@ -73,7 +73,7 @@
void C2VDACompIntfTest::checkReadOnlyFailureOnConfig(const T* param) {
std::vector<C2Param* const> params{ (C2Param* const)param };
std::vector<std::unique_ptr<C2SettingResult>> failures;
- ASSERT_EQ(C2_BAD_VALUE, mIntf->config_nb(params, &failures));
+ ASSERT_EQ(C2_BAD_VALUE, mIntf->config_vb(params, C2_DONT_BLOCK, &failures));
ASSERT_EQ(1u, failures.size());
EXPECT_EQ(C2SettingResult::READ_ONLY, failures[0]->failure);
}
@@ -82,14 +82,14 @@
void C2VDACompIntfTest::testReadOnlyParamOnStack(const T* expected, const T* invalid) {
T param;
std::vector<C2Param* const> stackParams{ ¶m };
- ASSERT_EQ(C2_OK, mIntf->query_nb(stackParams, {}, nullptr));
+ ASSERT_EQ(C2_OK, mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr));
EXPECT_EQ(*expected, param);
checkReadOnlyFailureOnConfig(¶m);
checkReadOnlyFailureOnConfig(invalid);
// The param must not change after failed config.
- ASSERT_EQ(C2_OK, mIntf->query_nb(stackParams, {}, nullptr));
+ ASSERT_EQ(C2_OK, mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr));
EXPECT_EQ(*expected, param);
}
@@ -99,7 +99,7 @@
uint32_t index = expected->index();
- ASSERT_EQ(C2_OK, mIntf->query_nb({}, {index}, &heapParams));
+ ASSERT_EQ(C2_OK, mIntf->query_vb({}, {index}, C2_DONT_BLOCK, &heapParams));
ASSERT_EQ(1u, heapParams.size());
EXPECT_EQ(*expected, *heapParams[0]);
@@ -108,7 +108,7 @@
// The param must not change after failed config.
heapParams.clear();
- ASSERT_EQ(C2_OK, mIntf->query_nb({}, {index}, &heapParams));
+ ASSERT_EQ(C2_OK, mIntf->query_vb({}, {index}, C2_DONT_BLOCK, &heapParams));
ASSERT_EQ(1u, heapParams.size());
EXPECT_EQ(*expected, *heapParams[0]);
}
@@ -117,19 +117,19 @@
void C2VDACompIntfTest::testWritableParam(const T* const newParam) {
std::vector<C2Param* const> params{ (C2Param* const)newParam };
std::vector<std::unique_ptr<C2SettingResult>> failures;
- ASSERT_EQ(C2_OK, mIntf->config_nb(params, &failures));
+ ASSERT_EQ(C2_OK, mIntf->config_vb(params, C2_DONT_BLOCK, &failures));
EXPECT_EQ(0u, failures.size());
// The param must change to newParam
// Check like param on stack
T param;
std::vector<C2Param* const> stackParams{ ¶m };
- ASSERT_EQ(C2_OK, mIntf->query_nb(stackParams, {}, nullptr));
+ ASSERT_EQ(C2_OK, mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr));
EXPECT_EQ(*newParam, param);
// Check also like param on heap
std::vector<std::unique_ptr<C2Param>> heapParams;
- ASSERT_EQ(C2_OK, mIntf->query_nb({}, {newParam->index()}, &heapParams));
+ ASSERT_EQ(C2_OK, mIntf->query_vb({}, {newParam->index()}, C2_DONT_BLOCK, &heapParams));
ASSERT_EQ(1u, heapParams.size());
EXPECT_EQ(*newParam, *heapParams[0]);
}
@@ -139,23 +139,23 @@
// Get the current parameter info
T preParam;
std::vector<C2Param* const> stackParams { &preParam };
- ASSERT_EQ(C2_OK, mIntf->query_nb(stackParams, {}, nullptr));
+ ASSERT_EQ(C2_OK, mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr));
// Config invalid value. The failure is expected
std::vector<C2Param* const> params{ (C2Param* const)invalidParam };
std::vector<std::unique_ptr<C2SettingResult>> failures;
- ASSERT_EQ(C2_BAD_VALUE, mIntf->config_nb(params, &failures));
+ ASSERT_EQ(C2_BAD_VALUE, mIntf->config_vb(params, C2_DONT_BLOCK, &failures));
EXPECT_EQ(1u, failures.size());
//The param must not change after config failed
T param;
std::vector<C2Param* const> stackParams2 { ¶m };
- ASSERT_EQ(C2_OK, mIntf->query_nb(stackParams2, {}, nullptr));
+ ASSERT_EQ(C2_OK, mIntf->query_vb(stackParams2, {}, C2_DONT_BLOCK, nullptr));
EXPECT_EQ(preParam, param);
// Check also like param on heap
std::vector<std::unique_ptr<C2Param>> heapParams;
- ASSERT_EQ(C2_OK, mIntf->query_nb({}, {invalidParam->index()}, &heapParams));
+ ASSERT_EQ(C2_OK, mIntf->query_vb({}, {invalidParam->index()}, C2_DONT_BLOCK, &heapParams));
ASSERT_EQ(1u, heapParams.size());
EXPECT_EQ(preParam, *heapParams[0]);
}
@@ -283,14 +283,14 @@
};
ASSERT_EQ(
C2_OK,
- mIntf->querySupportedValues_nb(widthC2FSV));
+ mIntf->querySupportedValues_vb(widthC2FSV, C2_DONT_BLOCK));
std::vector<C2FieldSupportedValuesQuery> heightC2FSV = {
{ C2ParamField(&videoSize, &C2VideoSizeStreamInfo::mHeight),
C2FieldSupportedValuesQuery::CURRENT },
};
ASSERT_EQ(
C2_OK,
- mIntf->querySupportedValues_nb(heightC2FSV));
+ mIntf->querySupportedValues_vb(heightC2FSV, C2_DONT_BLOCK));
ASSERT_EQ(1u, widthC2FSV.size());
ASSERT_EQ(C2_OK, widthC2FSV[0].status);
ASSERT_EQ(C2FieldSupportedValues::RANGE, widthC2FSV[0].values.type);
@@ -318,12 +318,12 @@
{ C2ParamField(&maxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::mWidth),
C2FieldSupportedValuesQuery::CURRENT },
};
- mIntf->querySupportedValues_nb(widthC2FSV);
+ mIntf->querySupportedValues_vb(widthC2FSV, C2_DONT_BLOCK);
std::vector<C2FieldSupportedValuesQuery> heightC2FSV = {
{ C2ParamField(&maxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::mHeight),
C2FieldSupportedValuesQuery::CURRENT },
};
- mIntf->querySupportedValues_nb(heightC2FSV);
+ mIntf->querySupportedValues_vb(heightC2FSV, C2_DONT_BLOCK);
ASSERT_EQ(1u, widthC2FSV.size());
ASSERT_EQ(C2_OK, widthC2FSV[0].status);
@@ -354,7 +354,7 @@
};
ASSERT_EQ(
C2_OK,
- mIntf->querySupportedValues_nb(profileValues));
+ mIntf->querySupportedValues_vb(profileValues, C2_DONT_BLOCK));
ASSERT_EQ(1u, profileValues.size());
ASSERT_EQ(C2_OK, profileValues[0].status);
@@ -369,7 +369,7 @@
TEST_F(C2VDACompIntfTest, TestUnsupportedParam) {
C2ComponentTemporalInfo unsupportedParam;
std::vector<C2Param* const> stackParams{ &unsupportedParam };
- ASSERT_EQ(C2_BAD_INDEX, mIntf->query_nb(stackParams, {}, nullptr));
+ ASSERT_EQ(C2_BAD_INDEX, mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr));
EXPECT_EQ(0u, unsupportedParam.size()); // invalidated
}
diff --git a/tests/C2VDAComponent_test.cpp b/tests/C2VDAComponent_test.cpp
index d856e83..9389484 100644
--- a/tests/C2VDAComponent_test.cpp
+++ b/tests/C2VDAComponent_test.cpp
@@ -353,7 +353,7 @@
C2PortBlockPoolsTuning::output::alloc_unique(
{ static_cast<uint64_t>(C2BlockPool::BASIC_GRAPHIC) });
std::vector<std::unique_ptr<C2SettingResult>> result;
- ASSERT_EQ(component->intf()->config_nb({pools.get()}, &result), C2_OK);
+ ASSERT_EQ(component->intf()->config_vb({pools.get()}, C2_DONT_BLOCK, &result), C2_OK);
ASSERT_EQ(result.size(), 0u);
ASSERT_EQ(component->start(), C2_OK);