📄 proppage.cpp
字号:
/* * LAME MP3 encoder for DirectShow * Basic property page * * Copyright (c) 2000-2005 Marie Orlova, Peter Gubanov, Vitaly Ivanov, Elecard Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */#include <streams.h>#include <olectl.h>#include <commctrl.h>#include "iaudioprops.h"#include "mpegac.h"#include "resource.h"#include "PropPage.h"#include "Reg.h"// strings to appear in comboboxesconst char * szBitRateString[2][14] = { { "32 kbps","40 kbps","48 kbps","56 kbps", "64 kbps","80 kbps","96 kbps","112 kbps", "128 kbps","160 kbps","192 kbps","224 kbps", "256 kbps","320 kbps" }, { "8 kbps","16 kbps","24 kbps","32 kbps", "40 kbps","48 kbps","56 kbps","64 kbps", "80 kbps","96 kbps","112 kbps","128 kbps", "144 kbps","160 kbps" }};LPCSTR szQualityDesc[10] = { "High", "High", "High", "High", "High", "Medium", "Medium", "Low", "Low", "Fast mode"};LPCSTR szVBRqDesc[10] = { "0 - ~1:4", "1 - ~1:5", "2 - ~1:6", "3 - ~1:7", "4 - ~1:9", "5 - ~1:9", "6 - ~1:10", "7 - ~1:11", "8 - ~1:12", "9 - ~1:14"};struct SSampleRate { DWORD dwSampleRate; LPCSTR lpSampleRate;};SSampleRate srRates[9] = { // MPEG-1 {48000, "48 kHz"}, {44100, "44.1 kHz"}, {32000, "32 kHz"}, // MPEG-2 {24000, "24 kHz"}, {22050, "22.05 kHz"}, {16000, "16 kHz"}, // MPEG-2.5 {12000, "12 kHz"}, {11025, "11.025 kHz"}, { 8000, "8 kHz"}};////////////////////////////////////////////////////////////////// CreateInstance////////////////////////////////////////////////////////////////CUnknown *CMpegAudEncPropertyPage::CreateInstance( LPUNKNOWN punk, HRESULT *phr ){ CMpegAudEncPropertyPage *pNewObject = new CMpegAudEncPropertyPage( punk, phr ); if( pNewObject == NULL ) *phr = E_OUTOFMEMORY; return pNewObject;}////////////////////////////////////////////////////////////////// Constructor////////////////////////////////////////////////////////////////CMpegAudEncPropertyPage::CMpegAudEncPropertyPage(LPUNKNOWN punk, HRESULT *phr) : CBasePropertyPage(NAME("Encoder Property Page"), punk, IDD_AUDIOENCPROPS, IDS_AUDIO_PROPS_TITLE) , m_pAEProps(NULL){ ASSERT(phr); m_srIdx = 0; InitCommonControls();}//// OnConnect//// Give us the filter to communicate withHRESULT CMpegAudEncPropertyPage::OnConnect(IUnknown *pUnknown){ ASSERT(m_pAEProps == NULL); // Ask the filter for it's control interface HRESULT hr = pUnknown->QueryInterface(IID_IAudioEncoderProperties,(void **)&m_pAEProps); if (FAILED(hr)) return E_NOINTERFACE; ASSERT(m_pAEProps); // Get current filter state m_pAEProps->get_Bitrate(&m_dwBitrate); m_pAEProps->get_Variable(&m_dwVariable); m_pAEProps->get_VariableMin(&m_dwMin); m_pAEProps->get_VariableMax(&m_dwMax); m_pAEProps->get_Quality(&m_dwQuality); m_pAEProps->get_VariableQ(&m_dwVBRq); m_pAEProps->get_SampleRate(&m_dwSampleRate); m_pAEProps->get_CRCFlag(&m_dwCRC); m_pAEProps->get_ForceMono(&m_dwForceMono); m_pAEProps->get_SetDuration(&m_dwSetDuration); m_pAEProps->get_CopyrightFlag(&m_dwCopyright); m_pAEProps->get_OriginalFlag(&m_dwOriginal); return NOERROR;}//// OnDisconnect//// Release the interfaceHRESULT CMpegAudEncPropertyPage::OnDisconnect(){ // Release the interface if (m_pAEProps == NULL) return E_UNEXPECTED; m_pAEProps->set_Bitrate(m_dwBitrate); m_pAEProps->set_Variable(m_dwVariable); m_pAEProps->set_VariableMin(m_dwMin); m_pAEProps->set_VariableMax(m_dwMax); m_pAEProps->set_Quality(m_dwQuality); m_pAEProps->set_VariableQ(m_dwVBRq); m_pAEProps->set_SampleRate(m_dwSampleRate); m_pAEProps->set_CRCFlag(m_dwCRC); m_pAEProps->set_ForceMono(m_dwForceMono); m_pAEProps->set_SetDuration(m_dwSetDuration); m_pAEProps->set_CopyrightFlag(m_dwCopyright); m_pAEProps->set_OriginalFlag(m_dwOriginal); m_pAEProps->SaveAudioEncoderPropertiesToRegistry(); m_pAEProps->Release(); m_pAEProps = NULL; return NOERROR;}//// OnActivate//// Called on dialog creationHRESULT CMpegAudEncPropertyPage::OnActivate(void){ InitPropertiesDialog(m_hwnd); return NOERROR;}//// OnDeactivate//// Called on dialog destructionHRESULT CMpegAudEncPropertyPage::OnDeactivate(void){ return NOERROR;}////////////////////////////////////////////////////////////////// OnReceiveMessage - message handler function////////////////////////////////////////////////////////////////BOOL CMpegAudEncPropertyPage::OnReceiveMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam){ switch (uMsg) { case WM_HSCROLL: if ((HWND)lParam == m_hwndQuality) { int pos = SendMessage(m_hwndQuality, TBM_GETPOS, 0, 0); if (pos >= 0 && pos < 10) { SetDlgItemText(hwnd,IDC_TEXT_QUALITY,szQualityDesc[pos]); m_pAEProps->set_Quality(pos); SetDirty(); } } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_COMBO_CBR: if (HIWORD(wParam) == CBN_SELCHANGE) { int nBitrate = SendDlgItemMessage(hwnd, IDC_COMBO_CBR, CB_GETCURSEL, 0, 0L); DWORD dwSampleRate; m_pAEProps->get_SampleRate(&dwSampleRate); DWORD dwBitrate; if (dwSampleRate >= 32000) { // Consider MPEG 1 dwBitrate = dwBitRateValue[0][nBitrate]; } else { // Consider MPEG 2/2.5 dwBitrate = dwBitRateValue[1][nBitrate]; } m_pAEProps->set_Bitrate(dwBitrate); SetDirty(); } break; case IDC_COMBO_VBRMIN: if (HIWORD(wParam) == CBN_SELCHANGE) { int nVariableMin = SendDlgItemMessage(hwnd, IDC_COMBO_VBRMIN, CB_GETCURSEL, 0, 0L); DWORD dwSampleRate; m_pAEProps->get_SampleRate(&dwSampleRate); DWORD dwMin; if (dwSampleRate >= 32000) { // Consider MPEG 1 dwMin = dwBitRateValue[0][nVariableMin]; } else { // Consider MPEG 2/2.5 dwMin = dwBitRateValue[1][nVariableMin]; } m_pAEProps->set_VariableMin(dwMin); SetDirty(); } break; case IDC_COMBO_VBRMAX: if (HIWORD(wParam) == CBN_SELCHANGE) { int nVariableMax = SendDlgItemMessage(hwnd, IDC_COMBO_VBRMAX, CB_GETCURSEL, 0, 0L); DWORD dwSampleRate; m_pAEProps->get_SampleRate(&dwSampleRate); DWORD dwMax; if (dwSampleRate >= 32000) { // Consider MPEG 1 dwMax = dwBitRateValue[0][nVariableMax]; } else { // Consider MPEG 2/2.5 dwMax = dwBitRateValue[1][nVariableMax]; } m_pAEProps->set_VariableMax(dwMax); SetDirty(); } break; case IDC_COMBO_SAMPLE_RATE: if (HIWORD(wParam) == CBN_SELCHANGE) { int nSampleRate = SendDlgItemMessage(hwnd, IDC_COMBO_SAMPLE_RATE, CB_GETCURSEL, 0, 0L); if (nSampleRate < 0) nSampleRate = 0; else if (nSampleRate > 2) nSampleRate = 2; DWORD dwSampleRate = srRates[nSampleRate * 3 + m_srIdx].dwSampleRate; m_pAEProps->set_SampleRate(dwSampleRate); InitPropertiesDialog(hwnd); SetDirty(); } break; case IDC_COMBO_VBRq: if (HIWORD(wParam) == CBN_SELCHANGE) { int nVBRq = SendDlgItemMessage(hwnd, IDC_COMBO_VBRq, CB_GETCURSEL, 0, 0L); if (nVBRq >=0 && nVBRq <=9) m_pAEProps->set_VariableQ(nVBRq); SetDirty(); } break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -