codec2: Add support to derive from base class for audio encoders
Test: run cts -m CtsMediaTestCases --test android.media.cts.EncoderTest
Bug: 124962433
Change-Id: I35dfb7e8b87c1d4b356b02cdee5fdd850e1002b1
diff --git a/media/codec2/components/flac/C2SoftFlacEnc.cpp b/media/codec2/components/flac/C2SoftFlacEnc.cpp
index 0ce2543..cf34dff 100644
--- a/media/codec2/components/flac/C2SoftFlacEnc.cpp
+++ b/media/codec2/components/flac/C2SoftFlacEnc.cpp
@@ -28,28 +28,32 @@
namespace android {
-class C2SoftFlacEnc::IntfImpl : public C2InterfaceHelper {
+namespace {
+
+constexpr char COMPONENT_NAME[] = "c2.android.flac.encoder";
+
+} // namespace
+
+class C2SoftFlacEnc::IntfImpl : public SimpleInterface<void>::BaseParams {
public:
explicit IntfImpl(const std::shared_ptr<C2ReflectorHelper> &helper)
- : C2InterfaceHelper(helper) {
+ : SimpleInterface<void>::BaseParams(
+ helper,
+ COMPONENT_NAME,
+ C2Component::KIND_ENCODER,
+ C2Component::DOMAIN_AUDIO,
+ MEDIA_MIMETYPE_AUDIO_FLAC) {
+ 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_RAW))
- .build());
- addParameter(
- DefineParam(mOutputMediaType, C2_PARAMKEY_OUTPUT_MEDIA_TYPE)
- .withConstValue(AllocSharedString<C2PortMediaTypeSetting::output>(
- MEDIA_MIMETYPE_AUDIO_FLAC))
+ DefineParam(mAttrib, C2_PARAMKEY_COMPONENT_ATTRIBUTES)
+ .withConstValue(new C2ComponentAttributesSetting(
+ C2Component::ATTRIB_IS_TEMPORAL))
.build());
addParameter(
DefineParam(mSampleRate, C2_PARAMKEY_SAMPLE_RATE)
@@ -92,17 +96,12 @@
int32_t getPcmEncodingInfo() const { return mPcmEncodingInfo->value; }
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::input> mSampleRate;
std::shared_ptr<C2StreamChannelCountInfo::input> mChannelCount;
std::shared_ptr<C2StreamBitrateInfo::output> mBitrate;
std::shared_ptr<C2StreamMaxBufferSizeInfo::input> mInputMaxBufSize;
std::shared_ptr<C2StreamPcmEncodingInfo::input> mPcmEncodingInfo;
};
-constexpr char COMPONENT_NAME[] = "c2.android.flac.encoder";
C2SoftFlacEnc::C2SoftFlacEnc(
const char *name,