📄 amr_prop.cpp
字号:
//-----------------------------------------------------------------------------
//
// Monogram AMR Encoder
//
// Base on the 3GPP source codes for AMR
//
// Author : Igor Janos
//
//-----------------------------------------------------------------------------
#include "stdafx.h"
#define MAX_TEXT_LENGTH 1024
#define WM_UPDATE_VISUALS (WM_USER + 1003)
#define ITEM(x) (GetDlgItem(m_Dlg, x))
const int ModeTab[] = {
4750,
5150,
5900,
6700,
7400,
7950,
10200,
12200
};
const int ModeCount = sizeof(ModeTab) / sizeof(ModeTab[0]);
//-----------------------------------------------------------------------------
//
// CAMRPropertyPage class
//
//-----------------------------------------------------------------------------
CUnknown *CAMRPropertyPage::CreateInstance(LPUNKNOWN lpUnk, HRESULT *phr)
{
return new CAMRPropertyPage(lpUnk, phr);
}
CAMRPropertyPage::CAMRPropertyPage(LPUNKNOWN lpUnk, HRESULT *phr) :
CBasePropertyPage(NAME("AMR Property Page"), lpUnk, IDD_PAGE_AMR, IDS_PAGE_AMR),
encoder(NULL)
{
}
CAMRPropertyPage::~CAMRPropertyPage()
{
}
HRESULT CAMRPropertyPage::OnConnect(IUnknown *pUnknown)
{
ASSERT(!encoder);
HRESULT hr = pUnknown->QueryInterface(IID_IMonogramAMREncoder, (void**)&encoder);
if (FAILED(hr)) return hr;
// okej
return NOERROR;
}
HRESULT CAMRPropertyPage::OnDisconnect()
{
if (encoder) {
encoder->Release();
encoder = NULL;
}
return NOERROR;
}
HRESULT CAMRPropertyPage::OnActivate()
{
for (int i=0; i<ModeCount; i++) {
CString t;
t.Format(_T("%5.03f kbps"), ModeTab[i] / 1000.0);
ComboBox_AddString(ITEM(IDC_COMBO_MODE), t);
}
int mode;
if (encoder) {
encoder->GetMode(&mode);
ComboBox_SetCurSel(ITEM(IDC_COMBO_MODE), mode);
}
// update timer
SetTimer(m_Dlg, 0, 200, NULL);
UpdateStats();
return NOERROR;
}
HRESULT CAMRPropertyPage::OnDeactivate()
{
KillTimer(m_Dlg, 0);
return NOERROR;
}
HRESULT CAMRPropertyPage::OnApplyChanges()
{
int mode = ComboBox_GetCurSel(ITEM(IDC_COMBO_MODE));
if (encoder) encoder->SetMode(mode);
return NOERROR;
}
INT_PTR CAMRPropertyPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_COMMAND:
{
int cmd = HIWORD(wParam);
if (cmd == CBN_SELCHANGE) {
SetDirty();
}
}
break;
case WM_TIMER:
{
// updatujeme rychlost stahovania
UpdateStats();
}
break;
}
return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);
}
void CAMRPropertyPage::UpdateStats()
{
if (!encoder) return ;
AMR_INFO info;
encoder->GetInfo(&info);
CString t;
t.Format(_T("%d Hz"), info.samplerate);
Static_SetText(ITEM(IDC_STATIC_SAMPLERATE), t);
t.Format(_T("%d"), info.channels);
Static_SetText(ITEM(IDC_STATIC_CHANNELS), t);
t.Format(_T("%I64d"), info.frames);
Static_SetText(ITEM(IDC_STATIC_FRAMES), t);
}
void CAMRPropertyPage::SetDirty()
{
m_bDirty = TRUE;
if (m_pPageSite) {
m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -