c_encoder_fhgaac.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "c_encoder_fhgaac.h"
  2. #include "../../utils.h"
  3. HINSTANCE C_ENCODER_FHGAAC::hEncoderInstance = NULL;
  4. C_ENCODER_FHGAAC::C_ENCODER_FHGAAC(HWND winamp) : C_ENCODER_NSV(sizeof(T_ENCODER_FHGAAC_INFO)) {
  5. SetName("Fraunhofer Encoder");
  6. winampWnd = winamp;
  7. ConfigAudio3 = NULL;
  8. if(hEncoderInstance == NULL) {
  9. wchar_t dir[MAX_PATH] = {0};
  10. snwprintf(dir, MAX_PATH, L"%s\\enc_fhgaac.dll", GetPluginDirectoryW(winamp));
  11. hEncoderInstance = LoadLibraryW(dir);
  12. }
  13. if(hEncoderInstance) {
  14. void * CreateAudio3=(void *)GetProcAddress(hEncoderInstance, "CreateAudio3");
  15. void * GetAudioTypes3=(void *)GetProcAddress(hEncoderInstance, "GetAudioTypes3");
  16. void * ConfigAudio3=(void *)GetProcAddress(hEncoderInstance, "ConfigAudio3");
  17. void * SetWinampHWND=(void *)GetProcAddress(hEncoderInstance, "SetWinampHWND");
  18. SetEncoder(CreateAudio3,GetAudioTypes3,ConfigAudio3,SetWinampHWND,1);
  19. }
  20. T_ENCODER_FHGAAC_INFO * EncInfo = (T_ENCODER_FHGAAC_INFO *)ExtendedInfoPtr;
  21. EncInfo->output_bitRate = FHGAAC_DEFAULT_OUTPUTBITRATE;
  22. EncInfo->output_profile = FHGAAC_DEFAULT_OUTPUTPROFILE;
  23. EncInfo->output_surround = FHGAAC_DEFAULT_OUTPUTSURROUND;
  24. }
  25. C_ENCODER_FHGAAC::~C_ENCODER_FHGAAC() {
  26. C_ENCODER_NSV::~C_ENCODER_NSV();
  27. }
  28. static int cacheVal=0;
  29. bool C_ENCODER_FHGAAC::isPresent(HWND winamp) {
  30. if(cacheVal!=0 && hEncoderInstance!=0) return cacheVal==2;
  31. bool ret=false;
  32. wchar_t dir[MAX_PATH] = {0};
  33. snwprintf(dir, MAX_PATH, L"%s\\enc_fhgaac.dll", GetPluginDirectoryW(winamp));
  34. FILE * f = _wfopen(dir, L"rb");
  35. if (f) {
  36. fseek(f,0,2);
  37. if(ftell(f) > 0) ret=true;
  38. fclose(f);
  39. }
  40. cacheVal=ret?2:1;
  41. return ret;
  42. }
  43. void C_ENCODER_FHGAAC::FillAttribs() {
  44. T_ENCODER_FHGAAC_INFO &EncInfo = *(T_ENCODER_FHGAAC_INFO *)ExtendedInfoPtr;
  45. T_ENCODER_FHGAAC_INFO *attribs = new T_ENCODER_FHGAAC_INFO;
  46. *attribs = EncInfo;
  47. AddAttrib("",attribs);
  48. }
  49. void C_ENCODER_FHGAAC::FillConfFile(char * conf_file, char * section) {
  50. if(!section) section="audio_adtsaac";
  51. T_ENCODER_FHGAAC_INFO &EncInfo = *(T_ENCODER_FHGAAC_INFO *)ExtendedInfoPtr;
  52. WritePrivateProfileInt("profile", EncInfo.output_profile, section, conf_file);
  53. WritePrivateProfileInt("bitrate", EncInfo.output_bitRate, section, conf_file);
  54. WritePrivateProfileInt("surround", EncInfo.output_surround, section, conf_file);
  55. WritePrivateProfileInt("shoutcast", 1, section, conf_file);
  56. }
  57. void C_ENCODER_FHGAAC::ReadConfFile(char * conf_file, char * section) {
  58. if(!section) section="audio_adtsaac";
  59. T_ENCODER_FHGAAC_INFO &EncInfo = *(T_ENCODER_FHGAAC_INFO *)ExtendedInfoPtr;
  60. T_ENCODER_FHGAAC_INFO *attribs = new T_ENCODER_FHGAAC_INFO;
  61. *attribs = EncInfo;
  62. attribs->output_profile = GetPrivateProfileInt(section,"profile",FHGAAC_DEFAULT_OUTPUTPROFILE,conf_file);
  63. attribs->output_bitRate = GetPrivateProfileInt(section,"bitrate",FHGAAC_DEFAULT_OUTPUTBITRATE,conf_file);
  64. attribs->output_surround = GetPrivateProfileInt(section,"surround",FHGAAC_DEFAULT_OUTPUTSURROUND,conf_file);
  65. ChangeSettings(attribs);
  66. }