player.h 848 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include "demuxer.h"
  3. #include "display.h"
  4. #include "format_converter.h"
  5. #include "queue.h"
  6. #include "timer.h"
  7. #include "video_decoder.h"
  8. #include <memory>
  9. #include <stdexcept>
  10. #include <string>
  11. #include <thread>
  12. #include <vector>
  13. extern "C" {
  14. #include <libavcodec/avcodec.h>
  15. }
  16. class Player {
  17. public:
  18. Player(const std::string &file_name);
  19. void operator()();
  20. private:
  21. void demultiplex();
  22. void decode_video();
  23. void video();
  24. private:
  25. std::unique_ptr<Demuxer> demuxer_;
  26. std::unique_ptr<VideoDecoder> video_decoder_;
  27. std::unique_ptr<FormatConverter> format_converter_;
  28. std::unique_ptr<Display> display_;
  29. std::unique_ptr<Timer> timer_;
  30. std::unique_ptr<PacketQueue> packet_queue_;
  31. std::unique_ptr<FrameQueue> frame_queue_;
  32. std::vector<std::thread> stages_;
  33. static const size_t queue_size_;
  34. std::exception_ptr exception_{};
  35. };