subtitle_stream.h 798 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include "stream.h"
  3. #include "subtitle_sampler.h"
  4. namespace ffmpeg {
  5. /**
  6. * Class uses FFMPEG library to decode one subtitle stream.
  7. */
  8. struct AVSubtitleKeeper : AVSubtitle {
  9. int64_t release{0};
  10. };
  11. class SubtitleStream : public Stream {
  12. public:
  13. SubtitleStream(
  14. AVFormatContext* inputCtx,
  15. int index,
  16. bool convertPtsToWallTime,
  17. const SubtitleFormat& format);
  18. ~SubtitleStream() override;
  19. protected:
  20. void setFramePts(DecoderHeader* header, bool flush) override;
  21. private:
  22. int initFormat() override;
  23. int analyzePacket(const AVPacket* packet, bool* gotFrame) override;
  24. int copyFrameBytes(ByteStorage* out, bool flush) override;
  25. void releaseSubtitle();
  26. private:
  27. SubtitleSampler sampler_;
  28. AVSubtitleKeeper sub_;
  29. };
  30. } // namespace ffmpeg