inference.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include <iostream>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <gst/gst.h>
  6. #include <glib.h>
  7. #include <stdio.h>
  8. #include <math.h>
  9. #include <string.h>
  10. #include <sys/time.h>
  11. #include "gstnvdsmeta.h"
  12. #include "gst-nvmessage.h"
  13. #include "DataSource.h"
  14. // ZLMediaKit
  15. #include "Util/logger.h"
  16. #include "Util/NoticeCenter.h"
  17. #include "Poller/EventPoller.h"
  18. #include "Player/PlayerProxy.h"
  19. #include "Rtmp/RtmpPusher.h"
  20. #include "Common/config.h"
  21. #include "Pusher/MediaPusher.h"
  22. #include "Extension/Frame.h"
  23. #include "Util/SqlPool.h"
  24. #include "Network/TcpClient.h"
  25. #include "Poller/Timer.h"
  26. #include "TCPClient.h"
  27. #include <list>
  28. using namespace std;
  29. namespace MIVA{
  30. // 基于Deepstream
  31. class Inference
  32. {
  33. private:
  34. // Deepstream
  35. GMainLoop *loop = NULL;
  36. GstElement *pipeline = NULL,*streammux = NULL, *sink = NULL, *pgie = NULL,
  37. *queue1, *queue2, *queue3, *queue4, *queue5, *nvvidconv = NULL,
  38. *nvosd = NULL, *tiler = NULL;
  39. GstElement *transform = NULL;
  40. GstBus *bus = NULL;
  41. guint bus_watch_id;
  42. GstPad *tiler_src_pad = NULL;
  43. guint tiler_rows, tiler_columns;
  44. guint pgie_batch_size;
  45. public:
  46. static std::shared_ptr<Inference> CreateNew();
  47. Inference();
  48. ~Inference();
  49. public:
  50. int32_t Init(std::list<DataSource> DataList);
  51. void Destory();
  52. void StartTask();
  53. private:
  54. // static
  55. static GstPadProbeReturn tiler_src_pad_buffer_probe(GstPad * pad, GstPadProbeInfo * info, gpointer u_data);
  56. static gboolean bus_call (GstBus * bus, GstMessage * msg, gpointer data);
  57. static void cb_newpad (GstElement * decodebin, GstPad * decoder_src_pad, gpointer data);
  58. static void decodebin_child_added (GstChildProxy * child_proxy, GObject * object,
  59. gchar * name, gpointer user_data);
  60. static GstElement* create_source_bin(guint index, gchar * uri);
  61. };
  62. }