ifc_mkvaudiodecoder.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include <bfc/dispatch.h>
  3. class NOVTABLE ifc_mkvaudiodecoder : public Dispatchable
  4. {
  5. protected:
  6. ifc_mkvaudiodecoder() {}
  7. ~ifc_mkvaudiodecoder() {}
  8. public:
  9. enum
  10. {
  11. MKV_SUCCESS = 0,
  12. MKV_NEED_MORE_INPUT = -1,
  13. MKV_FAILURE=1,
  14. };
  15. int OutputFrameSize(size_t *frame_size);
  16. int GetOutputProperties(unsigned int *sampleRate, unsigned int *channels, unsigned int *bitsPerSample, bool *isFloat); // can return an error code for "havn't locked to stream yet"
  17. int DecodeBlock(const void *inputBuffer, size_t inputBufferBytes, void *outputBuffer, size_t *outputBufferBytes);
  18. void Flush();
  19. void Close(); // self-destructs
  20. void EndOfStream(); // no more input, output anything you have buffered
  21. DISPATCH_CODES
  22. {
  23. OUTPUT_FRAME_SIZE = 0,
  24. GET_OUTPUT_PROPERTIES = 1,
  25. DECODE_BLOCK = 2,
  26. FLUSH = 3,
  27. CLOSE = 4,
  28. END_OF_STREAM = 5,
  29. };
  30. };
  31. inline int ifc_mkvaudiodecoder::OutputFrameSize(size_t *frame_size)
  32. {
  33. return _call(OUTPUT_FRAME_SIZE, (int)MKV_FAILURE, frame_size);
  34. }
  35. inline int ifc_mkvaudiodecoder::GetOutputProperties(unsigned int *sampleRate, unsigned int *channels, unsigned int *bitsPerSample, bool *isFloat)
  36. {
  37. return _call(GET_OUTPUT_PROPERTIES, (int)MKV_FAILURE, sampleRate, channels, bitsPerSample, isFloat);
  38. }
  39. inline int ifc_mkvaudiodecoder::DecodeBlock(const void *inputBuffer, size_t inputBufferBytes, void *outputBuffer, size_t *outputBufferBytes)
  40. {
  41. return _call(DECODE_BLOCK, (int)MKV_FAILURE, inputBuffer, inputBufferBytes, outputBuffer, outputBufferBytes);
  42. }
  43. inline void ifc_mkvaudiodecoder::Flush()
  44. {
  45. _voidcall(FLUSH);
  46. }
  47. inline void ifc_mkvaudiodecoder::Close()
  48. {
  49. _voidcall(CLOSE);
  50. }
  51. inline void ifc_mkvaudiodecoder::EndOfStream()
  52. {
  53. _voidcall(END_OF_STREAM);
  54. }