当前位置: &
& 查看源码
acm.cpp:源码内容
&*&Lame&ACM&wrapper,&encode/decode&MP3&based&RIFF/AVI&files&in&MS&Windows
&*&&Copyright&(c)&2002&Steve&Lhomme&&steve.lhomme&at&free.fr&
&*&This&library&is&free&&you&can&redistribute&it&and/or
&*&modify&it&under&the&terms&of&the&GNU&Lesser&General&Public
&*&License&as&published&by&the&Free&Software&F&either
&*&version&2.1&of&the&License,&or&(at&your&option)&any&later&version.
&*&This&library&is&distributed&in&the&hope&that&it&will&be&useful,
&*&but&WITHOUT&ANY&WARRANTY;&without&even&the&implied&warranty&of
&*&MERCHANTABILITY&or&FITNESS&FOR&A&PARTICULAR&PURPOSE.&&See&the&GNU
&*&Lesser&General&Public&License&for&more&details.
&*&You&should&have&received&a©&of&the&GNU&Lesser&General&Public
&*&License&along&with&this&&if¬,&write&to&the&Free&Software
&*&Foundation,&Inc.,&59&Temple&Place,&Suite&330,&Boston,&MA&&&&USA
author&Steve&Lhomme
version&$Id:&ACM.cpp,v&1.14&&18:43:30&robux4&Exp&$
#if&!defined(STRICT)
#define&STRICT
#endif&//&STRICT
#include&&algorithm&
#include&&windows.h&
#include&&windowsx.h&
#include&&intshcut.h&
#include&&mmreg.h&
#include&&msacm.h&
#include&&msacmdrv.h&
#include&&assert.h&
#include&&version.h&
#include&&adebug.h&
#include&&resource.h&
#include&&ACMStream.h&
#ifdef&ENABLE_DECODING
#include&&DecodeStream.h&
#endif&//&ENABLE_DECODING
#include&&ACM.h&
#ifndef&IDC_HAND
#define&IDC_HAND&&&&&&&&&&&&MAKEINTRESOURCE(32649)
#endif&//&IDC_HAND
char&ACM::VersionString[20];
const&char&ACM_VERSION[]&=&&0.9.0&;
#ifdef&WIN32
//&&32-bit&versions
#if&(WINVER&&=&0x0400)
&#define&VERSION_ACM_DRIVER&&MAKE_ACM_VERSION(4,&&0,&0)
#define&VERSION_ACM_DRIVER&&MAKE_ACM_VERSION(3,&51,&0)
#define&VERSION_MSACM&MAKE_ACM_VERSION(3,&50,&0)
//&&16-bit&versions
#define&VERSION_ACM_DRIVER&MAKE_ACM_VERSION(1,&0,&0)
#define&VERSION_MSACM&MAKE_ACM_VERSION(2,&1,&0)
#define&PERSONAL_FORMAT&WAVE_FORMAT_MPEGLAYER3
#define&SIZE_FORMAT_STRUCT&sizeof(MPEGLAYER3WAVEFORMAT)
//#define&SIZE_FORMAT_STRUCT&0
//static&const&char&channel_mode[][13]&=&{&mono&,&stereo&,&joint&stereo&,&dual&channel&};
static&const&char&channel_mode[][13]&=&{&mono&,&stereo&};
static&const&unsigned&int&mpeg1_freq[]&=&{,32000};
static&const&unsigned&int&mpeg2_freq[]&=&{,,};
static&const&unsigned&int&mpeg1_bitrate[]&=&{320,&256,&224,&192,&160,&128,&112,&96,&80,&64,&56,&48,&40,&32};
static&const&unsigned&int&mpeg2_bitrate[]&=&{160,&144,&128,&112,&&96,&&80,&&64,&56,&48,&40,&32,&24,&16,&&8};
#define&SIZE_CHANNEL_MODE&(sizeof(channel_mode)&&/&(sizeof(char)&*&13))
#define&SIZE_FREQ_MPEG1&(sizeof(mpeg1_freq)&&&&/&sizeof(unsigned&int))
#define&SIZE_FREQ_MPEG2&(sizeof(mpeg2_freq)&&&&/&sizeof(unsigned&int))
#define&SIZE_BITRATE_MPEG1&(sizeof(mpeg1_bitrate)&/&sizeof(unsigned&int))
#define&SIZE_BITRATE_MPEG2&(sizeof(mpeg2_bitrate)&/&sizeof(unsigned&int))
static&const&int&FORMAT_TAG_MAX_NB&=&2;&//&PCM&and&PERSONAL&(mandatory&to&have&at&least&PCM&and&your&format)
static&const&int&FILTER_TAG_MAX_NB&=&0;&//&this&is&a&codec,¬&a&filter
//&number&of&supported&PCM&formats
static&const&int&FORMAT_MAX_NB_PCM&=
2&*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&//&number&of&PCM&channel&mode&(stereo/mono)
(SIZE_FREQ_MPEG1&+&//&number&of&MPEG&1&sampling&freq
SIZE_FREQ_MPEG2);&//&number&of&MPEG&2&sampling&freq
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
bool&bitrate_item::operator&(const&bitrate_item&&&other_bitrate)&const
return&(other_bitrate.frequency&&&frequency&||
&&&&(other_bitrate.frequency&==&frequency&&&
&(other_bitrate.bitrate&&&bitrate&||
&&(other_bitrate.bitrate&==&bitrate&&&
&&&(other_bitrate.channels&&&channels)))));
//////////////////////////////////////////////////////////////////////
//&Configuration&Dialog
//////////////////////////////////////////////////////////////////////
static&CALLBACK&ConfigProc(
&&HWND&hwndDlg,&&//&handle&to&dialog&box
UINT&uMsg,&&&&&//&message
WPARAM&wParam,&//&first&message¶meter
LPARAM&lParam&&//&second&message¶meter
switch&(uMsg)&{
case&WM_COMMAND:
command&=&GET_WM_COMMAND_ID(wParam,&lParam);
&&&&&&&&&&&&if&(IDOK&==&command)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&EndDialog(hwndDlg,&(IDOK&==&command));
&&&&&&&&&&&&}&else&if&(IDCANCEL&==&command)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&EndDialog(hwndDlg,&(IDOK&==&command));
&&&&&&&&&&&&}
&&&&&&&&&&&&bResult&=&FALSE;
bResult&=&FALSE;&//&will&be&treated&by&DefWindowProc
inline&DWORD&ACM::Configure(HWND&hParentWindow,&LPDRVCONFIGINFO&pConfig)
my_debug.OutPut(DEBUG_LEVEL_FUNC_START,&&ACM&:&Configure&(Parent&Window&=&0x%08X)&,hParentWindow);
DialogBoxParam(&my_hModule,&MAKEINTRESOURCE(IDD_CONFIG),&hParentWindow,&::ConfigProc&,&(LPARAM)this);
return&DRVCNF_OK;&//&Can&also&return
//&DRVCNF_CANCEL
//&and&DRVCNF_RESTART
//////////////////////////////////////////////////////////////////////
//&About&Dialog
//////////////////////////////////////////////////////////////////////
static&BOOL&CALLBACK&AboutProc(
&&HWND&hwndDlg,&&//&handle&to&dialog&box
UINT&uMsg,&&&&&//&message
WPARAM&wParam,&//&first&message¶meter
LPARAM&lParam&&//&second&message¶meter
static&HBRUSH&hBrushStatic&=&NULL;
// static&LOGFONT&&&//&structure&for&font&information&&
// static&HFONT&
static&HCURSOR&hcOverCursor&=&NULL;
switch&(uMsg)&{
case&WM_INITDIALOG:
char&tmp[150];
wsprintf(tmp,&LAME&MP3&codec&v%s&,&ACM::GetVersionString());
::SetWindowText(GetDlgItem(&hwndDlg,&IDC_STATIC_ABOUT_TITLE),&tmp);
::GetObject(::GetStockObject(DEFAULT_GUI_FONT),&sizeof(LOGFONT),&&lf);&
lf.lfUnderline&=&TRUE;
hfnt&=&::CreateFontIndirect(&lf);
::SendMessage(::GetDlgItem(hwndDlg,IDC_STATIC_ABOUT_URL),&WM_SETFONT,&(WPARAM)&hfnt,&TRUE);
hBrushStatic&=&::CreateSolidBrush(::GetSysColor&(COLOR_BTNFACE));
hcOverCursor&=&::LoadCursor(NULL,(LPCTSTR)IDC_HAND);&
if&(hcOverCursor&==&NULL)
hcOverCursor&=&::LoadCursor(NULL,(LPCTSTR)IDC_CROSS);&
bResult&=&TRUE;
case&WM_CTLCOLORSTATIC:
///&todo&only&if&there&are&URLs
if&((HWND)lParam&==&::GetDlgItem(hwndDlg,IDC_STATIC_ABOUT_URL))
::SetTextColor((HDC)wParam,&::GetSysColor&(COLOR_HIGHLIGHT));
::SetBkColor((HDC)wParam,&::GetSysColor&(COLOR_BTNFACE));
return&(LRESULT)&hBrushS
return&(LRESULT)&NULL;
case&WM_MOUSEMOVE:
::GetCursorPos(&pnt);
::GetWindowRect(&::GetDlgItem(hwndDlg,IDC_STATIC_ABOUT_URL),&&rect);
if&(&&::PtInRect(&rect,pnt)&&)
::SetCursor(hcOverCursor);
case&WM_LBUTTONUP:
::GetCursorPos(&pnt);
::GetWindowRect(&::GetDlgItem(hwndDlg,IDC_STATIC_ABOUT_URL),&&rect);
TCHAR&Url[200];
bool&bUrl&=&
if&(::PtInRect(&rect,pnt))
wsprintf(Url,LAME_URL);
LPSTR&tmpS
HRESULT&hresult&=&::TranslateURL(Url,&TRANSLATEURL_FL_GUESS_PROTOCOL|TRANSLATEURL_FL_GUESS_PROTOCOL,&&tmpStr);
if&(hresult&==&S_OK)
::ShellExecute(hwndDlg,&open&,tmpStr,NULL,&&,SW_SHOWMAXIMIZED&);
else&if&(hresult&==&S_FALSE)
::ShellExecute(hwndDlg,&open&,Url,NULL,&&,SW_SHOWMAXIMIZED&);
case&WM_COMMAND:
command&=&GET_WM_COMMAND_ID(wParam,&lParam);
&&&&&&&&&&&&if&(IDOK&==&command)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&EndDialog(hwndDlg,&TRUE);
&&&&&&&&&&&&}
&&&&&&&&&&&&bResult&=&FALSE;
case&IDC_STATIC_ABOUT_URL:
bResult&=&FALSE;&//&will&be&treated&by&DefWindowProc
inline&DWORD&ACM::About(HWND&hParentWindow)
my_debug.OutPut(DEBUG_LEVEL_FUNC_START,&&ACM&:&About&(Parent&Window&=&0x%08X)&,hParentWindow);
DialogBoxParam(&my_hModule,&MAKEINTRESOURCE(IDD_ABOUT),&hParentWindow,&::AboutProc&,&(LPARAM)this);
return&DRVCNF_OK;&//&Can&also&return
//&DRVCNF_CANCEL
//&and&DRVCNF_RESTART
//////////////////////////////////////////////////////////////////////
//&Construction/Destruction
//////////////////////////////////////////////////////////////////////
ACM::ACM(&HMODULE&hModule&)
&:my_hModule(hModule),
&&my_hIcon(NULL),
&&my_debug(ADbg(DEBUG_LEVEL_CREATION)),
&&my_EncodingProperties(hModule)
my_EncodingProperties.ParamsRestore();
///&todo&get&the&debug&level&from&the®istry
unsigned&char&DebugFileName[512];
char&tmp[128];
wsprintf(tmp,&LAMEacm&0x%08X&,this);
my_debug.setPrefix(tmp);&///&todo&get&it&from&the®istry
my_debug.setIncludeTime(true);&&///&todo&get&it&from&the®istry
//&Check&in&the®istry&if&we&have&to&Output&Debug&information
DebugFileName[0]&=&'