142 lines
4.2 KiB
C
142 lines
4.2 KiB
C
/*
|
|
* Copyright (C) 2022 Amlogic Corporation.
|
|
*
|
|
* 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 _AML_ENC_API_H_
|
|
#define _AML_ENC_API_H_
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <math.h>
|
|
#include <fcntl.h>
|
|
#include <errno.h>
|
|
#include <pthread.h>
|
|
#include <fcntl.h>
|
|
#include <dlfcn.h>
|
|
#include <string.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/prctl.h>
|
|
#include <sys/time.h>
|
|
|
|
|
|
#define AOT_AAC_LC 2
|
|
|
|
typedef enum {
|
|
AML_ENC_CONFIG_VOLUME,
|
|
|
|
} aml_enc_config_type_t;
|
|
|
|
/**
|
|
* AENC encoding codec
|
|
*/
|
|
typedef enum {
|
|
ENC_ENCODE_UNKNOWN = 0,
|
|
ENC_ENCODE_MP3, /**< Encoding to MP3 codec */
|
|
ENC_ENCODE_AAC, /**< Encoding to AAC codec */
|
|
ENC_ENCODE_PCM /**< Encoding to PCM codec */
|
|
} enc_encoding_format_t;
|
|
|
|
/**
|
|
* AENC encoding bitrate
|
|
*/
|
|
typedef enum {
|
|
ENC_BIT_UNKNOWN = 0, /**< NO set */
|
|
ENC_BIT_48K, /**< Encoding bitrate to 48K */
|
|
ENC_BIT_56K, /**< Encoding bitrate to 56K */
|
|
ENC_BIT_64K, /**< Encoding bitrate to 64K */
|
|
ENC_BIT_80K, /**< Encoding bitrate to 80K */
|
|
ENC_BIT_112K, /**< Encoding bitrate to 112K */
|
|
ENC_BIT_128K, /**< Encoding bitrate to 128K. default */
|
|
ENC_BIT_160K, /**< Encoding bitrate to 160K */
|
|
ENC_BIT_192K, /**< Encoding bitrate to 192K */
|
|
ENC_BIT_224K, /**< Encoding bitrate to 224K */
|
|
ENC_BIT_256K, /**< Encoding bitrate to 256K */
|
|
ENC_BIT_320K, /**< Encoding bitrate to 320K */
|
|
} enc_bitrate_t;
|
|
|
|
typedef struct aml_enc_ {
|
|
enc_encoding_format_t format;
|
|
} aml_enc_t;
|
|
|
|
typedef struct aml_enc_info {
|
|
int frame_size;
|
|
} aml_enc_info_t;
|
|
|
|
typedef enum {
|
|
AML_ENC_FRAME_SIZE, //runtime param
|
|
} aml_enc_info_type_t;
|
|
|
|
typedef struct aml_aac_config {
|
|
int bitrate;
|
|
int aot;
|
|
int format;
|
|
int sample_rate;
|
|
int channels;
|
|
int bits_per_sample;
|
|
int vbr;
|
|
int afterburner;
|
|
int eld_sbr;
|
|
} aml_aac_config_t;
|
|
|
|
typedef struct aml_enc_config {
|
|
/*config for encode init*/
|
|
aml_aac_config_t aac_config;
|
|
enc_encoding_format_t format;
|
|
float volume;
|
|
int bitrate;
|
|
} aml_enc_config_t;
|
|
|
|
#define ENC_BUF_SIZE_MAX (10 * 1024)
|
|
typedef struct {
|
|
unsigned long long pts; /**< PTS for each encoding packet */
|
|
unsigned char pData[ENC_BUF_SIZE_MAX]; /**< pointer to Audio Data */
|
|
unsigned int dataLen; /**< Audio Data Length */
|
|
} enc_data_t;
|
|
|
|
struct aml_enc_ctx
|
|
{
|
|
aml_enc_config_t enc_cfg;
|
|
aml_enc_t *enc_handle;
|
|
int frame_len;
|
|
int enc_buf_space;
|
|
enc_data_t enc_data;
|
|
};
|
|
|
|
typedef int (*Enc_Init)(aml_enc_t **aml_enc, aml_enc_config_t *enc_config);
|
|
typedef int (*Enc_Release)(aml_enc_t *aml_enc);
|
|
typedef int (*Enc_Process)(aml_enc_t *aml_enc, int16_t* in_buffer, size_t bytes, unsigned char*out_buffer, int *length);
|
|
typedef int (*Enc_Config)(aml_enc_t *aml_enc, aml_enc_config_type_t config_type, aml_enc_config_t * enc_config);
|
|
typedef int (*Enc_Info)(aml_enc_t *aml_enc, aml_enc_info_type_t info_type, aml_enc_info_t *info);
|
|
|
|
typedef struct aml_enc_func {
|
|
Enc_Init enc_init;
|
|
Enc_Release enc_release;
|
|
Enc_Process enc_process;
|
|
Enc_Config enc_config;
|
|
Enc_Info enc_info;
|
|
} aml_enc_func_t;
|
|
|
|
int aml_encoder_init(aml_enc_t **aml_enc, aml_enc_config_t *enc_config);
|
|
int aml_encoder_process(aml_enc_t *aml_enc, int16_t* in_buffer, size_t bytes, unsigned char*out_buffer, int *length);
|
|
int aml_encoder_getinfo(aml_enc_t *aml_enc, aml_enc_info_type_t info_type, aml_enc_info_t *info);
|
|
int aml_encoder_release(aml_enc_t *aml_enc);
|
|
int aml_encoder_config(aml_enc_t *aml_enc, aml_enc_config_type_t config_type, aml_enc_config_t * enc_config);
|
|
int aml_encoder_config_prepare(aml_enc_config_t *enc_config);
|
|
int aml_encoder_capture(struct aml_enc_ctx *enc_ctx, const void *in_buf, int32_t in_size, void *out_abuffer);
|
|
|
|
#endif
|