aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Encoder/enc_fhgaac/preferences_mp4.cpp
blob: 7f06dfb086f2d5e05b64d6ff50499490ac402c97 (plain) (blame)
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
#include "../Agave/Language/api_language.h"
#include "config.h"
#include "preferences.h"
#include "../Winamp/wa_ipc.h"
#include <windows.h>
#include <assert.h>
#include "resource.h"
#include "link_control.h"
#include "../nu/ComboBox.h"
#include "../nu/Slider.h"
#include <strsafe.h>

extern HWND winampwnd;

INT_PTR CALLBACK Preferences_MP4_DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_INITDIALOG:
		{
			AACConfigurationFile *cfg = (AACConfigurationFile *)lParam;
			cfg->changing = false;
			SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)cfg);

				ComboBox mode_list(hwnd, IDC_MODE);
				mode_list.AddString(WASABI_API_LNGSTRINGW(IDS_VBR), AAC_MODE_VBR); assert(AAC_MODE_VBR == 0);
				mode_list.AddString(WASABI_API_LNGSTRINGW(IDS_CBR), AAC_MODE_CBR); assert(AAC_MODE_CBR == 1);
				mode_list.SelectItem(cfg->config.mode);

			ComboBox profile_list(hwnd, IDC_PROFILE);
			profile_list.AddString(WASABI_API_LNGSTRINGW(IDS_AUTOMATIC), AAC_PROFILE_AUTOMATIC); assert(AAC_PROFILE_AUTOMATIC == 0);
			profile_list.AddString(L"AAC LC", AAC_PROFILE_LC); assert(AAC_PROFILE_LC == 1);
			profile_list.AddString(L"HE-AAC", AAC_PROFILE_HE); assert(AAC_PROFILE_HE == 2);
			profile_list.AddString(L"HE-AAC v2", AAC_PROFILE_HE_V2); assert(AAC_PROFILE_HE_V2 == 3);

			UpdateUI(hwnd, cfg);
			UpdateInfo(hwnd, &cfg->config);
			link_startsubclass(hwnd, IDC_URL);
			link_startsubclass(hwnd, IDC_LOGO);
			link_startsubclass(hwnd, IDC_HELPLINK);

			char temp[128] = {0};
			if (Preferences_GetEncoderVersion(temp, sizeof(temp)/sizeof(*temp)) == 0)
			{
				SetDlgItemTextA(hwnd, IDC_VERSION, temp);
			}

			// this will make sure that we've got the aacplus logo shown even when using a localised version
			SendDlgItemMessage(hwnd,IDC_LOGO,STM_SETIMAGE,IMAGE_BITMAP, (LPARAM)LoadImage(WASABI_API_ORIG_HINST?WASABI_API_ORIG_HINST:enc_fhg_HINST,MAKEINTRESOURCE(IDB_FHGLOGO),IMAGE_BITMAP,0,0,LR_SHARED));
		}
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDC_HELPLINK:
			SendMessage(winampwnd, WM_WA_IPC, (WPARAM)"http://help.winamp.com/", IPC_OPEN_URL);
			break;
		case IDC_LOGO:
		case IDC_URL:
			SendMessage(winampwnd, WM_WA_IPC, (WPARAM)"http://www.iis.fraunhofer.de/en/bf/amm", IPC_OPEN_URL);
			break;


		case IDC_MODE:
			if (HIWORD(wParam) ==  CBN_SELCHANGE)
			{
				AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
				cfg->config.mode = (unsigned int)ComboBox(hwnd, IDC_MODE).GetSelection();
				UpdateUI(hwnd, cfg);
				UpdateInfo(hwnd, &cfg->config);
				AACConfig_Save(cfg);
			}
			break;

		case IDC_EDIT_PRESET:
			if (HIWORD(wParam) == EN_CHANGE)
			{
				AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
				if (!cfg->changing)
				{
					BOOL s=0;
					unsigned int t=GetDlgItemInt(hwnd,IDC_EDIT_PRESET,&s,0);
					if (s)
					{
						if (cfg->config.mode == AAC_MODE_VBR)
						{
							cfg->config.preset= t;
						}
						else
						{
							cfg->config.bitrate = t;
						}
						UpdateUI(hwnd, cfg);
						UpdateInfo(hwnd, &cfg->config);
						AACConfig_Save(cfg);
					}
				}
			}
			break;

		case IDC_PROFILE:
			if (HIWORD(wParam) ==  CBN_SELCHANGE)
			{
				AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
				cfg->config.profile = (unsigned int)ComboBox(hwnd, IDC_PROFILE).GetSelection();
				UpdateUI(hwnd, cfg);
				UpdateInfo(hwnd, &cfg->config);
				AACConfig_Save(cfg);
			}
			break;
		}
		break;

	case WM_HSCROLL:
		if (GetDlgItem(hwnd, IDC_SLIDER_PRESET) == (HWND)lParam)
		{
			wchar_t temp[128] = {0};
			AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
			if (cfg->config.mode == AAC_MODE_VBR)
			{
				cfg->config.preset = (unsigned int)SendMessage(GetDlgItem(hwnd,IDC_SLIDER_PRESET),TBM_GETPOS,0,0);
				StringCbPrintf(temp, sizeof(temp), L"%u", cfg->config.preset);
				SetDlgItemText(hwnd, IDC_EDIT_PRESET, temp);
				UpdateInfo(hwnd, &cfg->config);
				AACConfig_Save(cfg);
			}
			else
			{
				cfg->config.bitrate = GetSliderBitrate(hwnd);
				StringCbPrintf(temp, sizeof(temp), L"%u", cfg->config.bitrate);
				SetDlgItemText(hwnd, IDC_EDIT_PRESET, temp);
				UpdateInfo(hwnd, &cfg->config);
				AACConfig_Save(cfg);
			}
		}
		break;
	}

	link_handledraw(hwnd,msg,wParam,lParam);

	const int controls[] = 
	{
		IDC_SLIDER_PRESET,
	};
	if (FALSE != WASABI_API_APP->DirectMouseWheel_ProcessDialogMessage(hwnd, msg, wParam, lParam, controls, ARRAYSIZE(controls)))
	{
		return 1;
	}

	return 0;
}