CCodecBufferChannel: Refers KEY_MAX_INPUT_SIZE value in toArrayMode, not C2_NAME_STREAM_MAX_BUFFER_SIZE_SETTING

Looking the exiting CCodec code, there is no place to fill the value for
C2_NAME_STREAM_MAX_BUFFER_SIZE_SETTING. App doesn't specify the value for it in their provided
format, because it is a codec2 internal parameter. App instead uses KEY_MAX_INPUT_SIZE to specify
the maximum size of input buffers.
CCodecBufferChannel always allocates buffers whose size is kLinearBufferSize (=1048576) in
toArrayMode() until the total number of buffers becomes |minSize|. On the other hand, first some
input buffers are allocated by requestNewBuffer(), where the buffer size specified by
KEY_MAX_INPUT_SIZE is used. Therefore, the buffer sizes in the same array become different.
As said above, App would specify the buffer size by KEY_MAX_INPUT_SIZE. KEY_MAX_INPUT_SIZE should
be referred in toArrayMode() as well as requestNewBuffer().

Bug: 119580521
Test: GtsMediaTestCases
Change-Id: I0b185225436308689ce38084b17d8fc56fe1d956
Merged-In: I0b185225436308689ce38084b17d8fc56fe1d956
(cherry picked from commit d0fd5ea15f4500181610ab41bfad82b956643eac)
(cherry picked from commit d5d142e5e22def3a1ef1ee16b565ab1d59a7553a)
diff --git a/media/sfplugin/CCodecBufferChannel.cpp b/media/sfplugin/CCodecBufferChannel.cpp
index 8fa4c79..51213ab 100644
--- a/media/sfplugin/CCodecBufferChannel.cpp
+++ b/media/sfplugin/CCodecBufferChannel.cpp
@@ -771,8 +771,13 @@
     std::unique_ptr<CCodecBufferChannel::InputBuffers> toArrayMode(
             size_t size) final {
         int32_t capacity = kLinearBufferSize;
-        (void)mFormat->findInt32(C2_NAME_STREAM_MAX_BUFFER_SIZE_SETTING, &capacity);
-
+        (void)mFormat->findInt32(KEY_MAX_INPUT_SIZE, &capacity);
+        if ((size_t)capacity > kMaxLinearBufferSize) {
+            ALOGD("client requested %d, capped to %zu", capacity, kMaxLinearBufferSize);
+            capacity = kMaxLinearBufferSize;
+        }
+        // TODO: proper max input size
+        // TODO: read usage from intf
         std::unique_ptr<InputBuffersArray> array(
                 new InputBuffersArray(mComponentName.c_str(), "1D-Input[N]"));
         array->setPool(mPool);