1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MMC_MMC_INTERFACE_MMC_INTERFACE_H_ 18 #define MMC_MMC_INTERFACE_MMC_INTERFACE_H_ 19 20 #include <stdint.h> 21 22 #include "mmc/proto/mmc_config.pb.h" 23 24 namespace mmc { 25 26 // An abstract interface representing either an encoder or a decoder. 27 class MmcInterface { 28 public: 29 virtual ~MmcInterface() = default; 30 31 // Builds and configures the encoder/decoder instance. 32 // 33 // Returns: 34 // Input frame size accepted by the transcoder, if init succeeded. 35 // Negative errno on error, otherwise. 36 virtual int init(ConfigParam config) = 0; 37 38 // Resets the encoder/decoder instance. 39 virtual void cleanup() = 0; 40 41 // Transcodes data in |i_buf|, and stores the result in |o_buf|. 42 // 43 // Returns: 44 // Transcoded data length, if transcode succeeded. 45 // Negative errno on error, otherwise. 46 virtual int transcode(uint8_t* i_buf, int i_len, uint8_t* o_buf, 47 int o_len) = 0; 48 }; 49 50 } // namespace mmc 51 52 #endif // MMC_MMC_INTERFACE_MMC_INTERFACE_H_ 53