udp.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include <memory>
  3. #include <string>
  4. #include <vector>
  5. #include <map>
  6. #include <list>
  7. #include <queue>
  8. #include "cnstream_frame.hpp"
  9. #include "cnstream_module.hpp"
  10. #include "easyinfer/model_loader.h"
  11. #include "easytrack/easy_track.h"
  12. #include "cnstream_frame_va.hpp"
  13. #include "Util/util.h"
  14. #include "Util/logger.h"
  15. #include "Network/Socket.h"
  16. #include "rapidjson/prettywriter.h"
  17. using namespace toolkit;
  18. namespace cnstream{
  19. class udp : public cnstream::Module, public cnstream::ModuleCreator<udp> {
  20. using super = cnstream::Module;
  21. public:
  22. explicit udp(const std::string &name) : super(name) {}
  23. bool Open(cnstream::ModuleParamSet paramSet) override;
  24. void Close() override { std::cout << this->GetName() << " Close called" << std::endl; }
  25. int Process(std::shared_ptr<cnstream::CNFrameInfo> data) override;
  26. static void makeAddr(struct sockaddr *out,const char *ip,uint16_t port);
  27. private:
  28. udp(const udp &) = delete;
  29. udp &operator=(udp const &) = delete;
  30. Socket::Ptr sockerUdp = nullptr;
  31. rapidjson::StringBuffer buffer_;
  32. rapidjson::PrettyWriter<rapidjson::StringBuffer> writer_;
  33. int bindPort;
  34. std::string sendSockerIP;
  35. int sendPort;
  36. };
  37. };