c_encoder_nsv.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* This is an abstract class to use the NSV style of encoder.
  2. */
  3. #ifndef __C_ENCODER_NSV_H__
  4. #define __C_ENCODER_NSV_H__
  5. #include "c_encoder.h"
  6. #include "enc_if.h"
  7. #include <windows.h>
  8. #include <Shlobj.h>
  9. #include "../../Resource/resource.h"
  10. struct T_ENCODER_NSV_INFO {
  11. unsigned int output_bitRate;
  12. unsigned int input_numChannels;
  13. unsigned int input_sampleRate;
  14. };
  15. class C_ENCODER_NSV : public C_ENCODER {
  16. private:
  17. HANDLE hMutex;
  18. protected:
  19. // These are exported by enc_*.dll
  20. AudioCoder* (*CreateAudio3)(int nch, int srate, int bps, unsigned int srct, unsigned int *outt, char *configfile);
  21. int (*GetAudioTypes3)(int idx, char *desc);
  22. HWND (*ConfigAudio3)(HWND hwndParent, HINSTANCE hinst, unsigned int outt, char *configfile);
  23. void (*SetWinampHWND)(HWND hwnd);
  24. int (*SetConfigItem)(unsigned int outt, char *item, char *data, char *configfile);
  25. int (*GetConfigItem)(unsigned int outt, char *item, char *data, int len, char *configfile);
  26. /* We don't need the rest of the exports
  27. AudioCoder *(*FinishAudio3)(char *fn, AudioCoder *c);
  28. void (*PrepareToFinish)(const char *filename, AudioCoder *coder);
  29. */
  30. // our encoder (the AudioCoder class is defined in enc_if.h)
  31. AudioCoder* encoder;
  32. // the type of the output format
  33. unsigned int fourcc;
  34. // fill up the attribute list (using AddAttrib)
  35. virtual void FillAttribs()=0;
  36. // child classes MUST call this in their constructor
  37. // note: encoderNum defaults to 0 which resolves to the first encoder
  38. // in most enc_* but make sure to set this correctly for others
  39. virtual void SetEncoder(void * CreateAudio3, void * GetAudioTypes3, void * ConfigAudio3, void * SetWinampHWND, int encoderNum=0);
  40. // this is used in Configure()
  41. virtual HINSTANCE GetEncoderInstance()=0;
  42. // this is used for esternal encoders so they can be correctly localised
  43. HWND winampWnd;
  44. public:
  45. C_ENCODER_NSV(int ExtInfoSize = sizeof(T_ENCODER_NSV_INFO));
  46. virtual ~C_ENCODER_NSV();
  47. virtual void Close();
  48. virtual void Reset();
  49. virtual int Encode(const void *inputbuf, const unsigned int inputbufsize, void *outputbuf, const unsigned int outputbufsize, int *inputamtused); /* all values are in BYTES! */
  50. // show configuration dialog
  51. virtual void Configure(HWND parent,HINSTANCE hDllInstance);
  52. virtual bool UseNsvConfig() { return true; };
  53. // populate the configuration file with current settings
  54. virtual void FillConfFile(char * conf_file, char * section=NULL)=0;
  55. // read the configuration file and change current settings
  56. virtual void ReadConfFile(char * conf_file, char * section=NULL)=0;
  57. };
  58. #endif /* !__C_ENCODER_NSV_H__ */