video_encoder.h 789 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef REMOTEAR2_VIDEO_ENCODER_H
  2. #define REMOTEAR2_VIDEO_ENCODER_H
  3. #include <glad/gl.h> // make windows happy
  4. #include <cuda_gl_interop.h>
  5. #include <memory>
  6. class video_encoder {
  7. public:
  8. video_encoder();
  9. ~video_encoder();
  10. bool initialize();
  11. bool start_encode(int width, int height, int fps, int bitrate,
  12. bool save_file = false, bool save_frame_length = true);
  13. void stop_encode();
  14. bool encode_frame(void *frame_ptr, void **output_ptr, size_t *output_size);
  15. bool encode_frame(cudaGraphicsResource *res, void **output_ptr, size_t *output_size);
  16. bool is_encoding();
  17. // force next frame to be IDR frame
  18. void refresh();
  19. private:
  20. struct impl;
  21. std::unique_ptr<impl> pimpl;
  22. };
  23. #endif //REMOTEAR2_VIDEO_ENCODER_H