diff --git a/system/stack/mmc/mmc_interface/mmc_interface.h b/system/stack/mmc/mmc_interface/mmc_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..a6c35f0c6cb44d18814d6047872d462c41402db8 --- /dev/null +++ b/system/stack/mmc/mmc_interface/mmc_interface.h @@ -0,0 +1,52 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MMC_MMC_INTERFACE_MMC_INTERFACE_H_ +#define MMC_MMC_INTERFACE_MMC_INTERFACE_H_ + +#include <stdint.h> + +#include "mmc/proto/mmc_config.pb.h" + +namespace mmc { + +// An abstract interface representing either an encoder or a decoder. +class MmcInterface { + public: + virtual ~MmcInterface() = default; + + // Builds and configures the encoder/decoder instance. + // + // Returns: + // Input frame size accepted by the transcoder, if init succeeded. + // Negative errno on error, otherwise. + virtual int init(ConfigParam config) = 0; + + // Resets the encoder/decoder instance. + virtual void cleanup() = 0; + + // Transcodes data in |i_buf|, and stores the result in |o_buf|. + // + // Returns: + // Transcoded data length, if transcode succeeded. + // Negative errno on error, otherwise. + virtual int transcode(uint8_t* i_buf, int i_len, uint8_t* o_buf, + int o_len) = 0; +}; + +} // namespace mmc + +#endif // MMC_MMC_INTERFACE_MMC_INTERFACE_H_ diff --git a/system/stack/mmc/proto/BUILD.gn b/system/stack/mmc/proto/BUILD.gn index 5e766a9d10ad1383f2d71eb7eaf0e961efdc3a9d..01a4c7c66daa1bbe4d7383c0a86528102bd38a60 100644 --- a/system/stack/mmc/proto/BUILD.gn +++ b/system/stack/mmc/proto/BUILD.gn @@ -24,3 +24,13 @@ proto_library("mmc_config_proto") { ] standalone=true } + +proto_library("mmc_service_proto") { + proto_in_dir = "./" + proto_out_dir = "include/mmc/proto" + sources = [ + "${proto_in_dir}/mmc_service.proto", + ] + deps = [ ":mmc_config_proto" ] + standalone=true +} diff --git a/system/stack/mmc/proto/mmc_config.proto b/system/stack/mmc/proto/mmc_config.proto index 5c4466f9ed8d30bb7b6cb4ae0a4b5abf57345bd8..58d3733783edb26586890f840b0c7f8a0455d374 100644 --- a/system/stack/mmc/proto/mmc_config.proto +++ b/system/stack/mmc/proto/mmc_config.proto @@ -23,7 +23,7 @@ option optimize_for = LITE_RUNTIME; // union of Lc3 config and codec parameters message Lc3Param { // encoder/decoder config - int32 dt_hz = 1; + int32 dt_us = 1; int32 sr_hz = 2; int32 sr_pcm_hz = 3; diff --git a/system/stack/mmc/proto/mmc_service.proto b/system/stack/mmc/proto/mmc_service.proto new file mode 100644 index 0000000000000000000000000000000000000000..c7819b80834fde53336d63f8cc8ab695dcc5a062 --- /dev/null +++ b/system/stack/mmc/proto/mmc_service.proto @@ -0,0 +1,35 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto3"; + +package mmc; + +import "mmc_config.proto"; + +option optimize_for = LITE_RUNTIME; + +message CodecInitRequest { + // Codec-specific parameters passed by client. + ConfigParam config = 1; +} + +message CodecInitResponse { + // Socket name generated by the daemon. + string socket_token = 1; + // Input frame size accepted by the codec server. + int32 input_frame_size = 2; +}