codec2: Add support to derive from base class for audio decoders
Test: run cts -m CtsMediaTestCases --test android.media.cts.DecoderTest
Bug: 124962433
Change-Id: I7b53404423eb1978b9739128324b1ffa009d9926
diff --git a/media/codec2/components/mp3/C2SoftMp3Dec.cpp b/media/codec2/components/mp3/C2SoftMp3Dec.cpp
index 9db6d8f..5ba7e3d 100644
--- a/media/codec2/components/mp3/C2SoftMp3Dec.cpp
+++ b/media/codec2/components/mp3/C2SoftMp3Dec.cpp
@@ -30,35 +30,32 @@
namespace android {
+namespace {
+
constexpr char COMPONENT_NAME[] = "c2.android.mp3.decoder";
-class C2SoftMP3::IntfImpl : public C2InterfaceHelper {
+} // namespace
+
+class C2SoftMP3::IntfImpl : public SimpleInterface<void>::BaseParams {
public:
explicit IntfImpl(const std::shared_ptr<C2ReflectorHelper> &helper)
- : C2InterfaceHelper(helper) {
-
+ : SimpleInterface<void>::BaseParams(
+ helper,
+ COMPONENT_NAME,
+ C2Component::KIND_DECODER,
+ C2Component::DOMAIN_AUDIO,
+ MEDIA_MIMETYPE_AUDIO_MPEG) {
+ noPrivateBuffers();
+ noInputReferences();
+ noOutputReferences();
+ noInputLatency();
+ noTimeStretch();
setDerivedInstance(this);
addParameter(
- DefineParam(mInputFormat, C2_PARAMKEY_INPUT_STREAM_BUFFER_TYPE)
- .withConstValue(new C2StreamBufferTypeSetting::input(0u, C2BufferData::LINEAR))
- .build());
-
- addParameter(
- DefineParam(mOutputFormat, C2_PARAMKEY_OUTPUT_STREAM_BUFFER_TYPE)
- .withConstValue(new C2StreamBufferTypeSetting::output(0u, C2BufferData::LINEAR))
- .build());
-
- addParameter(
- DefineParam(mInputMediaType, C2_PARAMKEY_INPUT_MEDIA_TYPE)
- .withConstValue(AllocSharedString<C2PortMediaTypeSetting::input>(
- MEDIA_MIMETYPE_AUDIO_MPEG))
- .build());
-
- addParameter(
- DefineParam(mOutputMediaType, C2_PARAMKEY_OUTPUT_MEDIA_TYPE)
- .withConstValue(AllocSharedString<C2PortMediaTypeSetting::output>(
- MEDIA_MIMETYPE_AUDIO_RAW))
+ DefineParam(mAttrib, C2_PARAMKEY_COMPONENT_ATTRIBUTES)
+ .withConstValue(new C2ComponentAttributesSetting(
+ C2Component::ATTRIB_IS_TEMPORAL))
.build());
addParameter(
@@ -90,10 +87,6 @@
}
private:
- std::shared_ptr<C2StreamBufferTypeSetting::input> mInputFormat;
- std::shared_ptr<C2StreamBufferTypeSetting::output> mOutputFormat;
- std::shared_ptr<C2PortMediaTypeSetting::input> mInputMediaType;
- std::shared_ptr<C2PortMediaTypeSetting::output> mOutputMediaType;
std::shared_ptr<C2StreamSampleRateInfo::output> mSampleRate;
std::shared_ptr<C2StreamChannelCountInfo::output> mChannelCount;
std::shared_ptr<C2StreamBitrateInfo::input> mBitrate;