Rtpcommon.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "Rtpcommon.h"
  2. #include <cstring> // for memset, strncpy
  3. RtpRecvClientInfo_t::RtpRecvClientInfo_t()
  4. {
  5. memset(clientIP, 0, 32);
  6. clientPort = 0;
  7. compareItemID = 0;
  8. compareItemRoadNum = 0;
  9. memset(sessionName, 0, 32);
  10. type = 0; // 默认类型为0
  11. }
  12. RtpRecvClientInfo_t::RtpRecvClientInfo_t(const RtpRecvClientInfo_t& other)
  13. {
  14. *this = other; // 使用赋值运算符重载来复制数据
  15. }
  16. RtpRecvClientInfo_t& RtpRecvClientInfo_t::operator=(const RtpRecvClientInfo_t& other)
  17. {
  18. if (this != &other)
  19. {
  20. strncpy(clientIP, other.clientIP, sizeof(clientIP) - 1);
  21. clientIP[sizeof(clientIP) - 1] = '\0';
  22. clientPort = other.clientPort;
  23. compareItemID = other.compareItemID;
  24. compareItemRoadNum = other.compareItemRoadNum;
  25. strncpy(sessionName, other.sessionName, sizeof(sessionName) - 1);
  26. sessionName[sizeof(sessionName) - 1] = '\0';
  27. type = other.type;
  28. }
  29. return *this;
  30. }
  31. RtpSendClientInfo_t::RtpSendClientInfo_t()
  32. {
  33. }
  34. RtpSendClientInfo_t::RtpSendClientInfo_t(const RtpSendClientInfo_t& other)
  35. {
  36. *this = other;
  37. }
  38. RtpSendClientInfo_t& RtpSendClientInfo_t::operator=(const RtpSendClientInfo_t& other)
  39. {
  40. if (this != &other)
  41. {
  42. localPort = other.localPort;
  43. clientIP = other.clientIP;
  44. clientPort = other.clientPort;
  45. compareItemID = other.compareItemID;
  46. compareItemRoadNum = other.compareItemRoadNum;
  47. // udpSocket = other.udpSocket; /* 不拷贝udp套接字 */
  48. }
  49. return *this;
  50. }