~ft/aacdec

ref: 65a708ac330ddc83d16ddaa5387d368276c888cb aacdec/CoreAAC/CoreAACInfoProp.cpp -rw-r--r-- 4.3 KiB
65a708ac — menno forgot 1 18 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include <stdio.h>
#include <streams.h>
#include "ICoreAAC.h"
#include "CoreAACInfoProp.h"
#include "resource.h"

// ----------------------------------------------------------------------------

CUnknown *WINAPI CCoreAACInfoProp::CreateInstance(LPUNKNOWN punk, HRESULT *phr)
{
	CCoreAACInfoProp *pNewObject = new CCoreAACInfoProp(punk, phr);
	if (!pNewObject)
		*phr = E_OUTOFMEMORY;
	return pNewObject;
}

// ----------------------------------------------------------------------------

CCoreAACInfoProp::CCoreAACInfoProp(LPUNKNOWN pUnk, HRESULT *phr) :
	CBasePropertyPage(NAME("Info"), pUnk, IDD_DIALOG_INFO, IDS_INFO),
	m_pICoreAACDec(NULL),
	m_fWindowInActive(TRUE)
{
	
}

// ----------------------------------------------------------------------------

CCoreAACInfoProp::~CCoreAACInfoProp()
{
	
}

// ----------------------------------------------------------------------------

HRESULT CCoreAACInfoProp::OnConnect(IUnknown *pUnknown)
{
	if (pUnknown == NULL)
	{
		return E_POINTER;
	}
	
	ASSERT(m_pICoreAACDec == NULL);

	// Ask the filter for it's control interface		
	HRESULT hr = pUnknown->QueryInterface(IID_ICoreAACDec,reinterpret_cast<void**>(&m_pICoreAACDec));
	if(FAILED(hr))
	{
		return hr;
	}
	
	ASSERT(m_pICoreAACDec);

	m_pICoreAACDec->get_DownMatrix(&m_DownMatrix);

	return S_OK;
}

// ----------------------------------------------------------------------------

HRESULT CCoreAACInfoProp::OnDisconnect()
{
	// Release the interface
	if (m_pICoreAACDec == NULL) {
		return E_UNEXPECTED;
	}
	m_pICoreAACDec->Release();
	m_pICoreAACDec = NULL;
	return NOERROR;
}

// ----------------------------------------------------------------------------

HRESULT CCoreAACInfoProp::OnActivate()
{		
	char msgFormat[255];
	m_fWindowInActive = FALSE;
	
	char* profileName = NULL;
	m_pICoreAACDec->get_ProfileName(&profileName);
	SetDlgItemText(m_hwnd, IDC_LABEL_PROFILE, profileName);
	
	int sampleRate = 0;
	m_pICoreAACDec->get_SampleRate(&sampleRate);
	wsprintf(msgFormat, "%d Hz", sampleRate);
	SetDlgItemText(m_hwnd, IDC_LABEL_SAMPLERATE, msgFormat);
	
	int channels = 0;
	m_pICoreAACDec->get_Channels(&channels);
	wsprintf(msgFormat, "%d", channels);
	SetDlgItemText(m_hwnd, IDC_LABEL_CHANNELS, msgFormat);
	
	int bps = 0;
	m_pICoreAACDec->get_BitsPerSample(&bps);
	wsprintf(msgFormat, "%d", bps);
	SetDlgItemText(m_hwnd, IDC_LABEL_BPS, msgFormat);
	
	CheckDlgButton(m_hwnd,IDC_CHECK_DOWNMIX, m_DownMatrix ? BST_CHECKED : BST_UNCHECKED);

	RefreshDisplay(m_hwnd);
	SetTimer(m_hwnd,0,1000,NULL);
	
	return S_OK;
}

// ----------------------------------------------------------------------------

HRESULT CCoreAACInfoProp::OnDeactivate()
{
	KillTimer(m_hwnd,0);
	m_fWindowInActive = TRUE;
	return S_OK;
}

// ----------------------------------------------------------------------------

HRESULT CCoreAACInfoProp::OnApplyChanges(void)
{
	m_pICoreAACDec->set_DownMatrix(m_DownMatrix);
	return S_OK;
}

// ----------------------------------------------------------------------------

BOOL CCoreAACInfoProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if(m_fWindowInActive)
		return FALSE;
	
	switch(uMsg)
	{
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDC_CHECK_DOWNMIX:
			m_DownMatrix = (IsDlgButtonChecked(hwnd,IDC_CHECK_DOWNMIX) == BST_CHECKED) ? true : false;
			SetDirty();
			break;
		}
		break;
		
		case WM_TIMER:
			RefreshDisplay(hwnd);
			return (LRESULT) 1;
	}
	
	return CBasePropertyPage::OnReceiveMessage(hwnd, uMsg, wParam, lParam);			
}

// ----------------------------------------------------------------------------

void CCoreAACInfoProp::RefreshDisplay(HWND hwnd)
{
	static char msgFormat[16];
	
	int bitrate = 0;		
	m_pICoreAACDec->get_Bitrate(&bitrate);
	if(bitrate)
		wsprintf(msgFormat, "%d kbps", bitrate/1000);
	else
		wsprintf(msgFormat, "-");
	SetDlgItemText(hwnd, IDC_LABEL_BITRATE, msgFormat);
	
	unsigned int frames_decoded = 0;
	m_pICoreAACDec->get_FramesDecoded(&frames_decoded);
	if(frames_decoded)
		wsprintf(msgFormat, "%d", frames_decoded);
	else
		wsprintf(msgFormat, "-");		
	SetDlgItemText(hwnd, IDC_LABEL_FRAMES_DECODED, msgFormat);
	
}

// ----------------------------------------------------------------------------

void CCoreAACInfoProp::SetDirty()
{
    m_bDirty = TRUE;
    if (m_pPageSite)
        m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
}

// ----------------------------------------------------------------------------