| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027 |
- /**
- *
- * 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 software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; 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 copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
- /*!
- \author Steve Lhomme
- \version \$Id$
- */
- #if !defined(STRICT)
- #define STRICT
- #endif // !defined(STRICT)
- #include <windows.h>
- #include <windowsx.h>
- #include <shlobj.h>
- #include <assert.h>
- #ifdef _MSC_VER
- // no problem with unknown pragmas
- #pragma warning(disable: 4068)
- #endif
- #include "resource.h"
- #include <lame.h>
- #include "adebug.h"
- #include "AEncodeProperties.h"
- #include "ACM.h"
- //#include "AParameters/AParameters.h"
- #ifndef TTS_BALLOON
- #define TTS_BALLOON 0x40
- #endif // TTS_BALLOON
- const unsigned int AEncodeProperties::the_Bitrates[18] = {320, 256, 224, 192, 160, 144, 128, 112, 96, 80, 64, 56, 48, 40, 32, 24, 16, 8 };
- const unsigned int AEncodeProperties::the_MPEG1_Bitrates[14] = {320, 256, 224, 192, 160, 128, 112, 96, 80, 64, 56, 48, 40, 32 };
- const unsigned int AEncodeProperties::the_MPEG2_Bitrates[14] = {160, 144, 128, 112, 96, 80, 64, 56, 48, 40, 32, 24, 16, 8};
- const unsigned int AEncodeProperties::the_ChannelModes[3] = { STEREO, JOINT_STEREO, DUAL_CHANNEL };
- //const char AEncodeProperties::the_Presets[][13] = {"None", "CD", "Studio", "Hi-Fi", "Phone", "Voice", "Radio", "Tape", "FM", "AM", "SW"};
- //const LAME_QUALTIY_PRESET AEncodeProperties::the_Presets[] = {LQP_NOPRESET, LQP_R3MIX_QUALITY, LQP_NORMAL_QUALITY, LQP_LOW_QUALITY, LQP_HIGH_QUALITY, LQP_VERYHIGH_QUALITY, LQP_VOICE_QUALITY, LQP_PHONE, LQP_SW, LQP_AM, LQP_FM, LQP_VOICE, LQP_RADIO, LQP_TAPE, LQP_HIFI, LQP_CD, LQP_STUDIO};
- //const unsigned int AEncodeProperties::the_SamplingFreqs[9] = { 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000 };
- ToolTipItem AEncodeProperties::Tooltips[13]={
- { IDC_CHECK_ENC_ABR, "Allow encoding with an average bitrate\r\ninstead of a constant one.\r\n\r\nIt can improve the quality for the same bitrate." },
- { IDC_CHECK_COPYRIGHT, "Mark the encoded data as copyrighted." },
- { IDC_CHECK_CHECKSUM, "Put a checksum in the encoded data.\r\n\r\nThis can make the file less sensitive to data loss." },
- { IDC_CHECK_ORIGINAL, "Mark the encoded data as an original file." },
- { IDC_CHECK_PRIVATE, "Mark the encoded data as private." },
- { IDC_COMBO_ENC_STEREO, "Select the type of stereo mode used for encoding:\r\n\r\n- Stereo : the usual one\r\n- Joint-Stereo : mix both channel to achieve better compression\r\n- Dual Channel : treat both channel as separate" },
- { IDC_STATIC_DECODING, "Decoding not supported for the moment by the codec." },
- { IDC_CHECK_ENC_SMART, "Disable bitrate when there is too much compression.\r\n(default 1:15 ratio)" },
- { IDC_STATIC_CONFIG_VERSION, "Version of this codec.\r\n\r\nvX.X.X is the version of the codec interface.\r\nX.XX is the version of the encoding engine." },
- { IDC_SLIDER_AVERAGE_MIN, "Select the minimum Average Bitrate allowed." },
- { IDC_SLIDER_AVERAGE_MAX, "Select the maximum Average Bitrate allowed." },
- { IDC_SLIDER_AVERAGE_STEP, "Select the step of Average Bitrate between the min and max.\r\n\r\nA step of 5 between 152 and 165 means you have :\r\n165, 160 and 155" },
- { IDC_SLIDER_AVERAGE_SAMPLE, "Check the resulting values of the (min,max,step) combination.\r\n\r\nUse the keyboard to navigate (right -> left)." },
- };
- //int AEncodeProperties::tst = 0;
- /*
- #pragma argsused
- static UINT CALLBACK DLLFindCallback(
- HWND hdlg, // handle to child dialog box
- UINT uiMsg, // message identifier
- WPARAM wParam, // message parameter
- LPARAM lParam // message parameter
- )
- {
- UINT result = 0;
- switch (uiMsg)
- {
- case WM_NOTIFY:
- OFNOTIFY * info = (OFNOTIFY *)lParam;
- if (info->hdr.code == CDN_FILEOK)
- {
- result = 1; // by default we don't accept the file
- // Check if the selected file is a valid DLL with all the required functions
- ALameDLL * tstFile = new ALameDLL;
- if (tstFile != NULL)
- {
- if (tstFile->Load(info->lpOFN->lpstrFile))
- {
- result = 0;
- }
- delete tstFile;
- }
- if (result == 1)
- {
- TCHAR output[250];
- ::LoadString(AOut::GetInstance(),IDS_STRING_DLL_UNRECOGNIZED,output,250);
- AOut::MyMessageBox( output, MB_OK|MB_ICONEXCLAMATION, hdlg);
- SetWindowLong(hdlg, DWL_MSGRESULT , -100);
- }
- }
- }
- return result;
- }
- #pragma argsused
- static int CALLBACK BrowseFolderCallbackroc(
- HWND hwnd,
- UINT uMsg,
- LPARAM lParam,
- LPARAM lpData
- )
- {
- AEncodeProperties * the_prop;
- the_prop = (AEncodeProperties *) lpData;
- if (uMsg == BFFM_INITIALIZED)
- {
- // char FolderName[MAX_PATH];
- // SHGetPathFromIDList((LPITEMIDLIST) lParam,FolderName);
- //ADbg tst;
- //tst.OutPut("init folder to %s ",the_prop->GetOutputDirectory());
- // CreateFile();
- ::SendMessage(hwnd, BFFM_SETSELECTION, (WPARAM)TRUE, (LPARAM)the_prop->GetOutputDirectory());
- }/* else if (uMsg == BFFM_SELCHANGED)
- {
- // verify that the folder is writable
- // ::SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)0); // disable
- char FolderName[MAX_PATH];
- SHGetPathFromIDList((LPITEMIDLIST) lParam, FolderName);
-
- // if (CreateFile(FolderName,STANDARD_RIGHTS_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL) == INVALID_HANDLE_VALUE)
- if ((GetFileAttributes(FolderName) & FILE_ATTRIBUTE_DIRECTORY) != 0)
- ::SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)1); // enable
- else
- ::SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)0); // disable
- //ADbg tst;
- //tst.OutPut("change folder to %s ",FolderName);
- }* /
- return 0;
- }
- */
- #pragma argsused
- static BOOL CALLBACK ConfigProc(
- HWND hwndDlg, // handle to dialog box
- UINT uMsg, // message
- WPARAM wParam, // first message parameter
- LPARAM lParam // second message parameter
- )
- {
- BOOL bResult;
- AEncodeProperties * the_prop;
- the_prop = (AEncodeProperties *) GetProp(hwndDlg, "AEncodeProperties-Config");
- switch (uMsg) {
- case WM_COMMAND:
- if (the_prop != NULL)
- {
- bResult = the_prop->HandleDialogCommand( hwndDlg, wParam, lParam);
- }
- break;
- case WM_INITDIALOG:
- assert(the_prop == NULL);
- the_prop = (AEncodeProperties *) lParam;
- the_prop->my_debug.OutPut("there hwnd = 0x%08X",hwndDlg);
- assert(the_prop != NULL);
- SetProp(hwndDlg, "AEncodeProperties-Config", the_prop);
- the_prop->InitConfigDlg(hwndDlg);
- bResult = TRUE;
- break;
- case WM_HSCROLL:
- // check if it's the ABR sliders
- if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_MIN))
- {
- the_prop->UpdateDlgFromSlides(hwndDlg);
- }
- else if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_MAX))
- {
- the_prop->UpdateDlgFromSlides(hwndDlg);
- }
- else if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_STEP))
- {
- the_prop->UpdateDlgFromSlides(hwndDlg);
- }
- else if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_SAMPLE))
- {
- the_prop->UpdateDlgFromSlides(hwndDlg);
- }
- break;
- case WM_NOTIFY:
- if (TTN_GETDISPINFO == ((LPNMHDR)lParam)->code) {
- NMTTDISPINFO *lphdr = (NMTTDISPINFO *)lParam;
- UINT id = (lphdr->uFlags & TTF_IDISHWND) ? GetWindowLong((HWND)lphdr->hdr.idFrom, GWL_ID) : lphdr->hdr.idFrom;
- *lphdr->lpszText = 0;
- SendMessage(lphdr->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 5000);
- for(int i=0; i<sizeof AEncodeProperties::Tooltips/sizeof AEncodeProperties::Tooltips[0]; ++i) {
- if (id == AEncodeProperties::Tooltips[i].id)
- lphdr->lpszText = const_cast<char *>(AEncodeProperties::Tooltips[i].tip);
- }
- return TRUE;
- }
- break;
- default:
- bResult = FALSE; // will be treated by DefWindowProc
- }
- return bResult;
- }
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- /**
- \class AEncodeProperties
- */
- const char * AEncodeProperties::GetChannelModeString(int a_channelID) const
- {
- assert(a_channelID < sizeof(the_ChannelModes));
- switch (a_channelID) {
- case 0:
- return "Stereo";
- case 1:
- return "Joint-stereo";
- case 2:
- return "Dual Channel";
- default:
- assert(a_channelID);
- return NULL;
- }
- }
- const int AEncodeProperties::GetBitrateString(char * string, int string_size, int a_bitrateID) const
- {
- assert(a_bitrateID < sizeof(the_Bitrates));
- assert(string != NULL);
- if (string_size >= 4)
- return wsprintf(string,"%d",the_Bitrates[a_bitrateID]);
- else
- return -1;
- }
- const unsigned int AEncodeProperties::GetChannelModeValue() const
- {
- assert(nChannelIndex < sizeof(the_ChannelModes));
- return the_ChannelModes[nChannelIndex];
- }
- const unsigned int AEncodeProperties::GetBitrateValue() const
- {
- assert(nMinBitrateIndex < sizeof(the_Bitrates));
- return the_Bitrates[nMinBitrateIndex];
- }
- inline const int AEncodeProperties::GetBitrateValueMPEG2(DWORD & bitrate) const
- {
- int i;
- for (i=0;i<sizeof(the_MPEG2_Bitrates)/sizeof(unsigned int);i++)
- {
- if (the_MPEG2_Bitrates[i] == the_Bitrates[nMinBitrateIndex])
- {
- bitrate = the_MPEG2_Bitrates[i];
- return 0;
- }
- else if (the_MPEG2_Bitrates[i] < the_Bitrates[nMinBitrateIndex])
- {
- bitrate = the_MPEG2_Bitrates[i];
- return -1;
- }
- }
-
- bitrate = 160;
- return -1;
- }
- inline const int AEncodeProperties::GetBitrateValueMPEG1(DWORD & bitrate) const
- {
- int i;
- for (i=sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1;i>=0;i--)
- {
- if (the_MPEG1_Bitrates[i] == the_Bitrates[nMinBitrateIndex])
- {
- bitrate = the_MPEG1_Bitrates[i];
- return 0;
- }
- else if (the_MPEG1_Bitrates[i] > the_Bitrates[nMinBitrateIndex])
- {
- bitrate = the_MPEG1_Bitrates[i];
- return 1;
- }
- }
-
- bitrate = 32;
- return 1;
- }
- /*
- const int AEncodeProperties::GetBitrateValue(DWORD & bitrate, const DWORD MPEG_Version) const
- {
- assert((MPEG_Version == MPEG1) || (MPEG_Version == MPEG2));
- assert(nMinBitrateIndex < sizeof(the_Bitrates));
- if (MPEG_Version == MPEG2)
- return GetBitrateValueMPEG2(bitrate);
- else
- return GetBitrateValueMPEG1(bitrate);
- }
- /*
- const char * AEncodeProperties::GetPresetModeString(const int a_presetID) const
- {
- assert(a_presetID < sizeof(the_Presets));
- switch (a_presetID) {
- case 1:
- return "r3mix";
- case 2:
- return "Normal";
- case 3:
- return "Low";
- case 4:
- return "High";
- case 5:
- return "Very High";
- case 6:
- return "Voice";
- case 7:
- return "Phone";
- case 8:
- return "SW";
- case 9:
- return "AM";
- case 10:
- return "FM";
- case 11:
- return "Voice";
- case 12:
- return "Radio";
- case 13:
- return "Tape";
- case 14:
- return "Hi-Fi";
- case 15:
- return "CD";
- case 16:
- return "Studio";
- default:
- return "None";
- }
- }
- const LAME_QUALTIY_PRESET AEncodeProperties::GetPresetModeValue() const
- {
- assert(nPresetIndex < sizeof(the_Presets));
- return the_Presets[nPresetIndex];
- }
- */
- bool AEncodeProperties::Config(const HINSTANCE Hinstance, const HWND HwndParent)
- {
- //WM_INITDIALOG ?
- // remember the instance to retreive strings
- // hDllInstance = Hinstance;
- my_debug.OutPut("here");
- int ret = ::DialogBoxParam(Hinstance, MAKEINTRESOURCE(IDD_CONFIG), HwndParent, ::ConfigProc, (LPARAM) this);
- /* if (ret == -1)
- {
- LPVOID lpMsgBuf;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL
- );
- // Process any inserts in lpMsgBuf.
- // ...
- // Display the string.
- AOut::MyMessageBox( (LPCTSTR)lpMsgBuf, MB_OK | MB_ICONINFORMATION );
- // Free the buffer.
- LocalFree( lpMsgBuf );
- return false;
- }
- */
- return true;
- }
- bool AEncodeProperties::InitConfigDlg(HWND HwndDlg)
- {
- // get all the required strings
- // TCHAR Version[5];
- // LoadString(hDllInstance, IDS_STRING_VERSION, Version, 5);
- int i;
- // Add required channel modes
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO), CB_RESETCONTENT , NULL, NULL);
- for (i=0;i<GetChannelLentgh();i++)
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO), CB_ADDSTRING, NULL, (LPARAM) GetChannelModeString(i));
- char tmp[20];
- wsprintf(tmp, "v%s",ACM::GetVersionString());
- SetWindowText( GetDlgItem( HwndDlg, IDC_STATIC_CONFIG_VERSION), tmp);
- // Add all possible re-sampling freq
- /* SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_RESETCONTENT , NULL, NULL);
- char tmp[10];
- for (i=0;i<sizeof(the_SamplingFreqs)/sizeof(unsigned int);i++)
- {
- wsprintf(tmp, "%d", the_SamplingFreqs[i]);
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_ADDSTRING, NULL, (LPARAM) tmp );
- }
- */
- // Add required bitrates
- /* SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE), CB_RESETCONTENT , NULL, NULL);
- for (i=0;i<GetBitrateLentgh();i++)
- {
- GetBitrateString(tmp, 5, i);
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE), CB_ADDSTRING, NULL, (LPARAM) tmp );
- }
- // Add bitrates to the VBR combo box too
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_RESETCONTENT , NULL, NULL);
- for (i=0;i<GetBitrateLentgh();i++)
- {
- GetBitrateString(tmp, 5, i);
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_ADDSTRING, NULL, (LPARAM) tmp );
- }
- // Add VBR Quality Slider
- SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_SETRANGE, TRUE, MAKELONG(0,9));
- // Add presets
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET), CB_RESETCONTENT , NULL, NULL);
- for (i=0;i<GetPresetLentgh();i++)
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET), CB_ADDSTRING, NULL, (LPARAM) GetPresetModeString(i));
- */
- // Add ABR Sliders
- SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_SETRANGE, TRUE, MAKELONG(8,320));
- SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_SETRANGE, TRUE, MAKELONG(8,320));
- SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_SETRANGE, TRUE, MAKELONG(1,16));
- // Tool-Tip initialiasiation
- TOOLINFO ti;
- HWND ToolTipWnd;
- char DisplayStr[30] = "test tooltip";
- ToolTipWnd = CreateWindowEx(WS_EX_TOPMOST,
- TOOLTIPS_CLASS,
- NULL,
- WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP|TTS_BALLOON ,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- HwndDlg,
- NULL,
- NULL,
- NULL
- );
- SetWindowPos(ToolTipWnd,
- HWND_TOPMOST,
- 0,
- 0,
- 0,
- 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
- ti.cbSize = sizeof(TOOLINFO);
- ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
- ti.hwnd = HwndDlg;
- ti.lpszText = LPSTR_TEXTCALLBACK;
-
- /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */
- for(i=0; i<sizeof Tooltips/sizeof Tooltips[0]; ++i) {
- ti.uId = (WPARAM)GetDlgItem(HwndDlg, Tooltips[i].id);
- if (ti.uId)
- SendMessage(ToolTipWnd, TTM_ADDTOOL, 0, (LPARAM)&ti);
- }
- my_debug.OutPut("call UpdateConfigs");
- UpdateConfigs(HwndDlg);
- my_debug.OutPut("call UpdateDlgFromValue");
- UpdateDlgFromValue(HwndDlg);
- my_debug.OutPut("finished InitConfigDlg");
- return true;
- }
- bool AEncodeProperties::UpdateDlgFromValue(HWND HwndDlg)
- {
- // get all the required strings
- // TCHAR Version[5];
- // LoadString(hDllInstance, IDS_STRING_VERSION, Version, 5);
- int i;
- // Check boxes if required
- ::CheckDlgButton( HwndDlg, IDC_CHECK_CHECKSUM, GetCRCMode() ?BST_CHECKED:BST_UNCHECKED );
- ::CheckDlgButton( HwndDlg, IDC_CHECK_ORIGINAL, GetOriginalMode() ?BST_CHECKED:BST_UNCHECKED );
- ::CheckDlgButton( HwndDlg, IDC_CHECK_PRIVATE, GetPrivateMode() ?BST_CHECKED:BST_UNCHECKED );
- ::CheckDlgButton( HwndDlg, IDC_CHECK_COPYRIGHT, GetCopyrightMode() ?BST_CHECKED:BST_UNCHECKED );
- ::CheckDlgButton( HwndDlg, IDC_CHECK_ENC_SMART, GetSmartOutputMode()?BST_CHECKED:BST_UNCHECKED );
- ::CheckDlgButton( HwndDlg, IDC_CHECK_ENC_ABR, GetAbrOutputMode() ?BST_CHECKED:BST_UNCHECKED );
- // ::CheckDlgButton( HwndDlg, IDC_CHECK_RESERVOIR, !GetNoBiResMode() ?BST_CHECKED:BST_UNCHECKED );
- // ::CheckDlgButton( HwndDlg, IDC_CHECK_XINGVBR, GetXingFrameMode()?BST_CHECKED:BST_UNCHECKED );
- // ::CheckDlgButton( HwndDlg, IDC_CHECK_RESAMPLE, GetResampleMode() ?BST_CHECKED:BST_UNCHECKED );
- // ::CheckDlgButton( HwndDlg, IDC_CHECK_CHANNELFORCE, bForceChannel ?BST_CHECKED:BST_UNCHECKED );
-
- // Add required channel modes
- for (i=0;i<GetChannelLentgh();i++)
- {
- if (i == nChannelIndex)
- {
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO), CB_SETCURSEL, i, NULL);
- break;
- }
- }
- // Add VBR Quality
- SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_SETPOS, TRUE, AverageBitrate_Min);
- SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_SETPOS, TRUE, AverageBitrate_Max);
- SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_SETPOS, TRUE, AverageBitrate_Step);
- SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETPOS, TRUE, AverageBitrate_Max);
- UpdateDlgFromSlides(HwndDlg);
- EnableAbrOptions(HwndDlg, GetAbrOutputMode());
- // UpdateAbrSteps(AverageBitrate_Min, AverageBitrate_Max, AverageBitrate_Step);
- // Add all possible re-sampling freq
- /* SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_SETCURSEL, nSamplingFreqIndex, NULL);
-
- // Add required bitrates
- for (i=0;i<GetBitrateLentgh();i++)
- {
- if (i == nMinBitrateIndex)
- {
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE), CB_SETCURSEL, i, NULL);
- break;
- }
- }
- // Add bitrates to the VBR combo box too
- for (i=0;i<GetBitrateLentgh();i++)
- {
- if (i == nMaxBitrateIndex)
- {
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_SETCURSEL, i, NULL);
- break;
- }
- }
- // SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_SETRANGE, TRUE, MAKELONG(0,9));
- char tmp[3];
- wsprintf(tmp,"%d",VbrQuality);
- SetWindowText(GetDlgItem( HwndDlg, IDC_CONFIG_QUALITY), tmp);
- SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_SETPOS, TRUE, VbrQuality);
-
- wsprintf(tmp,"%d",AverageBitrate);
- SetWindowText(GetDlgItem( HwndDlg, IDC_EDIT_AVERAGE), tmp);
-
- // Display VBR settings if needed
- AEncodeProperties::DisplayVbrOptions(HwndDlg, mBRmode);
- // Display Resample settings if needed
- if (GetResampleMode())
- {
- ::EnableWindow(::GetDlgItem(HwndDlg,IDC_COMBO_SAMPLEFREQ), TRUE);
- }
- else
- {
- ::EnableWindow(::GetDlgItem(HwndDlg,IDC_COMBO_SAMPLEFREQ), FALSE);
- }
- // Add presets
- for (i=0;i<GetPresetLentgh();i++)
- {
- if (i == nPresetIndex)
- {
- SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET), CB_SETCURSEL, i, NULL);
- break;
- }
- }
- // Add User configs
- // SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_RESETCONTENT , NULL, NULL);
- ::SetWindowText(::GetDlgItem( HwndDlg, IDC_EDIT_OUTPUTDIR), OutputDir.c_str());
- */
- /**
- \todo Select the right saved config
- */
- return true;
- }
- bool AEncodeProperties::UpdateValueFromDlg(HWND HwndDlg)
- {
- nChannelIndex = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO), CB_GETCURSEL, NULL, NULL);
- // nMinBitrateIndex = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE), CB_GETCURSEL, NULL, NULL);
- // nMaxBitrateIndex = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_GETCURSEL, NULL, NULL);
- // nPresetIndex = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET), CB_GETCURSEL, NULL, NULL);
- // VbrQuality = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_GETPOS , NULL, NULL);
- // nSamplingFreqIndex = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_GETCURSEL, NULL, NULL);
- bCRC = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_CHECKSUM) == BST_CHECKED);
- bCopyright = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_COPYRIGHT) == BST_CHECKED);
- bOriginal = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_ORIGINAL) == BST_CHECKED);
- bPrivate = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_PRIVATE) == BST_CHECKED);
- bSmartOutput = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_ENC_SMART) == BST_CHECKED);
- bAbrOutput = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_ENC_ABR) == BST_CHECKED);
- // bNoBitRes =!(::IsDlgButtonChecked( HwndDlg, IDC_CHECK_RESERVOIR) == BST_CHECKED);
- // bXingFrame = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_XINGVBR) == BST_CHECKED);
- // bResample = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_RESAMPLE) == BST_CHECKED);
- // bForceChannel = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_CHANNELFORCE) == BST_CHECKED);
- AverageBitrate_Min = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_GETPOS , NULL, NULL);
- AverageBitrate_Max = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_GETPOS , NULL, NULL);
- AverageBitrate_Step = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_GETPOS , NULL, NULL);
- EnableAbrOptions(HwndDlg, bAbrOutput);
- my_debug.OutPut("nChannelIndex %d, bCRC %d, bCopyright %d, bOriginal %d, bPrivate %d",nChannelIndex, bCRC, bCopyright, bOriginal, bPrivate);
- /* char tmpPath[MAX_PATH];
- ::GetWindowText( ::GetDlgItem( HwndDlg, IDC_EDIT_OUTPUTDIR), tmpPath, MAX_PATH);
- OutputDir = tmpPath;
- if (::IsDlgButtonChecked(HwndDlg, IDC_RADIO_BITRATE_CBR) == BST_CHECKED)
- mBRmode = BR_CBR;
- else if (::IsDlgButtonChecked(HwndDlg, IDC_RADIO_BITRATE_VBR) == BST_CHECKED)
- mBRmode = BR_VBR;
- else
- mBRmode = BR_ABR;
-
- ::GetWindowText( ::GetDlgItem( HwndDlg, IDC_EDIT_AVERAGE), tmpPath, MAX_PATH);
- AverageBitrate = atoi(tmpPath);
- if (AverageBitrate < 8)
- AverageBitrate = 8;
- if (AverageBitrate > 320)
- AverageBitrate = 320;
- */
- return true;
- }
- /*
- VBRMETHOD AEncodeProperties::GetVBRValue(DWORD & MaxBitrate, int & Quality, DWORD & AbrBitrate, BOOL & VBRHeader, const DWORD MPEG_Version) const
- {
- assert((MPEG_Version == MPEG1) || (MPEG_Version == MPEG2));
- assert(nMaxBitrateIndex < sizeof(the_Bitrates));
- if (mBRmode == BR_VBR)
- {
- MaxBitrate = the_Bitrates[nMaxBitrateIndex];
- if (MPEG_Version == MPEG1)
- MaxBitrate = MaxBitrate>the_MPEG1_Bitrates[sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1]?MaxBitrate:the_MPEG1_Bitrates[sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1];
- else
- MaxBitrate = MaxBitrate<the_MPEG2_Bitrates[0]?MaxBitrate:the_MPEG2_Bitrates[0];
- VBRHeader = bXingFrame;
- Quality = VbrQuality;
- AbrBitrate = 0;
- return VBR_METHOD_DEFAULT; // for the moment
- }
- else if (mBRmode == BR_ABR)
- {
- MaxBitrate = the_Bitrates[nMaxBitrateIndex];
- if (MPEG_Version == MPEG1)
- MaxBitrate = MaxBitrate>the_MPEG1_Bitrates[sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1]?MaxBitrate:the_MPEG1_Bitrates[sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1];
- else
- MaxBitrate = MaxBitrate<the_MPEG2_Bitrates[0]?MaxBitrate:the_MPEG2_Bitrates[0];
- VBRHeader = bXingFrame;
- Quality = 0;
- AbrBitrate = AverageBitrate*1000;
- return VBR_METHOD_ABR;
- }
- else
- {
- return VBR_METHOD_NONE;
- }
- }
- */
- void AEncodeProperties::ParamsRestore()
- {
- // use these default parameters in case one is not found
- bCopyright = true;
- bCRC = true;
- bOriginal = true;
- bPrivate = true;
- bNoBitRes = false; // enable bit reservoir
- bXingFrame = true;
- bResample = false;
- bForceChannel = false;
- bSmartOutput = true;
- bAbrOutput = true;
-
- AverageBitrate_Min = 80; // a bit lame
- AverageBitrate_Max = 160; // a bit lame
- AverageBitrate_Step = 8; // a bit lame
- SmartRatioMax = 15.0;
- nChannelIndex = 2; // joint-stereo
- mBRmode = BR_CBR;
- nMinBitrateIndex = 6; // 128 kbps (works for both MPEGI and II)
- nMaxBitrateIndex = 4; // 160 kbps (works for both MPEGI and II)
- nPresetIndex = 0; // None
- VbrQuality = 1; // Quite High
- // AverageBitrate = 128; // a bit lame
- nSamplingFreqIndex = 1; // 44100
- // OutputDir = "c:\\";
- // DllLocation = "plugins\\lame_enc.dll";
- // get the values from the saved file if possible
- if (my_stored_data.LoadFile(my_store_location))
- {
- TiXmlNode* node;
- node = my_stored_data.FirstChild("lame_acm");
- TiXmlElement* CurrentNode = node->FirstChildElement("encodings");
- std::string CurrentConfig = "";
- if (CurrentNode->Attribute("default") != NULL)
- {
- CurrentConfig = *CurrentNode->Attribute("default");
- }
- /* // output parameters
- TiXmlElement* iterateElmt = node->FirstChildElement("DLL");
- if (iterateElmt != NULL)
- {
- const std::string * tmpname = iterateElmt->Attribute("location");
- if (tmpname != NULL)
- {
- DllLocation = *tmpname;
- }
- }
- */
- GetValuesFromKey(CurrentConfig, *CurrentNode);
- }
- else
- {
- /**
- \todo save the data in the file !
- */
- }
- }
- void AEncodeProperties::ParamsSave()
- {
- /*
- save the current parameters in the corresponding subkey
-
- HKEY OssKey;
- if (RegCreateKeyEx ( HKEY_LOCAL_MACHINE, "SOFTWARE\\MUKOLI\\out_lame", 0, "", REG_OPTION_NON_VOLATILE, KEY_WRITE , NULL, &OssKey, NULL ) == ERROR_SUCCESS) {
- if (RegSetValueEx(OssKey, "DLL Location", 0, REG_EXPAND_SZ, (CONST BYTE *)DllLocation, strlen(DllLocation)+1 ) != ERROR_SUCCESS)
- return;
-
- RegCloseKey(OssKey);
- }
- */
- }
- /*
- void AEncodeProperties::DisplayVbrOptions(const HWND hDialog, const BRMode the_mode)
- {
- bool bVBR = false;
- bool bABR = false;
- switch ( the_mode )
- {
- case BR_CBR:
- ::CheckRadioButton(hDialog, IDC_RADIO_BITRATE_CBR, IDC_RADIO_BITRATE_ABR, IDC_RADIO_BITRATE_CBR);
- break;
- case BR_VBR:
- ::CheckRadioButton(hDialog, IDC_RADIO_BITRATE_CBR, IDC_RADIO_BITRATE_ABR, IDC_RADIO_BITRATE_VBR);
- bVBR = true;
- break;
- case BR_ABR:
- ::CheckRadioButton(hDialog, IDC_RADIO_BITRATE_CBR, IDC_RADIO_BITRATE_ABR, IDC_RADIO_BITRATE_ABR);
- bABR = true;
- break;
- }
- if(bVBR|bABR)
- {
- ::SetWindowText(::GetDlgItem(hDialog,IDC_STATIC_MINBITRATE), "Min Bitrate");
- }
- else
- {
- ::SetWindowText(::GetDlgItem(hDialog,IDC_STATIC_MINBITRATE), "Bitrate");
- }
- ::EnableWindow(::GetDlgItem( hDialog, IDC_CHECK_XINGVBR), bVBR|bABR);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_COMBO_MAXBITRATE), bVBR|bABR);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_MAXBITRATE), bVBR|bABR);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_QUALITY), bVBR);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_CONFIG_QUALITY), bVBR);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_VBRQUALITY), bVBR);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_VBRQUALITY_LOW), bVBR);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_VBRQUALITY_HIGH), bVBR);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_ABR), bABR);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_EDIT_AVERAGE), bABR);
- }
- */
- AEncodeProperties::AEncodeProperties(HMODULE hModule)
- :my_debug(ADbg(DEBUG_LEVEL_CREATION)),
- my_hModule(hModule)
- {
- std::string path = "";
- // HMODULE htmp = LoadLibrary("out_lame.dll");
- if (hModule != NULL)
- {
- char output[MAX_PATH];
- ::GetModuleFileName(hModule, output, MAX_PATH);
- // ::FreeLibrary(htmp);
- path = output;
- }
- my_store_location = path.substr(0,path.find_last_of('\\')+1);
- my_store_location += "lame_acm.xml";
- my_debug.OutPut("store path = %s",my_store_location.c_str());
- //#ifdef OLD
- // ::OutputDebugString(my_store_location.c_str());
- // make sure the XML file is present
- HANDLE hFile = ::CreateFile(my_store_location.c_str(), 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL );
- ::CloseHandle(hFile);
- //#endif // OLD
- my_debug.OutPut("AEncodeProperties creation completed (0x%08X)",this);
- }
- // Save the values to the right XML saved config
- void AEncodeProperties::SaveValuesToStringKey(const std::string & config_name)
- {
- // get the current data in the file to keep them
- if (my_stored_data.LoadFile(my_store_location))
- {
- // check if the Node corresponding to the config_name already exist.
- TiXmlNode* node = my_stored_data.FirstChild("lame_acm");
- if (node != NULL)
- {
- TiXmlElement* ConfigNode = node->FirstChildElement("encodings");
- if (ConfigNode != NULL)
- {
- // look all the <config> tags
- TiXmlElement* tmpNode = ConfigNode->FirstChildElement("config");
- while (tmpNode != NULL)
- {
- const std::string * tmpname = tmpNode->Attribute("name");
- if (tmpname->compare(config_name) == 0)
- {
- break;
- }
- tmpNode = tmpNode->NextSiblingElement("config");
- }
- if (tmpNode == NULL)
- {
- // Create the node
- tmpNode = new TiXmlElement("config");
- tmpNode->SetAttribute("name",config_name);
- // save data in the node
- SaveValuesToElement(tmpNode);
- ConfigNode->InsertEndChild(*tmpNode);
- }
- else
- {
- // save data in the node
- SaveValuesToElement(tmpNode);
- }
- // and save the file
- my_stored_data.SaveFile(my_store_location);
- }
- }
- }
- }
- void AEncodeProperties::GetValuesFromKey(const std::string & config_name, const TiXmlNode & parentNode)
- {
- TiXmlElement* tmpElt;
- TiXmlElement* iterateElmt;
- // find the config that correspond to CurrentConfig
- iterateElmt = parentNode.FirstChildElement("config");
- while (iterateElmt != NULL)
- {
- const std::string * tmpname = iterateElmt->Attribute("name");
- if ((tmpname != NULL) && (tmpname->compare(config_name) == 0))
- {
- break;
- }
- iterateElmt = iterateElmt->NextSiblingElement("config");
- }
- if (iterateElmt != NULL)
- {
- // get all the parameters saved in this Element
- const std::string * tmpname;
- // Smart output parameter
- tmpElt = iterateElmt->FirstChildElement("Smart");
- if (tmpElt != NULL)
- {
- tmpname = tmpElt->Attribute("use");
- if (tmpname != NULL)
- bSmartOutput = (tmpname->compare("true") == 0);
-
- tmpname = tmpElt->Attribute("ratio");
- if (tmpname != NULL)
- SmartRatioMax = atof(tmpname->c_str());
- }
- // Smart output parameter
- tmpElt = iterateElmt->FirstChildElement("ABR");
- if (tmpElt != NULL)
- {
- tmpname = tmpElt->Attribute("use");
- if (tmpname != NULL)
- bAbrOutput = (tmpname->compare("true") == 0);
-
- tmpname = tmpElt->Attribute("min");
- if (tmpname != NULL)
- AverageBitrate_Min = atoi(tmpname->c_str());
- tmpname = tmpElt->Attribute("max");
- if (tmpname != NULL)
- AverageBitrate_Max = atoi(tmpname->c_str());
- tmpname = tmpElt->Attribute("step");
- if (tmpname != NULL)
- AverageBitrate_Step = atoi(tmpname->c_str());
- }
- // Copyright parameter
- tmpElt = iterateElmt->FirstChildElement("Copyright");
- if (tmpElt != NULL)
- {
- tmpname = tmpElt->Attribute("use");
- if (tmpname != NULL)
- bCopyright = (tmpname->compare("true") == 0);
- }
- // Copyright parameter
- tmpElt = iterateElmt->FirstChildElement("CRC");
- if (tmpElt != NULL)
- {
- tmpname = tmpElt->Attribute("use");
- if (tmpname != NULL)
- bCRC = (tmpname->compare("true") == 0);
- }
- // Copyright parameter
- tmpElt = iterateElmt->FirstChildElement("Original");
- if (tmpElt != NULL)
- {
- tmpname = tmpElt->Attribute("use");
- if (tmpname != NULL)
- bOriginal = (tmpname->compare("true") == 0);
- }
- // Copyright parameter
- tmpElt = iterateElmt->FirstChildElement("Private");
- if (tmpElt != NULL)
- {
- tmpname = tmpElt->Attribute("use");
- if (tmpname != NULL)
- bPrivate = (tmpname->compare("true") == 0);
- }
- /*
- // Copyright parameter
- tmpElt = iterateElmt->FirstChildElement("Bit_reservoir");
- if (tmpElt != NULL)
- {
- tmpname = tmpElt->Attribute("use");
- if (tmpname != NULL)
- bNoBitRes = !(tmpname->compare("true") == 0);
- }
- // bitrates
- tmpElt = iterateElmt->FirstChildElement("bitrate");
- tmpname = tmpElt->Attribute("min");
- if (tmpname != NULL)
- {
- unsigned int uitmp = atoi(tmpname->c_str());
- for (int i=0;i<sizeof(the_Bitrates)/sizeof(unsigned int);i++)
- {
- if (the_Bitrates[i] == uitmp)
- {
- nMinBitrateIndex = i;
- break;
- }
- }
- }
- tmpname = tmpElt->Attribute("max");
- if (tmpname != NULL)
- {
- unsigned int uitmp = atoi(tmpname->c_str());
- for (int i=0;i<sizeof(the_Bitrates)/sizeof(unsigned int);i++)
- {
- if (the_Bitrates[i] == uitmp)
- {
- nMaxBitrateIndex = i;
- break;
- }
- }
- }
- */
- /*
- // resampling parameters
- tmpElt = iterateElmt->FirstChildElement("resampling");
- if (tmpElt != NULL)
- {
- tmpname = tmpElt->Attribute("use");
- if (tmpname != NULL)
- bResample = (tmpname->compare("true") == 0);
- unsigned int uitmp = atoi(tmpElt->Attribute("freq")->c_str());
- for (int i=0;i<sizeof(the_SamplingFreqs)/sizeof(unsigned int);i++)
- {
- if (the_SamplingFreqs[i] == uitmp)
- {
- nSamplingFreqIndex = i;
- break;
- }
- }
- }
- // VBR parameters
- tmpElt = iterateElmt->FirstChildElement("VBR");
- if (tmpElt != NULL)
- {
- tmpname = tmpElt->Attribute("use");
- if (tmpname != NULL)
- {
- if (tmpname->compare("ABR") == 0)
- mBRmode = BR_ABR;
- else if (tmpname->compare("true") == 0)
- mBRmode = BR_VBR;
- else
- mBRmode = BR_CBR;
- }
- tmpname = tmpElt->Attribute("header");
- if (tmpname != NULL)
- bXingFrame = (tmpname->compare("true") == 0);
- tmpname = tmpElt->Attribute("quality");
- if (tmpname != NULL)
- {
- VbrQuality = atoi(tmpname->c_str());
- }
- tmpname = tmpElt->Attribute("average");
- if (tmpname != NULL)
- {
- AverageBitrate = atoi(tmpname->c_str());
- }
- else
- {
- }
- }
- // output parameters
- tmpElt = iterateElmt->FirstChildElement("output");
- if (tmpElt != NULL)
- {
- OutputDir = *tmpElt->Attribute("path");
- }
- */
- //#ifdef OLD
- // Channel mode parameter
- tmpElt = iterateElmt->FirstChildElement("Channel");
- if (tmpElt != NULL)
- {
- const std::string * tmpStr = tmpElt->Attribute("mode");
- if (tmpStr != NULL)
- {
- for (int i=0;i<GetChannelLentgh();i++)
- {
- if (tmpStr->compare(GetChannelModeString(i)) == 0)
- {
- nChannelIndex = i;
- break;
- }
- }
- }
- /*
- tmpname = tmpElt->Attribute("force");
- if (tmpname != NULL)
- bForceChannel = (tmpname->compare("true") == 0);
- */
- }
- //#endif // OLD
- // Preset parameter
- /*
- tmpElt = iterateElmt->FirstChildElement("Preset");
- if (tmpElt != NULL)
- {
- const std::string * tmpStr = tmpElt->Attribute("type");
- for (int i=0;i<GetPresetLentgh();i++)
- {
- if (tmpStr->compare(GetPresetModeString(i)) == 0)
- {
- nPresetIndex = i;
- break;
- }
- }
- }
- */
- }
- }
- /**
- \todo save the parameters
- * /
- void AEncodeProperties::SaveParams(const HWND hParentWnd)
- {
- char string[MAX_PATH];
- /* int nIdx = SendMessage(::GetDlgItem( hParentWnd ,IDC_COMBO_SETTINGS ), CB_GETCURSEL, NULL, NULL);
- ::SendMessage(::GetDlgItem( hParentWnd ,IDC_COMBO_SETTINGS ), CB_GETLBTEXT , nIdx, (LPARAM) string);
- * /
- }*/
- bool AEncodeProperties::operator !=(const AEncodeProperties & the_instance) const
- {
- /*
- ::OutputDebugString(bCopyright != the_instance.bCopyright?"1":"-");
- ::OutputDebugString(bCRC != the_instance.bCRC ?"2":"-");
- ::OutputDebugString(bOriginal != the_instance.bOriginal ?"3":"-");
- ::OutputDebugString(bPrivate != the_instance.bPrivate ?"4":"-");
- ::OutputDebugString(bNoBitRes != the_instance.bNoBitRes ?"5":"-");
- ::OutputDebugString(mBRmode != the_instance.mBRmode ?"6":"-");
- ::OutputDebugString(bXingFrame != the_instance.bXingFrame?"7":"-");
- ::OutputDebugString(bForceChannel != the_instance.bForceChannel?"8":"-");
- ::OutputDebugString(bResample != the_instance.bResample ?"9":"-");
- ::OutputDebugString(nChannelIndex != the_instance.nChannelIndex?"10":"-");
- ::OutputDebugString(nMinBitrateIndex != the_instance.nMinBitrateIndex?"11":"-");
- ::OutputDebugString(nMaxBitrateIndex != the_instance.nMaxBitrateIndex?"12":"-");
- ::OutputDebugString(nPresetIndex != the_instance.nPresetIndex?"13":"-");
- ::OutputDebugString(VbrQuality != the_instance.VbrQuality?"14":"-");
- ::OutputDebugString(AverageBitrate != the_instance.AverageBitrate?"15":"-");
- ::OutputDebugString(nSamplingFreqIndex != the_instance.nSamplingFreqIndex?"16":"-");
- ::OutputDebugString(OutputDir.compare(the_instance.OutputDir) != 0?"17":"-");
- std::string tmp = "";
- char tmpI[10];
- _itoa(AverageBitrate,tmpI,10);
- tmp += tmpI;
- tmp += " != ";
- _itoa(the_instance.AverageBitrate,tmpI,10);
- tmp += tmpI;
- ::OutputDebugString(tmp.c_str());
- */
- return ((bCopyright != the_instance.bCopyright)
- || (bCRC != the_instance.bCRC)
- || (bOriginal != the_instance.bOriginal)
- || (bPrivate != the_instance.bPrivate)
- || (bSmartOutput != the_instance.bSmartOutput)
- || (SmartRatioMax != the_instance.SmartRatioMax)
- || (bAbrOutput != the_instance.bAbrOutput)
- || (AverageBitrate_Min != the_instance.AverageBitrate_Min)
- || (AverageBitrate_Max != the_instance.AverageBitrate_Max)
- || (AverageBitrate_Step != the_instance.AverageBitrate_Step)
- || (bNoBitRes != the_instance.bNoBitRes)
- || (mBRmode != the_instance.mBRmode)
- || (bXingFrame != the_instance.bXingFrame)
- || (bForceChannel != the_instance.bForceChannel)
- || (bResample != the_instance.bResample)
- || (nChannelIndex != the_instance.nChannelIndex)
- || (nMinBitrateIndex != the_instance.nMinBitrateIndex)
- || (nMaxBitrateIndex != the_instance.nMaxBitrateIndex)
- || (nPresetIndex != the_instance.nPresetIndex)
- || (VbrQuality != the_instance.VbrQuality)
- // || (AverageBitrate != the_instance.AverageBitrate)
- || (nSamplingFreqIndex != the_instance.nSamplingFreqIndex)
- // || (OutputDir.compare(the_instance.OutputDir) != 0)
- );
- }
- void AEncodeProperties::SelectSavedParams(const std::string the_string)
- {
- // get the values from the saved file if possible
- if (my_stored_data.LoadFile(my_store_location))
- {
- TiXmlNode* node;
- node = my_stored_data.FirstChild("lame_acm");
- TiXmlElement* CurrentNode = node->FirstChildElement("encodings");
- if (CurrentNode != NULL)
- {
- CurrentNode->SetAttribute("default",the_string);
- GetValuesFromKey(the_string, *CurrentNode);
- my_stored_data.SaveFile(my_store_location);
- }
- }
- }
- inline void AEncodeProperties::SetAttributeBool(TiXmlElement * the_elt,const std::string & the_string, const bool the_value) const
- {
- if (the_value == false)
- the_elt->SetAttribute(the_string, "false");
- else
- the_elt->SetAttribute(the_string, "true");
- }
- void AEncodeProperties::SaveValuesToElement(TiXmlElement * the_element) const
- {
- // get all the parameters saved in this Element
- TiXmlElement * tmpElt;
- // Bit Reservoir parameter
- /*
- tmpElt = the_element->FirstChildElement("Bit_reservoir");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("Bit_reservoir");
- SetAttributeBool(tmpElt, "use", !bNoBitRes);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- SetAttributeBool(tmpElt, "use", !bNoBitRes);
- }
- */
- // Copyright parameter
- tmpElt = the_element->FirstChildElement("Copyright");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("Copyright");
- SetAttributeBool( tmpElt, "use", bCopyright);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- SetAttributeBool( tmpElt, "use", bCopyright);
- }
- // Smart Output parameter
- tmpElt = the_element->FirstChildElement("Smart");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("Smart");
- SetAttributeBool( tmpElt, "use", bSmartOutput);
- tmpElt->SetAttribute("ratio", SmartRatioMax);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- SetAttributeBool( tmpElt, "use", bSmartOutput);
- tmpElt->SetAttribute("ratio", SmartRatioMax);
- }
- // Smart Output parameter
- tmpElt = the_element->FirstChildElement("ABR");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("ABR");
- SetAttributeBool( tmpElt, "use", bAbrOutput);
- tmpElt->SetAttribute("min", AverageBitrate_Min);
- tmpElt->SetAttribute("max", AverageBitrate_Max);
- tmpElt->SetAttribute("step", AverageBitrate_Step);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- SetAttributeBool( tmpElt, "use", bAbrOutput);
- tmpElt->SetAttribute("min", AverageBitrate_Min);
- tmpElt->SetAttribute("max", AverageBitrate_Max);
- tmpElt->SetAttribute("step", AverageBitrate_Step);
- }
- // CRC parameter
- tmpElt = the_element->FirstChildElement("CRC");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("CRC");
- SetAttributeBool( tmpElt, "use", bCRC);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- SetAttributeBool( tmpElt, "use", bCRC);
- }
- // Original parameter
- tmpElt = the_element->FirstChildElement("Original");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("Original");
- SetAttributeBool( tmpElt, "use", bOriginal);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- SetAttributeBool( tmpElt, "use", bOriginal);
- }
- // Private parameter
- tmpElt = the_element->FirstChildElement("Private");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("Private");
- SetAttributeBool( tmpElt, "use", bPrivate);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- SetAttributeBool( tmpElt, "use", bPrivate);
- }
- // Channel Mode parameter
- tmpElt = the_element->FirstChildElement("Channel");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("Channel");
- tmpElt->SetAttribute("mode", GetChannelModeString(nChannelIndex));
- // SetAttributeBool( tmpElt, "force", bForceChannel);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- tmpElt->SetAttribute("mode", GetChannelModeString(nChannelIndex));
- // SetAttributeBool( tmpElt, "force", bForceChannel);
- }
- /*
- // Preset parameter
- tmpElt = the_element->FirstChildElement("Preset");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("Preset");
- tmpElt->SetAttribute("type", GetPresetModeString(nPresetIndex));
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- tmpElt->SetAttribute("type", GetPresetModeString(nPresetIndex));
- }
- // Bitrate parameter
- tmpElt = the_element->FirstChildElement("bitrate");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("bitrate");
- tmpElt->SetAttribute("min", the_Bitrates[nMinBitrateIndex]);
- tmpElt->SetAttribute("max", the_Bitrates[nMaxBitrateIndex]);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- tmpElt->SetAttribute("min", the_Bitrates[nMinBitrateIndex]);
- tmpElt->SetAttribute("max", the_Bitrates[nMaxBitrateIndex]);
- }
- // Output Directory parameter
- tmpElt = the_element->FirstChildElement("output");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("output");
- tmpElt->SetAttribute("path", OutputDir);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- tmpElt->SetAttribute("path", OutputDir);
- }
- */
- /*
- // Resampling parameter
- tmpElt = the_element->FirstChildElement("resampling");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("resampling");
- SetAttributeBool( tmpElt, "use", bResample);
- tmpElt->SetAttribute("freq", the_SamplingFreqs[nSamplingFreqIndex]);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- SetAttributeBool( tmpElt, "use", bResample);
- tmpElt->SetAttribute("freq", the_SamplingFreqs[nSamplingFreqIndex]);
- }
- // VBR parameter
- tmpElt = the_element->FirstChildElement("VBR");
- if (tmpElt == NULL)
- {
- tmpElt = new TiXmlElement("VBR");
-
- if (mBRmode == BR_ABR)
- tmpElt->SetAttribute("use", "ABR");
- else
- SetAttributeBool( tmpElt, "use", (mBRmode != BR_CBR));
- SetAttributeBool( tmpElt, "header", bXingFrame);
- tmpElt->SetAttribute("quality", VbrQuality);
- tmpElt->SetAttribute("average", AverageBitrate);
- the_element->InsertEndChild(*tmpElt);
- }
- else
- {
- if (mBRmode == BR_ABR)
- tmpElt->SetAttribute("use", "ABR");
- else
- SetAttributeBool( tmpElt, "use", (mBRmode != BR_CBR));
- SetAttributeBool( tmpElt, "header", bXingFrame);
- tmpElt->SetAttribute("quality", VbrQuality);
- tmpElt->SetAttribute("average", AverageBitrate);
- }
- */
- }
- bool AEncodeProperties::HandleDialogCommand(const HWND parentWnd, const WPARAM wParam, const LPARAM lParam)
- {
- UINT command;
- command = GET_WM_COMMAND_ID(wParam, lParam);
- switch (command)
- {
- case IDOK :
- {
- bool bShouldEnd = true;
- // save parameters
- char string[MAX_PATH];
- // ::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH);
- wsprintf(string,"Current"); // only the Current config is supported at the moment
-
- my_debug.OutPut("my_hModule = 0x%08X",my_hModule);
- /*
- AEncodeProperties tmpDlgProps(my_hModule);
- AEncodeProperties tmpSavedProps(my_hModule);
- //#ifdef OLD
- tmpDlgProps.UpdateValueFromDlg(parentWnd);
- tmpSavedProps.SelectSavedParams(string);
- tmpSavedProps.ParamsRestore();
- // check if the values from the DLG are the same as the one saved in the config file
- // if yes, just do nothing
- /*
- if (tmpDlgProps != tmpSavedProps)
- {
- int save;
- if (strcmp(string,"Current") == 0)
- {
- // otherwise, prompt the user if he wants to overwrite the settings
- TCHAR tmpStr[250];
- ::LoadString(AOut::GetInstance(),IDS_STRING_PROMPT_REPLACE_CURRENT,tmpStr,250);
- save = AOut::MyMessageBox( tmpStr, MB_OKCANCEL|MB_ICONQUESTION, parentWnd);
- }
- else
- {
- // otherwise, prompt the user if he wants to overwrite the settings
- TCHAR tmpStr[250];
- ::LoadString(AOut::GetInstance(),IDS_STRING_PROMPT_REPLACE_SETING,tmpStr,250);
- TCHAR tmpDsp[500];
- wsprintf(tmpDsp,tmpStr,string);
- save = AOut::MyMessageBox( tmpDsp, MB_YESNOCANCEL|MB_ICONQUESTION, parentWnd);
- }
- if (save == IDCANCEL)
- bShouldEnd = false;
- else if (save == IDNO)
- {
- // save the values in 'current'
- UpdateValueFromDlg(parentWnd);
- SaveValuesToStringKey("Current");
- SelectSavedParams("Current");
- }
- else
- {
- // do so and save in XML
- UpdateValueFromDlg(parentWnd);
- SaveValuesToStringKey(string);
- }
- }
- */
- //#endif // OLD
- my_debug.OutPut("before : nChannelIndex %d, bCRC %d, bCopyright %d, bOriginal %d, bPrivate %d",nChannelIndex, bCRC, bCopyright, bOriginal, bPrivate);
- my_debug.OutPut("call UpdateValueFromDlg");
- UpdateValueFromDlg(parentWnd);
- my_debug.OutPut("call SaveValuesToStringKey");
- SaveValuesToStringKey("Current"); // only Current config is supported now
- // SaveParams(parentWnd);
- //my_debug.OutPut("call SelectSavedParams");
- // SelectSavedParams(string);
- // UpdateDlgFromValue(parentWnd);
- my_debug.OutPut("finished saving");
- if (bShouldEnd)
- {
- RemoveProp(parentWnd, "AEncodeProperties-Config");
-
- EndDialog(parentWnd, true);
- }
- }
- break;
- case IDCANCEL:
- RemoveProp(parentWnd, "AEncodeProperties-Config");
- EndDialog(parentWnd, false);
- break;
- /* case IDC_FIND_DLL:
- {
- OPENFILENAME file;
- char DllLocation[512];
- wsprintf(DllLocation,"%s",GetDllLocation());
- memset(&file, 0, sizeof(file));
- file.lStructSize = sizeof(file);
- file.hwndOwner = parentWnd;
- file.Flags = OFN_FILEMUSTEXIST | OFN_NODEREFERENCELINKS | OFN_ENABLEHOOK | OFN_EXPLORER ;
- /// file.lpstrFile = AOut::the_AOut->DllLocation;
- file.lpstrFile = DllLocation;
- file.lpstrFilter = "Lame DLL (lame_enc.dll)\0LAME_ENC.DLL\0DLL (*.dll)\0*.DLL\0All (*.*)\0*.*\0";
- file.nFilterIndex = 1;
- file.nMaxFile = sizeof(DllLocation);
- file.lpfnHook = DLLFindCallback; // use to validate the DLL chosen
- GetOpenFileName(&file);
- SetDllLocation(DllLocation);
- // use this filename if necessary
- }
- break;
- */
- /* case IDC_BUTTON_OUTPUT:
- {
- #ifndef SIMPLE_FOLDER
- BROWSEINFO info;
- memset(&info,0,sizeof(info));
- char FolderName[MAX_PATH];
- info.hwndOwner = parentWnd;
- info.pszDisplayName = FolderName;
- info.lpfn = BrowseFolderCallbackroc;
- info.lParam = (LPARAM) this;
- // get the localised window title
- TCHAR output[250];
- ::LoadString(AOut::GetInstance(),IDS_STRING_DIR_SELECT,output,250);
- info.lpszTitle = output;
- #ifdef BIF_EDITBOX
- info.ulFlags |= BIF_EDITBOX;
- #else // BIF_EDITBOX
- info.ulFlags |= 0x0010;
- #endif // BIF_EDITBOX
- #ifdef BIF_VALIDATE
- info.ulFlags |= BIF_VALIDATE;
- #else // BIF_VALIDATE
- info.ulFlags |= 0x0020;
- #endif // BIF_VALIDATE
- #ifdef BIF_NEWDIALOGSTYLE
- info.ulFlags |= BIF_NEWDIALOGSTYLE;
- #else // BIF_NEWDIALOGSTYLE
- info.ulFlags |= 0x0040;
- #endif // BIF_NEWDIALOGSTYLE
- ITEMIDLIST *item = SHBrowseForFolder(&info);
- if (item != NULL)
- {
- char tmpOutputDir[MAX_PATH];
- wsprintf(tmpOutputDir,"%s",GetOutputDirectory());
- SHGetPathFromIDList( item,tmpOutputDir );
- SetOutputDirectory( tmpOutputDir );
- ::SetWindowText(GetDlgItem( parentWnd, IDC_EDIT_OUTPUTDIR), tmpOutputDir);
- // wsprintf(OutputDir,FolderName);
- }
- #else // SIMPLE_FOLDER
- OPENFILENAME file;
- memset(&file, 0, sizeof(file));
- file.lStructSize = sizeof(file);
- file.hwndOwner = parentWnd;
- file.Flags = OFN_FILEMUSTEXIST | OFN_NODEREFERENCELINKS | OFN_ENABLEHOOK | OFN_EXPLORER ;
- // file.lpstrFile = GetDllLocation();
- // file.lpstrFile = GetOutputDirectory();
- file.lpstrInitialDir = GetOutputDirectory();
- file.lpstrFilter = "A Directory\0.*\0";
- // file.nFilterIndex = 1;
- file.nMaxFile = MAX_PATH;
- // file.lpfnHook = DLLFindCallback; // use to validate the DLL chosen
- // file.Flags = OFN_ENABLESIZING | OFN_NOREADONLYRETURN | OFN_HIDEREADONLY;
- file.Flags = OFN_NOREADONLYRETURN | OFN_HIDEREADONLY | OFN_EXPLORER;
- TCHAR output[250];
- ::LoadString(AOut::GetInstance(),IDS_STRING_DIR_SELECT,output,250);
- file.lpstrTitle = output;
- GetSaveFileName(&file);
- #endif // SIMPLE_FOLDER
- }
- break;
- */
- case IDC_CHECK_ENC_ABR:
- EnableAbrOptions(parentWnd, ::IsDlgButtonChecked( parentWnd, IDC_CHECK_ENC_ABR) == BST_CHECKED);
- break;
- /* case IDC_RADIO_BITRATE_CBR:
- AEncodeProperties::DisplayVbrOptions(parentWnd, AEncodeProperties::BR_CBR);
- break;
- case IDC_RADIO_BITRATE_VBR:
- AEncodeProperties::DisplayVbrOptions(parentWnd, AEncodeProperties::BR_VBR);
- break;
- case IDC_RADIO_BITRATE_ABR:
- AEncodeProperties::DisplayVbrOptions(parentWnd, AEncodeProperties::BR_ABR);
- break;
- case IDC_CHECK_RESAMPLE:
- {
- bool tmp_bResampleUsed = (::IsDlgButtonChecked( parentWnd, IDC_CHECK_RESAMPLE) == BST_CHECKED);
- if (tmp_bResampleUsed)
- {
- ::EnableWindow(::GetDlgItem(parentWnd,IDC_COMBO_SAMPLEFREQ), TRUE);
- }
- else
- {
- ::EnableWindow(::GetDlgItem(parentWnd,IDC_COMBO_SAMPLEFREQ), FALSE);
- }
- }
- break;
- */
- /* case IDC_COMBO_SETTINGS:
- // if (CBN_SELCHANGE == GET_WM_COMMAND_CMD(wParam, lParam))
- if (CBN_SELENDOK == GET_WM_COMMAND_CMD(wParam, lParam))
- {
- char string[MAX_PATH];
- int nIdx = SendMessage(HWND(lParam), CB_GETCURSEL, NULL, NULL);
- SendMessage(HWND(lParam), CB_GETLBTEXT , nIdx, (LPARAM) string);
- // get the info corresponding to the new selected item
- SelectSavedParams(string);
- UpdateDlgFromValue(parentWnd);
- }
- break;
- */
- /* case IDC_BUTTON_CONFIG_SAVE:
- {
- // save the data in the current config
- char string[MAX_PATH];
- ::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH);
- UpdateValueFromDlg(parentWnd);
- SaveValuesToStringKey(string);
- SelectSavedParams(string);
- UpdateConfigs(parentWnd);
- UpdateDlgFromValue(parentWnd);
- }
- break;
- case IDC_BUTTON_CONFIG_RENAME:
- {
- char string[MAX_PATH];
- ::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH);
- if (RenameCurrentTo(string))
- {
- // Update the names displayed
- UpdateConfigs(parentWnd);
- }
- }
- break;
- case IDC_BUTTON_CONFIG_DELETE:
- {
- char string[MAX_PATH];
- ::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH);
-
- if (DeleteConfig(string))
- {
- // Update the names displayed
- UpdateConfigs(parentWnd);
- UpdateDlgFromValue(parentWnd);
- }
- }
- break;
- */
- }
-
- return FALSE;
- }
- bool AEncodeProperties::RenameCurrentTo(const std::string & new_config_name)
- {
- bool bResult = false;
- // display all the names of the saved configs
- // get the values from the saved file if possible
- if (my_stored_data.LoadFile(my_store_location))
- {
- TiXmlNode* node;
- node = my_stored_data.FirstChild("lame_acm");
- TiXmlElement* CurrentNode = node->FirstChildElement("encodings");
- if (CurrentNode->Attribute("default") != NULL)
- {
- std::string CurrentConfigName = *CurrentNode->Attribute("default");
- // no rename possible for Current
- if (CurrentConfigName == "")
- {
- bResult = true;
- }
- else if (CurrentConfigName != "Current")
- {
- // find the config that correspond to CurrentConfig
- TiXmlElement* iterateElmt = CurrentNode->FirstChildElement("config");
- // int Idx = 0;
- while (iterateElmt != NULL)
- {
- const std::string * tmpname = iterateElmt->Attribute("name");
- /**
- \todo support language names
- */
- if (tmpname != NULL)
- {
- if (tmpname->compare(CurrentConfigName) == 0)
- {
- iterateElmt->SetAttribute("name",new_config_name);
- bResult = true;
- break;
- }
- }
- // Idx++;
- iterateElmt = iterateElmt->NextSiblingElement("config");
- }
- }
- if (bResult)
- {
- CurrentNode->SetAttribute("default",new_config_name);
- my_stored_data.SaveFile(my_store_location);
- }
- }
- }
- return bResult;
- }
- bool AEncodeProperties::DeleteConfig(const std::string & config_name)
- {
- bool bResult = false;
- if (config_name != "Current")
- {
- // display all the names of the saved configs
- // get the values from the saved file if possible
- if (my_stored_data.LoadFile(my_store_location))
- {
- TiXmlNode* node;
- node = my_stored_data.FirstChild("lame_acm");
- TiXmlElement* CurrentNode = node->FirstChildElement("encodings");
- TiXmlElement* iterateElmt = CurrentNode->FirstChildElement("config");
- // int Idx = 0;
- while (iterateElmt != NULL)
- {
- const std::string * tmpname = iterateElmt->Attribute("name");
- /**
- \todo support language names
- */
- if (tmpname != NULL)
- {
- if (tmpname->compare(config_name) == 0)
- {
- CurrentNode->RemoveChild(iterateElmt);
- bResult = true;
- break;
- }
- }
- // Idx++;
- iterateElmt = iterateElmt->NextSiblingElement("config");
- }
- }
- if (bResult)
- {
- my_stored_data.SaveFile(my_store_location);
- // select a new default config : "Current"
- SelectSavedParams("Current");
- }
- }
- return bResult;
- }
- void AEncodeProperties::UpdateConfigs(const HWND HwndDlg)
- {
- // Add User configs
- // SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_RESETCONTENT , NULL, NULL);
- // display all the names of the saved configs
- // get the values from the saved file if possible
- if (my_stored_data.LoadFile(my_store_location))
- {
- TiXmlNode* node;
- node = my_stored_data.FirstChild("lame_acm");
- TiXmlElement* CurrentNode = node->FirstChildElement("encodings");
- std::string CurrentConfig = "";
- if (CurrentNode->Attribute("default") != NULL)
- {
- CurrentConfig = *CurrentNode->Attribute("default");
- }
- TiXmlElement* iterateElmt;
- my_debug.OutPut("are we here ?");
- // find the config that correspond to CurrentConfig
- iterateElmt = CurrentNode->FirstChildElement("config");
- int Idx = 0;
- while (iterateElmt != NULL)
- {
- const std::string * tmpname = iterateElmt->Attribute("name");
- /**
- \todo support language names
- */
- if (tmpname != NULL)
- {
- // SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_ADDSTRING, NULL, (LPARAM) tmpname->c_str());
- if (tmpname->compare(CurrentConfig) == 0)
- {
- // SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_SETCURSEL, Idx, NULL);
- SelectSavedParams(*tmpname);
- UpdateDlgFromValue(HwndDlg);
- }
- }
- my_debug.OutPut("Idx = %d",Idx);
- Idx++;
- // only Current config supported now
- // iterateElmt = iterateElmt->NextSiblingElement("config");
- iterateElmt = NULL;
- my_debug.OutPut("iterateElmt = 0x%08X",iterateElmt);
- }
- }
- }
- /*
- void AEncodeProperties::UpdateAbrSteps(unsigned int min, unsigned int max, unsigned int step) const
- {
- }
- */
- void AEncodeProperties::UpdateDlgFromSlides(HWND hwndDlg) const
- {
- UINT value_min, value_max, value_step, value;
- char tmp[4];
- value_min = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_GETPOS, NULL, NULL);
- value_max = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_GETPOS, NULL, NULL);
- if (value_min>value_max)
- {
- SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_SETPOS, TRUE, value_max);
- UpdateDlgFromSlides(hwndDlg);
- return;
- }
- if (value_max<value_min)
- {
- SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_SETPOS, TRUE, value_min);
- UpdateDlgFromSlides(hwndDlg);
- return;
- }
- wsprintf(tmp,"%3d",value_min);
- ::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_MIN_VALUE), tmp);
-
- SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETRANGEMIN, TRUE, value_min);
- wsprintf(tmp,"%3d",value_max);
- ::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_MAX_VALUE), tmp);
-
- SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETRANGEMAX, TRUE, value_max);
-
- value_step = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_GETPOS, NULL, NULL);
- wsprintf(tmp,"%3d",value_step);
- ::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_STEP_VALUE), tmp);
- SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_CLEARTICS, TRUE, 0);
- for(UINT i=value_max; i>=value_min;i-=value_step)
- {
- SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETTIC, 0, i);
- }
- SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETLINESIZE, 0, value_step);
- SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETPAGESIZE, 0, value_step);
-
- value = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_GETPOS, NULL, NULL);
- wsprintf(tmp,"%3d",value);
- ::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_SAMPLE_VALUE), tmp);
- }
- void AEncodeProperties::EnableAbrOptions(HWND hDialog, bool enable)
- {
- ::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_MIN), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_MAX), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_STEP), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_SAMPLE), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MIN), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MAX), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_STEP), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_SAMPLE), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MIN_VALUE), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MAX_VALUE), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_STEP_VALUE), enable);
- ::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_SAMPLE_VALUE), enable);
- }
|