2
* LAME MP3 encoder for DirectShow
3
* Advanced property page
5
* Copyright (c) 2000-2005 Marie Orlova, Peter Gubanov, Vitaly Ivanov, Elecard Ltd.
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Library General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Library General Public License for more details.
17
* You should have received a copy of the GNU Library General Public
18
* License along with this library; if not, write to the
19
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
26
#include "iaudioprops.h"
29
#include "PropPage_adv.h"
32
#define MPG_MD_STEREO 0
33
#define MPG_MD_JOINT_STEREO 1
34
#define MPG_MD_DUAL_CHANNEL 2
37
// Strings which apear in comboboxes
38
const char *chChMode[4] = {
44
////////////////////////////////////////////////////////////////
46
////////////////////////////////////////////////////////////////
47
CUnknown *CMpegAudEncPropertyPageAdv::CreateInstance( LPUNKNOWN punk, HRESULT *phr )
49
CMpegAudEncPropertyPageAdv *pNewObject
50
= new CMpegAudEncPropertyPageAdv( punk, phr );
52
if( pNewObject == NULL )
58
////////////////////////////////////////////////////////////////
60
////////////////////////////////////////////////////////////////
61
CMpegAudEncPropertyPageAdv::CMpegAudEncPropertyPageAdv(LPUNKNOWN punk, HRESULT *phr) :
62
CBasePropertyPage(NAME("Encoder Advanced Property Page"), punk, IDD_ADVPROPS, IDS_AUDIO_ADVANCED_TITLE),
73
// Give us the filter to communicate with
74
HRESULT CMpegAudEncPropertyPageAdv::OnConnect(IUnknown *pUnknown)
76
ASSERT(m_pAEProps == NULL);
78
// Ask the filter for it's control interface
80
HRESULT hr = pUnknown->QueryInterface(IID_IAudioEncoderProperties,(void **)&m_pAEProps);
81
if (FAILED(hr) || !m_pAEProps)
86
// Get current filter state
87
// m_pAEProps->LoadAudioEncoderPropertiesFromRegistry();
89
m_pAEProps->get_EnforceVBRmin(&m_dwEnforceVBRmin);
90
m_pAEProps->get_VoiceMode(&m_dwVoiceMode);
91
m_pAEProps->get_KeepAllFreq(&m_dwKeepAllFreq);
92
m_pAEProps->get_StrictISO(&m_dwStrictISO);
93
m_pAEProps->get_NoShortBlock(&m_dwNoShortBlock);
94
m_pAEProps->get_XingTag(&m_dwXingTag);
95
m_pAEProps->get_ChannelMode(&m_dwChannelMode);
96
m_pAEProps->get_ForceMS(&m_dwForceMS);
97
m_pAEProps->get_ModeFixed(&m_dwModeFixed);
98
m_pAEProps->get_SampleOverlap(&m_dwOverlap);
99
m_pAEProps->get_SetDuration(&m_dwSetStop);
107
// Release the interface
109
HRESULT CMpegAudEncPropertyPageAdv::OnDisconnect()
111
// Release the interface
112
if (m_pAEProps == NULL)
115
m_pAEProps->set_EnforceVBRmin(m_dwEnforceVBRmin);
116
m_pAEProps->set_VoiceMode(m_dwVoiceMode);
117
m_pAEProps->set_KeepAllFreq(m_dwKeepAllFreq);
118
m_pAEProps->set_StrictISO(m_dwStrictISO);
119
m_pAEProps->set_NoShortBlock(m_dwNoShortBlock);
120
m_pAEProps->set_XingTag(m_dwXingTag);
121
m_pAEProps->set_ChannelMode(m_dwChannelMode);
122
m_pAEProps->set_ForceMS(m_dwForceMS);
123
m_pAEProps->set_ModeFixed(m_dwModeFixed);
124
m_pAEProps->set_SampleOverlap(m_dwOverlap);
125
m_pAEProps->set_SetDuration(m_dwSetStop);
126
m_pAEProps->SaveAudioEncoderPropertiesToRegistry();
128
m_pAEProps->Release();
137
// Called on dialog creation
139
HRESULT CMpegAudEncPropertyPageAdv::OnActivate(void)
141
InitPropertiesDialog(m_hwnd);
149
// Called on dialog destruction
151
HRESULT CMpegAudEncPropertyPageAdv::OnDeactivate(void)
156
////////////////////////////////////////////////////////////////
157
// OnReceiveMessage - message handler function
158
////////////////////////////////////////////////////////////////
159
BOOL CMpegAudEncPropertyPageAdv::OnReceiveMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
164
switch (LOWORD(wParam))
166
case IDC_RADIO_STEREO:
167
case IDC_RADIO_JSTEREO:
172
DWORD dwChannelMode = LOWORD(wParam) - IDC_RADIO_STEREO;
173
CheckRadioButton(hwnd, IDC_RADIO_STEREO, IDC_RADIO_MONO, LOWORD(wParam));
175
if (dwChannelMode == MPG_MD_JOINT_STEREO)
176
EnableWindow(GetDlgItem(hwnd,IDC_CHECK_FORCE_MS),TRUE);
178
EnableWindow(GetDlgItem(hwnd,IDC_CHECK_FORCE_MS),FALSE);
180
m_pAEProps->set_ChannelMode(dwChannelMode);
185
case IDC_CHECK_ENFORCE_MIN:
186
m_pAEProps->set_EnforceVBRmin(IsDlgButtonChecked(hwnd, IDC_CHECK_ENFORCE_MIN));
190
case IDC_CHECK_VOICE:
191
m_pAEProps->set_VoiceMode(IsDlgButtonChecked(hwnd, IDC_CHECK_VOICE));
195
case IDC_CHECK_KEEP_ALL_FREQ:
196
m_pAEProps->set_KeepAllFreq(IsDlgButtonChecked(hwnd, IDC_CHECK_KEEP_ALL_FREQ));
200
case IDC_CHECK_STRICT_ISO:
201
m_pAEProps->set_StrictISO(IsDlgButtonChecked(hwnd, IDC_CHECK_STRICT_ISO));
205
case IDC_CHECK_DISABLE_SHORT_BLOCK:
206
m_pAEProps->set_NoShortBlock(IsDlgButtonChecked(hwnd, IDC_CHECK_DISABLE_SHORT_BLOCK));
210
case IDC_CHECK_XING_TAG:
211
m_pAEProps->set_XingTag(IsDlgButtonChecked(hwnd, IDC_CHECK_XING_TAG));
215
case IDC_CHECK_FORCE_MS:
216
m_pAEProps->set_ForceMS(IsDlgButtonChecked(hwnd, IDC_CHECK_FORCE_MS));
220
case IDC_CHECK_MODE_FIXED:
221
m_pAEProps->set_ModeFixed(IsDlgButtonChecked(hwnd, IDC_CHECK_MODE_FIXED));
225
case IDC_CHECK_OVERLAP:
226
m_pAEProps->set_SampleOverlap(IsDlgButtonChecked(hwnd, IDC_CHECK_OVERLAP));
231
m_pAEProps->set_SetDuration(IsDlgButtonChecked(hwnd, IDC_CHECK_STOP));
251
HRESULT CMpegAudEncPropertyPageAdv::OnApplyChanges()
253
m_pAEProps->get_EnforceVBRmin(&m_dwEnforceVBRmin);
254
m_pAEProps->get_VoiceMode(&m_dwVoiceMode);
255
m_pAEProps->get_KeepAllFreq(&m_dwKeepAllFreq);
256
m_pAEProps->get_StrictISO(&m_dwStrictISO);
257
m_pAEProps->get_ChannelMode(&m_dwChannelMode);
258
m_pAEProps->get_ForceMS(&m_dwForceMS);
259
m_pAEProps->get_NoShortBlock(&m_dwNoShortBlock);
260
m_pAEProps->get_XingTag(&m_dwXingTag);
261
m_pAEProps->get_ModeFixed(&m_dwModeFixed);
262
m_pAEProps->get_SampleOverlap(&m_dwOverlap);
263
m_pAEProps->get_SetDuration(&m_dwSetStop);
264
m_pAEProps->SaveAudioEncoderPropertiesToRegistry();
266
m_pAEProps->ApplyChanges();
272
// Initialize dialogbox controls with proper values
274
void CMpegAudEncPropertyPageAdv::InitPropertiesDialog(HWND hwndParent)
276
EnableControls(hwndParent, TRUE);
279
// initialize radio bottons
282
m_pAEProps->get_ChannelMode(&dwChannelMode);
283
CheckRadioButton(hwndParent, IDC_RADIO_STEREO, IDC_RADIO_MONO, IDC_RADIO_STEREO + dwChannelMode);
285
if (dwChannelMode == MPG_MD_JOINT_STEREO)
286
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_FORCE_MS), TRUE);
288
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_FORCE_MS), FALSE);
291
// initialize checkboxes
293
DWORD dwEnforceVBRmin;
294
m_pAEProps->get_EnforceVBRmin(&dwEnforceVBRmin);
295
CheckDlgButton(hwndParent, IDC_CHECK_ENFORCE_MIN, dwEnforceVBRmin ? BST_CHECKED : BST_UNCHECKED);
298
m_pAEProps->get_VoiceMode(&dwVoiceMode);
299
CheckDlgButton(hwndParent, IDC_CHECK_VOICE, dwVoiceMode ? BST_CHECKED : BST_UNCHECKED);
302
m_pAEProps->get_KeepAllFreq(&dwKeepAllFreq);
303
CheckDlgButton(hwndParent, IDC_CHECK_KEEP_ALL_FREQ, dwKeepAllFreq ? BST_CHECKED : BST_UNCHECKED);
306
m_pAEProps->get_StrictISO(&dwStrictISO);
307
CheckDlgButton(hwndParent, IDC_CHECK_STRICT_ISO, dwStrictISO ? BST_CHECKED : BST_UNCHECKED);
309
DWORD dwNoShortBlock;
310
m_pAEProps->get_NoShortBlock(&dwNoShortBlock);
311
CheckDlgButton(hwndParent, IDC_CHECK_DISABLE_SHORT_BLOCK, dwNoShortBlock ? BST_CHECKED : BST_UNCHECKED);
314
m_pAEProps->get_XingTag(&dwXingEnabled);
315
CheckDlgButton(hwndParent, IDC_CHECK_XING_TAG, dwXingEnabled ? BST_CHECKED : BST_UNCHECKED);
318
m_pAEProps->get_ForceMS(&dwForceMS);
319
CheckDlgButton(hwndParent, IDC_CHECK_FORCE_MS, dwForceMS ? BST_CHECKED : BST_UNCHECKED);
322
m_pAEProps->get_ModeFixed(&dwModeFixed);
323
CheckDlgButton(hwndParent, IDC_CHECK_MODE_FIXED, dwModeFixed ? BST_CHECKED : BST_UNCHECKED);
326
m_pAEProps->get_SampleOverlap(&dwOverlap);
327
CheckDlgButton(hwndParent, IDC_CHECK_OVERLAP, dwOverlap ? BST_CHECKED : BST_UNCHECKED);
330
m_pAEProps->get_SetDuration(&dwStopTime);
331
CheckDlgButton(hwndParent, IDC_CHECK_STOP, dwStopTime ? BST_CHECKED : BST_UNCHECKED);
335
////////////////////////////////////////////////////////////////
337
////////////////////////////////////////////////////////////////
338
void CMpegAudEncPropertyPageAdv::EnableControls(HWND hwndParent, bool bEnable)
340
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_ENFORCE_MIN), bEnable);
341
EnableWindow(GetDlgItem(hwndParent, IDC_RADIO_STEREO), bEnable);
342
EnableWindow(GetDlgItem(hwndParent, IDC_RADIO_JSTEREO), bEnable);
343
EnableWindow(GetDlgItem(hwndParent, IDC_RADIO_DUAL), bEnable);
344
EnableWindow(GetDlgItem(hwndParent, IDC_RADIO_MONO), bEnable);
345
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_FORCE_MS), bEnable);
346
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_VOICE), bEnable);
347
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_KEEP_ALL_FREQ), bEnable);
348
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_STRICT_ISO), bEnable);
349
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_DISABLE_SHORT_BLOCK), bEnable);
350
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_XING_TAG), bEnable);
351
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_MODE_FIXED), bEnable);
352
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_OVERLAP), bEnable);
353
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_STOP), bEnable);
359
// notifies the property page site of changes
361
void CMpegAudEncPropertyPageAdv::SetDirty()
365
m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);