preferences_mp4.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #include "../Agave/Language/api_language.h"
  2. #include "config.h"
  3. #include "preferences.h"
  4. #include "../Winamp/wa_ipc.h"
  5. #include <windows.h>
  6. #include <assert.h>
  7. #include "resource.h"
  8. #include "link_control.h"
  9. #include "../nu/ComboBox.h"
  10. #include "../nu/Slider.h"
  11. #include <strsafe.h>
  12. extern HWND winampwnd;
  13. INT_PTR CALLBACK Preferences_MP4_DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  14. {
  15. switch(msg)
  16. {
  17. case WM_INITDIALOG:
  18. {
  19. AACConfigurationFile *cfg = (AACConfigurationFile *)lParam;
  20. cfg->changing = false;
  21. SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)cfg);
  22. ComboBox mode_list(hwnd, IDC_MODE);
  23. mode_list.AddString(WASABI_API_LNGSTRINGW(IDS_VBR), AAC_MODE_VBR); assert(AAC_MODE_VBR == 0);
  24. mode_list.AddString(WASABI_API_LNGSTRINGW(IDS_CBR), AAC_MODE_CBR); assert(AAC_MODE_CBR == 1);
  25. mode_list.SelectItem(cfg->config.mode);
  26. ComboBox profile_list(hwnd, IDC_PROFILE);
  27. profile_list.AddString(WASABI_API_LNGSTRINGW(IDS_AUTOMATIC), AAC_PROFILE_AUTOMATIC); assert(AAC_PROFILE_AUTOMATIC == 0);
  28. profile_list.AddString(L"AAC LC", AAC_PROFILE_LC); assert(AAC_PROFILE_LC == 1);
  29. profile_list.AddString(L"HE-AAC", AAC_PROFILE_HE); assert(AAC_PROFILE_HE == 2);
  30. profile_list.AddString(L"HE-AAC v2", AAC_PROFILE_HE_V2); assert(AAC_PROFILE_HE_V2 == 3);
  31. UpdateUI(hwnd, cfg);
  32. UpdateInfo(hwnd, &cfg->config);
  33. link_startsubclass(hwnd, IDC_URL);
  34. link_startsubclass(hwnd, IDC_LOGO);
  35. link_startsubclass(hwnd, IDC_HELPLINK);
  36. char temp[128] = {0};
  37. if (Preferences_GetEncoderVersion(temp, sizeof(temp)/sizeof(*temp)) == 0)
  38. {
  39. SetDlgItemTextA(hwnd, IDC_VERSION, temp);
  40. }
  41. // this will make sure that we've got the aacplus logo shown even when using a localised version
  42. 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));
  43. }
  44. break;
  45. case WM_COMMAND:
  46. switch (LOWORD(wParam))
  47. {
  48. case IDC_HELPLINK:
  49. SendMessage(winampwnd, WM_WA_IPC, (WPARAM)"http://help.winamp.com/", IPC_OPEN_URL);
  50. break;
  51. case IDC_LOGO:
  52. case IDC_URL:
  53. SendMessage(winampwnd, WM_WA_IPC, (WPARAM)"http://www.iis.fraunhofer.de/en/bf/amm", IPC_OPEN_URL);
  54. break;
  55. case IDC_MODE:
  56. if (HIWORD(wParam) == CBN_SELCHANGE)
  57. {
  58. AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  59. cfg->config.mode = (unsigned int)ComboBox(hwnd, IDC_MODE).GetSelection();
  60. UpdateUI(hwnd, cfg);
  61. UpdateInfo(hwnd, &cfg->config);
  62. AACConfig_Save(cfg);
  63. }
  64. break;
  65. case IDC_EDIT_PRESET:
  66. if (HIWORD(wParam) == EN_CHANGE)
  67. {
  68. AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  69. if (!cfg->changing)
  70. {
  71. BOOL s=0;
  72. unsigned int t=GetDlgItemInt(hwnd,IDC_EDIT_PRESET,&s,0);
  73. if (s)
  74. {
  75. if (cfg->config.mode == AAC_MODE_VBR)
  76. {
  77. cfg->config.preset= t;
  78. }
  79. else
  80. {
  81. cfg->config.bitrate = t;
  82. }
  83. UpdateUI(hwnd, cfg);
  84. UpdateInfo(hwnd, &cfg->config);
  85. AACConfig_Save(cfg);
  86. }
  87. }
  88. }
  89. break;
  90. case IDC_PROFILE:
  91. if (HIWORD(wParam) == CBN_SELCHANGE)
  92. {
  93. AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  94. cfg->config.profile = (unsigned int)ComboBox(hwnd, IDC_PROFILE).GetSelection();
  95. UpdateUI(hwnd, cfg);
  96. UpdateInfo(hwnd, &cfg->config);
  97. AACConfig_Save(cfg);
  98. }
  99. break;
  100. }
  101. break;
  102. case WM_HSCROLL:
  103. if (GetDlgItem(hwnd, IDC_SLIDER_PRESET) == (HWND)lParam)
  104. {
  105. wchar_t temp[128] = {0};
  106. AACConfigurationFile *cfg = (AACConfigurationFile *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  107. if (cfg->config.mode == AAC_MODE_VBR)
  108. {
  109. cfg->config.preset = (unsigned int)SendMessage(GetDlgItem(hwnd,IDC_SLIDER_PRESET),TBM_GETPOS,0,0);
  110. StringCbPrintf(temp, sizeof(temp), L"%u", cfg->config.preset);
  111. SetDlgItemText(hwnd, IDC_EDIT_PRESET, temp);
  112. UpdateInfo(hwnd, &cfg->config);
  113. AACConfig_Save(cfg);
  114. }
  115. else
  116. {
  117. cfg->config.bitrate = GetSliderBitrate(hwnd);
  118. StringCbPrintf(temp, sizeof(temp), L"%u", cfg->config.bitrate);
  119. SetDlgItemText(hwnd, IDC_EDIT_PRESET, temp);
  120. UpdateInfo(hwnd, &cfg->config);
  121. AACConfig_Save(cfg);
  122. }
  123. }
  124. break;
  125. }
  126. link_handledraw(hwnd,msg,wParam,lParam);
  127. const int controls[] =
  128. {
  129. IDC_SLIDER_PRESET,
  130. };
  131. if (FALSE != WASABI_API_APP->DirectMouseWheel_ProcessDialogMessage(hwnd, msg, wParam, lParam, controls, ARRAYSIZE(controls)))
  132. {
  133. return 1;
  134. }
  135. return 0;
  136. }