📄 unabladeencapi.pas
字号:
(*
----------------------------------------------
unaBladeAPI.pas
Voice Communicator components version 2.5
API for Blade and Lame MP3 encoders
----------------------------------------------
This source code cannot be used without
proper permission granted to you as a private
person or an entity by the Lake of Soft, Ltd
Visit http://lakeofsoft.com/ for details.
Copyright (c) 2001, 2003 Lake of Soft, Ltd
All rights reserved
----------------------------------------------
created by:
Lake, 21 Oct 2002
modified by:
Lake, Oct-Nov 2002
Lake, Feb-May 2003
----------------------------------------------
*)
{$I unaDef.inc}
unit
unaBladeEncAPI;
interface
uses
Windows;
// ============= una specific =================
const
UNA_ENCODER_ERR_BASE = $10000000;
UNA_ENCODER_ERR_NO_DLL = UNA_ENCODER_ERR_BASE + 1;
UNA_ENCODER_ERR_NO_PROCEDURE = UNA_ENCODER_ERR_BASE + 2;
// ============= Blade ========================
const
//* encoding formats */
BE_CONFIG_MP3 = 0;
BE_CONFIG_AAC = BE_CONFIG_MP3 + 998; // not supported, added by Lake
type
//* type definitions */
PHBE_STREAM = ^HBE_STREAM;
HBE_STREAM = DWORD;
BE_ERR = integer;
const
//* error codes */
BE_ERR_SUCCESSFUL = $00000000;
BE_ERR_INVALID_FORMAT = $00000001;
BE_ERR_INVALID_FORMAT_PARAMETERS = $00000002;
BE_ERR_NO_MORE_HANDLES = $00000003;
BE_ERR_INVALID_HANDLE = $00000004;
//* other constants */
BE_MAX_HOMEPAGE = 256;
//* format specific variables */
BE_MP3_MODE_STEREO = 0;
BE_MP3_MODE_DUALCHANNEL = 2;
BE_MP3_MODE_MONO = 3;
type
// -- --
tBE_CONFIG_MP3 = packed record
dwSampleRate: DWORD; // 48000, 44100 and 32000 allowed
byMode: BYTE; // BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL, BE_MP3_MODE_MONO
wBitrate: WORD; // 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320 allowed
bPrivate: Windows.BOOL;
bCRC: Windows.BOOL;
bCopyright: Windows.BOOL;
bOriginal: Windows.BOOL;
end;
// -- --
tBE_CONFIG_AAC = packed record
dwSampleRate: DWORD;
raac_byMode: BYTE;
wBitrate: WORD;
byEncodingMethod: BYTE;
end;
// -- --
PBE_CONFIG = ^BE_CONFIG;
BE_CONFIG = packed record
case dwConfig: DWORD of // BE_CONFIG_XXXXX
// Currently only BE_CONFIG_MP3 is supported
BE_CONFIG_MP3: (
r_mp3: tBE_CONFIG_MP3
);
BE_CONFIG_AAC: (
r_aac: tBE_CONFIG_AAC;
);
end;
// -- --
PBE_VERSION = ^BE_VERSION;
BE_VERSION = packed record
// BladeEnc DLL Version number
byDLLMajorVersion: BYTE;
byDLLMinorVersion: BYTE;
// BladeEnc Engine Version Number
byMajorVersion: BYTE ;
byMinorVersion: BYTE ;
// DLL Release date
byDay: BYTE;
byMonth: BYTE ;
wYear: WORD;
// BladeEnc Homepage URL
zHomepage: array[0..BE_MAX_HOMEPAGE] of char;
end;
// ============= Lame ========================
const
//* LAME encoding formats */
BE_CONFIG_LAME = 256;
// supported by Lame only
BE_MP3_MODE_JSTEREO = 1;
//* LAME error codes */
BE_ERR_BUFFER_TOO_SMALL = $00000005;
// ?
MPEG1 = 1;
MPEG2 = 0;
CURRENT_STRUCT_VERSION = 1;
//#define CURRENT_STRUCT_SIZE sizeof(BE_CONFIG) // is currently 331 bytes
// VBRMETHOD:
VBR_METHOD_NONE = -1;
VBR_METHOD_DEFAULT = 0;
VBR_METHOD_OLD = 1;
VBR_METHOD_NEW = 2;
VBR_METHOD_MTRH = 3;
VBR_METHOD_ABR = 4;
// LAME_QUALTIY_PRESET:
LQP_NOPRESET = -1;
// QUALITY PRESETS
LQP_NORMAL_QUALITY = 0;
LQP_LOW_QUALITY = 1;
LQP_HIGH_QUALITY = 2;
LQP_VOICE_QUALITY = 3;
LQP_R3MIX = 4;
LQP_VERYHIGH_QUALITY = 5;
LQP_STANDARD = 6;
LQP_FAST_STANDARD = 7;
LQP_EXTREME = 8;
LQP_FAST_EXTREME = 9;
LQP_INSANE = 10;
LQP_ABR = 11;
LQP_CBR = 12;
// NEW PRESET VALUES
LQP_PHONE = 1000;
LQP_SW = 2000;
LQP_AM = 3000;
LQP_FM = 4000;
LQP_VOICE = 5000;
LQP_RADIO = 6000;
LQP_TAPE = 7000;
LQP_HIFI = 8000;
LQP_CD = 9000;
LQP_STUDIO = 10000;
type
{$EXTERNALSYM LONG}
LONG = longInt;
// -- --
tBE_CONFIG_LHV1 = packed record
// STRUCTURE INFORMATION
dwStructVersion: DWORD;
dwStructSize: DWORD;
// BASIC ENCODER SETTINGS
dwSampleRate: DWORD; // SAMPLERATE OF INPUT FILE (ALLOWED SAMPLERATE VALUES DEPENDS ON dwMPEGVersion)
dwReSampleRate: DWORD; // DOWNSAMPLERATE, 0=ENCODER DECIDES
nMode: LONG; // BE_MP3_MODE_XXX
dwBitrate: DWORD; // CBR bitrate, VBR min bitrate
dwMaxBitrate: DWORD; // CBR ignored, VBR Max bitrate
nPreset: LONG; // LQP_XXX
dwMpegVersion: DWORD; // FUTURE USE, MPEG-1 OR MPEG-2
dwPsyModel: DWORD; // FUTURE USE, SET TO 0
dwEmphasis: DWORD; // FUTURE USE, SET TO 0
// BIT STREAM SETTINGS
bPrivate: Windows.BOOL; // Set Private Bit (TRUE/FALSE)
bCRC: Windows.BOOL; // Insert CRC (TRUE/FALSE)
bCopyright: Windows.BOOL; // Set Copyright Bit (TRUE/FALSE)
bOriginal: Windows.BOOL; // Set Original Bit (TRUE/FALSE)
// VBR STUFF
bWriteVBRHeader: Windows.BOOL; // WRITE XING VBR HEADER (TRUE/FALSE)
bEnableVBR: Windows.BOOL; // USE VBR ENCODING (TRUE/FALSE)
nVBRQuality: LONG; // VBR QUALITY 0..9
//
dwVbrAbr_bps: DWORD; // Use ABR in stead of nVBRQuality
nVbrMethod: LONG; // VBR_XXX
bNoRes: Windows.BOOL; // Disable Bit resorvoir (TRUE/FALSE)
bStrictIso: Windows.BOOL; // Use strict ISO encoding rules (TRUE/FALSE)
// stub
btReserved: array[0..254 - 4 * sizeOf(DWORD)] of byte; // FUTURE USE, SET TO 0
end;
// -- --
PBE_CONFIG_FORMATLAME = ^BE_CONFIG_FORMATLAME;
BE_CONFIG_FORMATLAME = packed record
case dwConfig: DWORD of // BE_CONFIG_XXX
BE_CONFIG_MP3: (
r_mp3: tBE_CONFIG_MP3;
);
BE_CONFIG_LAME: (
r_lhv1: tBE_CONFIG_LHV1;
);
BE_CONFIG_AAC: (
r_aac: tBE_CONFIG_AAC;
);
end;
// ============= Blade ========================
// stubs for BE API, added by Lake
type
//
{DP:METHOD
Prototype for beInitStream() routine.
}
proc_beInitStream = function(pbeConfig: PBE_CONFIG; var dwSamples: DWORD; var dwBufferSize: DWORD; var phbeStream: HBE_STREAM): BE_ERR; cdecl;
{DP:METHOD
Prototype for beEncodeChunk() routine.
}
proc_beEncodeChunk = function(hbeStream: HBE_STREAM; nSamples: DWORD; pSamples: pointer; pOutput: pointer; var pdwOutput: DWORD): BE_ERR; cdecl;
{DP:METHOD
Prototype for beDeinitStream() routine.
}
proc_beDeinitStream = function(hbeStream: HBE_STREAM; pOutput: pointer; var pdwOutput: DWORD): BE_ERR; cdecl;
{DP:METHOD
Prototype for beCloseStream() routine.
}
proc_beCloseStream = function(hbeStream: HBE_STREAM): BE_ERR; cdecl;
{DP:METHOD
Prototype for beVersion() routine.
}
proc_beVersion = procedure(var pbeVersion: BE_VERSION); cdecl;
type
//
// -- tBladeLibrary_proc --
//
pBladeLibrary_proc = ^tBladeLibrary_proc;
tBladeLibrary_proc = record
r_be_module: hModule;
r_be_moduleRefCount: integer;
//
r_beInitStream : proc_beInitStream;
r_beEncodeChunk : proc_beEncodeChunk;
r_beDeinitStream: proc_beDeinitStream;
r_beCloseStream : proc_beCloseStream;
r_beVersion : proc_beVersion;
end;
{DP:METHOD
This function is the first to call before starting an encoding stream.
}
function beInitStream(const bladeProc: tBladeLibrary_proc; config: PBE_CONFIG; out nSamples: DWORD; out minOutputBufSize: DWORD; out stream: HBE_STREAM): BE_ERR;
{DP:METHOD
Encodes a chunk of samples. Please note that if you have set the output to
generate mono MP3 files you must feed beEncodeChunk() with mono samples!
}
function beEncodeChunk(const bladeProc: tBladeLibrary_proc; stream: HBE_STREAM; nSamples: DWORD; samplesBuf: pointer; outputBuf: pointer; out outputUsed: DWORD): BE_ERR;
{DP:METHOD
This function should be called after encoding the last chunk in order to
flush the encoder. It writes any encoded data that still might be left inside
the encoder to the output buffer.
<BR>This function should NOT be called unless you have encoded all of the chunks in your stream.
}
function beDeinitStream(const bladeProc: tBladeLibrary_proc; stream: HBE_STREAM; outputBuf: pointer; out outputUsed: DWORD): BE_ERR;
{DP:METHOD
Last function to be called when finished encoding a stream.
<BR>Should unlike beDeinitStream() also be called if the encoding is canceled.
}
function beCloseStream(const bladeProc: tBladeLibrary_proc; stream: HBE_STREAM): BE_ERR;
{DP:METHOD
Returns information like version numbers (both of the DLL and encoding engine),
release date and URL for BladeEnc's homepage. All this information should be made
available to the user of your product through a dialog box or something similar.
}
function beVersion(const bladeProc: tBladeLibrary_proc; out version: BE_VERSION): bool;
// -- DLL specific --
const
//
c_bladeEncDLL = 'BladeEnc.dll';
{DP:METHOD
Loads Blade DLL.
<BR>Returns 0 if successuf, or Windows specific error code.
}
function blade_loadDLL(var bladeProc: tBladeLibrary_proc; const pathAndName: string = c_bladeEncDLL): integer;
{DP:METHOD
Unloads Blade DLL.
<BR>Returns 0 if successuf, or Windows specific error code.
}
function blade_unloadDLL(var bladeProc: tBladeLibrary_proc): integer;
// ============= Lame ========================
// stubs for Lame API, added by Lake
type
{DP:METHOD
Prototype for lameWriteVBRHeader() routine.
}
proc_lameWriteVBRHeader = function(fileName: LPCSTR): BE_ERR; cdecl;
type
//
// -- tLameLibrary_proc --
//
pLameLibrary_proc = ^tLameLibrary_proc;
tLameLibrary_proc = record
r_lame_module: hModule;
r_lame_moduleRefCount: integer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -