ifc_flvaudiodecoder.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. enum
  3. {
  4. FLV_AUDIO_SUCCESS = 0,
  5. FLV_AUDIO_FAILURE = 1,
  6. FLV_AUDIO_NEEDS_MORE_INPUT = 2,
  7. };
  8. class ifc_flvaudiodecoder : public Dispatchable
  9. {
  10. protected:
  11. ifc_flvaudiodecoder() {}
  12. ~ifc_flvaudiodecoder() {}
  13. public:
  14. int GetOutputFormat(unsigned int *sample_rate, unsigned int *channels, unsigned int *bits);
  15. int DecodeSample(const void *input_buffer, size_t input_buffer_bytes, void *samples, size_t *samples_size_bytes, double *bitrate);
  16. void Flush();
  17. void Close();
  18. int Ready(); // returns 1 for ready [default], 0 for not ready. Some codecs in FLV use the first packet for decoder config data. return 1 from this once you've gotten it
  19. void SetPreferences(unsigned int max_channels, unsigned int preferred_bits);
  20. DISPATCH_CODES
  21. {
  22. FLV_AUDIO_GETOUTPUTFORMAT = 0,
  23. FLV_AUDIO_DECODE = 1,
  24. FLV_AUDIO_FLUSH = 2,
  25. FLV_AUDIO_CLOSE = 3,
  26. FLV_AUDIO_READY = 4,
  27. FLV_AUDIO_SETPREFERENCES=5,
  28. };
  29. };
  30. inline int ifc_flvaudiodecoder::GetOutputFormat(unsigned int *sample_rate, unsigned int *channels, unsigned int *bits)
  31. {
  32. return _call(FLV_AUDIO_GETOUTPUTFORMAT, (int)FLV_AUDIO_FAILURE, sample_rate, channels, bits);
  33. }
  34. inline int ifc_flvaudiodecoder::DecodeSample(const void *input_buffer, size_t input_buffer_bytes, void *samples, size_t *samples_size_bytes, double *bitrate)
  35. {
  36. return _call(FLV_AUDIO_DECODE, (int)FLV_AUDIO_FAILURE, input_buffer, input_buffer_bytes, samples, samples_size_bytes, bitrate);
  37. }
  38. inline void ifc_flvaudiodecoder::Flush()
  39. {
  40. _voidcall(FLV_AUDIO_FLUSH);
  41. }
  42. inline void ifc_flvaudiodecoder::Close()
  43. {
  44. _voidcall(FLV_AUDIO_CLOSE);
  45. }
  46. inline int ifc_flvaudiodecoder::Ready()
  47. {
  48. return _call(FLV_AUDIO_READY, (int)1); // default to true so that decoders that don't implement won't block in_flv from seeking
  49. }
  50. inline void ifc_flvaudiodecoder::SetPreferences(unsigned int max_channels, unsigned int preferred_bits)
  51. {
  52. _voidcall(FLV_AUDIO_SETPREFERENCES, max_channels, preferred_bits);
  53. }