Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72d97350 authored by Jennifer's avatar Jennifer
Browse files

Floss: define MMC interface

In this patch, we define common codec methods (init, cleanup, transcode)
in |MMCInterface|, a wrapper that routes data to the appropriate
receiver or implementation. The caller of codec libraries would use the
interface to access basic codec utilities.

Bug: 285999597
Tag: #floss
Test: m - None
Change-Id: I8f6489d60b3afcc276035509a4633ad31b10e1fc
parent fcf34698
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
/*
 * 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_