mirror of https://gitlab.com/ecodis/exhale.git
correction to C API
This commit is contained in:
parent
00423757b1
commit
74512c0ce1
|
@ -12,6 +12,7 @@
|
|||
#define _EXHALE_DECL_H_
|
||||
|
||||
#include <stdint.h> /* for (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t */
|
||||
#include <stdbool.h>
|
||||
|
||||
#if defined (_WIN32) || defined (WIN32) || defined (_WIN64) || defined (WIN64)
|
||||
# ifdef EXHALE_DYN_LINK
|
||||
|
|
|
@ -45,6 +45,7 @@ if(CMAKE_DL_LIBS)
|
|||
target_link_libraries(exhaleLib PRIVATE ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
target_include_directories(exhaleLib PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
||||
set_target_properties(exhaleLib PROPERTIES PUBLIC_HEADER "${PROJECT_SOURCE_DIR}/include/exhaleDecl.h")
|
||||
|
||||
# PCH requires at least 3.16
|
||||
# I actually don't know if this works or not
|
||||
|
@ -54,4 +55,5 @@ endif()
|
|||
|
||||
install(TARGETS exhaleLib
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
||||
|
|
|
@ -2162,3 +2162,55 @@ unsigned ExhaleEncoder::initEncoder (unsigned char* const audioConfigBuffer, uin
|
|||
|
||||
return errorValue;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// C constructor
|
||||
EXHALE_DECL ExhaleEncAPI* exhaleCreate (int32_t* const inputPcmData, unsigned char* const outputAuData,
|
||||
const unsigned sampleRate , const unsigned numChannels ,
|
||||
const unsigned frameLength , const unsigned indepPeriod ,
|
||||
const unsigned varBitRateMode , const bool useNoiseFilling ,
|
||||
const bool useEcodisExt)
|
||||
{
|
||||
return reinterpret_cast<ExhaleEncAPI*> (new ExhaleEncoder (inputPcmData, outputAuData, sampleRate, numChannels, frameLength, indepPeriod, varBitRateMode
|
||||
#if !RESTRICT_TO_AAC
|
||||
, useNoiseFilling, useEcodisExt
|
||||
#endif
|
||||
));
|
||||
}
|
||||
|
||||
// C destructor
|
||||
EXHALE_DECL unsigned exhaleDelete (ExhaleEncAPI* exhaleEnc)
|
||||
{
|
||||
if (exhaleEnc != NULL) { delete reinterpret_cast<ExhaleEncoder*> (exhaleEnc); return 0; }
|
||||
|
||||
return USHRT_MAX; // error
|
||||
}
|
||||
|
||||
// C initializer
|
||||
EXHALE_DECL unsigned exhaleInitEncoder (ExhaleEncAPI* exhaleEnc, unsigned char* const audioConfigBuffer,
|
||||
uint32_t* const audioConfigBytes)
|
||||
{
|
||||
if (exhaleEnc != NULL) return reinterpret_cast<ExhaleEncoder*> (exhaleEnc)->initEncoder (audioConfigBuffer, audioConfigBytes);
|
||||
|
||||
return USHRT_MAX; // error
|
||||
}
|
||||
|
||||
// C lookahead encoder
|
||||
EXHALE_DECL unsigned exhaleEncodeLookahead (ExhaleEncAPI* exhaleEnc)
|
||||
{
|
||||
if (exhaleEnc != NULL) return reinterpret_cast<ExhaleEncoder*> (exhaleEnc)->encodeLookahead ();
|
||||
|
||||
return USHRT_MAX; // error
|
||||
}
|
||||
|
||||
// C frame encoder
|
||||
EXHALE_DECL unsigned exhaleEncodeFrame (ExhaleEncAPI* exhaleEnc)
|
||||
{
|
||||
if (exhaleEnc != NULL) return reinterpret_cast<ExhaleEncoder*> (exhaleEnc)->encodeFrame ();
|
||||
|
||||
return USHRT_MAX; // error
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
|
|
@ -155,57 +155,4 @@ public:
|
|||
|
||||
}; // ExhaleEncoder
|
||||
|
||||
#ifdef EXHALE_DYN_LINK
|
||||
extern "C"
|
||||
{
|
||||
// C constructor
|
||||
EXHALE_DECL ExhaleEncAPI* exhaleCreate (int32_t* const inputPcmData, unsigned char* const outputAuData,
|
||||
const unsigned sampleRate = 44100, const unsigned numChannels = 2,
|
||||
const unsigned frameLength = 1024, const unsigned indepPeriod = 45,
|
||||
const unsigned varBitRateMode = 3, const bool useNoiseFilling = true,
|
||||
const bool useEcodisExt = false)
|
||||
{
|
||||
return reinterpret_cast<ExhaleEncAPI*> (new ExhaleEncoder (inputPcmData, outputAuData, sampleRate, numChannels, frameLength, indepPeriod, varBitRateMode
|
||||
#if !RESTRICT_TO_AAC
|
||||
, useNoiseFilling, useEcodisExt
|
||||
#endif
|
||||
));
|
||||
}
|
||||
|
||||
// C destructor
|
||||
EXHALE_DECL unsigned exhaleDelete (ExhaleEncAPI* exhaleEnc)
|
||||
{
|
||||
if (exhaleEnc != NULL) { delete reinterpret_cast<ExhaleEncoder*> (exhaleEnc); return 0; }
|
||||
|
||||
return USHRT_MAX; // error
|
||||
}
|
||||
|
||||
// C initializer
|
||||
EXHALE_DECL unsigned exhaleInitEncoder (ExhaleEncAPI* exhaleEnc, unsigned char* const audioConfigBuffer,
|
||||
uint32_t* const audioConfigBytes = nullptr)
|
||||
{
|
||||
if (exhaleEnc != NULL) return reinterpret_cast<ExhaleEncoder*> (exhaleEnc)->initEncoder (audioConfigBuffer, audioConfigBytes);
|
||||
|
||||
return USHRT_MAX; // error
|
||||
}
|
||||
|
||||
// C lookahead encoder
|
||||
EXHALE_DECL unsigned exhaleEncodeLookahead (ExhaleEncAPI* exhaleEnc)
|
||||
{
|
||||
if (exhaleEnc != NULL) return reinterpret_cast<ExhaleEncoder*> (exhaleEnc)->encodeLookahead ();
|
||||
|
||||
return USHRT_MAX; // error
|
||||
}
|
||||
|
||||
// C frame encoder
|
||||
EXHALE_DECL unsigned exhaleEncodeFrame (ExhaleEncAPI* exhaleEnc)
|
||||
{
|
||||
if (exhaleEnc != NULL) return reinterpret_cast<ExhaleEncoder*> (exhaleEnc)->encodeFrame ();
|
||||
|
||||
return USHRT_MAX; // error
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
#endif // EXHALE_DYN_LINK
|
||||
|
||||
#endif // _EXHALE_ENC_H_
|
||||
|
|
Loading…
Reference in New Issue