ifc_flvvideodecoder.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. enum
  3. {
  4. FLV_VIDEO_SUCCESS = 0,
  5. FLV_VIDEO_FAILURE = 1,
  6. };
  7. class ifc_flvvideodecoder : public Dispatchable
  8. {
  9. protected:
  10. ifc_flvvideodecoder() {}
  11. ~ifc_flvvideodecoder() {}
  12. public:
  13. int GetOutputFormat(int *x, int *y, int *color_format);
  14. int DecodeSample(const void *inputBuffer, size_t inputBufferBytes, int32_t timestamp);
  15. void Flush();
  16. void Close();
  17. int GetPicture(void **data, void **decoder_data, uint64_t *timestamp);
  18. void FreePicture(void *data, void *decoder_data);
  19. 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
  20. DISPATCH_CODES
  21. {
  22. FLV_VIDEO_GETOUTPUTFORMAT = 0,
  23. FLV_VIDEO_DECODE = 1,
  24. FLV_VIDEO_FLUSH = 2,
  25. FLV_VIDEO_CLOSE = 3,
  26. FLV_VIDEO_GET_PICTURE = 4,
  27. FLV_VIDEO_FREE_PICTURE = 5,
  28. FLV_VIDEO_READY = 6,
  29. };
  30. };
  31. inline int ifc_flvvideodecoder::GetOutputFormat(int *x, int *y, int *color_format)
  32. {
  33. return _call(FLV_VIDEO_GETOUTPUTFORMAT, (int)FLV_VIDEO_FAILURE, x, y, color_format);
  34. }
  35. inline int ifc_flvvideodecoder::DecodeSample(const void *inputBuffer, size_t inputBufferBytes, int32_t timestamp)
  36. {
  37. return _call(FLV_VIDEO_DECODE, (int)FLV_VIDEO_FAILURE, inputBuffer, inputBufferBytes, timestamp);
  38. }
  39. inline void ifc_flvvideodecoder::Flush()
  40. {
  41. _voidcall(FLV_VIDEO_FLUSH);
  42. }
  43. inline void ifc_flvvideodecoder::Close()
  44. {
  45. _voidcall(FLV_VIDEO_CLOSE);
  46. }
  47. inline int ifc_flvvideodecoder::GetPicture(void **data, void **decoder_data, uint64_t *timestamp)
  48. {
  49. return _call(FLV_VIDEO_GET_PICTURE, (int)FLV_VIDEO_FAILURE, data, decoder_data, timestamp);
  50. }
  51. inline void ifc_flvvideodecoder::FreePicture(void *data, void *decoder_data)
  52. {
  53. _voidcall(FLV_VIDEO_FREE_PICTURE, data, decoder_data);
  54. }
  55. inline int ifc_flvvideodecoder::Ready()
  56. {
  57. return _call(FLV_VIDEO_READY, (int)1); // default to true so that decoders that don't implement won't block in_flv from seeking
  58. }