| 1 |
/* |
| 2 |
* LAME MP3 encoder for DirectShow |
| 3 |
* Advanced property page |
| 4 |
* |
| 5 |
* Copyright (c) 2000-2005 Marie Orlova, Peter Gubanov, Vitaly Ivanov, Elecard Ltd. |
| 6 |
* |
| 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. |
| 11 |
* |
| 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. |
| 16 |
* |
| 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. |
| 21 |
*/ |
| 22 |
|
| 23 |
#include <streams.h> |
| 24 |
#include <olectl.h> |
| 25 |
#include <commctrl.h> |
| 26 |
#include "iaudioprops.h" |
| 27 |
#include "mpegac.h" |
| 28 |
#include "resource.h" |
| 29 |
#include "PropPage_adv.h" |
| 30 |
#include "Reg.h" |
| 31 |
|
| 32 |
#define MPG_MD_STEREO 0 |
| 33 |
#define MPG_MD_JOINT_STEREO 1 |
| 34 |
#define MPG_MD_DUAL_CHANNEL 2 |
| 35 |
#define MPG_MD_MONO 3 |
| 36 |
|
| 37 |
// Strings which apear in comboboxes |
| 38 |
const char *chChMode[4] = { |
| 39 |
"Mono", |
| 40 |
"Standard stereo", |
| 41 |
"Joint stereo", |
| 42 |
"Dual channel"}; |
| 43 |
|
| 44 |
//////////////////////////////////////////////////////////////// |
| 45 |
// CreateInstance |
| 46 |
//////////////////////////////////////////////////////////////// |
| 47 |
CUnknown *CMpegAudEncPropertyPageAdv::CreateInstance( LPUNKNOWN punk, HRESULT *phr ) |
| 48 |
{ |
| 49 |
CMpegAudEncPropertyPageAdv *pNewObject |
| 50 |
= new CMpegAudEncPropertyPageAdv( punk, phr ); |
| 51 |
|
| 52 |
if( pNewObject == NULL ) |
| 53 |
*phr = E_OUTOFMEMORY; |
| 54 |
|
| 55 |
return pNewObject; |
| 56 |
} |
| 57 |
|
| 58 |
//////////////////////////////////////////////////////////////// |
| 59 |
// Constructor |
| 60 |
//////////////////////////////////////////////////////////////// |
| 61 |
CMpegAudEncPropertyPageAdv::CMpegAudEncPropertyPageAdv(LPUNKNOWN punk, HRESULT *phr) : |
| 62 |
CBasePropertyPage(NAME("Encoder Advanced Property Page"), punk, IDD_ADVPROPS, IDS_AUDIO_ADVANCED_TITLE), |
| 63 |
m_pAEProps(NULL) |
| 64 |
{ |
| 65 |
ASSERT(phr); |
| 66 |
|
| 67 |
InitCommonControls(); |
| 68 |
} |
| 69 |
|
| 70 |
// |
| 71 |
// OnConnect |
| 72 |
// |
| 73 |
// Give us the filter to communicate with |
| 74 |
HRESULT CMpegAudEncPropertyPageAdv::OnConnect(IUnknown *pUnknown) |
| 75 |
{ |
| 76 |
ASSERT(m_pAEProps == NULL); |
| 77 |
|
| 78 |
// Ask the filter for it's control interface |
| 79 |
|
| 80 |
HRESULT hr = pUnknown->QueryInterface(IID_IAudioEncoderProperties,(void **)&m_pAEProps); |
| 81 |
if (FAILED(hr) || !m_pAEProps) |
| 82 |
return E_NOINTERFACE; |
| 83 |
|
| 84 |
ASSERT(m_pAEProps); |
| 85 |
|
| 86 |
// Get current filter state |
| 87 |
// m_pAEProps->LoadAudioEncoderPropertiesFromRegistry(); |
| 88 |
|
| 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); |
| 100 |
|
| 101 |
return NOERROR; |
| 102 |
} |
| 103 |
|
| 104 |
// |
| 105 |
// OnDisconnect |
| 106 |
// |
| 107 |
// Release the interface |
| 108 |
|
| 109 |
HRESULT CMpegAudEncPropertyPageAdv::OnDisconnect() |
| 110 |
{ |
| 111 |
// Release the interface |
| 112 |
if (m_pAEProps == NULL) |
| 113 |
return E_UNEXPECTED; |
| 114 |
|
| 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(); |
| 127 |
|
| 128 |
m_pAEProps->Release(); |
| 129 |
m_pAEProps = NULL; |
| 130 |
|
| 131 |
return NOERROR; |
| 132 |
} |
| 133 |
|
| 134 |
// |
| 135 |
// OnActivate |
| 136 |
// |
| 137 |
// Called on dialog creation |
| 138 |
|
| 139 |
HRESULT CMpegAudEncPropertyPageAdv::OnActivate(void) |
| 140 |
{ |
| 141 |
InitPropertiesDialog(m_hwnd); |
| 142 |
|
| 143 |
return NOERROR; |
| 144 |
} |
| 145 |
|
| 146 |
// |
| 147 |
// OnDeactivate |
| 148 |
// |
| 149 |
// Called on dialog destruction |
| 150 |
|
| 151 |
HRESULT CMpegAudEncPropertyPageAdv::OnDeactivate(void) |
| 152 |
{ |
| 153 |
return NOERROR; |
| 154 |
} |
| 155 |
|
| 156 |
//////////////////////////////////////////////////////////////// |
| 157 |
// OnReceiveMessage - message handler function |
| 158 |
//////////////////////////////////////////////////////////////// |
| 159 |
BOOL CMpegAudEncPropertyPageAdv::OnReceiveMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) |
| 160 |
{ |
| 161 |
switch (uMsg) |
| 162 |
{ |
| 163 |
case WM_COMMAND: |
| 164 |
switch (LOWORD(wParam)) |
| 165 |
{ |
| 166 |
case IDC_RADIO_STEREO: |
| 167 |
case IDC_RADIO_JSTEREO: |
| 168 |
case IDC_RADIO_DUAL: |
| 169 |
case IDC_RADIO_MONO: |
| 170 |
{ |
| 171 |
|
| 172 |
DWORD dwChannelMode = LOWORD(wParam) - IDC_RADIO_STEREO; |
| 173 |
CheckRadioButton(hwnd, IDC_RADIO_STEREO, IDC_RADIO_MONO, LOWORD(wParam)); |
| 174 |
|
| 175 |
if (dwChannelMode == MPG_MD_JOINT_STEREO) |
| 176 |
EnableWindow(GetDlgItem(hwnd,IDC_CHECK_FORCE_MS),TRUE); |
| 177 |
else |
| 178 |
EnableWindow(GetDlgItem(hwnd,IDC_CHECK_FORCE_MS),FALSE); |
| 179 |
|
| 180 |
m_pAEProps->set_ChannelMode(dwChannelMode); |
| 181 |
SetDirty(); |
| 182 |
} |
| 183 |
break; |
| 184 |
|
| 185 |
case IDC_CHECK_ENFORCE_MIN: |
| 186 |
m_pAEProps->set_EnforceVBRmin(IsDlgButtonChecked(hwnd, IDC_CHECK_ENFORCE_MIN)); |
| 187 |
SetDirty(); |
| 188 |
break; |
| 189 |
|
| 190 |
case IDC_CHECK_VOICE: |
| 191 |
m_pAEProps->set_VoiceMode(IsDlgButtonChecked(hwnd, IDC_CHECK_VOICE)); |
| 192 |
SetDirty(); |
| 193 |
break; |
| 194 |
|
| 195 |
case IDC_CHECK_KEEP_ALL_FREQ: |
| 196 |
m_pAEProps->set_KeepAllFreq(IsDlgButtonChecked(hwnd, IDC_CHECK_KEEP_ALL_FREQ)); |
| 197 |
SetDirty(); |
| 198 |
break; |
| 199 |
|
| 200 |
case IDC_CHECK_STRICT_ISO: |
| 201 |
m_pAEProps->set_StrictISO(IsDlgButtonChecked(hwnd, IDC_CHECK_STRICT_ISO)); |
| 202 |
SetDirty(); |
| 203 |
break; |
| 204 |
|
| 205 |
case IDC_CHECK_DISABLE_SHORT_BLOCK: |
| 206 |
m_pAEProps->set_NoShortBlock(IsDlgButtonChecked(hwnd, IDC_CHECK_DISABLE_SHORT_BLOCK)); |
| 207 |
SetDirty(); |
| 208 |
break; |
| 209 |
|
| 210 |
case IDC_CHECK_XING_TAG: |
| 211 |
m_pAEProps->set_XingTag(IsDlgButtonChecked(hwnd, IDC_CHECK_XING_TAG)); |
| 212 |
SetDirty(); |
| 213 |
break; |
| 214 |
|
| 215 |
case IDC_CHECK_FORCE_MS: |
| 216 |
m_pAEProps->set_ForceMS(IsDlgButtonChecked(hwnd, IDC_CHECK_FORCE_MS)); |
| 217 |
SetDirty(); |
| 218 |
break; |
| 219 |
|
| 220 |
case IDC_CHECK_MODE_FIXED: |
| 221 |
m_pAEProps->set_ModeFixed(IsDlgButtonChecked(hwnd, IDC_CHECK_MODE_FIXED)); |
| 222 |
SetDirty(); |
| 223 |
break; |
| 224 |
|
| 225 |
case IDC_CHECK_OVERLAP: |
| 226 |
m_pAEProps->set_SampleOverlap(IsDlgButtonChecked(hwnd, IDC_CHECK_OVERLAP)); |
| 227 |
SetDirty(); |
| 228 |
break; |
| 229 |
|
| 230 |
case IDC_CHECK_STOP: |
| 231 |
m_pAEProps->set_SetDuration(IsDlgButtonChecked(hwnd, IDC_CHECK_STOP)); |
| 232 |
SetDirty(); |
| 233 |
break; |
| 234 |
} |
| 235 |
|
| 236 |
return TRUE; |
| 237 |
|
| 238 |
case WM_DESTROY: |
| 239 |
return TRUE; |
| 240 |
|
| 241 |
default: |
| 242 |
return FALSE; |
| 243 |
} |
| 244 |
|
| 245 |
return TRUE; |
| 246 |
} |
| 247 |
|
| 248 |
// |
| 249 |
// OnApplyChanges |
| 250 |
// |
| 251 |
HRESULT CMpegAudEncPropertyPageAdv::OnApplyChanges() |
| 252 |
{ |
| 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(); |
| 265 |
|
| 266 |
m_pAEProps->ApplyChanges(); |
| 267 |
|
| 268 |
return S_OK; |
| 269 |
} |
| 270 |
|
| 271 |
// |
| 272 |
// Initialize dialogbox controls with proper values |
| 273 |
// |
| 274 |
void CMpegAudEncPropertyPageAdv::InitPropertiesDialog(HWND hwndParent) |
| 275 |
{ |
| 276 |
EnableControls(hwndParent, TRUE); |
| 277 |
|
| 278 |
// |
| 279 |
// initialize radio bottons |
| 280 |
// |
| 281 |
DWORD dwChannelMode; |
| 282 |
m_pAEProps->get_ChannelMode(&dwChannelMode); |
| 283 |
CheckRadioButton(hwndParent, IDC_RADIO_STEREO, IDC_RADIO_MONO, IDC_RADIO_STEREO + dwChannelMode); |
| 284 |
|
| 285 |
if (dwChannelMode == MPG_MD_JOINT_STEREO) |
| 286 |
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_FORCE_MS), TRUE); |
| 287 |
else |
| 288 |
EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_FORCE_MS), FALSE); |
| 289 |
|
| 290 |
// |
| 291 |
// initialize checkboxes |
| 292 |
// |
| 293 |
DWORD dwEnforceVBRmin; |
| 294 |
m_pAEProps->get_EnforceVBRmin(&dwEnforceVBRmin); |
| 295 |
CheckDlgButton(hwndParent, IDC_CHECK_ENFORCE_MIN, dwEnforceVBRmin ? BST_CHECKED : BST_UNCHECKED); |
| 296 |
|
| 297 |
DWORD dwVoiceMode; |
| 298 |
m_pAEProps->get_VoiceMode(&dwVoiceMode); |
| 299 |
CheckDlgButton(hwndParent, IDC_CHECK_VOICE, dwVoiceMode ? BST_CHECKED : BST_UNCHECKED); |
| 300 |
|
| 301 |
DWORD dwKeepAllFreq; |
| 302 |
m_pAEProps->get_KeepAllFreq(&dwKeepAllFreq); |
| 303 |
CheckDlgButton(hwndParent, IDC_CHECK_KEEP_ALL_FREQ, dwKeepAllFreq ? BST_CHECKED : BST_UNCHECKED); |
| 304 |
|
| 305 |
DWORD dwStrictISO; |
| 306 |
m_pAEProps->get_StrictISO(&dwStrictISO); |
| 307 |
CheckDlgButton(hwndParent, IDC_CHECK_STRICT_ISO, dwStrictISO ? BST_CHECKED : BST_UNCHECKED); |
| 308 |
|
| 309 |
DWORD dwNoShortBlock; |
| 310 |
m_pAEProps->get_NoShortBlock(&dwNoShortBlock); |
| 311 |
CheckDlgButton(hwndParent, IDC_CHECK_DISABLE_SHORT_BLOCK, dwNoShortBlock ? BST_CHECKED : BST_UNCHECKED); |
| 312 |
|
| 313 |
DWORD dwXingEnabled; |
| 314 |
m_pAEProps->get_XingTag(&dwXingEnabled); |
| 315 |
CheckDlgButton(hwndParent, IDC_CHECK_XING_TAG, dwXingEnabled ? BST_CHECKED : BST_UNCHECKED); |
| 316 |
|
| 317 |
DWORD dwForceMS; |
| 318 |
m_pAEProps->get_ForceMS(&dwForceMS); |
| 319 |
CheckDlgButton(hwndParent, IDC_CHECK_FORCE_MS, dwForceMS ? BST_CHECKED : BST_UNCHECKED); |
| 320 |
|
| 321 |
DWORD dwModeFixed; |
| 322 |
m_pAEProps->get_ModeFixed(&dwModeFixed); |
| 323 |
CheckDlgButton(hwndParent, IDC_CHECK_MODE_FIXED, dwModeFixed ? BST_CHECKED : BST_UNCHECKED); |
| 324 |
|
| 325 |
DWORD dwOverlap; |
| 326 |
m_pAEProps->get_SampleOverlap(&dwOverlap); |
| 327 |
CheckDlgButton(hwndParent, IDC_CHECK_OVERLAP, dwOverlap ? BST_CHECKED : BST_UNCHECKED); |
| 328 |
|
| 329 |
DWORD dwStopTime; |
| 330 |
m_pAEProps->get_SetDuration(&dwStopTime); |
| 331 |
CheckDlgButton(hwndParent, IDC_CHECK_STOP, dwStopTime ? BST_CHECKED : BST_UNCHECKED); |
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
//////////////////////////////////////////////////////////////// |
| 336 |
// EnableControls |
| 337 |
//////////////////////////////////////////////////////////////// |
| 338 |
void CMpegAudEncPropertyPageAdv::EnableControls(HWND hwndParent, bool bEnable) |
| 339 |
{ |
| 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); |
| 354 |
} |
| 355 |
|
| 356 |
// |
| 357 |
// SetDirty |
| 358 |
// |
| 359 |
// notifies the property page site of changes |
| 360 |
|
| 361 |
void CMpegAudEncPropertyPageAdv::SetDirty() |
| 362 |
{ |
| 363 |
m_bDirty = TRUE; |
| 364 |
if (m_pPageSite) |
| 365 |
m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY); |
| 366 |
} |
| 367 |
|