123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #ifndef MODULES_ENCODER_INCLUDE_ENCODER_HPP_
- #define MODULES_ENCODER_INCLUDE_ENCODER_HPP_
- #include <memory>
- #include <mutex>
- #include <set>
- #include <string>
- #include <unordered_map>
- #include "cnstream_frame.hpp"
- #include "cnstream_module.hpp"
- #include "cnstream_frame_va.hpp"
- #include "private/cnstream_param.hpp"
- #include "video/video_stream/video_stream.hpp"
- namespace cnstream {
- using CNFrameInfoPtr = std::shared_ptr<CNFrameInfo>;
- struct EncoderContext;
- struct EncodeParam {
- int device_id = 0;
- bool mlu_input_frame = false;
- bool mlu_encoder = true;
- int dst_width = 0;
- int dst_height = 0;
- double frame_rate = 0;
- int bit_rate = 4000000;
- int gop_size = 10;
- int tile_cols = 0;
- int tile_rows = 0;
- bool resample = false;
- std::string file_name = "";
- };
- class Encode : public Module, public ModuleCreator<Encode> {
- public:
-
- explicit Encode(const std::string& name);
-
- ~Encode();
-
- bool Open(ModuleParamSet paramSet) override;
-
- void Close() override;
-
- int Process(CNFrameInfoPtr data) override;
- void OnEos(const std::string &stream_id) override;
- private:
- EncoderContext * GetContext(CNFrameInfoPtr data);
- EncoderContext * CreateContext(CNFrameInfoPtr data, const std::string &stream_id);
- std::unique_ptr<ModuleParamsHelper<EncodeParam>> param_helper_ = nullptr;
- std::mutex ctx_lock_;
- std::unordered_map<std::string, EncoderContext *> contexts_;
- std::set<std::string> tile_streams_;
- };
- }
- #endif
|