1159b3361Sopenharmony_ci/**
2159b3361Sopenharmony_ci *
3159b3361Sopenharmony_ci * Lame ACM wrapper, encode/decode MP3 based RIFF/AVI files in MS Windows
4159b3361Sopenharmony_ci *
5159b3361Sopenharmony_ci *  Copyright (c) 2002 Steve Lhomme <steve.lhomme at free.fr>
6159b3361Sopenharmony_ci *
7159b3361Sopenharmony_ci * This library is free software; you can redistribute it and/or
8159b3361Sopenharmony_ci * modify it under the terms of the GNU Lesser General Public
9159b3361Sopenharmony_ci * License as published by the Free Software Foundation; either
10159b3361Sopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
11159b3361Sopenharmony_ci *
12159b3361Sopenharmony_ci * This library is distributed in the hope that it will be useful,
13159b3361Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
14159b3361Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15159b3361Sopenharmony_ci * Lesser General Public License for more details.
16159b3361Sopenharmony_ci *
17159b3361Sopenharmony_ci * You should have received a copy of the GNU Lesser General Public
18159b3361Sopenharmony_ci * License along with this library; if not, write to the Free Software
19159b3361Sopenharmony_ci * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20159b3361Sopenharmony_ci *
21159b3361Sopenharmony_ci */
22159b3361Sopenharmony_ci
23159b3361Sopenharmony_ci/*!
24159b3361Sopenharmony_ci	\author Steve Lhomme
25159b3361Sopenharmony_ci	\version \$Id$
26159b3361Sopenharmony_ci*/
27159b3361Sopenharmony_ci
28159b3361Sopenharmony_ci#if !defined(STRICT)
29159b3361Sopenharmony_ci#define STRICT
30159b3361Sopenharmony_ci#endif // !defined(STRICT)
31159b3361Sopenharmony_ci
32159b3361Sopenharmony_ci#include <windows.h>
33159b3361Sopenharmony_ci#include <windowsx.h>
34159b3361Sopenharmony_ci#include <shlobj.h>
35159b3361Sopenharmony_ci#include <assert.h>
36159b3361Sopenharmony_ci
37159b3361Sopenharmony_ci#ifdef _MSC_VER
38159b3361Sopenharmony_ci// no problem with unknown pragmas
39159b3361Sopenharmony_ci#pragma warning(disable: 4068)
40159b3361Sopenharmony_ci#endif
41159b3361Sopenharmony_ci
42159b3361Sopenharmony_ci#include "resource.h"
43159b3361Sopenharmony_ci#include <lame.h>
44159b3361Sopenharmony_ci#include "adebug.h"
45159b3361Sopenharmony_ci#include "AEncodeProperties.h"
46159b3361Sopenharmony_ci#include "ACM.h"
47159b3361Sopenharmony_ci//#include "AParameters/AParameters.h"
48159b3361Sopenharmony_ci
49159b3361Sopenharmony_ci#ifndef TTS_BALLOON
50159b3361Sopenharmony_ci#define TTS_BALLOON            0x40
51159b3361Sopenharmony_ci#endif // TTS_BALLOON
52159b3361Sopenharmony_ci
53159b3361Sopenharmony_ciconst unsigned int AEncodeProperties::the_Bitrates[18] = {320, 256, 224, 192, 160, 144, 128, 112, 96, 80, 64, 56, 48, 40, 32, 24, 16, 8 };
54159b3361Sopenharmony_ciconst unsigned int AEncodeProperties::the_MPEG1_Bitrates[14] = {320, 256, 224, 192, 160, 128, 112, 96, 80, 64, 56, 48, 40, 32 };
55159b3361Sopenharmony_ciconst unsigned int AEncodeProperties::the_MPEG2_Bitrates[14] = {160, 144, 128, 112, 96, 80, 64, 56, 48, 40, 32, 24, 16, 8};
56159b3361Sopenharmony_ciconst unsigned int AEncodeProperties::the_ChannelModes[3] = { STEREO, JOINT_STEREO, DUAL_CHANNEL };
57159b3361Sopenharmony_ci//const char         AEncodeProperties::the_Presets[][13] = {"None", "CD", "Studio", "Hi-Fi", "Phone", "Voice", "Radio", "Tape", "FM", "AM", "SW"};
58159b3361Sopenharmony_ci//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};
59159b3361Sopenharmony_ci//const unsigned int AEncodeProperties::the_SamplingFreqs[9] = { 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000 };
60159b3361Sopenharmony_ci
61159b3361Sopenharmony_ciToolTipItem AEncodeProperties::Tooltips[13]={
62159b3361Sopenharmony_ci	{ 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." },
63159b3361Sopenharmony_ci	{ IDC_CHECK_COPYRIGHT, "Mark the encoded data as copyrighted." },
64159b3361Sopenharmony_ci	{ IDC_CHECK_CHECKSUM, "Put a checksum in the encoded data.\r\n\r\nThis can make the file less sensitive to data loss." },
65159b3361Sopenharmony_ci	{ IDC_CHECK_ORIGINAL, "Mark the encoded data as an original file." },
66159b3361Sopenharmony_ci	{ IDC_CHECK_PRIVATE, "Mark the encoded data as private." },
67159b3361Sopenharmony_ci	{ 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" },
68159b3361Sopenharmony_ci	{ IDC_STATIC_DECODING, "Decoding not supported for the moment by the codec." },
69159b3361Sopenharmony_ci	{ IDC_CHECK_ENC_SMART, "Disable bitrate when there is too much compression.\r\n(default 1:15 ratio)" },
70159b3361Sopenharmony_ci	{ 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." },
71159b3361Sopenharmony_ci	{ IDC_SLIDER_AVERAGE_MIN, "Select the minimum Average Bitrate allowed." },
72159b3361Sopenharmony_ci	{ IDC_SLIDER_AVERAGE_MAX, "Select the maximum Average Bitrate allowed." },
73159b3361Sopenharmony_ci	{ 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" },
74159b3361Sopenharmony_ci	{ IDC_SLIDER_AVERAGE_SAMPLE, "Check the resulting values of the (min,max,step) combination.\r\n\r\nUse the keyboard to navigate (right -> left)." },
75159b3361Sopenharmony_ci};
76159b3361Sopenharmony_ci//int AEncodeProperties::tst = 0;
77159b3361Sopenharmony_ci
78159b3361Sopenharmony_ci/*
79159b3361Sopenharmony_ci#pragma argsused
80159b3361Sopenharmony_cistatic UINT CALLBACK DLLFindCallback(
81159b3361Sopenharmony_ci  HWND hdlg,      // handle to child dialog box
82159b3361Sopenharmony_ci  UINT uiMsg,     // message identifier
83159b3361Sopenharmony_ci  WPARAM wParam,  // message parameter
84159b3361Sopenharmony_ci  LPARAM lParam   // message parameter
85159b3361Sopenharmony_ci  )
86159b3361Sopenharmony_ci{
87159b3361Sopenharmony_ci	UINT result = 0;
88159b3361Sopenharmony_ci
89159b3361Sopenharmony_ci	switch (uiMsg)
90159b3361Sopenharmony_ci	{
91159b3361Sopenharmony_ci		case WM_NOTIFY:
92159b3361Sopenharmony_ci			OFNOTIFY * info = (OFNOTIFY *)lParam;
93159b3361Sopenharmony_ci			if (info->hdr.code == CDN_FILEOK)
94159b3361Sopenharmony_ci			{
95159b3361Sopenharmony_ci				result = 1; // by default we don't accept the file
96159b3361Sopenharmony_ci
97159b3361Sopenharmony_ci				// Check if the selected file is a valid DLL with all the required functions
98159b3361Sopenharmony_ci				ALameDLL * tstFile = new ALameDLL;
99159b3361Sopenharmony_ci				if (tstFile != NULL)
100159b3361Sopenharmony_ci				{
101159b3361Sopenharmony_ci					if (tstFile->Load(info->lpOFN->lpstrFile))
102159b3361Sopenharmony_ci					{
103159b3361Sopenharmony_ci						result = 0;
104159b3361Sopenharmony_ci					}
105159b3361Sopenharmony_ci
106159b3361Sopenharmony_ci					delete tstFile;
107159b3361Sopenharmony_ci				}
108159b3361Sopenharmony_ci
109159b3361Sopenharmony_ci				if (result == 1)
110159b3361Sopenharmony_ci				{
111159b3361Sopenharmony_ci					TCHAR output[250];
112159b3361Sopenharmony_ci					::LoadString(AOut::GetInstance(),IDS_STRING_DLL_UNRECOGNIZED,output,250);
113159b3361Sopenharmony_ci					AOut::MyMessageBox( output, MB_OK|MB_ICONEXCLAMATION, hdlg);
114159b3361Sopenharmony_ci					SetWindowLong(hdlg, DWL_MSGRESULT , -100);
115159b3361Sopenharmony_ci				}
116159b3361Sopenharmony_ci			}
117159b3361Sopenharmony_ci	}
118159b3361Sopenharmony_ci
119159b3361Sopenharmony_ci	return result;
120159b3361Sopenharmony_ci}
121159b3361Sopenharmony_ci
122159b3361Sopenharmony_ci#pragma argsused
123159b3361Sopenharmony_cistatic int CALLBACK BrowseFolderCallbackroc(
124159b3361Sopenharmony_ci    HWND hwnd,
125159b3361Sopenharmony_ci    UINT uMsg,
126159b3361Sopenharmony_ci    LPARAM lParam,
127159b3361Sopenharmony_ci    LPARAM lpData
128159b3361Sopenharmony_ci    )
129159b3361Sopenharmony_ci{
130159b3361Sopenharmony_ci	AEncodeProperties * the_prop;
131159b3361Sopenharmony_ci	the_prop = (AEncodeProperties *) lpData;
132159b3361Sopenharmony_ci
133159b3361Sopenharmony_ci
134159b3361Sopenharmony_ci	if (uMsg == BFFM_INITIALIZED)
135159b3361Sopenharmony_ci	{
136159b3361Sopenharmony_ci//		char FolderName[MAX_PATH];
137159b3361Sopenharmony_ci//		SHGetPathFromIDList((LPITEMIDLIST) lParam,FolderName);
138159b3361Sopenharmony_ci//ADbg tst;
139159b3361Sopenharmony_ci//tst.OutPut("init folder to %s ",the_prop->GetOutputDirectory());
140159b3361Sopenharmony_ci//		CreateFile();
141159b3361Sopenharmony_ci		::SendMessage(hwnd, BFFM_SETSELECTION, (WPARAM)TRUE, (LPARAM)the_prop->GetOutputDirectory());
142159b3361Sopenharmony_ci	}/* else if (uMsg == BFFM_SELCHANGED)
143159b3361Sopenharmony_ci	{
144159b3361Sopenharmony_ci		// verify that the folder is writable
145159b3361Sopenharmony_ci//		::SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)0); // disable
146159b3361Sopenharmony_ci		char FolderName[MAX_PATH];
147159b3361Sopenharmony_ci		SHGetPathFromIDList((LPITEMIDLIST) lParam, FolderName);
148159b3361Sopenharmony_ci
149159b3361Sopenharmony_ci//		if (CreateFile(FolderName,STANDARD_RIGHTS_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL) == INVALID_HANDLE_VALUE)
150159b3361Sopenharmony_ci		if ((GetFileAttributes(FolderName) & FILE_ATTRIBUTE_DIRECTORY) != 0)
151159b3361Sopenharmony_ci			::SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)1); // enable
152159b3361Sopenharmony_ci		else
153159b3361Sopenharmony_ci			::SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)0); // disable
154159b3361Sopenharmony_ci//ADbg tst;
155159b3361Sopenharmony_ci//tst.OutPut("change folder to %s ",FolderName);
156159b3361Sopenharmony_ci	}* /
157159b3361Sopenharmony_ci
158159b3361Sopenharmony_ci	return 0;
159159b3361Sopenharmony_ci}
160159b3361Sopenharmony_ci*/
161159b3361Sopenharmony_ci#pragma argsused
162159b3361Sopenharmony_cistatic BOOL CALLBACK ConfigProc(
163159b3361Sopenharmony_ci  HWND hwndDlg,  // handle to dialog box
164159b3361Sopenharmony_ci  UINT uMsg,     // message
165159b3361Sopenharmony_ci  WPARAM wParam, // first message parameter
166159b3361Sopenharmony_ci  LPARAM lParam  // second message parameter
167159b3361Sopenharmony_ci  )
168159b3361Sopenharmony_ci{
169159b3361Sopenharmony_ci	BOOL bResult = FALSE;
170159b3361Sopenharmony_ci	AEncodeProperties * the_prop;
171159b3361Sopenharmony_ci	the_prop = (AEncodeProperties *) GetProp(hwndDlg, "AEncodeProperties-Config");
172159b3361Sopenharmony_ci
173159b3361Sopenharmony_ci	switch (uMsg) {
174159b3361Sopenharmony_ci		case WM_COMMAND:
175159b3361Sopenharmony_ci			if (the_prop != NULL)
176159b3361Sopenharmony_ci			{
177159b3361Sopenharmony_ci				bResult = the_prop->HandleDialogCommand( hwndDlg, wParam, lParam);
178159b3361Sopenharmony_ci			}
179159b3361Sopenharmony_ci			break;
180159b3361Sopenharmony_ci		case WM_INITDIALOG:
181159b3361Sopenharmony_ci			assert(the_prop == NULL);
182159b3361Sopenharmony_ci
183159b3361Sopenharmony_ci			the_prop = (AEncodeProperties *) lParam;
184159b3361Sopenharmony_ci			the_prop->my_debug.OutPut("there hwnd = 0x%08X",hwndDlg);
185159b3361Sopenharmony_ci
186159b3361Sopenharmony_ci			assert(the_prop != NULL);
187159b3361Sopenharmony_ci
188159b3361Sopenharmony_ci			SetProp(hwndDlg, "AEncodeProperties-Config", the_prop);
189159b3361Sopenharmony_ci
190159b3361Sopenharmony_ci			the_prop->InitConfigDlg(hwndDlg);
191159b3361Sopenharmony_ci
192159b3361Sopenharmony_ci			bResult = TRUE;
193159b3361Sopenharmony_ci			break;
194159b3361Sopenharmony_ci
195159b3361Sopenharmony_ci		case WM_HSCROLL:
196159b3361Sopenharmony_ci			// check if it's the ABR sliders
197159b3361Sopenharmony_ci			if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_MIN))
198159b3361Sopenharmony_ci			{
199159b3361Sopenharmony_ci				the_prop->UpdateDlgFromSlides(hwndDlg);
200159b3361Sopenharmony_ci			}
201159b3361Sopenharmony_ci			else if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_MAX))
202159b3361Sopenharmony_ci			{
203159b3361Sopenharmony_ci				the_prop->UpdateDlgFromSlides(hwndDlg);
204159b3361Sopenharmony_ci			}
205159b3361Sopenharmony_ci			else if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_STEP))
206159b3361Sopenharmony_ci			{
207159b3361Sopenharmony_ci				the_prop->UpdateDlgFromSlides(hwndDlg);
208159b3361Sopenharmony_ci			}
209159b3361Sopenharmony_ci			else if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_SAMPLE))
210159b3361Sopenharmony_ci			{
211159b3361Sopenharmony_ci				the_prop->UpdateDlgFromSlides(hwndDlg);
212159b3361Sopenharmony_ci			}
213159b3361Sopenharmony_ci			break;
214159b3361Sopenharmony_ci
215159b3361Sopenharmony_ci		case WM_NOTIFY:
216159b3361Sopenharmony_ci			if (TTN_GETDISPINFO == ((LPNMHDR)lParam)->code) {
217159b3361Sopenharmony_ci				NMTTDISPINFO *lphdr = (NMTTDISPINFO *)lParam;
218159b3361Sopenharmony_ci				UINT id = (lphdr->uFlags & TTF_IDISHWND) ? GetWindowLong((HWND)lphdr->hdr.idFrom, GWL_ID) : lphdr->hdr.idFrom;
219159b3361Sopenharmony_ci
220159b3361Sopenharmony_ci				*lphdr->lpszText = 0;
221159b3361Sopenharmony_ci
222159b3361Sopenharmony_ci				SendMessage(lphdr->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 5000);
223159b3361Sopenharmony_ci
224159b3361Sopenharmony_ci				for(int i=0; i<sizeof AEncodeProperties::Tooltips/sizeof AEncodeProperties::Tooltips[0]; ++i) {
225159b3361Sopenharmony_ci					if (id == AEncodeProperties::Tooltips[i].id)
226159b3361Sopenharmony_ci						lphdr->lpszText = const_cast<char *>(AEncodeProperties::Tooltips[i].tip);
227159b3361Sopenharmony_ci				}
228159b3361Sopenharmony_ci
229159b3361Sopenharmony_ci				return TRUE;
230159b3361Sopenharmony_ci			}
231159b3361Sopenharmony_ci			break;
232159b3361Sopenharmony_ci
233159b3361Sopenharmony_ci		default:
234159b3361Sopenharmony_ci			bResult = FALSE; // will be treated by DefWindowProc
235159b3361Sopenharmony_ci	}
236159b3361Sopenharmony_ci	return bResult;
237159b3361Sopenharmony_ci}
238159b3361Sopenharmony_ci
239159b3361Sopenharmony_ci//////////////////////////////////////////////////////////////////////
240159b3361Sopenharmony_ci// Construction/Destruction
241159b3361Sopenharmony_ci//////////////////////////////////////////////////////////////////////
242159b3361Sopenharmony_ci/**
243159b3361Sopenharmony_ci	\class AEncodeProperties
244159b3361Sopenharmony_ci*/
245159b3361Sopenharmony_ci
246159b3361Sopenharmony_ci
247159b3361Sopenharmony_ciconst char * AEncodeProperties::GetChannelModeString(int a_channelID) const
248159b3361Sopenharmony_ci{
249159b3361Sopenharmony_ci	assert(a_channelID < sizeof(the_ChannelModes));
250159b3361Sopenharmony_ci
251159b3361Sopenharmony_ci	switch (a_channelID) {
252159b3361Sopenharmony_ci		case 0:
253159b3361Sopenharmony_ci			return "Stereo";
254159b3361Sopenharmony_ci		case 1:
255159b3361Sopenharmony_ci			return "Joint-stereo";
256159b3361Sopenharmony_ci		case 2:
257159b3361Sopenharmony_ci			return "Dual Channel";
258159b3361Sopenharmony_ci		default:
259159b3361Sopenharmony_ci			assert(a_channelID);
260159b3361Sopenharmony_ci			return NULL;
261159b3361Sopenharmony_ci	}
262159b3361Sopenharmony_ci}
263159b3361Sopenharmony_ci
264159b3361Sopenharmony_ciconst int AEncodeProperties::GetBitrateString(char * string, int string_size, int a_bitrateID) const
265159b3361Sopenharmony_ci{
266159b3361Sopenharmony_ci	assert(a_bitrateID < sizeof(the_Bitrates));
267159b3361Sopenharmony_ci	assert(string != NULL);
268159b3361Sopenharmony_ci
269159b3361Sopenharmony_ci	if (string_size >= 4)
270159b3361Sopenharmony_ci		return wsprintf(string,"%d",the_Bitrates[a_bitrateID]);
271159b3361Sopenharmony_ci	else
272159b3361Sopenharmony_ci		return -1;
273159b3361Sopenharmony_ci}
274159b3361Sopenharmony_ci
275159b3361Sopenharmony_ciconst unsigned int AEncodeProperties::GetChannelModeValue() const
276159b3361Sopenharmony_ci{
277159b3361Sopenharmony_ci	assert(nChannelIndex < sizeof(the_ChannelModes));
278159b3361Sopenharmony_ci
279159b3361Sopenharmony_ci	return the_ChannelModes[nChannelIndex];
280159b3361Sopenharmony_ci}
281159b3361Sopenharmony_ci
282159b3361Sopenharmony_ciconst unsigned int AEncodeProperties::GetBitrateValue() const
283159b3361Sopenharmony_ci{
284159b3361Sopenharmony_ci	assert(nMinBitrateIndex < sizeof(the_Bitrates));
285159b3361Sopenharmony_ci
286159b3361Sopenharmony_ci	return the_Bitrates[nMinBitrateIndex];
287159b3361Sopenharmony_ci}
288159b3361Sopenharmony_ci
289159b3361Sopenharmony_ciinline const int AEncodeProperties::GetBitrateValueMPEG2(DWORD & bitrate) const
290159b3361Sopenharmony_ci{
291159b3361Sopenharmony_ci	int i;
292159b3361Sopenharmony_ci
293159b3361Sopenharmony_ci	for (i=0;i<sizeof(the_MPEG2_Bitrates)/sizeof(unsigned int);i++)
294159b3361Sopenharmony_ci	{
295159b3361Sopenharmony_ci		if (the_MPEG2_Bitrates[i] == the_Bitrates[nMinBitrateIndex])
296159b3361Sopenharmony_ci		{
297159b3361Sopenharmony_ci			bitrate = the_MPEG2_Bitrates[i];
298159b3361Sopenharmony_ci			return 0;
299159b3361Sopenharmony_ci		}
300159b3361Sopenharmony_ci		else if (the_MPEG2_Bitrates[i] < the_Bitrates[nMinBitrateIndex])
301159b3361Sopenharmony_ci		{
302159b3361Sopenharmony_ci			bitrate = the_MPEG2_Bitrates[i];
303159b3361Sopenharmony_ci			return -1;
304159b3361Sopenharmony_ci		}
305159b3361Sopenharmony_ci	}
306159b3361Sopenharmony_ci
307159b3361Sopenharmony_ci	bitrate = 160;
308159b3361Sopenharmony_ci	return -1;
309159b3361Sopenharmony_ci}
310159b3361Sopenharmony_ci
311159b3361Sopenharmony_ciinline const int AEncodeProperties::GetBitrateValueMPEG1(DWORD & bitrate) const
312159b3361Sopenharmony_ci{
313159b3361Sopenharmony_ci	int i;
314159b3361Sopenharmony_ci
315159b3361Sopenharmony_ci	for (i=sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1;i>=0;i--)
316159b3361Sopenharmony_ci	{
317159b3361Sopenharmony_ci		if (the_MPEG1_Bitrates[i] == the_Bitrates[nMinBitrateIndex])
318159b3361Sopenharmony_ci		{
319159b3361Sopenharmony_ci			bitrate = the_MPEG1_Bitrates[i];
320159b3361Sopenharmony_ci			return 0;
321159b3361Sopenharmony_ci		}
322159b3361Sopenharmony_ci		else if (the_MPEG1_Bitrates[i] > the_Bitrates[nMinBitrateIndex])
323159b3361Sopenharmony_ci		{
324159b3361Sopenharmony_ci			bitrate = the_MPEG1_Bitrates[i];
325159b3361Sopenharmony_ci			return 1;
326159b3361Sopenharmony_ci		}
327159b3361Sopenharmony_ci	}
328159b3361Sopenharmony_ci
329159b3361Sopenharmony_ci	bitrate = 32;
330159b3361Sopenharmony_ci	return 1;
331159b3361Sopenharmony_ci}
332159b3361Sopenharmony_ci/*
333159b3361Sopenharmony_ciconst int AEncodeProperties::GetBitrateValue(DWORD & bitrate, const DWORD MPEG_Version) const
334159b3361Sopenharmony_ci{
335159b3361Sopenharmony_ci	assert((MPEG_Version == MPEG1) || (MPEG_Version == MPEG2));
336159b3361Sopenharmony_ci	assert(nMinBitrateIndex < sizeof(the_Bitrates));
337159b3361Sopenharmony_ci
338159b3361Sopenharmony_ci	if (MPEG_Version == MPEG2)
339159b3361Sopenharmony_ci		return GetBitrateValueMPEG2(bitrate);
340159b3361Sopenharmony_ci	else
341159b3361Sopenharmony_ci		return GetBitrateValueMPEG1(bitrate);
342159b3361Sopenharmony_ci}
343159b3361Sopenharmony_ci/*
344159b3361Sopenharmony_ciconst char * AEncodeProperties::GetPresetModeString(const int a_presetID) const
345159b3361Sopenharmony_ci{
346159b3361Sopenharmony_ci	assert(a_presetID < sizeof(the_Presets));
347159b3361Sopenharmony_ci
348159b3361Sopenharmony_ci	switch (a_presetID) {
349159b3361Sopenharmony_ci		case 1:
350159b3361Sopenharmony_ci			return "r3mix";
351159b3361Sopenharmony_ci		case 2:
352159b3361Sopenharmony_ci			return "Normal";
353159b3361Sopenharmony_ci		case 3:
354159b3361Sopenharmony_ci			return "Low";
355159b3361Sopenharmony_ci		case 4:
356159b3361Sopenharmony_ci			return "High";
357159b3361Sopenharmony_ci		case 5:
358159b3361Sopenharmony_ci			return "Very High";
359159b3361Sopenharmony_ci		case 6:
360159b3361Sopenharmony_ci			return "Voice";
361159b3361Sopenharmony_ci		case 7:
362159b3361Sopenharmony_ci			return "Phone";
363159b3361Sopenharmony_ci		case 8:
364159b3361Sopenharmony_ci			return "SW";
365159b3361Sopenharmony_ci		case 9:
366159b3361Sopenharmony_ci			return "AM";
367159b3361Sopenharmony_ci		case 10:
368159b3361Sopenharmony_ci			return "FM";
369159b3361Sopenharmony_ci		case 11:
370159b3361Sopenharmony_ci			return "Voice";
371159b3361Sopenharmony_ci		case 12:
372159b3361Sopenharmony_ci			return "Radio";
373159b3361Sopenharmony_ci		case 13:
374159b3361Sopenharmony_ci			return "Tape";
375159b3361Sopenharmony_ci		case 14:
376159b3361Sopenharmony_ci			return "Hi-Fi";
377159b3361Sopenharmony_ci		case 15:
378159b3361Sopenharmony_ci			return "CD";
379159b3361Sopenharmony_ci		case 16:
380159b3361Sopenharmony_ci			return "Studio";
381159b3361Sopenharmony_ci		default:
382159b3361Sopenharmony_ci			return "None";
383159b3361Sopenharmony_ci	}
384159b3361Sopenharmony_ci}
385159b3361Sopenharmony_ci
386159b3361Sopenharmony_ciconst LAME_QUALTIY_PRESET AEncodeProperties::GetPresetModeValue() const
387159b3361Sopenharmony_ci{
388159b3361Sopenharmony_ci	assert(nPresetIndex < sizeof(the_Presets));
389159b3361Sopenharmony_ci
390159b3361Sopenharmony_ci	return the_Presets[nPresetIndex];
391159b3361Sopenharmony_ci}
392159b3361Sopenharmony_ci*/
393159b3361Sopenharmony_cibool AEncodeProperties::Config(const HINSTANCE Hinstance, const HWND HwndParent)
394159b3361Sopenharmony_ci{
395159b3361Sopenharmony_ci	//WM_INITDIALOG ?
396159b3361Sopenharmony_ci
397159b3361Sopenharmony_ci	// remember the instance to retreive strings
398159b3361Sopenharmony_ci//	hDllInstance = Hinstance;
399159b3361Sopenharmony_ci
400159b3361Sopenharmony_ci	my_debug.OutPut("here");
401159b3361Sopenharmony_ci	int ret = ::DialogBoxParam(Hinstance, MAKEINTRESOURCE(IDD_CONFIG), HwndParent, ::ConfigProc, (LPARAM) this);
402159b3361Sopenharmony_ci/*	if (ret == -1)
403159b3361Sopenharmony_ci	{
404159b3361Sopenharmony_ci		LPVOID lpMsgBuf;
405159b3361Sopenharmony_ci		FormatMessage(
406159b3361Sopenharmony_ci			FORMAT_MESSAGE_ALLOCATE_BUFFER |
407159b3361Sopenharmony_ci			FORMAT_MESSAGE_FROM_SYSTEM |
408159b3361Sopenharmony_ci			FORMAT_MESSAGE_IGNORE_INSERTS,
409159b3361Sopenharmony_ci			NULL,
410159b3361Sopenharmony_ci			GetLastError(),
411159b3361Sopenharmony_ci			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
412159b3361Sopenharmony_ci			(LPTSTR) &lpMsgBuf,
413159b3361Sopenharmony_ci			0,
414159b3361Sopenharmony_ci			NULL
415159b3361Sopenharmony_ci		);
416159b3361Sopenharmony_ci		// Process any inserts in lpMsgBuf.
417159b3361Sopenharmony_ci		// ...
418159b3361Sopenharmony_ci		// Display the string.
419159b3361Sopenharmony_ci		AOut::MyMessageBox( (LPCTSTR)lpMsgBuf, MB_OK | MB_ICONINFORMATION );
420159b3361Sopenharmony_ci		// Free the buffer.
421159b3361Sopenharmony_ci		LocalFree( lpMsgBuf );
422159b3361Sopenharmony_ci		return false;
423159b3361Sopenharmony_ci	}
424159b3361Sopenharmony_ci*/
425159b3361Sopenharmony_ci	return true;
426159b3361Sopenharmony_ci}
427159b3361Sopenharmony_ci
428159b3361Sopenharmony_cibool AEncodeProperties::InitConfigDlg(HWND HwndDlg)
429159b3361Sopenharmony_ci{
430159b3361Sopenharmony_ci	// get all the required strings
431159b3361Sopenharmony_ci//	TCHAR Version[5];
432159b3361Sopenharmony_ci//	LoadString(hDllInstance, IDS_STRING_VERSION, Version, 5);
433159b3361Sopenharmony_ci
434159b3361Sopenharmony_ci	int i;
435159b3361Sopenharmony_ci
436159b3361Sopenharmony_ci	// Add required channel modes
437159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO), CB_RESETCONTENT , NULL, NULL);
438159b3361Sopenharmony_ci	for (i=0;i<GetChannelLentgh();i++)
439159b3361Sopenharmony_ci		SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO), CB_ADDSTRING, NULL, (LPARAM) GetChannelModeString(i));
440159b3361Sopenharmony_ci
441159b3361Sopenharmony_ci	char tmp[20];
442159b3361Sopenharmony_ci	wsprintf(tmp, "v%s",ACM::GetVersionString());
443159b3361Sopenharmony_ci	SetWindowText( GetDlgItem( HwndDlg, IDC_STATIC_CONFIG_VERSION), tmp);
444159b3361Sopenharmony_ci
445159b3361Sopenharmony_ci	// Add all possible re-sampling freq
446159b3361Sopenharmony_ci/*	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_RESETCONTENT , NULL, NULL);
447159b3361Sopenharmony_ci	char tmp[10];
448159b3361Sopenharmony_ci	for (i=0;i<sizeof(the_SamplingFreqs)/sizeof(unsigned int);i++)
449159b3361Sopenharmony_ci	{
450159b3361Sopenharmony_ci		wsprintf(tmp, "%d", the_SamplingFreqs[i]);
451159b3361Sopenharmony_ci		SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_ADDSTRING, NULL, (LPARAM) tmp );
452159b3361Sopenharmony_ci	}
453159b3361Sopenharmony_ci*/
454159b3361Sopenharmony_ci
455159b3361Sopenharmony_ci	// Add required bitrates
456159b3361Sopenharmony_ci/*	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE), CB_RESETCONTENT , NULL, NULL);
457159b3361Sopenharmony_ci	for (i=0;i<GetBitrateLentgh();i++)
458159b3361Sopenharmony_ci	{
459159b3361Sopenharmony_ci		GetBitrateString(tmp, 5, i);
460159b3361Sopenharmony_ci		SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE), CB_ADDSTRING, NULL, (LPARAM) tmp );
461159b3361Sopenharmony_ci	}
462159b3361Sopenharmony_ci
463159b3361Sopenharmony_ci	// Add bitrates to the VBR combo box too
464159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_RESETCONTENT , NULL, NULL);
465159b3361Sopenharmony_ci	for (i=0;i<GetBitrateLentgh();i++)
466159b3361Sopenharmony_ci	{
467159b3361Sopenharmony_ci		GetBitrateString(tmp, 5, i);
468159b3361Sopenharmony_ci		SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_ADDSTRING, NULL, (LPARAM) tmp );
469159b3361Sopenharmony_ci	}
470159b3361Sopenharmony_ci
471159b3361Sopenharmony_ci	// Add VBR Quality Slider
472159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_SETRANGE, TRUE, MAKELONG(0,9));
473159b3361Sopenharmony_ci
474159b3361Sopenharmony_ci	// Add presets
475159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET), CB_RESETCONTENT , NULL, NULL);
476159b3361Sopenharmony_ci	for (i=0;i<GetPresetLentgh();i++)
477159b3361Sopenharmony_ci		SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET), CB_ADDSTRING, NULL, (LPARAM) GetPresetModeString(i));
478159b3361Sopenharmony_ci*/
479159b3361Sopenharmony_ci
480159b3361Sopenharmony_ci	// Add ABR Sliders
481159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_SETRANGE, TRUE, MAKELONG(8,320));
482159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_SETRANGE, TRUE, MAKELONG(8,320));
483159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_SETRANGE, TRUE, MAKELONG(1,16));
484159b3361Sopenharmony_ci
485159b3361Sopenharmony_ci	// Tool-Tip initialiasiation
486159b3361Sopenharmony_ci	TOOLINFO ti;
487159b3361Sopenharmony_ci	HWND ToolTipWnd;
488159b3361Sopenharmony_ci	char DisplayStr[30] = "test tooltip";
489159b3361Sopenharmony_ci
490159b3361Sopenharmony_ci	ToolTipWnd = CreateWindowEx(WS_EX_TOPMOST,
491159b3361Sopenharmony_ci        TOOLTIPS_CLASS,
492159b3361Sopenharmony_ci        NULL,
493159b3361Sopenharmony_ci        WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP|TTS_BALLOON ,
494159b3361Sopenharmony_ci        CW_USEDEFAULT,
495159b3361Sopenharmony_ci        CW_USEDEFAULT,
496159b3361Sopenharmony_ci        CW_USEDEFAULT,
497159b3361Sopenharmony_ci        CW_USEDEFAULT,
498159b3361Sopenharmony_ci        HwndDlg,
499159b3361Sopenharmony_ci        NULL,
500159b3361Sopenharmony_ci        NULL,
501159b3361Sopenharmony_ci        NULL
502159b3361Sopenharmony_ci        );
503159b3361Sopenharmony_ci
504159b3361Sopenharmony_ci	SetWindowPos(ToolTipWnd,
505159b3361Sopenharmony_ci        HWND_TOPMOST,
506159b3361Sopenharmony_ci        0,
507159b3361Sopenharmony_ci        0,
508159b3361Sopenharmony_ci        0,
509159b3361Sopenharmony_ci        0,
510159b3361Sopenharmony_ci        SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
511159b3361Sopenharmony_ci
512159b3361Sopenharmony_ci    /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
513159b3361Sopenharmony_ci	ti.cbSize		= sizeof(TOOLINFO);
514159b3361Sopenharmony_ci	ti.uFlags		= TTF_SUBCLASS | TTF_IDISHWND;
515159b3361Sopenharmony_ci	ti.hwnd			= HwndDlg;
516159b3361Sopenharmony_ci	ti.lpszText		= LPSTR_TEXTCALLBACK;
517159b3361Sopenharmony_ci
518159b3361Sopenharmony_ci    /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */
519159b3361Sopenharmony_ci	for(i=0; i<sizeof Tooltips/sizeof Tooltips[0]; ++i) {
520159b3361Sopenharmony_ci		ti.uId			= (WPARAM)GetDlgItem(HwndDlg, Tooltips[i].id);
521159b3361Sopenharmony_ci
522159b3361Sopenharmony_ci		if (ti.uId)
523159b3361Sopenharmony_ci			SendMessage(ToolTipWnd, TTM_ADDTOOL, 0, (LPARAM)&ti);
524159b3361Sopenharmony_ci	}
525159b3361Sopenharmony_ci
526159b3361Sopenharmony_cimy_debug.OutPut("call UpdateConfigs");
527159b3361Sopenharmony_ci
528159b3361Sopenharmony_ci	UpdateConfigs(HwndDlg);
529159b3361Sopenharmony_ci
530159b3361Sopenharmony_cimy_debug.OutPut("call UpdateDlgFromValue");
531159b3361Sopenharmony_ci
532159b3361Sopenharmony_ci	UpdateDlgFromValue(HwndDlg);
533159b3361Sopenharmony_ci
534159b3361Sopenharmony_ci
535159b3361Sopenharmony_ci	my_debug.OutPut("finished InitConfigDlg");
536159b3361Sopenharmony_ci
537159b3361Sopenharmony_ci
538159b3361Sopenharmony_ci	return true;
539159b3361Sopenharmony_ci}
540159b3361Sopenharmony_ci
541159b3361Sopenharmony_cibool AEncodeProperties::UpdateDlgFromValue(HWND HwndDlg)
542159b3361Sopenharmony_ci{
543159b3361Sopenharmony_ci	// get all the required strings
544159b3361Sopenharmony_ci//	TCHAR Version[5];
545159b3361Sopenharmony_ci//	LoadString(hDllInstance, IDS_STRING_VERSION, Version, 5);
546159b3361Sopenharmony_ci
547159b3361Sopenharmony_ci	int i;
548159b3361Sopenharmony_ci
549159b3361Sopenharmony_ci	// Check boxes if required
550159b3361Sopenharmony_ci	::CheckDlgButton( HwndDlg, IDC_CHECK_CHECKSUM,     GetCRCMode()        ?BST_CHECKED:BST_UNCHECKED );
551159b3361Sopenharmony_ci	::CheckDlgButton( HwndDlg, IDC_CHECK_ORIGINAL,     GetOriginalMode()   ?BST_CHECKED:BST_UNCHECKED );
552159b3361Sopenharmony_ci	::CheckDlgButton( HwndDlg, IDC_CHECK_PRIVATE,      GetPrivateMode()    ?BST_CHECKED:BST_UNCHECKED );
553159b3361Sopenharmony_ci	::CheckDlgButton( HwndDlg, IDC_CHECK_COPYRIGHT,    GetCopyrightMode()  ?BST_CHECKED:BST_UNCHECKED );
554159b3361Sopenharmony_ci	::CheckDlgButton( HwndDlg, IDC_CHECK_ENC_SMART,    GetSmartOutputMode()?BST_CHECKED:BST_UNCHECKED );
555159b3361Sopenharmony_ci	::CheckDlgButton( HwndDlg, IDC_CHECK_ENC_ABR,      GetAbrOutputMode()  ?BST_CHECKED:BST_UNCHECKED );
556159b3361Sopenharmony_ci//	::CheckDlgButton( HwndDlg, IDC_CHECK_RESERVOIR,    !GetNoBiResMode() ?BST_CHECKED:BST_UNCHECKED );
557159b3361Sopenharmony_ci//	::CheckDlgButton( HwndDlg, IDC_CHECK_XINGVBR,      GetXingFrameMode()?BST_CHECKED:BST_UNCHECKED );
558159b3361Sopenharmony_ci//	::CheckDlgButton( HwndDlg, IDC_CHECK_RESAMPLE,     GetResampleMode() ?BST_CHECKED:BST_UNCHECKED );
559159b3361Sopenharmony_ci//	::CheckDlgButton( HwndDlg, IDC_CHECK_CHANNELFORCE, bForceChannel     ?BST_CHECKED:BST_UNCHECKED );
560159b3361Sopenharmony_ci
561159b3361Sopenharmony_ci	// Add required channel modes
562159b3361Sopenharmony_ci	for (i=0;i<GetChannelLentgh();i++)
563159b3361Sopenharmony_ci	{
564159b3361Sopenharmony_ci		if (i == nChannelIndex)
565159b3361Sopenharmony_ci		{
566159b3361Sopenharmony_ci			SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO), CB_SETCURSEL, i, NULL);
567159b3361Sopenharmony_ci			break;
568159b3361Sopenharmony_ci		}
569159b3361Sopenharmony_ci	}
570159b3361Sopenharmony_ci
571159b3361Sopenharmony_ci	// Add VBR Quality
572159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_SETPOS, TRUE, AverageBitrate_Min);
573159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_SETPOS, TRUE, AverageBitrate_Max);
574159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_SETPOS, TRUE, AverageBitrate_Step);
575159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETPOS, TRUE, AverageBitrate_Max);
576159b3361Sopenharmony_ci
577159b3361Sopenharmony_ci	UpdateDlgFromSlides(HwndDlg);
578159b3361Sopenharmony_ci
579159b3361Sopenharmony_ci	EnableAbrOptions(HwndDlg, GetAbrOutputMode());
580159b3361Sopenharmony_ci//	UpdateAbrSteps(AverageBitrate_Min, AverageBitrate_Max, AverageBitrate_Step);
581159b3361Sopenharmony_ci	// Add all possible re-sampling freq
582159b3361Sopenharmony_ci/*	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_SETCURSEL, nSamplingFreqIndex, NULL);
583159b3361Sopenharmony_ci
584159b3361Sopenharmony_ci
585159b3361Sopenharmony_ci	// Add required bitrates
586159b3361Sopenharmony_ci	for (i=0;i<GetBitrateLentgh();i++)
587159b3361Sopenharmony_ci	{
588159b3361Sopenharmony_ci		if (i == nMinBitrateIndex)
589159b3361Sopenharmony_ci		{
590159b3361Sopenharmony_ci			SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE), CB_SETCURSEL, i, NULL);
591159b3361Sopenharmony_ci			break;
592159b3361Sopenharmony_ci		}
593159b3361Sopenharmony_ci	}
594159b3361Sopenharmony_ci
595159b3361Sopenharmony_ci	// Add bitrates to the VBR combo box too
596159b3361Sopenharmony_ci	for (i=0;i<GetBitrateLentgh();i++)
597159b3361Sopenharmony_ci	{
598159b3361Sopenharmony_ci		if (i == nMaxBitrateIndex)
599159b3361Sopenharmony_ci		{
600159b3361Sopenharmony_ci			SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_SETCURSEL, i, NULL);
601159b3361Sopenharmony_ci			break;
602159b3361Sopenharmony_ci		}
603159b3361Sopenharmony_ci	}
604159b3361Sopenharmony_ci
605159b3361Sopenharmony_ci//	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_SETRANGE, TRUE, MAKELONG(0,9));
606159b3361Sopenharmony_ci
607159b3361Sopenharmony_ci	char tmp[3];
608159b3361Sopenharmony_ci	wsprintf(tmp,"%d",VbrQuality);
609159b3361Sopenharmony_ci	SetWindowText(GetDlgItem( HwndDlg, IDC_CONFIG_QUALITY), tmp);
610159b3361Sopenharmony_ci	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_SETPOS, TRUE, VbrQuality);
611159b3361Sopenharmony_ci
612159b3361Sopenharmony_ci	wsprintf(tmp,"%d",AverageBitrate);
613159b3361Sopenharmony_ci	SetWindowText(GetDlgItem( HwndDlg, IDC_EDIT_AVERAGE), tmp);
614159b3361Sopenharmony_ci
615159b3361Sopenharmony_ci	// Display VBR settings if needed
616159b3361Sopenharmony_ci	AEncodeProperties::DisplayVbrOptions(HwndDlg, mBRmode);
617159b3361Sopenharmony_ci
618159b3361Sopenharmony_ci	// Display Resample settings if needed
619159b3361Sopenharmony_ci	if (GetResampleMode())
620159b3361Sopenharmony_ci	{
621159b3361Sopenharmony_ci		::EnableWindow(::GetDlgItem(HwndDlg,IDC_COMBO_SAMPLEFREQ), TRUE);
622159b3361Sopenharmony_ci	}
623159b3361Sopenharmony_ci	else
624159b3361Sopenharmony_ci	{
625159b3361Sopenharmony_ci		::EnableWindow(::GetDlgItem(HwndDlg,IDC_COMBO_SAMPLEFREQ), FALSE);
626159b3361Sopenharmony_ci	}
627159b3361Sopenharmony_ci
628159b3361Sopenharmony_ci
629159b3361Sopenharmony_ci	// Add presets
630159b3361Sopenharmony_ci	for (i=0;i<GetPresetLentgh();i++)
631159b3361Sopenharmony_ci	{
632159b3361Sopenharmony_ci		if (i == nPresetIndex)
633159b3361Sopenharmony_ci		{
634159b3361Sopenharmony_ci			SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET), CB_SETCURSEL, i, NULL);
635159b3361Sopenharmony_ci			break;
636159b3361Sopenharmony_ci		}
637159b3361Sopenharmony_ci	}
638159b3361Sopenharmony_ci
639159b3361Sopenharmony_ci	// Add User configs
640159b3361Sopenharmony_ci//	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_RESETCONTENT , NULL, NULL);
641159b3361Sopenharmony_ci	::SetWindowText(::GetDlgItem( HwndDlg, IDC_EDIT_OUTPUTDIR), OutputDir.c_str());
642159b3361Sopenharmony_ci*/
643159b3361Sopenharmony_ci	/**
644159b3361Sopenharmony_ci		\todo Select the right saved config
645159b3361Sopenharmony_ci	*/
646159b3361Sopenharmony_ci
647159b3361Sopenharmony_ci	return true;
648159b3361Sopenharmony_ci}
649159b3361Sopenharmony_ci
650159b3361Sopenharmony_cibool AEncodeProperties::UpdateValueFromDlg(HWND HwndDlg)
651159b3361Sopenharmony_ci{
652159b3361Sopenharmony_ci	nChannelIndex      = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO),   CB_GETCURSEL, NULL, NULL);
653159b3361Sopenharmony_ci//	nMinBitrateIndex   = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE),    CB_GETCURSEL, NULL, NULL);
654159b3361Sopenharmony_ci//	nMaxBitrateIndex   = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_GETCURSEL, NULL, NULL);
655159b3361Sopenharmony_ci//	nPresetIndex       = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET),     CB_GETCURSEL, NULL, NULL);
656159b3361Sopenharmony_ci//	VbrQuality         = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_GETPOS , NULL, NULL);
657159b3361Sopenharmony_ci//	nSamplingFreqIndex = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_GETCURSEL, NULL, NULL);
658159b3361Sopenharmony_ci
659159b3361Sopenharmony_ci	bCRC          = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_CHECKSUM)     == BST_CHECKED);
660159b3361Sopenharmony_ci	bCopyright    = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_COPYRIGHT)    == BST_CHECKED);
661159b3361Sopenharmony_ci	bOriginal     = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_ORIGINAL)     == BST_CHECKED);
662159b3361Sopenharmony_ci	bPrivate      = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_PRIVATE)      == BST_CHECKED);
663159b3361Sopenharmony_ci	bSmartOutput  = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_ENC_SMART)    == BST_CHECKED);
664159b3361Sopenharmony_ci	bAbrOutput    = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_ENC_ABR)      == BST_CHECKED);
665159b3361Sopenharmony_ci//	bNoBitRes     =!(::IsDlgButtonChecked( HwndDlg, IDC_CHECK_RESERVOIR)    == BST_CHECKED);
666159b3361Sopenharmony_ci//	bXingFrame    = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_XINGVBR)      == BST_CHECKED);
667159b3361Sopenharmony_ci//	bResample     = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_RESAMPLE)     == BST_CHECKED);
668159b3361Sopenharmony_ci//	bForceChannel = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_CHANNELFORCE) == BST_CHECKED);
669159b3361Sopenharmony_ci
670159b3361Sopenharmony_ci	AverageBitrate_Min  = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_GETPOS , NULL, NULL);
671159b3361Sopenharmony_ci	AverageBitrate_Max  = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_GETPOS , NULL, NULL);
672159b3361Sopenharmony_ci	AverageBitrate_Step = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_GETPOS , NULL, NULL);
673159b3361Sopenharmony_ci
674159b3361Sopenharmony_ci	EnableAbrOptions(HwndDlg, bAbrOutput);
675159b3361Sopenharmony_ci
676159b3361Sopenharmony_cimy_debug.OutPut("nChannelIndex %d, bCRC %d, bCopyright %d, bOriginal %d, bPrivate %d",nChannelIndex, bCRC, bCopyright, bOriginal, bPrivate);
677159b3361Sopenharmony_ci
678159b3361Sopenharmony_ci/*	char tmpPath[MAX_PATH];
679159b3361Sopenharmony_ci	::GetWindowText( ::GetDlgItem( HwndDlg, IDC_EDIT_OUTPUTDIR), tmpPath, MAX_PATH);
680159b3361Sopenharmony_ci	OutputDir = tmpPath;
681159b3361Sopenharmony_ci
682159b3361Sopenharmony_ci	if (::IsDlgButtonChecked(HwndDlg, IDC_RADIO_BITRATE_CBR) == BST_CHECKED)
683159b3361Sopenharmony_ci		mBRmode = BR_CBR;
684159b3361Sopenharmony_ci	else if (::IsDlgButtonChecked(HwndDlg, IDC_RADIO_BITRATE_VBR) == BST_CHECKED)
685159b3361Sopenharmony_ci		mBRmode = BR_VBR;
686159b3361Sopenharmony_ci	else
687159b3361Sopenharmony_ci		mBRmode = BR_ABR;
688159b3361Sopenharmony_ci
689159b3361Sopenharmony_ci	::GetWindowText( ::GetDlgItem( HwndDlg, IDC_EDIT_AVERAGE), tmpPath, MAX_PATH);
690159b3361Sopenharmony_ci	AverageBitrate = atoi(tmpPath);
691159b3361Sopenharmony_ci	if (AverageBitrate < 8)
692159b3361Sopenharmony_ci		AverageBitrate = 8;
693159b3361Sopenharmony_ci	if (AverageBitrate > 320)
694159b3361Sopenharmony_ci		AverageBitrate = 320;
695159b3361Sopenharmony_ci*/
696159b3361Sopenharmony_ci	return true;
697159b3361Sopenharmony_ci}
698159b3361Sopenharmony_ci/*
699159b3361Sopenharmony_ciVBRMETHOD AEncodeProperties::GetVBRValue(DWORD & MaxBitrate, int & Quality, DWORD & AbrBitrate, BOOL & VBRHeader, const DWORD MPEG_Version) const
700159b3361Sopenharmony_ci{
701159b3361Sopenharmony_ci	assert((MPEG_Version == MPEG1) || (MPEG_Version == MPEG2));
702159b3361Sopenharmony_ci	assert(nMaxBitrateIndex < sizeof(the_Bitrates));
703159b3361Sopenharmony_ci
704159b3361Sopenharmony_ci	if (mBRmode == BR_VBR)
705159b3361Sopenharmony_ci	{
706159b3361Sopenharmony_ci		MaxBitrate = the_Bitrates[nMaxBitrateIndex];
707159b3361Sopenharmony_ci
708159b3361Sopenharmony_ci		if (MPEG_Version == MPEG1)
709159b3361Sopenharmony_ci			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];
710159b3361Sopenharmony_ci		else
711159b3361Sopenharmony_ci			MaxBitrate = MaxBitrate<the_MPEG2_Bitrates[0]?MaxBitrate:the_MPEG2_Bitrates[0];
712159b3361Sopenharmony_ci
713159b3361Sopenharmony_ci		VBRHeader = bXingFrame;
714159b3361Sopenharmony_ci		Quality = VbrQuality;
715159b3361Sopenharmony_ci		AbrBitrate = 0;
716159b3361Sopenharmony_ci
717159b3361Sopenharmony_ci		return VBR_METHOD_DEFAULT; // for the moment
718159b3361Sopenharmony_ci	}
719159b3361Sopenharmony_ci	else if (mBRmode == BR_ABR)
720159b3361Sopenharmony_ci	{
721159b3361Sopenharmony_ci		MaxBitrate = the_Bitrates[nMaxBitrateIndex];
722159b3361Sopenharmony_ci
723159b3361Sopenharmony_ci		if (MPEG_Version == MPEG1)
724159b3361Sopenharmony_ci			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];
725159b3361Sopenharmony_ci		else
726159b3361Sopenharmony_ci			MaxBitrate = MaxBitrate<the_MPEG2_Bitrates[0]?MaxBitrate:the_MPEG2_Bitrates[0];
727159b3361Sopenharmony_ci
728159b3361Sopenharmony_ci		VBRHeader = bXingFrame;
729159b3361Sopenharmony_ci		Quality = 0;
730159b3361Sopenharmony_ci		AbrBitrate = AverageBitrate*1000;
731159b3361Sopenharmony_ci		return VBR_METHOD_ABR;
732159b3361Sopenharmony_ci	}
733159b3361Sopenharmony_ci	else
734159b3361Sopenharmony_ci	{
735159b3361Sopenharmony_ci		return VBR_METHOD_NONE;
736159b3361Sopenharmony_ci	}
737159b3361Sopenharmony_ci}
738159b3361Sopenharmony_ci*/
739159b3361Sopenharmony_civoid AEncodeProperties::ParamsRestore()
740159b3361Sopenharmony_ci{
741159b3361Sopenharmony_ci	// use these default parameters in case one is not found
742159b3361Sopenharmony_ci	bCopyright    = true;
743159b3361Sopenharmony_ci	bCRC          = true;
744159b3361Sopenharmony_ci	bOriginal     = true;
745159b3361Sopenharmony_ci	bPrivate      = true;
746159b3361Sopenharmony_ci	bNoBitRes     = false; // enable bit reservoir
747159b3361Sopenharmony_ci	bXingFrame    = true;
748159b3361Sopenharmony_ci	bResample     = false;
749159b3361Sopenharmony_ci	bForceChannel = false;
750159b3361Sopenharmony_ci	bSmartOutput  = true;
751159b3361Sopenharmony_ci	bAbrOutput    = true;
752159b3361Sopenharmony_ci
753159b3361Sopenharmony_ci	AverageBitrate_Min = 80; // a bit lame
754159b3361Sopenharmony_ci	AverageBitrate_Max = 160; // a bit lame
755159b3361Sopenharmony_ci	AverageBitrate_Step = 8; // a bit lame
756159b3361Sopenharmony_ci	SmartRatioMax = 15.0;
757159b3361Sopenharmony_ci
758159b3361Sopenharmony_ci	nChannelIndex = 2; // joint-stereo
759159b3361Sopenharmony_ci	mBRmode       = BR_CBR;
760159b3361Sopenharmony_ci	nMinBitrateIndex = 6; // 128 kbps (works for both MPEGI and II)
761159b3361Sopenharmony_ci	nMaxBitrateIndex = 4; // 160 kbps (works for both MPEGI and II)
762159b3361Sopenharmony_ci	nPresetIndex = 0; // None
763159b3361Sopenharmony_ci	VbrQuality = 1; // Quite High
764159b3361Sopenharmony_ci//	AverageBitrate = 128; // a bit lame
765159b3361Sopenharmony_ci	nSamplingFreqIndex = 1; // 44100
766159b3361Sopenharmony_ci
767159b3361Sopenharmony_ci//	OutputDir = "c:\\";
768159b3361Sopenharmony_ci
769159b3361Sopenharmony_ci//	DllLocation = "plugins\\lame_enc.dll";
770159b3361Sopenharmony_ci
771159b3361Sopenharmony_ci	// get the values from the saved file if possible
772159b3361Sopenharmony_ci	if (my_stored_data.LoadFile(my_store_location))
773159b3361Sopenharmony_ci	{
774159b3361Sopenharmony_ci		TiXmlNode* node;
775159b3361Sopenharmony_ci
776159b3361Sopenharmony_ci		node = my_stored_data.FirstChild("lame_acm");
777159b3361Sopenharmony_ci
778159b3361Sopenharmony_ci		TiXmlElement* CurrentNode = node->FirstChildElement("encodings");
779159b3361Sopenharmony_ci
780159b3361Sopenharmony_ci		std::string CurrentConfig = "";
781159b3361Sopenharmony_ci
782159b3361Sopenharmony_ci		if (CurrentNode->Attribute("default") != NULL)
783159b3361Sopenharmony_ci		{
784159b3361Sopenharmony_ci			CurrentConfig = *CurrentNode->Attribute("default");
785159b3361Sopenharmony_ci		}
786159b3361Sopenharmony_ci
787159b3361Sopenharmony_ci/*		// output parameters
788159b3361Sopenharmony_ci		TiXmlElement* iterateElmt = node->FirstChildElement("DLL");
789159b3361Sopenharmony_ci		if (iterateElmt != NULL)
790159b3361Sopenharmony_ci		{
791159b3361Sopenharmony_ci			const std::string * tmpname = iterateElmt->Attribute("location");
792159b3361Sopenharmony_ci			if (tmpname != NULL)
793159b3361Sopenharmony_ci			{
794159b3361Sopenharmony_ci				DllLocation = *tmpname;
795159b3361Sopenharmony_ci			}
796159b3361Sopenharmony_ci		}
797159b3361Sopenharmony_ci*/
798159b3361Sopenharmony_ci		GetValuesFromKey(CurrentConfig, *CurrentNode);
799159b3361Sopenharmony_ci	}
800159b3361Sopenharmony_ci	else
801159b3361Sopenharmony_ci	{
802159b3361Sopenharmony_ci		/**
803159b3361Sopenharmony_ci			\todo save the data in the file !
804159b3361Sopenharmony_ci		*/
805159b3361Sopenharmony_ci	}
806159b3361Sopenharmony_ci}
807159b3361Sopenharmony_ci
808159b3361Sopenharmony_civoid AEncodeProperties::ParamsSave()
809159b3361Sopenharmony_ci{
810159b3361Sopenharmony_ci/*
811159b3361Sopenharmony_ci
812159b3361Sopenharmony_ci
813159b3361Sopenharmony_ci	save the current parameters in the corresponding subkey
814159b3361Sopenharmony_ci
815159b3361Sopenharmony_ci
816159b3361Sopenharmony_ci
817159b3361Sopenharmony_ci
818159b3361Sopenharmony_ci	HKEY OssKey;
819159b3361Sopenharmony_ci
820159b3361Sopenharmony_ci	if (RegCreateKeyEx ( HKEY_LOCAL_MACHINE, "SOFTWARE\\MUKOLI\\out_lame", 0, "", REG_OPTION_NON_VOLATILE, KEY_WRITE , NULL, &OssKey, NULL ) == ERROR_SUCCESS) {
821159b3361Sopenharmony_ci
822159b3361Sopenharmony_ci		if (RegSetValueEx(OssKey, "DLL Location", 0, REG_EXPAND_SZ, (CONST BYTE *)DllLocation, strlen(DllLocation)+1 ) != ERROR_SUCCESS)
823159b3361Sopenharmony_ci			return;
824159b3361Sopenharmony_ci
825159b3361Sopenharmony_ci		RegCloseKey(OssKey);
826159b3361Sopenharmony_ci	}
827159b3361Sopenharmony_ci*/
828159b3361Sopenharmony_ci}
829159b3361Sopenharmony_ci/*
830159b3361Sopenharmony_civoid AEncodeProperties::DisplayVbrOptions(const HWND hDialog, const BRMode the_mode)
831159b3361Sopenharmony_ci{
832159b3361Sopenharmony_ci	bool bVBR = false;
833159b3361Sopenharmony_ci	bool bABR = false;
834159b3361Sopenharmony_ci
835159b3361Sopenharmony_ci	switch ( the_mode )
836159b3361Sopenharmony_ci	{
837159b3361Sopenharmony_ci		case BR_CBR:
838159b3361Sopenharmony_ci			::CheckRadioButton(hDialog, IDC_RADIO_BITRATE_CBR, IDC_RADIO_BITRATE_ABR, IDC_RADIO_BITRATE_CBR);
839159b3361Sopenharmony_ci			break;
840159b3361Sopenharmony_ci		case BR_VBR:
841159b3361Sopenharmony_ci			::CheckRadioButton(hDialog, IDC_RADIO_BITRATE_CBR, IDC_RADIO_BITRATE_ABR, IDC_RADIO_BITRATE_VBR);
842159b3361Sopenharmony_ci			bVBR = true;
843159b3361Sopenharmony_ci			break;
844159b3361Sopenharmony_ci		case BR_ABR:
845159b3361Sopenharmony_ci			::CheckRadioButton(hDialog, IDC_RADIO_BITRATE_CBR, IDC_RADIO_BITRATE_ABR, IDC_RADIO_BITRATE_ABR);
846159b3361Sopenharmony_ci			bABR = true;
847159b3361Sopenharmony_ci			break;
848159b3361Sopenharmony_ci
849159b3361Sopenharmony_ci	}
850159b3361Sopenharmony_ci
851159b3361Sopenharmony_ci	if(bVBR|bABR)
852159b3361Sopenharmony_ci	{
853159b3361Sopenharmony_ci		::SetWindowText(::GetDlgItem(hDialog,IDC_STATIC_MINBITRATE), "Min Bitrate");
854159b3361Sopenharmony_ci	}
855159b3361Sopenharmony_ci	else
856159b3361Sopenharmony_ci	{
857159b3361Sopenharmony_ci		::SetWindowText(::GetDlgItem(hDialog,IDC_STATIC_MINBITRATE), "Bitrate");
858159b3361Sopenharmony_ci	}
859159b3361Sopenharmony_ci
860159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_CHECK_XINGVBR), bVBR|bABR);
861159b3361Sopenharmony_ci
862159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_COMBO_MAXBITRATE), bVBR|bABR);
863159b3361Sopenharmony_ci
864159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_MAXBITRATE), bVBR|bABR);
865159b3361Sopenharmony_ci
866159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_QUALITY), bVBR);
867159b3361Sopenharmony_ci
868159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_CONFIG_QUALITY), bVBR);
869159b3361Sopenharmony_ci
870159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_VBRQUALITY), bVBR);
871159b3361Sopenharmony_ci
872159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_VBRQUALITY_LOW), bVBR);
873159b3361Sopenharmony_ci
874159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_VBRQUALITY_HIGH), bVBR);
875159b3361Sopenharmony_ci
876159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_ABR), bABR);
877159b3361Sopenharmony_ci
878159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_EDIT_AVERAGE), bABR);
879159b3361Sopenharmony_ci}
880159b3361Sopenharmony_ci*/
881159b3361Sopenharmony_ciAEncodeProperties::AEncodeProperties(HMODULE hModule)
882159b3361Sopenharmony_ci :my_debug(ADbg(DEBUG_LEVEL_CREATION)),
883159b3361Sopenharmony_ci my_hModule(hModule)
884159b3361Sopenharmony_ci{
885159b3361Sopenharmony_ci	std::string path = "";
886159b3361Sopenharmony_ci//	HMODULE htmp = LoadLibrary("out_lame.dll");
887159b3361Sopenharmony_ci	if (hModule != NULL)
888159b3361Sopenharmony_ci	{
889159b3361Sopenharmony_ci		char output[MAX_PATH];
890159b3361Sopenharmony_ci		::GetModuleFileName(hModule, output, MAX_PATH);
891159b3361Sopenharmony_ci//		::FreeLibrary(htmp);
892159b3361Sopenharmony_ci
893159b3361Sopenharmony_ci		path = output;
894159b3361Sopenharmony_ci	}
895159b3361Sopenharmony_ci	my_store_location = path.substr(0,path.find_last_of('\\')+1);
896159b3361Sopenharmony_ci	my_store_location += "lame_acm.xml";
897159b3361Sopenharmony_ci
898159b3361Sopenharmony_ci	my_debug.OutPut("store path = %s",my_store_location.c_str());
899159b3361Sopenharmony_ci//#ifdef OLD
900159b3361Sopenharmony_ci//	::OutputDebugString(my_store_location.c_str());
901159b3361Sopenharmony_ci
902159b3361Sopenharmony_ci	// make sure the XML file is present
903159b3361Sopenharmony_ci	HANDLE hFile = ::CreateFile(my_store_location.c_str(), 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL );
904159b3361Sopenharmony_ci	::CloseHandle(hFile);
905159b3361Sopenharmony_ci//#endif // OLD
906159b3361Sopenharmony_ci	my_debug.OutPut("AEncodeProperties creation completed (0x%08X)",this);
907159b3361Sopenharmony_ci}
908159b3361Sopenharmony_ci
909159b3361Sopenharmony_ci// Save the values to the right XML saved config
910159b3361Sopenharmony_civoid AEncodeProperties::SaveValuesToStringKey(const std::string & config_name)
911159b3361Sopenharmony_ci{
912159b3361Sopenharmony_ci	// get the current data in the file to keep them
913159b3361Sopenharmony_ci	if (my_stored_data.LoadFile(my_store_location))
914159b3361Sopenharmony_ci	{
915159b3361Sopenharmony_ci		// check if the Node corresponding to the config_name already exist.
916159b3361Sopenharmony_ci		TiXmlNode* node = my_stored_data.FirstChild("lame_acm");
917159b3361Sopenharmony_ci
918159b3361Sopenharmony_ci		if (node != NULL)
919159b3361Sopenharmony_ci		{
920159b3361Sopenharmony_ci			TiXmlElement* ConfigNode = node->FirstChildElement("encodings");
921159b3361Sopenharmony_ci
922159b3361Sopenharmony_ci			if (ConfigNode != NULL)
923159b3361Sopenharmony_ci			{
924159b3361Sopenharmony_ci				// look all the <config> tags
925159b3361Sopenharmony_ci				TiXmlElement* tmpNode = ConfigNode->FirstChildElement("config");
926159b3361Sopenharmony_ci				while (tmpNode != NULL)
927159b3361Sopenharmony_ci				{
928159b3361Sopenharmony_ci					const std::string * tmpname = tmpNode->Attribute("name");
929159b3361Sopenharmony_ci					if (tmpname->compare(config_name) == 0)
930159b3361Sopenharmony_ci					{
931159b3361Sopenharmony_ci						break;
932159b3361Sopenharmony_ci					}
933159b3361Sopenharmony_ci					tmpNode = tmpNode->NextSiblingElement("config");
934159b3361Sopenharmony_ci				}
935159b3361Sopenharmony_ci
936159b3361Sopenharmony_ci				if (tmpNode == NULL)
937159b3361Sopenharmony_ci				{
938159b3361Sopenharmony_ci					// Create the node
939159b3361Sopenharmony_ci					tmpNode = new TiXmlElement("config");
940159b3361Sopenharmony_ci					tmpNode->SetAttribute("name",config_name);
941159b3361Sopenharmony_ci
942159b3361Sopenharmony_ci					// save data in the node
943159b3361Sopenharmony_ci					SaveValuesToElement(tmpNode);
944159b3361Sopenharmony_ci
945159b3361Sopenharmony_ci					ConfigNode->InsertEndChild(*tmpNode);
946159b3361Sopenharmony_ci				}
947159b3361Sopenharmony_ci				else
948159b3361Sopenharmony_ci				{
949159b3361Sopenharmony_ci					// save data in the node
950159b3361Sopenharmony_ci					SaveValuesToElement(tmpNode);
951159b3361Sopenharmony_ci				}
952159b3361Sopenharmony_ci
953159b3361Sopenharmony_ci
954159b3361Sopenharmony_ci				// and save the file
955159b3361Sopenharmony_ci				my_stored_data.SaveFile(my_store_location);
956159b3361Sopenharmony_ci			}
957159b3361Sopenharmony_ci		}
958159b3361Sopenharmony_ci	}
959159b3361Sopenharmony_ci}
960159b3361Sopenharmony_ci
961159b3361Sopenharmony_civoid AEncodeProperties::GetValuesFromKey(const std::string & config_name, const TiXmlNode & parentNode)
962159b3361Sopenharmony_ci{
963159b3361Sopenharmony_ci	TiXmlElement* tmpElt;
964159b3361Sopenharmony_ci	TiXmlElement* iterateElmt;
965159b3361Sopenharmony_ci
966159b3361Sopenharmony_ci	// find the config that correspond to CurrentConfig
967159b3361Sopenharmony_ci	iterateElmt = parentNode.FirstChildElement("config");
968159b3361Sopenharmony_ci	while (iterateElmt != NULL)
969159b3361Sopenharmony_ci	{
970159b3361Sopenharmony_ci		const std::string * tmpname = iterateElmt->Attribute("name");
971159b3361Sopenharmony_ci		if ((tmpname != NULL) && (tmpname->compare(config_name) == 0))
972159b3361Sopenharmony_ci		{
973159b3361Sopenharmony_ci			break;
974159b3361Sopenharmony_ci		}
975159b3361Sopenharmony_ci		iterateElmt = iterateElmt->NextSiblingElement("config");
976159b3361Sopenharmony_ci	}
977159b3361Sopenharmony_ci
978159b3361Sopenharmony_ci	if (iterateElmt != NULL)
979159b3361Sopenharmony_ci	{
980159b3361Sopenharmony_ci		// get all the parameters saved in this Element
981159b3361Sopenharmony_ci		const std::string * tmpname;
982159b3361Sopenharmony_ci
983159b3361Sopenharmony_ci		// Smart output parameter
984159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("Smart");
985159b3361Sopenharmony_ci		if (tmpElt != NULL)
986159b3361Sopenharmony_ci		{
987159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("use");
988159b3361Sopenharmony_ci			if (tmpname != NULL)
989159b3361Sopenharmony_ci				bSmartOutput = (tmpname->compare("true") == 0);
990159b3361Sopenharmony_ci
991159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("ratio");
992159b3361Sopenharmony_ci			if (tmpname != NULL)
993159b3361Sopenharmony_ci				SmartRatioMax = atof(tmpname->c_str());
994159b3361Sopenharmony_ci		}
995159b3361Sopenharmony_ci
996159b3361Sopenharmony_ci		// Smart output parameter
997159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("ABR");
998159b3361Sopenharmony_ci		if (tmpElt != NULL)
999159b3361Sopenharmony_ci		{
1000159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("use");
1001159b3361Sopenharmony_ci			if (tmpname != NULL)
1002159b3361Sopenharmony_ci				bAbrOutput = (tmpname->compare("true") == 0);
1003159b3361Sopenharmony_ci
1004159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("min");
1005159b3361Sopenharmony_ci			if (tmpname != NULL)
1006159b3361Sopenharmony_ci				AverageBitrate_Min = atoi(tmpname->c_str());
1007159b3361Sopenharmony_ci
1008159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("max");
1009159b3361Sopenharmony_ci			if (tmpname != NULL)
1010159b3361Sopenharmony_ci				AverageBitrate_Max = atoi(tmpname->c_str());
1011159b3361Sopenharmony_ci
1012159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("step");
1013159b3361Sopenharmony_ci			if (tmpname != NULL)
1014159b3361Sopenharmony_ci				AverageBitrate_Step = atoi(tmpname->c_str());
1015159b3361Sopenharmony_ci		}
1016159b3361Sopenharmony_ci
1017159b3361Sopenharmony_ci		// Copyright parameter
1018159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("Copyright");
1019159b3361Sopenharmony_ci		if (tmpElt != NULL)
1020159b3361Sopenharmony_ci		{
1021159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("use");
1022159b3361Sopenharmony_ci			if (tmpname != NULL)
1023159b3361Sopenharmony_ci				bCopyright = (tmpname->compare("true") == 0);
1024159b3361Sopenharmony_ci		}
1025159b3361Sopenharmony_ci
1026159b3361Sopenharmony_ci		// Copyright parameter
1027159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("CRC");
1028159b3361Sopenharmony_ci		if (tmpElt != NULL)
1029159b3361Sopenharmony_ci		{
1030159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("use");
1031159b3361Sopenharmony_ci			if (tmpname != NULL)
1032159b3361Sopenharmony_ci				bCRC = (tmpname->compare("true") == 0);
1033159b3361Sopenharmony_ci		}
1034159b3361Sopenharmony_ci
1035159b3361Sopenharmony_ci		// Copyright parameter
1036159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("Original");
1037159b3361Sopenharmony_ci		if (tmpElt != NULL)
1038159b3361Sopenharmony_ci		{
1039159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("use");
1040159b3361Sopenharmony_ci			if (tmpname != NULL)
1041159b3361Sopenharmony_ci				bOriginal = (tmpname->compare("true") == 0);
1042159b3361Sopenharmony_ci		}
1043159b3361Sopenharmony_ci
1044159b3361Sopenharmony_ci		// Copyright parameter
1045159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("Private");
1046159b3361Sopenharmony_ci		if (tmpElt != NULL)
1047159b3361Sopenharmony_ci		{
1048159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("use");
1049159b3361Sopenharmony_ci			if (tmpname != NULL)
1050159b3361Sopenharmony_ci				bPrivate = (tmpname->compare("true") == 0);
1051159b3361Sopenharmony_ci		}
1052159b3361Sopenharmony_ci/*
1053159b3361Sopenharmony_ci		// Copyright parameter
1054159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("Bit_reservoir");
1055159b3361Sopenharmony_ci		if (tmpElt != NULL)
1056159b3361Sopenharmony_ci		{
1057159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("use");
1058159b3361Sopenharmony_ci			if (tmpname != NULL)
1059159b3361Sopenharmony_ci				bNoBitRes = !(tmpname->compare("true") == 0);
1060159b3361Sopenharmony_ci		}
1061159b3361Sopenharmony_ci
1062159b3361Sopenharmony_ci		// bitrates
1063159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("bitrate");
1064159b3361Sopenharmony_ci		tmpname = tmpElt->Attribute("min");
1065159b3361Sopenharmony_ci		if (tmpname != NULL)
1066159b3361Sopenharmony_ci		{
1067159b3361Sopenharmony_ci			unsigned int uitmp = atoi(tmpname->c_str());
1068159b3361Sopenharmony_ci			for (int i=0;i<sizeof(the_Bitrates)/sizeof(unsigned int);i++)
1069159b3361Sopenharmony_ci			{
1070159b3361Sopenharmony_ci				if (the_Bitrates[i] == uitmp)
1071159b3361Sopenharmony_ci				{
1072159b3361Sopenharmony_ci					nMinBitrateIndex = i;
1073159b3361Sopenharmony_ci					break;
1074159b3361Sopenharmony_ci				}
1075159b3361Sopenharmony_ci			}
1076159b3361Sopenharmony_ci		}
1077159b3361Sopenharmony_ci
1078159b3361Sopenharmony_ci		tmpname = tmpElt->Attribute("max");
1079159b3361Sopenharmony_ci		if (tmpname != NULL)
1080159b3361Sopenharmony_ci		{
1081159b3361Sopenharmony_ci			unsigned int uitmp = atoi(tmpname->c_str());
1082159b3361Sopenharmony_ci			for (int i=0;i<sizeof(the_Bitrates)/sizeof(unsigned int);i++)
1083159b3361Sopenharmony_ci			{
1084159b3361Sopenharmony_ci				if (the_Bitrates[i] == uitmp)
1085159b3361Sopenharmony_ci				{
1086159b3361Sopenharmony_ci					nMaxBitrateIndex = i;
1087159b3361Sopenharmony_ci					break;
1088159b3361Sopenharmony_ci				}
1089159b3361Sopenharmony_ci			}
1090159b3361Sopenharmony_ci		}
1091159b3361Sopenharmony_ci*/
1092159b3361Sopenharmony_ci/*
1093159b3361Sopenharmony_ci		// resampling parameters
1094159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("resampling");
1095159b3361Sopenharmony_ci		if (tmpElt != NULL)
1096159b3361Sopenharmony_ci		{
1097159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("use");
1098159b3361Sopenharmony_ci			if (tmpname != NULL)
1099159b3361Sopenharmony_ci				bResample = (tmpname->compare("true") == 0);
1100159b3361Sopenharmony_ci
1101159b3361Sopenharmony_ci			unsigned int uitmp = atoi(tmpElt->Attribute("freq")->c_str());
1102159b3361Sopenharmony_ci			for (int i=0;i<sizeof(the_SamplingFreqs)/sizeof(unsigned int);i++)
1103159b3361Sopenharmony_ci			{
1104159b3361Sopenharmony_ci				if (the_SamplingFreqs[i] == uitmp)
1105159b3361Sopenharmony_ci				{
1106159b3361Sopenharmony_ci					nSamplingFreqIndex = i;
1107159b3361Sopenharmony_ci					break;
1108159b3361Sopenharmony_ci				}
1109159b3361Sopenharmony_ci			}
1110159b3361Sopenharmony_ci		}
1111159b3361Sopenharmony_ci
1112159b3361Sopenharmony_ci		// VBR parameters
1113159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("VBR");
1114159b3361Sopenharmony_ci		if (tmpElt != NULL)
1115159b3361Sopenharmony_ci		{
1116159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("use");
1117159b3361Sopenharmony_ci			if (tmpname != NULL)
1118159b3361Sopenharmony_ci			{
1119159b3361Sopenharmony_ci				if (tmpname->compare("ABR") == 0)
1120159b3361Sopenharmony_ci					mBRmode = BR_ABR;
1121159b3361Sopenharmony_ci				else if (tmpname->compare("true") == 0)
1122159b3361Sopenharmony_ci					mBRmode = BR_VBR;
1123159b3361Sopenharmony_ci				else
1124159b3361Sopenharmony_ci					mBRmode = BR_CBR;
1125159b3361Sopenharmony_ci			}
1126159b3361Sopenharmony_ci
1127159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("header");
1128159b3361Sopenharmony_ci			if (tmpname != NULL)
1129159b3361Sopenharmony_ci				bXingFrame = (tmpname->compare("true") == 0);
1130159b3361Sopenharmony_ci
1131159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("quality");
1132159b3361Sopenharmony_ci			if (tmpname != NULL)
1133159b3361Sopenharmony_ci			{
1134159b3361Sopenharmony_ci				VbrQuality = atoi(tmpname->c_str());
1135159b3361Sopenharmony_ci			}
1136159b3361Sopenharmony_ci
1137159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("average");
1138159b3361Sopenharmony_ci			if (tmpname != NULL)
1139159b3361Sopenharmony_ci			{
1140159b3361Sopenharmony_ci				AverageBitrate = atoi(tmpname->c_str());
1141159b3361Sopenharmony_ci			}
1142159b3361Sopenharmony_ci			else
1143159b3361Sopenharmony_ci			{
1144159b3361Sopenharmony_ci			}
1145159b3361Sopenharmony_ci		}
1146159b3361Sopenharmony_ci
1147159b3361Sopenharmony_ci		// output parameters
1148159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("output");
1149159b3361Sopenharmony_ci		if (tmpElt != NULL)
1150159b3361Sopenharmony_ci		{
1151159b3361Sopenharmony_ci			OutputDir = *tmpElt->Attribute("path");
1152159b3361Sopenharmony_ci		}
1153159b3361Sopenharmony_ci*/
1154159b3361Sopenharmony_ci//#ifdef OLD
1155159b3361Sopenharmony_ci		// Channel mode parameter
1156159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("Channel");
1157159b3361Sopenharmony_ci		if (tmpElt != NULL)
1158159b3361Sopenharmony_ci		{
1159159b3361Sopenharmony_ci			const std::string * tmpStr = tmpElt->Attribute("mode");
1160159b3361Sopenharmony_ci			if (tmpStr != NULL)
1161159b3361Sopenharmony_ci			{
1162159b3361Sopenharmony_ci				for (int i=0;i<GetChannelLentgh();i++)
1163159b3361Sopenharmony_ci				{
1164159b3361Sopenharmony_ci					if (tmpStr->compare(GetChannelModeString(i)) == 0)
1165159b3361Sopenharmony_ci					{
1166159b3361Sopenharmony_ci						nChannelIndex = i;
1167159b3361Sopenharmony_ci						break;
1168159b3361Sopenharmony_ci					}
1169159b3361Sopenharmony_ci				}
1170159b3361Sopenharmony_ci			}
1171159b3361Sopenharmony_ci/*
1172159b3361Sopenharmony_ci			tmpname = tmpElt->Attribute("force");
1173159b3361Sopenharmony_ci			if (tmpname != NULL)
1174159b3361Sopenharmony_ci				bForceChannel = (tmpname->compare("true") == 0);
1175159b3361Sopenharmony_ci*/
1176159b3361Sopenharmony_ci		}
1177159b3361Sopenharmony_ci//#endif // OLD
1178159b3361Sopenharmony_ci
1179159b3361Sopenharmony_ci		// Preset parameter
1180159b3361Sopenharmony_ci/*
1181159b3361Sopenharmony_ci		tmpElt = iterateElmt->FirstChildElement("Preset");
1182159b3361Sopenharmony_ci		if (tmpElt != NULL)
1183159b3361Sopenharmony_ci		{
1184159b3361Sopenharmony_ci			const std::string * tmpStr = tmpElt->Attribute("type");
1185159b3361Sopenharmony_ci			for (int i=0;i<GetPresetLentgh();i++)
1186159b3361Sopenharmony_ci			{
1187159b3361Sopenharmony_ci				if (tmpStr->compare(GetPresetModeString(i)) == 0)
1188159b3361Sopenharmony_ci				{
1189159b3361Sopenharmony_ci					nPresetIndex = i;
1190159b3361Sopenharmony_ci					break;
1191159b3361Sopenharmony_ci				}
1192159b3361Sopenharmony_ci			}
1193159b3361Sopenharmony_ci
1194159b3361Sopenharmony_ci		}
1195159b3361Sopenharmony_ci*/
1196159b3361Sopenharmony_ci	}
1197159b3361Sopenharmony_ci}
1198159b3361Sopenharmony_ci
1199159b3361Sopenharmony_ci/**
1200159b3361Sopenharmony_ci	\todo save the parameters
1201159b3361Sopenharmony_ci* /
1202159b3361Sopenharmony_civoid AEncodeProperties::SaveParams(const HWND hParentWnd)
1203159b3361Sopenharmony_ci{
1204159b3361Sopenharmony_ci	char string[MAX_PATH];
1205159b3361Sopenharmony_ci/*	int nIdx = SendMessage(::GetDlgItem( hParentWnd ,IDC_COMBO_SETTINGS ), CB_GETCURSEL, NULL, NULL);
1206159b3361Sopenharmony_ci	::SendMessage(::GetDlgItem( hParentWnd ,IDC_COMBO_SETTINGS ), CB_GETLBTEXT , nIdx, (LPARAM) string);
1207159b3361Sopenharmony_ci* /
1208159b3361Sopenharmony_ci}*/
1209159b3361Sopenharmony_ci
1210159b3361Sopenharmony_cibool AEncodeProperties::operator !=(const AEncodeProperties & the_instance) const
1211159b3361Sopenharmony_ci{
1212159b3361Sopenharmony_ci/*
1213159b3361Sopenharmony_ci	::OutputDebugString(bCopyright != the_instance.bCopyright?"1":"-");
1214159b3361Sopenharmony_ci	::OutputDebugString(bCRC != the_instance.bCRC            ?"2":"-");
1215159b3361Sopenharmony_ci	::OutputDebugString(bOriginal != the_instance.bOriginal  ?"3":"-");
1216159b3361Sopenharmony_ci	::OutputDebugString(bPrivate != the_instance.bPrivate    ?"4":"-");
1217159b3361Sopenharmony_ci	::OutputDebugString(bNoBitRes != the_instance.bNoBitRes  ?"5":"-");
1218159b3361Sopenharmony_ci	::OutputDebugString(mBRmode != the_instance.mBRmode      ?"6":"-");
1219159b3361Sopenharmony_ci	::OutputDebugString(bXingFrame != the_instance.bXingFrame?"7":"-");
1220159b3361Sopenharmony_ci	::OutputDebugString(bForceChannel != the_instance.bForceChannel?"8":"-");
1221159b3361Sopenharmony_ci	::OutputDebugString(bResample != the_instance.bResample  ?"9":"-");
1222159b3361Sopenharmony_ci	::OutputDebugString(nChannelIndex != the_instance.nChannelIndex?"10":"-");
1223159b3361Sopenharmony_ci	::OutputDebugString(nMinBitrateIndex != the_instance.nMinBitrateIndex?"11":"-");
1224159b3361Sopenharmony_ci	::OutputDebugString(nMaxBitrateIndex != the_instance.nMaxBitrateIndex?"12":"-");
1225159b3361Sopenharmony_ci	::OutputDebugString(nPresetIndex != the_instance.nPresetIndex?"13":"-");
1226159b3361Sopenharmony_ci	::OutputDebugString(VbrQuality != the_instance.VbrQuality?"14":"-");
1227159b3361Sopenharmony_ci	::OutputDebugString(AverageBitrate != the_instance.AverageBitrate?"15":"-");
1228159b3361Sopenharmony_ci	::OutputDebugString(nSamplingFreqIndex != the_instance.nSamplingFreqIndex?"16":"-");
1229159b3361Sopenharmony_ci	::OutputDebugString(OutputDir.compare(the_instance.OutputDir) != 0?"17":"-");
1230159b3361Sopenharmony_ci
1231159b3361Sopenharmony_ci	std::string tmp = "";
1232159b3361Sopenharmony_ci	char tmpI[10];
1233159b3361Sopenharmony_ci	_itoa(AverageBitrate,tmpI,10);
1234159b3361Sopenharmony_ci	tmp += tmpI;
1235159b3361Sopenharmony_ci	tmp += " != ";
1236159b3361Sopenharmony_ci	_itoa(the_instance.AverageBitrate,tmpI,10);
1237159b3361Sopenharmony_ci	tmp += tmpI;
1238159b3361Sopenharmony_ci	::OutputDebugString(tmp.c_str());
1239159b3361Sopenharmony_ci*/
1240159b3361Sopenharmony_ci	return ((bCopyright != the_instance.bCopyright)
1241159b3361Sopenharmony_ci		 || (bCRC != the_instance.bCRC)
1242159b3361Sopenharmony_ci		 || (bOriginal != the_instance.bOriginal)
1243159b3361Sopenharmony_ci		 || (bPrivate != the_instance.bPrivate)
1244159b3361Sopenharmony_ci		 || (bSmartOutput != the_instance.bSmartOutput)
1245159b3361Sopenharmony_ci		 || (SmartRatioMax != the_instance.SmartRatioMax)
1246159b3361Sopenharmony_ci		 || (bAbrOutput != the_instance.bAbrOutput)
1247159b3361Sopenharmony_ci		 || (AverageBitrate_Min != the_instance.AverageBitrate_Min)
1248159b3361Sopenharmony_ci		 || (AverageBitrate_Max != the_instance.AverageBitrate_Max)
1249159b3361Sopenharmony_ci		 || (AverageBitrate_Step != the_instance.AverageBitrate_Step)
1250159b3361Sopenharmony_ci		 || (bNoBitRes != the_instance.bNoBitRes)
1251159b3361Sopenharmony_ci		 || (mBRmode != the_instance.mBRmode)
1252159b3361Sopenharmony_ci		 || (bXingFrame != the_instance.bXingFrame)
1253159b3361Sopenharmony_ci		 || (bForceChannel != the_instance.bForceChannel)
1254159b3361Sopenharmony_ci		 || (bResample != the_instance.bResample)
1255159b3361Sopenharmony_ci		 || (nChannelIndex != the_instance.nChannelIndex)
1256159b3361Sopenharmony_ci		 || (nMinBitrateIndex != the_instance.nMinBitrateIndex)
1257159b3361Sopenharmony_ci		 || (nMaxBitrateIndex != the_instance.nMaxBitrateIndex)
1258159b3361Sopenharmony_ci		 || (nPresetIndex != the_instance.nPresetIndex)
1259159b3361Sopenharmony_ci		 || (VbrQuality != the_instance.VbrQuality)
1260159b3361Sopenharmony_ci//		 || (AverageBitrate != the_instance.AverageBitrate)
1261159b3361Sopenharmony_ci		 || (nSamplingFreqIndex != the_instance.nSamplingFreqIndex)
1262159b3361Sopenharmony_ci//		 || (OutputDir.compare(the_instance.OutputDir) != 0)
1263159b3361Sopenharmony_ci		);
1264159b3361Sopenharmony_ci}
1265159b3361Sopenharmony_ci
1266159b3361Sopenharmony_civoid AEncodeProperties::SelectSavedParams(const std::string the_string)
1267159b3361Sopenharmony_ci{
1268159b3361Sopenharmony_ci	// get the values from the saved file if possible
1269159b3361Sopenharmony_ci	if (my_stored_data.LoadFile(my_store_location))
1270159b3361Sopenharmony_ci	{
1271159b3361Sopenharmony_ci		TiXmlNode* node;
1272159b3361Sopenharmony_ci
1273159b3361Sopenharmony_ci		node = my_stored_data.FirstChild("lame_acm");
1274159b3361Sopenharmony_ci
1275159b3361Sopenharmony_ci		TiXmlElement* CurrentNode = node->FirstChildElement("encodings");
1276159b3361Sopenharmony_ci
1277159b3361Sopenharmony_ci		if (CurrentNode != NULL)
1278159b3361Sopenharmony_ci		{
1279159b3361Sopenharmony_ci			CurrentNode->SetAttribute("default",the_string);
1280159b3361Sopenharmony_ci			GetValuesFromKey(the_string, *CurrentNode);
1281159b3361Sopenharmony_ci			my_stored_data.SaveFile(my_store_location);
1282159b3361Sopenharmony_ci		}
1283159b3361Sopenharmony_ci	}
1284159b3361Sopenharmony_ci}
1285159b3361Sopenharmony_ci
1286159b3361Sopenharmony_ciinline void AEncodeProperties::SetAttributeBool(TiXmlElement * the_elt,const std::string & the_string, const bool the_value) const
1287159b3361Sopenharmony_ci{
1288159b3361Sopenharmony_ci	if (the_value == false)
1289159b3361Sopenharmony_ci		the_elt->SetAttribute(the_string, "false");
1290159b3361Sopenharmony_ci	else
1291159b3361Sopenharmony_ci		the_elt->SetAttribute(the_string, "true");
1292159b3361Sopenharmony_ci}
1293159b3361Sopenharmony_ci
1294159b3361Sopenharmony_civoid AEncodeProperties::SaveValuesToElement(TiXmlElement * the_element) const
1295159b3361Sopenharmony_ci{
1296159b3361Sopenharmony_ci	// get all the parameters saved in this Element
1297159b3361Sopenharmony_ci	TiXmlElement * tmpElt;
1298159b3361Sopenharmony_ci
1299159b3361Sopenharmony_ci	// Bit Reservoir parameter
1300159b3361Sopenharmony_ci/*
1301159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("Bit_reservoir");
1302159b3361Sopenharmony_ci	if (tmpElt == NULL)
1303159b3361Sopenharmony_ci	{
1304159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("Bit_reservoir");
1305159b3361Sopenharmony_ci		SetAttributeBool(tmpElt, "use", !bNoBitRes);
1306159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1307159b3361Sopenharmony_ci	}
1308159b3361Sopenharmony_ci	else
1309159b3361Sopenharmony_ci	{
1310159b3361Sopenharmony_ci		SetAttributeBool(tmpElt, "use", !bNoBitRes);
1311159b3361Sopenharmony_ci	}
1312159b3361Sopenharmony_ci*/
1313159b3361Sopenharmony_ci	// Copyright parameter
1314159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("Copyright");
1315159b3361Sopenharmony_ci	if (tmpElt == NULL)
1316159b3361Sopenharmony_ci	{
1317159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("Copyright");
1318159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bCopyright);
1319159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1320159b3361Sopenharmony_ci	}
1321159b3361Sopenharmony_ci	else
1322159b3361Sopenharmony_ci	{
1323159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bCopyright);
1324159b3361Sopenharmony_ci	}
1325159b3361Sopenharmony_ci
1326159b3361Sopenharmony_ci	// Smart Output parameter
1327159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("Smart");
1328159b3361Sopenharmony_ci	if (tmpElt == NULL)
1329159b3361Sopenharmony_ci	{
1330159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("Smart");
1331159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bSmartOutput);
1332159b3361Sopenharmony_ci		tmpElt->SetAttribute("ratio", SmartRatioMax);
1333159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1334159b3361Sopenharmony_ci	}
1335159b3361Sopenharmony_ci	else
1336159b3361Sopenharmony_ci	{
1337159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bSmartOutput);
1338159b3361Sopenharmony_ci		tmpElt->SetAttribute("ratio", SmartRatioMax);
1339159b3361Sopenharmony_ci	}
1340159b3361Sopenharmony_ci
1341159b3361Sopenharmony_ci	// Smart Output parameter
1342159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("ABR");
1343159b3361Sopenharmony_ci	if (tmpElt == NULL)
1344159b3361Sopenharmony_ci	{
1345159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("ABR");
1346159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bAbrOutput);
1347159b3361Sopenharmony_ci		tmpElt->SetAttribute("min", AverageBitrate_Min);
1348159b3361Sopenharmony_ci		tmpElt->SetAttribute("max", AverageBitrate_Max);
1349159b3361Sopenharmony_ci		tmpElt->SetAttribute("step", AverageBitrate_Step);
1350159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1351159b3361Sopenharmony_ci	}
1352159b3361Sopenharmony_ci	else
1353159b3361Sopenharmony_ci	{
1354159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bAbrOutput);
1355159b3361Sopenharmony_ci		tmpElt->SetAttribute("min", AverageBitrate_Min);
1356159b3361Sopenharmony_ci		tmpElt->SetAttribute("max", AverageBitrate_Max);
1357159b3361Sopenharmony_ci		tmpElt->SetAttribute("step", AverageBitrate_Step);
1358159b3361Sopenharmony_ci	}
1359159b3361Sopenharmony_ci
1360159b3361Sopenharmony_ci	// CRC parameter
1361159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("CRC");
1362159b3361Sopenharmony_ci	if (tmpElt == NULL)
1363159b3361Sopenharmony_ci	{
1364159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("CRC");
1365159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bCRC);
1366159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1367159b3361Sopenharmony_ci	}
1368159b3361Sopenharmony_ci	else
1369159b3361Sopenharmony_ci	{
1370159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bCRC);
1371159b3361Sopenharmony_ci	}
1372159b3361Sopenharmony_ci
1373159b3361Sopenharmony_ci	// Original parameter
1374159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("Original");
1375159b3361Sopenharmony_ci	if (tmpElt == NULL)
1376159b3361Sopenharmony_ci	{
1377159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("Original");
1378159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bOriginal);
1379159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1380159b3361Sopenharmony_ci	}
1381159b3361Sopenharmony_ci	else
1382159b3361Sopenharmony_ci	{
1383159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bOriginal);
1384159b3361Sopenharmony_ci	}
1385159b3361Sopenharmony_ci
1386159b3361Sopenharmony_ci	// Private parameter
1387159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("Private");
1388159b3361Sopenharmony_ci	if (tmpElt == NULL)
1389159b3361Sopenharmony_ci	{
1390159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("Private");
1391159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bPrivate);
1392159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1393159b3361Sopenharmony_ci	}
1394159b3361Sopenharmony_ci	else
1395159b3361Sopenharmony_ci	{
1396159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bPrivate);
1397159b3361Sopenharmony_ci	}
1398159b3361Sopenharmony_ci
1399159b3361Sopenharmony_ci	// Channel Mode parameter
1400159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("Channel");
1401159b3361Sopenharmony_ci	if (tmpElt == NULL)
1402159b3361Sopenharmony_ci	{
1403159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("Channel");
1404159b3361Sopenharmony_ci		tmpElt->SetAttribute("mode", GetChannelModeString(nChannelIndex));
1405159b3361Sopenharmony_ci//		SetAttributeBool( tmpElt, "force", bForceChannel);
1406159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1407159b3361Sopenharmony_ci	}
1408159b3361Sopenharmony_ci	else
1409159b3361Sopenharmony_ci	{
1410159b3361Sopenharmony_ci		tmpElt->SetAttribute("mode", GetChannelModeString(nChannelIndex));
1411159b3361Sopenharmony_ci//		SetAttributeBool( tmpElt, "force", bForceChannel);
1412159b3361Sopenharmony_ci	}
1413159b3361Sopenharmony_ci/*
1414159b3361Sopenharmony_ci	// Preset parameter
1415159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("Preset");
1416159b3361Sopenharmony_ci	if (tmpElt == NULL)
1417159b3361Sopenharmony_ci	{
1418159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("Preset");
1419159b3361Sopenharmony_ci		tmpElt->SetAttribute("type", GetPresetModeString(nPresetIndex));
1420159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1421159b3361Sopenharmony_ci	}
1422159b3361Sopenharmony_ci	else
1423159b3361Sopenharmony_ci	{
1424159b3361Sopenharmony_ci		tmpElt->SetAttribute("type", GetPresetModeString(nPresetIndex));
1425159b3361Sopenharmony_ci	}
1426159b3361Sopenharmony_ci
1427159b3361Sopenharmony_ci	// Bitrate parameter
1428159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("bitrate");
1429159b3361Sopenharmony_ci	if (tmpElt == NULL)
1430159b3361Sopenharmony_ci	{
1431159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("bitrate");
1432159b3361Sopenharmony_ci		tmpElt->SetAttribute("min", the_Bitrates[nMinBitrateIndex]);
1433159b3361Sopenharmony_ci		tmpElt->SetAttribute("max", the_Bitrates[nMaxBitrateIndex]);
1434159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1435159b3361Sopenharmony_ci	}
1436159b3361Sopenharmony_ci	else
1437159b3361Sopenharmony_ci	{
1438159b3361Sopenharmony_ci		tmpElt->SetAttribute("min", the_Bitrates[nMinBitrateIndex]);
1439159b3361Sopenharmony_ci		tmpElt->SetAttribute("max", the_Bitrates[nMaxBitrateIndex]);
1440159b3361Sopenharmony_ci	}
1441159b3361Sopenharmony_ci
1442159b3361Sopenharmony_ci	// Output Directory parameter
1443159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("output");
1444159b3361Sopenharmony_ci	if (tmpElt == NULL)
1445159b3361Sopenharmony_ci	{
1446159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("output");
1447159b3361Sopenharmony_ci		tmpElt->SetAttribute("path", OutputDir);
1448159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1449159b3361Sopenharmony_ci	}
1450159b3361Sopenharmony_ci	else
1451159b3361Sopenharmony_ci	{
1452159b3361Sopenharmony_ci		tmpElt->SetAttribute("path", OutputDir);
1453159b3361Sopenharmony_ci	}
1454159b3361Sopenharmony_ci*/
1455159b3361Sopenharmony_ci/*
1456159b3361Sopenharmony_ci	// Resampling parameter
1457159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("resampling");
1458159b3361Sopenharmony_ci	if (tmpElt == NULL)
1459159b3361Sopenharmony_ci	{
1460159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("resampling");
1461159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bResample);
1462159b3361Sopenharmony_ci		tmpElt->SetAttribute("freq", the_SamplingFreqs[nSamplingFreqIndex]);
1463159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1464159b3361Sopenharmony_ci	}
1465159b3361Sopenharmony_ci	else
1466159b3361Sopenharmony_ci	{
1467159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "use", bResample);
1468159b3361Sopenharmony_ci		tmpElt->SetAttribute("freq", the_SamplingFreqs[nSamplingFreqIndex]);
1469159b3361Sopenharmony_ci	}
1470159b3361Sopenharmony_ci
1471159b3361Sopenharmony_ci	// VBR parameter
1472159b3361Sopenharmony_ci	tmpElt = the_element->FirstChildElement("VBR");
1473159b3361Sopenharmony_ci	if (tmpElt == NULL)
1474159b3361Sopenharmony_ci	{
1475159b3361Sopenharmony_ci		tmpElt = new TiXmlElement("VBR");
1476159b3361Sopenharmony_ci
1477159b3361Sopenharmony_ci		if (mBRmode == BR_ABR)
1478159b3361Sopenharmony_ci			tmpElt->SetAttribute("use", "ABR");
1479159b3361Sopenharmony_ci		else
1480159b3361Sopenharmony_ci			SetAttributeBool( tmpElt, "use", (mBRmode != BR_CBR));
1481159b3361Sopenharmony_ci
1482159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "header", bXingFrame);
1483159b3361Sopenharmony_ci		tmpElt->SetAttribute("quality", VbrQuality);
1484159b3361Sopenharmony_ci		tmpElt->SetAttribute("average", AverageBitrate);
1485159b3361Sopenharmony_ci		the_element->InsertEndChild(*tmpElt);
1486159b3361Sopenharmony_ci	}
1487159b3361Sopenharmony_ci	else
1488159b3361Sopenharmony_ci	{
1489159b3361Sopenharmony_ci		if (mBRmode == BR_ABR)
1490159b3361Sopenharmony_ci			tmpElt->SetAttribute("use", "ABR");
1491159b3361Sopenharmony_ci		else
1492159b3361Sopenharmony_ci			SetAttributeBool( tmpElt, "use", (mBRmode != BR_CBR));
1493159b3361Sopenharmony_ci
1494159b3361Sopenharmony_ci		SetAttributeBool( tmpElt, "header", bXingFrame);
1495159b3361Sopenharmony_ci		tmpElt->SetAttribute("quality", VbrQuality);
1496159b3361Sopenharmony_ci		tmpElt->SetAttribute("average", AverageBitrate);
1497159b3361Sopenharmony_ci	}
1498159b3361Sopenharmony_ci*/
1499159b3361Sopenharmony_ci}
1500159b3361Sopenharmony_ci
1501159b3361Sopenharmony_cibool AEncodeProperties::HandleDialogCommand(const HWND parentWnd, const WPARAM wParam, const LPARAM lParam)
1502159b3361Sopenharmony_ci{
1503159b3361Sopenharmony_ci	UINT command;
1504159b3361Sopenharmony_ci	command = GET_WM_COMMAND_ID(wParam, lParam);
1505159b3361Sopenharmony_ci
1506159b3361Sopenharmony_ci	switch (command)
1507159b3361Sopenharmony_ci	{
1508159b3361Sopenharmony_ci	case IDOK :
1509159b3361Sopenharmony_ci	{
1510159b3361Sopenharmony_ci		bool bShouldEnd = true;
1511159b3361Sopenharmony_ci
1512159b3361Sopenharmony_ci		// save parameters
1513159b3361Sopenharmony_ci		char string[MAX_PATH];
1514159b3361Sopenharmony_ci//		::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH);
1515159b3361Sopenharmony_ci
1516159b3361Sopenharmony_ci		wsprintf(string,"Current"); // only the Current config is supported at the moment
1517159b3361Sopenharmony_ci
1518159b3361Sopenharmony_ci		my_debug.OutPut("my_hModule = 0x%08X",my_hModule);
1519159b3361Sopenharmony_ci/*
1520159b3361Sopenharmony_ci		AEncodeProperties tmpDlgProps(my_hModule);
1521159b3361Sopenharmony_ci		AEncodeProperties tmpSavedProps(my_hModule);
1522159b3361Sopenharmony_ci//#ifdef OLD
1523159b3361Sopenharmony_ci		tmpDlgProps.UpdateValueFromDlg(parentWnd);
1524159b3361Sopenharmony_ci		tmpSavedProps.SelectSavedParams(string);
1525159b3361Sopenharmony_ci		tmpSavedProps.ParamsRestore();
1526159b3361Sopenharmony_ci		// check if the values from the DLG are the same as the one saved in the config file
1527159b3361Sopenharmony_ci		// if yes, just do nothing
1528159b3361Sopenharmony_ci/*
1529159b3361Sopenharmony_ci		if (tmpDlgProps != tmpSavedProps)
1530159b3361Sopenharmony_ci		{
1531159b3361Sopenharmony_ci			int save;
1532159b3361Sopenharmony_ci
1533159b3361Sopenharmony_ci			if (strcmp(string,"Current") == 0)
1534159b3361Sopenharmony_ci			{
1535159b3361Sopenharmony_ci				// otherwise, prompt the user if he wants to overwrite the settings
1536159b3361Sopenharmony_ci				TCHAR tmpStr[250];
1537159b3361Sopenharmony_ci				::LoadString(AOut::GetInstance(),IDS_STRING_PROMPT_REPLACE_CURRENT,tmpStr,250);
1538159b3361Sopenharmony_ci
1539159b3361Sopenharmony_ci				save = AOut::MyMessageBox( tmpStr, MB_OKCANCEL|MB_ICONQUESTION, parentWnd);
1540159b3361Sopenharmony_ci			}
1541159b3361Sopenharmony_ci			else
1542159b3361Sopenharmony_ci			{
1543159b3361Sopenharmony_ci				// otherwise, prompt the user if he wants to overwrite the settings
1544159b3361Sopenharmony_ci				TCHAR tmpStr[250];
1545159b3361Sopenharmony_ci				::LoadString(AOut::GetInstance(),IDS_STRING_PROMPT_REPLACE_SETING,tmpStr,250);
1546159b3361Sopenharmony_ci				TCHAR tmpDsp[500];
1547159b3361Sopenharmony_ci				wsprintf(tmpDsp,tmpStr,string);
1548159b3361Sopenharmony_ci
1549159b3361Sopenharmony_ci				save = AOut::MyMessageBox( tmpDsp, MB_YESNOCANCEL|MB_ICONQUESTION, parentWnd);
1550159b3361Sopenharmony_ci			}
1551159b3361Sopenharmony_ci
1552159b3361Sopenharmony_ci			if (save == IDCANCEL)
1553159b3361Sopenharmony_ci				bShouldEnd = false;
1554159b3361Sopenharmony_ci			else if (save == IDNO)
1555159b3361Sopenharmony_ci			{
1556159b3361Sopenharmony_ci				// save the values in 'current'
1557159b3361Sopenharmony_ci				UpdateValueFromDlg(parentWnd);
1558159b3361Sopenharmony_ci				SaveValuesToStringKey("Current");
1559159b3361Sopenharmony_ci				SelectSavedParams("Current");
1560159b3361Sopenharmony_ci			}
1561159b3361Sopenharmony_ci			else
1562159b3361Sopenharmony_ci			{
1563159b3361Sopenharmony_ci				// do so and save in XML
1564159b3361Sopenharmony_ci				UpdateValueFromDlg(parentWnd);
1565159b3361Sopenharmony_ci				SaveValuesToStringKey(string);
1566159b3361Sopenharmony_ci			}
1567159b3361Sopenharmony_ci		}
1568159b3361Sopenharmony_ci*/
1569159b3361Sopenharmony_ci//#endif // OLD
1570159b3361Sopenharmony_cimy_debug.OutPut("before : nChannelIndex %d, bCRC %d, bCopyright %d, bOriginal %d, bPrivate %d",nChannelIndex, bCRC, bCopyright, bOriginal, bPrivate);
1571159b3361Sopenharmony_ci
1572159b3361Sopenharmony_cimy_debug.OutPut("call UpdateValueFromDlg");
1573159b3361Sopenharmony_ci
1574159b3361Sopenharmony_ci		UpdateValueFromDlg(parentWnd);
1575159b3361Sopenharmony_ci
1576159b3361Sopenharmony_cimy_debug.OutPut("call SaveValuesToStringKey");
1577159b3361Sopenharmony_ci
1578159b3361Sopenharmony_ci		SaveValuesToStringKey("Current"); // only Current config is supported now
1579159b3361Sopenharmony_ci
1580159b3361Sopenharmony_ci//		SaveParams(parentWnd);
1581159b3361Sopenharmony_ci
1582159b3361Sopenharmony_ci//my_debug.OutPut("call SelectSavedParams");
1583159b3361Sopenharmony_ci
1584159b3361Sopenharmony_ci//		SelectSavedParams(string);
1585159b3361Sopenharmony_ci//		UpdateDlgFromValue(parentWnd);
1586159b3361Sopenharmony_ci
1587159b3361Sopenharmony_cimy_debug.OutPut("finished saving");
1588159b3361Sopenharmony_ci
1589159b3361Sopenharmony_ci		if (bShouldEnd)
1590159b3361Sopenharmony_ci		{
1591159b3361Sopenharmony_ci			RemoveProp(parentWnd, "AEncodeProperties-Config");
1592159b3361Sopenharmony_ci
1593159b3361Sopenharmony_ci			EndDialog(parentWnd, true);
1594159b3361Sopenharmony_ci		}
1595159b3361Sopenharmony_ci	}
1596159b3361Sopenharmony_ci	break;
1597159b3361Sopenharmony_ci
1598159b3361Sopenharmony_ci	case IDCANCEL:
1599159b3361Sopenharmony_ci		RemoveProp(parentWnd, "AEncodeProperties-Config");
1600159b3361Sopenharmony_ci        EndDialog(parentWnd, false);
1601159b3361Sopenharmony_ci		break;
1602159b3361Sopenharmony_ci
1603159b3361Sopenharmony_ci/*	case IDC_FIND_DLL:
1604159b3361Sopenharmony_ci	{
1605159b3361Sopenharmony_ci		OPENFILENAME file;
1606159b3361Sopenharmony_ci		char DllLocation[512];
1607159b3361Sopenharmony_ci		wsprintf(DllLocation,"%s",GetDllLocation());
1608159b3361Sopenharmony_ci
1609159b3361Sopenharmony_ci		memset(&file, 0, sizeof(file));
1610159b3361Sopenharmony_ci		file.lStructSize = sizeof(file);
1611159b3361Sopenharmony_ci		file.hwndOwner  = parentWnd;
1612159b3361Sopenharmony_ci		file.Flags = OFN_FILEMUSTEXIST | OFN_NODEREFERENCELINKS | OFN_ENABLEHOOK | OFN_EXPLORER ;
1613159b3361Sopenharmony_ci///				file.lpstrFile = AOut::the_AOut->DllLocation;
1614159b3361Sopenharmony_ci		file.lpstrFile = DllLocation;
1615159b3361Sopenharmony_ci		file.lpstrFilter = "Lame DLL (lame_enc.dll)\0LAME_ENC.DLL\0DLL (*.dll)\0*.DLL\0All (*.*)\0*.*\0";
1616159b3361Sopenharmony_ci		file.nFilterIndex = 1;
1617159b3361Sopenharmony_ci		file.nMaxFile  = sizeof(DllLocation);
1618159b3361Sopenharmony_ci		file.lpfnHook  = DLLFindCallback; // use to validate the DLL chosen
1619159b3361Sopenharmony_ci
1620159b3361Sopenharmony_ci		GetOpenFileName(&file);
1621159b3361Sopenharmony_ci
1622159b3361Sopenharmony_ci		SetDllLocation(DllLocation);
1623159b3361Sopenharmony_ci		// use this filename if necessary
1624159b3361Sopenharmony_ci	}
1625159b3361Sopenharmony_ci	break;
1626159b3361Sopenharmony_ci*/
1627159b3361Sopenharmony_ci/*	case IDC_BUTTON_OUTPUT:
1628159b3361Sopenharmony_ci	{
1629159b3361Sopenharmony_ci#ifndef SIMPLE_FOLDER
1630159b3361Sopenharmony_ci		BROWSEINFO info;
1631159b3361Sopenharmony_ci		memset(&info,0,sizeof(info));
1632159b3361Sopenharmony_ci
1633159b3361Sopenharmony_ci		char FolderName[MAX_PATH];
1634159b3361Sopenharmony_ci
1635159b3361Sopenharmony_ci		info.hwndOwner = parentWnd;
1636159b3361Sopenharmony_ci		info.pszDisplayName  = FolderName;
1637159b3361Sopenharmony_ci		info.lpfn = BrowseFolderCallbackroc;
1638159b3361Sopenharmony_ci		info.lParam = (LPARAM) this;
1639159b3361Sopenharmony_ci
1640159b3361Sopenharmony_ci		// get the localised window title
1641159b3361Sopenharmony_ci		TCHAR output[250];
1642159b3361Sopenharmony_ci		::LoadString(AOut::GetInstance(),IDS_STRING_DIR_SELECT,output,250);
1643159b3361Sopenharmony_ci		info.lpszTitle = output;
1644159b3361Sopenharmony_ci
1645159b3361Sopenharmony_ci#ifdef BIF_EDITBOX
1646159b3361Sopenharmony_ci		info.ulFlags |= BIF_EDITBOX;
1647159b3361Sopenharmony_ci#else // BIF_EDITBOX
1648159b3361Sopenharmony_ci		info.ulFlags |= 0x0010;
1649159b3361Sopenharmony_ci#endif // BIF_EDITBOX
1650159b3361Sopenharmony_ci
1651159b3361Sopenharmony_ci#ifdef BIF_VALIDATE
1652159b3361Sopenharmony_ci		info.ulFlags |= BIF_VALIDATE;
1653159b3361Sopenharmony_ci#else // BIF_VALIDATE
1654159b3361Sopenharmony_ci		info.ulFlags |= 0x0020;
1655159b3361Sopenharmony_ci#endif // BIF_VALIDATE
1656159b3361Sopenharmony_ci
1657159b3361Sopenharmony_ci#ifdef BIF_NEWDIALOGSTYLE
1658159b3361Sopenharmony_ci		info.ulFlags |= BIF_NEWDIALOGSTYLE;
1659159b3361Sopenharmony_ci#else // BIF_NEWDIALOGSTYLE
1660159b3361Sopenharmony_ci		info.ulFlags |= 0x0040;
1661159b3361Sopenharmony_ci#endif // BIF_NEWDIALOGSTYLE
1662159b3361Sopenharmony_ci
1663159b3361Sopenharmony_ci		ITEMIDLIST *item = SHBrowseForFolder(&info);
1664159b3361Sopenharmony_ci
1665159b3361Sopenharmony_ci    	if (item != NULL)
1666159b3361Sopenharmony_ci		{
1667159b3361Sopenharmony_ci			char tmpOutputDir[MAX_PATH];
1668159b3361Sopenharmony_ci			wsprintf(tmpOutputDir,"%s",GetOutputDirectory());
1669159b3361Sopenharmony_ci
1670159b3361Sopenharmony_ci			SHGetPathFromIDList( item,tmpOutputDir );
1671159b3361Sopenharmony_ci			SetOutputDirectory( tmpOutputDir );
1672159b3361Sopenharmony_ci			::SetWindowText(GetDlgItem( parentWnd, IDC_EDIT_OUTPUTDIR), tmpOutputDir);
1673159b3361Sopenharmony_ci//					wsprintf(OutputDir,FolderName);
1674159b3361Sopenharmony_ci		}
1675159b3361Sopenharmony_ci#else // SIMPLE_FOLDER
1676159b3361Sopenharmony_ci		OPENFILENAME file;
1677159b3361Sopenharmony_ci
1678159b3361Sopenharmony_ci		memset(&file, 0, sizeof(file));
1679159b3361Sopenharmony_ci		file.lStructSize = sizeof(file);
1680159b3361Sopenharmony_ci		file.hwndOwner  = parentWnd;
1681159b3361Sopenharmony_ci		file.Flags = OFN_FILEMUSTEXIST | OFN_NODEREFERENCELINKS | OFN_ENABLEHOOK | OFN_EXPLORER ;
1682159b3361Sopenharmony_ci//				file.lpstrFile = GetDllLocation();
1683159b3361Sopenharmony_ci//				file.lpstrFile = GetOutputDirectory();
1684159b3361Sopenharmony_ci		file.lpstrInitialDir = GetOutputDirectory();
1685159b3361Sopenharmony_ci		file.lpstrFilter = "A Directory\0.*\0";
1686159b3361Sopenharmony_ci//				file.nFilterIndex = 1;
1687159b3361Sopenharmony_ci		file.nMaxFile  = MAX_PATH;
1688159b3361Sopenharmony_ci//				file.lpfnHook  = DLLFindCallback; // use to validate the DLL chosen
1689159b3361Sopenharmony_ci//				file.Flags = OFN_ENABLESIZING | OFN_NOREADONLYRETURN | OFN_HIDEREADONLY;
1690159b3361Sopenharmony_ci		file.Flags = OFN_NOREADONLYRETURN | OFN_HIDEREADONLY | OFN_EXPLORER;
1691159b3361Sopenharmony_ci
1692159b3361Sopenharmony_ci		TCHAR output[250];
1693159b3361Sopenharmony_ci		::LoadString(AOut::GetInstance(),IDS_STRING_DIR_SELECT,output,250);
1694159b3361Sopenharmony_ci		file.lpstrTitle = output;
1695159b3361Sopenharmony_ci
1696159b3361Sopenharmony_ci		GetSaveFileName(&file);
1697159b3361Sopenharmony_ci#endif // SIMPLE_FOLDER
1698159b3361Sopenharmony_ci	}
1699159b3361Sopenharmony_ci	break;
1700159b3361Sopenharmony_ci*/
1701159b3361Sopenharmony_ci		case IDC_CHECK_ENC_ABR:
1702159b3361Sopenharmony_ci			EnableAbrOptions(parentWnd, ::IsDlgButtonChecked( parentWnd, IDC_CHECK_ENC_ABR) == BST_CHECKED);
1703159b3361Sopenharmony_ci			break;
1704159b3361Sopenharmony_ci/*	case IDC_RADIO_BITRATE_CBR:
1705159b3361Sopenharmony_ci		AEncodeProperties::DisplayVbrOptions(parentWnd, AEncodeProperties::BR_CBR);
1706159b3361Sopenharmony_ci		break;
1707159b3361Sopenharmony_ci
1708159b3361Sopenharmony_ci	case IDC_RADIO_BITRATE_VBR:
1709159b3361Sopenharmony_ci		AEncodeProperties::DisplayVbrOptions(parentWnd, AEncodeProperties::BR_VBR);
1710159b3361Sopenharmony_ci		break;
1711159b3361Sopenharmony_ci
1712159b3361Sopenharmony_ci	case IDC_RADIO_BITRATE_ABR:
1713159b3361Sopenharmony_ci		AEncodeProperties::DisplayVbrOptions(parentWnd, AEncodeProperties::BR_ABR);
1714159b3361Sopenharmony_ci		break;
1715159b3361Sopenharmony_ci
1716159b3361Sopenharmony_ci	case IDC_CHECK_RESAMPLE:
1717159b3361Sopenharmony_ci	{
1718159b3361Sopenharmony_ci		bool tmp_bResampleUsed = (::IsDlgButtonChecked( parentWnd, IDC_CHECK_RESAMPLE) == BST_CHECKED);
1719159b3361Sopenharmony_ci		if (tmp_bResampleUsed)
1720159b3361Sopenharmony_ci		{
1721159b3361Sopenharmony_ci			::EnableWindow(::GetDlgItem(parentWnd,IDC_COMBO_SAMPLEFREQ), TRUE);
1722159b3361Sopenharmony_ci		}
1723159b3361Sopenharmony_ci		else
1724159b3361Sopenharmony_ci		{
1725159b3361Sopenharmony_ci			::EnableWindow(::GetDlgItem(parentWnd,IDC_COMBO_SAMPLEFREQ), FALSE);
1726159b3361Sopenharmony_ci		}
1727159b3361Sopenharmony_ci	}
1728159b3361Sopenharmony_ci	break;
1729159b3361Sopenharmony_ci*/
1730159b3361Sopenharmony_ci/*	case IDC_COMBO_SETTINGS:
1731159b3361Sopenharmony_ci//				if (CBN_SELCHANGE == GET_WM_COMMAND_CMD(wParam, lParam))
1732159b3361Sopenharmony_ci		if (CBN_SELENDOK == GET_WM_COMMAND_CMD(wParam, lParam))
1733159b3361Sopenharmony_ci		{
1734159b3361Sopenharmony_ci			char string[MAX_PATH];
1735159b3361Sopenharmony_ci			int nIdx = SendMessage(HWND(lParam), CB_GETCURSEL, NULL, NULL);
1736159b3361Sopenharmony_ci			SendMessage(HWND(lParam), CB_GETLBTEXT , nIdx, (LPARAM) string);
1737159b3361Sopenharmony_ci
1738159b3361Sopenharmony_ci			// get the info corresponding to the new selected item
1739159b3361Sopenharmony_ci			SelectSavedParams(string);
1740159b3361Sopenharmony_ci			UpdateDlgFromValue(parentWnd);
1741159b3361Sopenharmony_ci		}
1742159b3361Sopenharmony_ci		break;
1743159b3361Sopenharmony_ci*/
1744159b3361Sopenharmony_ci/*	case IDC_BUTTON_CONFIG_SAVE:
1745159b3361Sopenharmony_ci	{
1746159b3361Sopenharmony_ci		// save the data in the current config
1747159b3361Sopenharmony_ci		char string[MAX_PATH];
1748159b3361Sopenharmony_ci		::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH);
1749159b3361Sopenharmony_ci
1750159b3361Sopenharmony_ci		UpdateValueFromDlg(parentWnd);
1751159b3361Sopenharmony_ci		SaveValuesToStringKey(string);
1752159b3361Sopenharmony_ci		SelectSavedParams(string);
1753159b3361Sopenharmony_ci		UpdateConfigs(parentWnd);
1754159b3361Sopenharmony_ci		UpdateDlgFromValue(parentWnd);
1755159b3361Sopenharmony_ci	}
1756159b3361Sopenharmony_ci	break;
1757159b3361Sopenharmony_ci
1758159b3361Sopenharmony_ci	case IDC_BUTTON_CONFIG_RENAME:
1759159b3361Sopenharmony_ci	{
1760159b3361Sopenharmony_ci		char string[MAX_PATH];
1761159b3361Sopenharmony_ci		::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH);
1762159b3361Sopenharmony_ci
1763159b3361Sopenharmony_ci		if (RenameCurrentTo(string))
1764159b3361Sopenharmony_ci		{
1765159b3361Sopenharmony_ci			// Update the names displayed
1766159b3361Sopenharmony_ci			UpdateConfigs(parentWnd);
1767159b3361Sopenharmony_ci		}
1768159b3361Sopenharmony_ci
1769159b3361Sopenharmony_ci	}
1770159b3361Sopenharmony_ci	break;
1771159b3361Sopenharmony_ci
1772159b3361Sopenharmony_ci	case IDC_BUTTON_CONFIG_DELETE:
1773159b3361Sopenharmony_ci	{
1774159b3361Sopenharmony_ci		char string[MAX_PATH];
1775159b3361Sopenharmony_ci		::GetWindowText(::GetDlgItem( parentWnd, IDC_COMBO_SETTINGS), string, MAX_PATH);
1776159b3361Sopenharmony_ci
1777159b3361Sopenharmony_ci		if (DeleteConfig(string))
1778159b3361Sopenharmony_ci		{
1779159b3361Sopenharmony_ci			// Update the names displayed
1780159b3361Sopenharmony_ci			UpdateConfigs(parentWnd);
1781159b3361Sopenharmony_ci			UpdateDlgFromValue(parentWnd);
1782159b3361Sopenharmony_ci		}
1783159b3361Sopenharmony_ci	}
1784159b3361Sopenharmony_ci	break;
1785159b3361Sopenharmony_ci*/
1786159b3361Sopenharmony_ci	}
1787159b3361Sopenharmony_ci
1788159b3361Sopenharmony_ci    return FALSE;
1789159b3361Sopenharmony_ci}
1790159b3361Sopenharmony_ci
1791159b3361Sopenharmony_cibool AEncodeProperties::RenameCurrentTo(const std::string & new_config_name)
1792159b3361Sopenharmony_ci{
1793159b3361Sopenharmony_ci	bool bResult = false;
1794159b3361Sopenharmony_ci
1795159b3361Sopenharmony_ci	// display all the names of the saved configs
1796159b3361Sopenharmony_ci	// get the values from the saved file if possible
1797159b3361Sopenharmony_ci	if (my_stored_data.LoadFile(my_store_location))
1798159b3361Sopenharmony_ci	{
1799159b3361Sopenharmony_ci		TiXmlNode* node;
1800159b3361Sopenharmony_ci
1801159b3361Sopenharmony_ci		node = my_stored_data.FirstChild("lame_acm");
1802159b3361Sopenharmony_ci
1803159b3361Sopenharmony_ci		TiXmlElement* CurrentNode = node->FirstChildElement("encodings");
1804159b3361Sopenharmony_ci
1805159b3361Sopenharmony_ci		if (CurrentNode->Attribute("default") != NULL)
1806159b3361Sopenharmony_ci		{
1807159b3361Sopenharmony_ci			std::string CurrentConfigName = *CurrentNode->Attribute("default");
1808159b3361Sopenharmony_ci
1809159b3361Sopenharmony_ci			// no rename possible for Current
1810159b3361Sopenharmony_ci			if (CurrentConfigName == "")
1811159b3361Sopenharmony_ci			{
1812159b3361Sopenharmony_ci				bResult = true;
1813159b3361Sopenharmony_ci			}
1814159b3361Sopenharmony_ci			else if (CurrentConfigName != "Current")
1815159b3361Sopenharmony_ci			{
1816159b3361Sopenharmony_ci				// find the config that correspond to CurrentConfig
1817159b3361Sopenharmony_ci				TiXmlElement* iterateElmt = CurrentNode->FirstChildElement("config");
1818159b3361Sopenharmony_ci//				int Idx = 0;
1819159b3361Sopenharmony_ci				while (iterateElmt != NULL)
1820159b3361Sopenharmony_ci				{
1821159b3361Sopenharmony_ci					const std::string * tmpname = iterateElmt->Attribute("name");
1822159b3361Sopenharmony_ci					/**
1823159b3361Sopenharmony_ci						\todo support language names
1824159b3361Sopenharmony_ci					*/
1825159b3361Sopenharmony_ci					if (tmpname != NULL)
1826159b3361Sopenharmony_ci					{
1827159b3361Sopenharmony_ci						if (tmpname->compare(CurrentConfigName) == 0)
1828159b3361Sopenharmony_ci						{
1829159b3361Sopenharmony_ci							iterateElmt->SetAttribute("name",new_config_name);
1830159b3361Sopenharmony_ci							bResult = true;
1831159b3361Sopenharmony_ci							break;
1832159b3361Sopenharmony_ci						}
1833159b3361Sopenharmony_ci					}
1834159b3361Sopenharmony_ci//					Idx++;
1835159b3361Sopenharmony_ci					iterateElmt = iterateElmt->NextSiblingElement("config");
1836159b3361Sopenharmony_ci				}
1837159b3361Sopenharmony_ci			}
1838159b3361Sopenharmony_ci
1839159b3361Sopenharmony_ci			if (bResult)
1840159b3361Sopenharmony_ci			{
1841159b3361Sopenharmony_ci				CurrentNode->SetAttribute("default",new_config_name);
1842159b3361Sopenharmony_ci
1843159b3361Sopenharmony_ci				my_stored_data.SaveFile(my_store_location);
1844159b3361Sopenharmony_ci			}
1845159b3361Sopenharmony_ci		}
1846159b3361Sopenharmony_ci	}
1847159b3361Sopenharmony_ci
1848159b3361Sopenharmony_ci	return bResult;
1849159b3361Sopenharmony_ci}
1850159b3361Sopenharmony_ci
1851159b3361Sopenharmony_cibool AEncodeProperties::DeleteConfig(const std::string & config_name)
1852159b3361Sopenharmony_ci{
1853159b3361Sopenharmony_ci	bool bResult = false;
1854159b3361Sopenharmony_ci
1855159b3361Sopenharmony_ci	if (config_name != "Current")
1856159b3361Sopenharmony_ci	{
1857159b3361Sopenharmony_ci		// display all the names of the saved configs
1858159b3361Sopenharmony_ci		// get the values from the saved file if possible
1859159b3361Sopenharmony_ci		if (my_stored_data.LoadFile(my_store_location))
1860159b3361Sopenharmony_ci		{
1861159b3361Sopenharmony_ci			TiXmlNode* node;
1862159b3361Sopenharmony_ci
1863159b3361Sopenharmony_ci			node = my_stored_data.FirstChild("lame_acm");
1864159b3361Sopenharmony_ci
1865159b3361Sopenharmony_ci			TiXmlElement* CurrentNode = node->FirstChildElement("encodings");
1866159b3361Sopenharmony_ci
1867159b3361Sopenharmony_ci			TiXmlElement* iterateElmt = CurrentNode->FirstChildElement("config");
1868159b3361Sopenharmony_ci//			int Idx = 0;
1869159b3361Sopenharmony_ci			while (iterateElmt != NULL)
1870159b3361Sopenharmony_ci			{
1871159b3361Sopenharmony_ci				const std::string * tmpname = iterateElmt->Attribute("name");
1872159b3361Sopenharmony_ci				/**
1873159b3361Sopenharmony_ci					\todo support language names
1874159b3361Sopenharmony_ci				*/
1875159b3361Sopenharmony_ci				if (tmpname != NULL)
1876159b3361Sopenharmony_ci				{
1877159b3361Sopenharmony_ci					if (tmpname->compare(config_name) == 0)
1878159b3361Sopenharmony_ci					{
1879159b3361Sopenharmony_ci						CurrentNode->RemoveChild(iterateElmt);
1880159b3361Sopenharmony_ci						bResult = true;
1881159b3361Sopenharmony_ci						break;
1882159b3361Sopenharmony_ci					}
1883159b3361Sopenharmony_ci				}
1884159b3361Sopenharmony_ci//				Idx++;
1885159b3361Sopenharmony_ci				iterateElmt = iterateElmt->NextSiblingElement("config");
1886159b3361Sopenharmony_ci			}
1887159b3361Sopenharmony_ci		}
1888159b3361Sopenharmony_ci
1889159b3361Sopenharmony_ci		if (bResult)
1890159b3361Sopenharmony_ci		{
1891159b3361Sopenharmony_ci			my_stored_data.SaveFile(my_store_location);
1892159b3361Sopenharmony_ci
1893159b3361Sopenharmony_ci			// select a new default config : "Current"
1894159b3361Sopenharmony_ci			SelectSavedParams("Current");
1895159b3361Sopenharmony_ci
1896159b3361Sopenharmony_ci		}
1897159b3361Sopenharmony_ci	}
1898159b3361Sopenharmony_ci
1899159b3361Sopenharmony_ci	return bResult;
1900159b3361Sopenharmony_ci}
1901159b3361Sopenharmony_ci
1902159b3361Sopenharmony_civoid AEncodeProperties::UpdateConfigs(const HWND HwndDlg)
1903159b3361Sopenharmony_ci{
1904159b3361Sopenharmony_ci	// Add User configs
1905159b3361Sopenharmony_ci//	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_RESETCONTENT , NULL, NULL);
1906159b3361Sopenharmony_ci
1907159b3361Sopenharmony_ci	// display all the names of the saved configs
1908159b3361Sopenharmony_ci	// get the values from the saved file if possible
1909159b3361Sopenharmony_ci	if (my_stored_data.LoadFile(my_store_location))
1910159b3361Sopenharmony_ci	{
1911159b3361Sopenharmony_ci		TiXmlNode* node;
1912159b3361Sopenharmony_ci
1913159b3361Sopenharmony_ci		node = my_stored_data.FirstChild("lame_acm");
1914159b3361Sopenharmony_ci
1915159b3361Sopenharmony_ci		TiXmlElement* CurrentNode = node->FirstChildElement("encodings");
1916159b3361Sopenharmony_ci
1917159b3361Sopenharmony_ci		std::string CurrentConfig = "";
1918159b3361Sopenharmony_ci
1919159b3361Sopenharmony_ci		if (CurrentNode->Attribute("default") != NULL)
1920159b3361Sopenharmony_ci		{
1921159b3361Sopenharmony_ci			CurrentConfig = *CurrentNode->Attribute("default");
1922159b3361Sopenharmony_ci		}
1923159b3361Sopenharmony_ci
1924159b3361Sopenharmony_ci		TiXmlElement* iterateElmt;
1925159b3361Sopenharmony_ci
1926159b3361Sopenharmony_cimy_debug.OutPut("are we here ?");
1927159b3361Sopenharmony_ci
1928159b3361Sopenharmony_ci		// find the config that correspond to CurrentConfig
1929159b3361Sopenharmony_ci		iterateElmt = CurrentNode->FirstChildElement("config");
1930159b3361Sopenharmony_ci		int Idx = 0;
1931159b3361Sopenharmony_ci		while (iterateElmt != NULL)
1932159b3361Sopenharmony_ci		{
1933159b3361Sopenharmony_ci			const std::string * tmpname = iterateElmt->Attribute("name");
1934159b3361Sopenharmony_ci			/**
1935159b3361Sopenharmony_ci				\todo support language names
1936159b3361Sopenharmony_ci			*/
1937159b3361Sopenharmony_ci			if (tmpname != NULL)
1938159b3361Sopenharmony_ci			{
1939159b3361Sopenharmony_ci//				SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_ADDSTRING, NULL, (LPARAM) tmpname->c_str());
1940159b3361Sopenharmony_ci				if (tmpname->compare(CurrentConfig) == 0)
1941159b3361Sopenharmony_ci				{
1942159b3361Sopenharmony_ci//					SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_SETCURSEL, Idx, NULL);
1943159b3361Sopenharmony_ci					SelectSavedParams(*tmpname);
1944159b3361Sopenharmony_ci					UpdateDlgFromValue(HwndDlg);
1945159b3361Sopenharmony_ci				}
1946159b3361Sopenharmony_ci			}
1947159b3361Sopenharmony_cimy_debug.OutPut("Idx = %d",Idx);
1948159b3361Sopenharmony_ci
1949159b3361Sopenharmony_ci			Idx++;
1950159b3361Sopenharmony_ci			// only Current config supported now
1951159b3361Sopenharmony_ci//			iterateElmt = iterateElmt->NextSiblingElement("config");
1952159b3361Sopenharmony_ci			iterateElmt = NULL;
1953159b3361Sopenharmony_cimy_debug.OutPut("iterateElmt = 0x%08X",iterateElmt);
1954159b3361Sopenharmony_ci
1955159b3361Sopenharmony_ci		}
1956159b3361Sopenharmony_ci	}
1957159b3361Sopenharmony_ci}
1958159b3361Sopenharmony_ci/*
1959159b3361Sopenharmony_civoid AEncodeProperties::UpdateAbrSteps(unsigned int min, unsigned int max, unsigned int step) const
1960159b3361Sopenharmony_ci{
1961159b3361Sopenharmony_ci}
1962159b3361Sopenharmony_ci*/
1963159b3361Sopenharmony_civoid AEncodeProperties::UpdateDlgFromSlides(HWND hwndDlg) const
1964159b3361Sopenharmony_ci{
1965159b3361Sopenharmony_ci	UINT value_min, value_max, value_step, value;
1966159b3361Sopenharmony_ci	char tmp[4];
1967159b3361Sopenharmony_ci
1968159b3361Sopenharmony_ci	value_min = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_GETPOS, NULL, NULL);
1969159b3361Sopenharmony_ci	value_max = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_GETPOS, NULL, NULL);
1970159b3361Sopenharmony_ci
1971159b3361Sopenharmony_ci	if (value_min>value_max)
1972159b3361Sopenharmony_ci	{
1973159b3361Sopenharmony_ci		SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_SETPOS, TRUE, value_max);
1974159b3361Sopenharmony_ci		UpdateDlgFromSlides(hwndDlg);
1975159b3361Sopenharmony_ci		return;
1976159b3361Sopenharmony_ci	}
1977159b3361Sopenharmony_ci
1978159b3361Sopenharmony_ci	if (value_max<value_min)
1979159b3361Sopenharmony_ci	{
1980159b3361Sopenharmony_ci		SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_SETPOS, TRUE, value_min);
1981159b3361Sopenharmony_ci		UpdateDlgFromSlides(hwndDlg);
1982159b3361Sopenharmony_ci		return;
1983159b3361Sopenharmony_ci	}
1984159b3361Sopenharmony_ci
1985159b3361Sopenharmony_ci	wsprintf(tmp,"%3d",value_min);
1986159b3361Sopenharmony_ci	::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_MIN_VALUE), tmp);
1987159b3361Sopenharmony_ci
1988159b3361Sopenharmony_ci	SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETRANGEMIN, TRUE, value_min);
1989159b3361Sopenharmony_ci
1990159b3361Sopenharmony_ci	wsprintf(tmp,"%3d",value_max);
1991159b3361Sopenharmony_ci	::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_MAX_VALUE), tmp);
1992159b3361Sopenharmony_ci
1993159b3361Sopenharmony_ci	SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETRANGEMAX, TRUE, value_max);
1994159b3361Sopenharmony_ci
1995159b3361Sopenharmony_ci	value_step = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_GETPOS, NULL, NULL);
1996159b3361Sopenharmony_ci	wsprintf(tmp,"%3d",value_step);
1997159b3361Sopenharmony_ci	::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_STEP_VALUE), tmp);
1998159b3361Sopenharmony_ci
1999159b3361Sopenharmony_ci	SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_CLEARTICS, TRUE, 0);
2000159b3361Sopenharmony_ci	for(UINT i=value_max; i>=value_min;i-=value_step)
2001159b3361Sopenharmony_ci	{
2002159b3361Sopenharmony_ci		SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETTIC, 0, i);
2003159b3361Sopenharmony_ci	}
2004159b3361Sopenharmony_ci	SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETLINESIZE, 0, value_step);
2005159b3361Sopenharmony_ci	SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETPAGESIZE, 0, value_step);
2006159b3361Sopenharmony_ci
2007159b3361Sopenharmony_ci	value = SendMessage(GetDlgItem( hwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_GETPOS, NULL, NULL);
2008159b3361Sopenharmony_ci	wsprintf(tmp,"%3d",value);
2009159b3361Sopenharmony_ci	::SetWindowText(GetDlgItem( hwndDlg, IDC_STATIC_AVERAGE_SAMPLE_VALUE), tmp);
2010159b3361Sopenharmony_ci}
2011159b3361Sopenharmony_ci
2012159b3361Sopenharmony_civoid AEncodeProperties::EnableAbrOptions(HWND hDialog, bool enable)
2013159b3361Sopenharmony_ci{
2014159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_MIN), enable);
2015159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_MAX), enable);
2016159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_STEP), enable);
2017159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_AVERAGE_SAMPLE), enable);
2018159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MIN), enable);
2019159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MAX), enable);
2020159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_STEP), enable);
2021159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_SAMPLE), enable);
2022159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MIN_VALUE), enable);
2023159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_MAX_VALUE), enable);
2024159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_STEP_VALUE), enable);
2025159b3361Sopenharmony_ci	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_AVERAGE_SAMPLE_VALUE), enable);
2026159b3361Sopenharmony_ci}
2027159b3361Sopenharmony_ci
2028