ifc_audioFileEncoder.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include <bfc/dispatch.h>
  3. class ifc_audioFileEncoder : public Dispatchable
  4. {
  5. protected:
  6. ifc_audioFileEncoder() {}
  7. ~ifc_audioFileEncoder() {}
  8. public:
  9. /*
  10. @param frame - frame number, optional (pass 0 every time if you don't have it).
  11. it is used for special purposes and is not generally needed.
  12. @param data - the input data (audio)
  13. @param data_len - number of valid bytes in data
  14. @param data_used - on return, set to the number of audio bytes read
  15. note for implementors:
  16. it is highly recommended that implementation use all available input data, but it is not required.
  17. note for users:
  18. if not all input data is read, you need to pass in the old data again
  19. but have more available. This is likely to happen when the block size of the codec
  20. does not match your buffer size
  21. */
  22. int Feed(uint32_t frame, const void *data, size_t data_len, size_t *data_used);
  23. // same as above, but used when you have no more input to pass
  24. // you can pass more audio data if you like (preferred if possible)
  25. // or pass 0 for data & data_len if you passed all your data to Feed()
  26. // note to implementors:
  27. // for many implementations: close your encoder (e.g. vorbis) but not your file writer (e.g. ogg)
  28. // note to users:
  29. // you still need to call Finish().
  30. int Finish(uint32_t frame, const void *data, size_t data_len, size_t *data_used);
  31. // call this to do whatever necessary
  32. // this is a separate call than Finish() because of time-constraints and the killswitch
  33. // for many implementations: close your file writer object here, write seek table, etc.
  34. // note to users:
  35. // after this function succeeds, you may use the file (write metadata, etc)
  36. int Finalize(int *killswitch);
  37. // @param block_size - on return, set to the 'natural' number of bytes that the audio encoder expects
  38. // can be helpful for users of this object to do more efficient I/O
  39. // optional (check the return value when you call this!)
  40. // but recommended
  41. int GetBlockSize(size_t *block_size);
  42. // @param fill_size - on return, set to the number of bytes needed to fill the audio encoder's current block
  43. // might be 0 for some types (WAV).
  44. // can be helpful for users of this object to do more efficient I/O
  45. // optional (check the return value when you call this!)
  46. // don't implement unless it's easy
  47. int GetFillSize(size_t *fill_size);
  48. // @param bytes_written - on return, set to the number of encoded bytes written so far.
  49. // used by the CD ripper to show a 'real time' bitrate
  50. // optional (check the return value when you call this!)
  51. // don't implement unless it's easy
  52. int GetBytesWritten(size_t *bytes_written);
  53. };