encoder_nvenc.h 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef REMOTEAR3_ENCODER_NVENC_H
  2. #define REMOTEAR3_ENCODER_NVENC_H
  3. #include "codec_base.hpp"
  4. #include "core/cuda_helper.hpp"
  5. #include "core/image_utility.hpp"
  6. #include <opencv2/core/types.hpp>
  7. #include <memory>
  8. class encoder_nvenc {
  9. public:
  10. ~encoder_nvenc();
  11. struct create_config {
  12. cv::Size frame_size;
  13. int frame_rate;
  14. float bitrate_mbps;
  15. bool save_file;
  16. bool save_length;
  17. CUcontext *ctx = nullptr;
  18. smart_cuda_stream *stream = nullptr;
  19. };
  20. using this_type = encoder_nvenc;
  21. using pointer = std::unique_ptr<this_type>;
  22. static pointer create(create_config conf);
  23. struct modifiable_config {
  24. int frame_rate;
  25. float bitrate_mbps;
  26. };
  27. void change_config(modifiable_config conf);
  28. frame_info encode(const image_u8c4 &img, bool force_idr = false);
  29. cv::Size frame_size() const;
  30. private:
  31. struct impl;
  32. std::unique_ptr<impl> pimpl;
  33. };
  34. #endif //REMOTEAR3_ENCODER_NVENC_H